Support TYPO3 v12.1 (#96)

* Support TYPO3 v12.0

All dependencies are compatible now.
We can update to support v12.0.

This commit will shift TYPO3 support from 10 and 11 to 11 and 12.
See Changelog entry.

Update dev dependencies to our latest best practice.
Auto migrate code base to follow CGL and use PHP 7.4.
This commit is contained in:
Daniel Siepmann 2022-12-07 13:37:19 +01:00 committed by GitHub
parent 89c4ad0ec0
commit 9f24518a0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 811 additions and 486 deletions

View file

@ -29,7 +29,6 @@ jobs:
strategy:
matrix:
php-version:
- 7.3
- 7.4
- 8.0
- 8.1
@ -46,39 +45,6 @@ jobs:
- name: PHP lint
run: "find *.php Classes Configuration Tests -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l"
check-dependencies:
runs-on: ubuntu-latest
needs:
- check-composer
strategy:
matrix:
include:
- php-version: '7.4'
typo3-version: '^10.4'
- php-version: '7.4'
typo3-version: '^11.5'
- php-version: '8.0'
typo3-version: '^11.5'
- php-version: '8.1'
typo3-version: '^11.5'
steps:
- uses: actions/checkout@v3
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
tools: composer:v2
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies with expected TYPO3 version
run: composer require --prefer-dist --no-progress --no-plugins "maglnet/composer-require-checker:^3.8" "typo3/cms-backend:${{ matrix.typo3-version }}" "typo3/cms-core:${{ matrix.typo3-version }}" "typo3/cms-dashboard:${{ matrix.typo3-version }}"
- name: Missing composer requirements
run: ./vendor/bin/composer-require-checker check --config-file dependency-checker.json
xml-linting:
runs-on: ubuntu-latest
needs:
@ -130,65 +96,13 @@ jobs:
- name: Coding Guideline
run: ./vendor/bin/ecs check
tests-sqlite:
runs-on: ubuntu-latest
needs:
- check-dependencies
- xml-linting
strategy:
matrix:
include:
- php-version: '7.3'
typo3-version: '^10.4'
- php-version: '7.4'
typo3-version: '^10.4'
- php-version: '7.4'
typo3-version: '^11.5'
- php-version: '8.0'
typo3-version: '^11.5'
- php-version: '8.1'
typo3-version: '^11.5'
steps:
- uses: actions/checkout@v3
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
tools: composer:v2
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies with expected TYPO3 version
run: composer require --prefer-dist --no-progress "typo3/cms-backend:${{ matrix.typo3-version }}" "typo3/cms-core:${{ matrix.typo3-version }}" "typo3/cms-dashboard:${{ matrix.typo3-version }}"
- name: PHPUnit Tests
run: ./vendor/bin/phpunit --testdox
tests-mysql:
runs-on: ubuntu-latest
needs:
- check-dependencies
- xml-linting
strategy:
matrix:
include:
- db-version: '5.6'
php-version: '7.3'
typo3-version: '^10.4'
- db-version: '5.6'
php-version: '7.4'
typo3-version: '^10.4'
- db-version: '5.7'
php-version: '7.3'
typo3-version: '^10.4'
- db-version: '5.7'
php-version: '7.4'
typo3-version: '^10.4'
- db-version: '8'
php-version: '7.4'
typo3-version: '^10.4'
- db-version: '8'
php-version: '7.4'
typo3-version: '^11.5'
@ -198,6 +112,9 @@ jobs:
- db-version: '8'
php-version: '8.1'
typo3-version: '^11.5'
- db-version: '8'
php-version: '8.1'
typo3-version: '~12.1.0'
steps:
- uses: actions/checkout@v3
@ -231,21 +148,17 @@ jobs:
code-quality:
runs-on: ubuntu-latest
needs:
- check-dependencies
strategy:
matrix:
include:
- php-version: '7.3'
typo3-version: '^10.4'
- php-version: '7.4'
typo3-version: '^10.4'
- php-version: '7.4'
typo3-version: '^11.5'
- php-version: '8.0'
typo3-version: '^11.5'
- php-version: '8.1'
typo3-version: '^11.5'
- php-version: '8.1'
typo3-version: '~12.1.0'
steps:
- uses: actions/checkout@v3

View file

@ -25,7 +25,6 @@ namespace DanielSiepmann\Tracking\Command;
use DanielSiepmann\Tracking\Domain\Repository\Pageview;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

View file

@ -91,7 +91,8 @@ class NewestPageviews implements ListDataProviderInterface
->from('tx_tracking_pageview')
->orderBy('crdate', 'desc')
->addOrderBy('uid', 'desc')
->setMaxResults($this->maxResults);
->setMaxResults($this->maxResults)
;
if ($constraints !== []) {
$this->queryBuilder->where(...$constraints);

View file

@ -63,14 +63,13 @@ class PageviewsPerDay implements ChartDataProviderInterface
private $languageLimitation;
public function __construct(
LanguageService $languageService,
QueryBuilder $queryBuilder,
int $days = 31,
array $pagesToExclude = [],
array $languageLimitation = [],
string $dateFormat = 'Y-m-d'
) {
$this->languageService = $languageService;
$this->languageService = $GLOBALS['LANG'];
$this->queryBuilder = $queryBuilder;
$this->days = $days;
$this->pagesToExclude = $pagesToExclude;
@ -80,20 +79,20 @@ class PageviewsPerDay implements ChartDataProviderInterface
public function getChartData(): array
{
list($labels, $data) = $this->calculateData();
[$labels, $data] = $this->calculateData();
return [
'labels' => $labels,
'datasets' => [
[
'label' => $this->languageService->sL(
Extension::LANGUAGE_PATH . 'widgets.pageViewsBar.chart.dataSet.0'
Extension::LANGUAGE_PATH . ':dashboard.widgets.pageViewsBar.chart.dataSet.0'
),
'backgroundColor' => WidgetApi::getDefaultChartColors()[0],
'border' => 0,
'data' => $data
]
]
'data' => $data,
],
],
];
}
@ -111,7 +110,6 @@ class PageviewsPerDay implements ChartDataProviderInterface
$start = (int) strtotime('-' . $this->days . ' day 0:00:00');
$end = (int) strtotime('tomorrow midnight');
foreach ($this->getPageviewsInPeriod($start, $end) as $day) {
$data[$day['label']] = (int) $day['count'];
}
@ -155,7 +153,7 @@ class PageviewsPerDay implements ChartDataProviderInterface
->where(...$constraints)
->groupBy('label')
->orderBy('label', 'ASC')
;
;
if ($this->queryBuilder->getConnection()->getDatabasePlatform()->getName() === 'sqlite') {
$this->queryBuilder->addSelectLiteral('date(crdate, "unixepoch") as "label"');

View file

@ -64,7 +64,7 @@ class PageviewsPerOperatingSystem implements ChartDataProviderInterface
public function getChartData(): array
{
list($labels, $data) = $this->getPageViewsPerPage();
[$labels, $data] = $this->getPageViewsPerPage();
return [
'labels' => $labels,
@ -72,7 +72,7 @@ class PageviewsPerOperatingSystem implements ChartDataProviderInterface
[
'backgroundColor' => WidgetApi::getDefaultChartColors(),
'data' => $data,
]
],
],
];
}
@ -113,7 +113,8 @@ class PageviewsPerOperatingSystem implements ChartDataProviderInterface
->addOrderBy('operating_system', 'asc')
->setMaxResults($this->maxResults)
->execute()
->fetchAll();
->fetchAll()
;
foreach ($result as $row) {
if (is_array($row) === false) {

View file

@ -23,8 +23,6 @@ declare(strict_types=1);
namespace DanielSiepmann\Tracking\Dashboard\Provider;
use DanielSiepmann\Tracking\Extension;
use Doctrine\DBAL\ParameterType;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
@ -82,7 +80,7 @@ class PageviewsPerPage implements ChartDataProviderInterface
public function getChartData(): array
{
list($labels, $data) = $this->getPageviewsPerPage();
[$labels, $data] = $this->getPageviewsPerPage();
return [
'labels' => $labels,
@ -90,7 +88,7 @@ class PageviewsPerPage implements ChartDataProviderInterface
[
'backgroundColor' => WidgetApi::getDefaultChartColors(),
'data' => $data,
]
],
],
];
}
@ -139,7 +137,8 @@ class PageviewsPerPage implements ChartDataProviderInterface
->addOrderBy('latest', 'desc')
->setMaxResults($this->maxResults)
->execute()
->fetchAll();
->fetchAll()
;
foreach ($result as $row) {
if (is_array($row) === false) {

View file

@ -23,15 +23,11 @@ declare(strict_types=1);
namespace DanielSiepmann\Tracking\Dashboard\Provider;
use DanielSiepmann\Tracking\Extension;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Statement;
use Generator;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Context\LanguageAspect;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\Query\Restriction\EndTimeRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\StartTimeRestriction;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Dashboard\WidgetApi;
use TYPO3\CMS\Dashboard\Widgets\ChartDataProviderInterface;
@ -100,7 +96,7 @@ class Recordviews implements ChartDataProviderInterface
public function getChartData(): array
{
list($labels, $data) = $this->getRecordviews();
[$labels, $data] = $this->getRecordviews();
return [
'labels' => $labels,
@ -108,7 +104,7 @@ class Recordviews implements ChartDataProviderInterface
[
'backgroundColor' => WidgetApi::getDefaultChartColors(),
'data' => $data,
]
],
],
];
}
@ -147,13 +143,13 @@ class Recordviews implements ChartDataProviderInterface
];
}
private function getRecordviewsRecords(): \Generator
private function getRecordviewsRecords(): Generator
{
$constraints = [
$this->queryBuilder->expr()->gte(
'tx_tracking_recordview.crdate',
strtotime('-' . $this->days . ' day 0:00:00')
)
),
];
if (count($this->pagesToExclude)) {
@ -198,7 +194,8 @@ class Recordviews implements ChartDataProviderInterface
->orderBy('total', 'desc')
->addOrderBy('latest', 'desc')
->setMaxResults($this->maxResults)
->execute();
->execute()
;
while ($row = $result->fetch()) {
yield $row;
@ -213,7 +210,11 @@ class Recordviews implements ChartDataProviderInterface
$record = BackendUtility::getRecord($table, $uid);
if (count($this->languageLimitation) === 1 && $record !== null) {
$record = $this->pageRepository->getRecordOverlay($table, $record, $this->languageLimitation[0]);
$record = $this->pageRepository->getRecordOverlay(
$table,
$record,
$this->createLanguageAspect($this->languageLimitation[0])
);
}
if (is_array($record) === false) {
@ -225,4 +226,13 @@ class Recordviews implements ChartDataProviderInterface
'type' => $record[$recordTypeField] ?? '',
];
}
private function createLanguageAspect(int $languageUid): LanguageAspect
{
return new LanguageAspect(
$languageUid,
null,
LanguageAspect::OVERLAYS_MIXED
);
}
}

View file

@ -25,10 +25,7 @@ namespace DanielSiepmann\Tracking\Domain\ExpressionLanguage;
use DanielSiepmann\Tracking\Domain\Model\Expression;
use DanielSiepmann\Tracking\Domain\Model\SymfonyExpression;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException;

View file

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace DanielSiepmann\Tracking\Domain\Model;
use DateTimeImmutable;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
class Pageview implements HasUserAgent
@ -43,7 +44,7 @@ class Pageview implements HasUserAgent
private $language;
/**
* @var \DateTimeImmutable
* @var DateTimeImmutable
*/
private $crdate;
@ -65,7 +66,7 @@ class Pageview implements HasUserAgent
public function __construct(
int $pageUid,
SiteLanguage $language,
\DateTimeImmutable $crdate,
DateTimeImmutable $crdate,
int $pageType,
string $url,
string $userAgent,
@ -95,7 +96,7 @@ class Pageview implements HasUserAgent
return $this->language;
}
public function getCrdate(): \DateTimeImmutable
public function getCrdate(): DateTimeImmutable
{
return $this->crdate;
}

View file

@ -52,7 +52,7 @@ class RecordRule
public static function fromArray(array $config): self
{
return new RecordRule(
return new self(
$config['matches'],
$config['recordUid'],
$config['tableName']

View file

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace DanielSiepmann\Tracking\Domain\Model;
use DateTimeImmutable;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
class Recordview implements HasUserAgent
@ -38,7 +39,7 @@ class Recordview implements HasUserAgent
private $language;
/**
* @var \DateTimeImmutable
* @var DateTimeImmutable
*/
private $crdate;
@ -65,7 +66,7 @@ class Recordview implements HasUserAgent
public function __construct(
int $pageUid,
SiteLanguage $language,
\DateTimeImmutable $crdate,
DateTimeImmutable $crdate,
string $url,
string $userAgent,
int $recordUid,
@ -90,7 +91,7 @@ class Recordview implements HasUserAgent
return $this->language;
}
public function getCrdate(): \DateTimeImmutable
public function getCrdate(): DateTimeImmutable
{
return $this->crdate;
}

View file

@ -24,10 +24,12 @@ declare(strict_types=1);
namespace DanielSiepmann\Tracking\Domain\Pageview;
use DanielSiepmann\Tracking\Domain\Model\Pageview;
use DateTimeImmutable;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Routing\PageArguments;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\CMS\Core\Site\SiteFinder;
use UnexpectedValueException;
class Factory
{
@ -46,7 +48,7 @@ class Factory
return new Pageview(
$this->getRouting($request)->getPageId(),
$this->getLanguage($request),
new \DateTimeImmutable(),
new DateTimeImmutable(),
(int) $this->getRouting($request)->getPageType(),
(string) $request->getUri(),
$request->getHeader('User-Agent')[0] ?? ''
@ -58,7 +60,7 @@ class Factory
return new Pageview(
(int) $dbRow['pid'],
$this->siteFinder->getSiteByPageId((int) $dbRow['pid'])->getLanguageById((int) $dbRow['sys_language_uid']),
new \DateTimeImmutable('@' . $dbRow['crdate']),
new DateTimeImmutable('@' . $dbRow['crdate']),
(int) $dbRow['type'],
$dbRow['url'],
$dbRow['user_agent'],
@ -71,7 +73,7 @@ class Factory
$language = $request->getAttribute('language');
if (!$language instanceof SiteLanguage) {
throw new \UnexpectedValueException('Could not fetch SiteLanguage from request attributes.', 1637847002);
throw new UnexpectedValueException('Could not fetch SiteLanguage from request attributes.', 1637847002);
}
return $language;
@ -82,7 +84,7 @@ class Factory
$routing = $request->getAttribute('routing');
if (!$routing instanceof PageArguments) {
throw new \UnexpectedValueException('Could not fetch PageArguments from request attributes.', 1637847002);
throw new UnexpectedValueException('Could not fetch PageArguments from request attributes.', 1637847002);
}
return $routing;

View file

@ -26,10 +26,11 @@ namespace DanielSiepmann\Tracking\Domain\Recordview;
use DanielSiepmann\Tracking\Domain\ExpressionLanguage\Factory as ExpressionFactory;
use DanielSiepmann\Tracking\Domain\Model\RecordRule;
use DanielSiepmann\Tracking\Domain\Model\Recordview;
use DateTimeImmutable;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use TYPO3\CMS\Core\Routing\PageArguments;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use UnexpectedValueException;
class Factory
{
@ -54,7 +55,7 @@ class Factory
)->evaluate();
if (is_numeric($recordUid) === false) {
throw new \UnexpectedValueException(
throw new UnexpectedValueException(
sprintf(
'Could not determine record uid based on expression: "%1$s", got type "%2$s".',
$rule->getUidExpression(),
@ -67,7 +68,7 @@ class Factory
return new Recordview(
self::getRouting($request)->getPageId(),
self::getLanguage($request),
new \DateTimeImmutable(),
new DateTimeImmutable(),
(string) $request->getUri(),
$request->getHeader('User-Agent')[0] ?? '',
(int) $recordUid,
@ -80,7 +81,7 @@ class Factory
$language = $request->getAttribute('language');
if (!$language instanceof SiteLanguage) {
throw new \UnexpectedValueException('Could not fetch SiteLanguage from request attributes.', 1637847002);
throw new UnexpectedValueException('Could not fetch SiteLanguage from request attributes.', 1637847002);
}
return $language;
@ -91,7 +92,7 @@ class Factory
$routing = $request->getAttribute('routing');
if (!$routing instanceof PageArguments) {
throw new \UnexpectedValueException('Could not fetch PageArguments from request attributes.', 1637847002);
throw new UnexpectedValueException('Could not fetch PageArguments from request attributes.', 1637847002);
}
return $routing;

View file

@ -25,6 +25,8 @@ namespace DanielSiepmann\Tracking\Domain\Repository;
use DanielSiepmann\Tracking\Domain\Model\Pageview as Model;
use DanielSiepmann\Tracking\Domain\Pageview\Factory;
use Generator;
use InvalidArgumentException;
use TYPO3\CMS\Core\Database\Connection;
class Pageview
@ -53,7 +55,8 @@ class Pageview
->count('uid')
->from('tx_tracking_pageview')
->execute()
->fetchColumn();
->fetchOne()
;
if (is_numeric($result)) {
return (int) $result;
@ -62,7 +65,7 @@ class Pageview
return 0;
}
public function findAll(): \Generator
public function findAll(): Generator
{
$queryBuilder = $this->connection->createQueryBuilder();
$pageViews = $queryBuilder->select('*')->from('tx_tracking_pageview')->execute();
@ -79,7 +82,7 @@ class Pageview
public function update(Model $pageview): void
{
if ($pageview->getUid() === 0) {
throw new \InvalidArgumentException('Can not update pageview if uid is 0.', 1585770573);
throw new InvalidArgumentException('Can not update pageview if uid is 0.', 1585770573);
}
$this->connection->update(

View file

@ -26,7 +26,6 @@ namespace DanielSiepmann\Tracking\Hooks;
use TYPO3\CMS\Core\DataHandling\DataHandler as Typo3DataHandler;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\StringUtility;
class DataHandler
{
@ -50,14 +49,14 @@ class DataHandler
private function preventCopyOfTrackingTables(Typo3DataHandler $dataHandler): void
{
$copyWhichTables = $dataHandler->compileAdminTables();
$copyWhichTables = array_keys($GLOBALS['TCA']);
if ($dataHandler->copyWhichTables !== '*') {
$copyWhichTables = GeneralUtility::trimExplode(',', $dataHandler->copyWhichTables, true);
}
$copyWhichTables = array_filter($copyWhichTables, function (string $tableName) {
return StringUtility::beginsWith($tableName, 'tx_tracking_') === false;
$copyWhichTables = array_filter($copyWhichTables, static function (string $tableName) {
return \str_starts_with($tableName, 'tx_tracking_') === false;
});
$dataHandler->copyWhichTables = implode(',', $copyWhichTables);

View file

@ -31,7 +31,6 @@ use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use TYPO3\CMS\Core\Context\Context;
class Recordview implements MiddlewareInterface

View file

@ -1,9 +1,11 @@
<?php
use DanielSiepmann\Tracking\Middleware\Pageview;
use DanielSiepmann\Tracking\Middleware\Recordview;
return [
'frontend' => [
'danielsiepmann/tracking/pageview' => [
'target' => \DanielSiepmann\Tracking\Middleware\Pageview::class,
'target' => Pageview::class,
'before' => [
'typo3/cms-frontend/content-length-headers',
],
@ -12,7 +14,7 @@ return [
],
],
'danielsiepmann/tracking/recordview' => [
'target' => \DanielSiepmann\Tracking\Middleware\Recordview::class,
'target' => Recordview::class,
'before' => [
'typo3/cms-frontend/content-length-headers',
],

View file

@ -12,7 +12,6 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'title' => 'LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.pageview',
'searchFields' => 'uid, url',
'iconfile' => 'EXT:tracking/Resources/Public/Icons/Record/Pageview.svg',
],
'types' => [
@ -35,19 +34,12 @@ return [
'config' => [
'type' => 'input',
'eval' => 'datetime',
'renderType' => 'inputDateTime',
],
],
'sys_language_uid' => [
'label' => 'LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.pageview.sys_language',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'sys_language',
'items' => [
['LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.pageview.sys_language.0', 0],
],
'readOnly' => true,
]
'config' => ['type' => 'language']
],
'user_agent' => [
'label' => 'LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.pageview.user_agent',

View file

@ -12,7 +12,6 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'title' => 'LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.recordview',
'searchFields' => 'uid, url',
'iconfile' => 'EXT:tracking/Resources/Public/Icons/Record/Recordview.svg',
],
'types' => [
@ -35,19 +34,12 @@ return [
'config' => [
'type' => 'input',
'eval' => 'datetime',
'renderType' => 'inputDateTime',
],
],
'sys_language_uid' => [
'label' => 'LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.recordview.sys_language',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'sys_language',
'items' => [
['LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.recordview.sys_language.0', 0],
],
'readOnly' => true,
]
'config' => ['type' => 'language']
],
'user_agent' => [
'label' => 'LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.recordview.user_agent',
@ -76,7 +68,6 @@ return [
'config' => [
'type' => 'group',
'allowed' => 'tt_content,sys_category,pages',
'internal_type' => 'db',
'maxitems' => 1,
'minitems' => 1,
'size' => 1,

View file

@ -0,0 +1,34 @@
2.0.0
=====
Breaking
--------
* Support TYPO3 v12.1, drop v10.
We only support last two TYPO3 versions.
Bugfixes and Security will be available for v10 and v11.
New features and breaking changes will only be available for v12.1 and v11.5 from now on.
* searchFields for records got removed.
This should speed up your instance TYPO3 backend search.
Feel free to add necessary fields by overwriting TCA yourself.
Features
--------
Nothing
Fixes
-----
Nothing
Tasks
-----
Nothing
Deprecation
-----------
Nothing

View file

@ -27,15 +27,15 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Command\UpdateDataCommand
* @covers \DanielSiepmann\Tracking\Command\UpdateDataCommand
*/
class UpdateDataCommandTest extends TestCase
{
protected $testExtensionsToLoad = [
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
protected $pathsToLinkInTestInstance = [
protected array $pathsToLinkInTestInstance = [
'typo3conf/ext/tracking/Tests/Functional/Fixtures/sites' => 'typo3conf/sites',
];
@ -50,12 +50,12 @@ class UpdateDataCommandTest extends TestCase
$tester = new CommandTester($subject);
$tester->execute([], ['capture_stderr_separately' => true]);
static::assertSame(0, $tester->getStatusCode());
self::assertSame(0, $tester->getStatusCode());
$records = $this->getAllRecords('tx_tracking_pageview');
static::assertCount(2, $records);
static::assertSame('Linux', $records[0]['operating_system']);
static::assertSame('Android', $records[1]['operating_system']);
self::assertCount(2, $records);
self::assertSame('Linux', $records[0]['operating_system']);
self::assertSame('Android', $records[1]['operating_system']);
}
/**
@ -69,12 +69,12 @@ class UpdateDataCommandTest extends TestCase
$tester = new CommandTester($subject);
$tester->execute([], ['capture_stderr_separately' => true]);
static::assertSame(0, $tester->getStatusCode());
self::assertSame(0, $tester->getStatusCode());
$records = $this->getAllRecords('tx_tracking_pageview');
static::assertCount(2, $records);
static::assertSame('Linux', $records[0]['operating_system']);
static::assertSame('Android', $records[1]['operating_system']);
self::assertCount(2, $records);
self::assertSame('Linux', $records[0]['operating_system']);
self::assertSame('Android', $records[1]['operating_system']);
}
/**
@ -88,9 +88,9 @@ class UpdateDataCommandTest extends TestCase
$tester = new CommandTester($subject);
$tester->execute([], ['capture_stderr_separately' => true]);
static::assertSame(0, $tester->getStatusCode());
self::assertSame(0, $tester->getStatusCode());
$records = $this->getAllRecords('tx_tracking_pageview');
static::assertCount(0, $records);
self::assertCount(0, $records);
}
}

View file

@ -27,11 +27,11 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Dashboard\Provider\NewestPageviews
* @covers \DanielSiepmann\Tracking\Dashboard\Provider\NewestPageviews
*/
class NewestPageviewsTest extends TestCase
{
protected $testExtensionsToLoad = [
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
@ -54,7 +54,7 @@ class NewestPageviewsTest extends TestCase
GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview')
);
static::assertSame([
self::assertSame([
'Url 10 - User-Agent 10',
'Url 9 - User-Agent 9',
'Url 8 - User-Agent 8',
@ -84,7 +84,7 @@ class NewestPageviewsTest extends TestCase
2
);
static::assertSame([
self::assertSame([
'Url 10 - User-Agent 10',
'Url 9 - User-Agent 9',
], $subject->getItems());
@ -111,7 +111,7 @@ class NewestPageviewsTest extends TestCase
[9]
);
static::assertSame([
self::assertSame([
'Url 10 - User-Agent 10',
'Url 8 - User-Agent 8',
'Url 7 - User-Agent 7',
@ -144,7 +144,7 @@ class NewestPageviewsTest extends TestCase
[1]
);
static::assertSame([
self::assertSame([
'Url 9 - User-Agent 9',
'Url 7 - User-Agent 7',
'Url 5 - User-Agent 5',

View file

@ -23,19 +23,31 @@ namespace DanielSiepmann\Tracking\Tests\Functional\Dashboard\Provider;
use DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerDay;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerDay
* @covers \DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerDay
*/
class PageviewsPerDayTest extends TestCase
{
protected $testExtensionsToLoad = [
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
protected function setUp(): void
{
parent::setUp();
$GLOBALS['LANG'] = $this->getContainer()->get(LanguageServiceFactory::class)->create('default');
}
protected function tearDown(): void
{
unset($GLOBALS['LANG']);
parent::tearDown();
}
/**
* @test
*/
@ -50,13 +62,12 @@ class PageviewsPerDayTest extends TestCase
}
$subject = new PageviewsPerDay(
GeneralUtility::makeInstance(LanguageService::class),
GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview')
GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
);
$result = $subject->getChartData();
static::assertCount(32, $result['labels']);
static::assertCount(32, $result['datasets'][0]['data']);
self::assertCount(32, $result['labels']);
self::assertCount(32, $result['datasets'][0]['data']);
}
/**
@ -74,14 +85,13 @@ class PageviewsPerDayTest extends TestCase
}
$subject = new PageviewsPerDay(
GeneralUtility::makeInstance(LanguageService::class),
GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
3
);
$result = $subject->getChartData();
static::assertCount(4, $result['labels']);
static::assertSame([
self::assertCount(4, $result['labels']);
self::assertSame([
1,
1,
1,
@ -104,15 +114,14 @@ class PageviewsPerDayTest extends TestCase
}
$subject = new PageviewsPerDay(
GeneralUtility::makeInstance(LanguageService::class),
GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
3,
[2]
);
$result = $subject->getChartData();
static::assertCount(4, $result['labels']);
static::assertSame([
self::assertCount(4, $result['labels']);
self::assertSame([
1,
0,
1,
@ -129,7 +138,6 @@ class PageviewsPerDayTest extends TestCase
$connection = $this->getConnectionPool()->getConnectionForTable('tx_tracking_pageview');
$subject = new PageviewsPerDay(
GeneralUtility::makeInstance(LanguageService::class),
GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
1,
[],
@ -138,11 +146,11 @@ class PageviewsPerDayTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
date('d.m.Y', strtotime('-1 day')),
date('d.m.Y'),
], $result['labels']);
static::assertCount(2, $result['datasets'][0]['data']);
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
@ -160,7 +168,6 @@ class PageviewsPerDayTest extends TestCase
}
$subject = new PageviewsPerDay(
GeneralUtility::makeInstance(LanguageService::class),
GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
11,
[],
@ -168,7 +175,7 @@ class PageviewsPerDayTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
0 => 0,
1 => 0,
2 => 1,

View file

@ -27,11 +27,11 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerOperatingSystem
* @covers \DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerOperatingSystem
*/
class PageviewsPerOperatingSystemTest extends TestCase
{
protected $testExtensionsToLoad = [
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
@ -54,7 +54,7 @@ class PageviewsPerOperatingSystemTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'System 1',
'System 10',
'System 2',
@ -62,7 +62,7 @@ class PageviewsPerOperatingSystemTest extends TestCase
'System 4',
'System 5',
], $result['labels']);
static::assertCount(6, $result['datasets'][0]['data']);
self::assertCount(6, $result['datasets'][0]['data']);
}
/**
@ -98,12 +98,12 @@ class PageviewsPerOperatingSystemTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'System 2',
'System 1',
'System 3',
], $result['labels']);
static::assertCount(3, $result['datasets'][0]['data']);
self::assertCount(3, $result['datasets'][0]['data']);
}
/**
@ -135,11 +135,11 @@ class PageviewsPerOperatingSystemTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'System 2',
'System 3',
], $result['labels']);
static::assertCount(2, $result['datasets'][0]['data']);
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
@ -164,13 +164,13 @@ class PageviewsPerOperatingSystemTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'System 1',
'System 10',
'System 2',
'System 3',
], $result['labels']);
static::assertCount(4, $result['datasets'][0]['data']);
self::assertCount(4, $result['datasets'][0]['data']);
}
/**
@ -197,13 +197,13 @@ class PageviewsPerOperatingSystemTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'System 1',
'System 3',
'System 5',
'System 7',
'System 9',
], $result['labels']);
static::assertCount(5, $result['datasets'][0]['data']);
self::assertCount(5, $result['datasets'][0]['data']);
}
}

View file

@ -24,18 +24,31 @@ namespace DanielSiepmann\Tracking\Tests\Functional\Dashboard\Provider;
use DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerPage;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerPage
* @covers \DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerPage
*/
class PageviewsPerPageTest extends TestCase
{
protected $testExtensionsToLoad = [
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
protected function setUp(): void
{
parent::setUp();
$GLOBALS['LANG'] = $this->getContainer()->get(LanguageServiceFactory::class)->create('default');
}
protected function tearDown(): void
{
unset($GLOBALS['LANG']);
parent::tearDown();
}
/**
* @test
*/
@ -56,7 +69,7 @@ class PageviewsPerPageTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Page 10',
'Page 9',
'Page 8',
@ -64,7 +77,7 @@ class PageviewsPerPageTest extends TestCase
'Page 6',
'Page 5',
], $result['labels']);
static::assertCount(6, $result['datasets'][0]['data']);
self::assertCount(6, $result['datasets'][0]['data']);
}
/**
@ -97,12 +110,12 @@ class PageviewsPerPageTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Page 2',
'Page 3',
'Page 1',
], $result['labels']);
static::assertCount(3, $result['datasets'][0]['data']);
self::assertCount(3, $result['datasets'][0]['data']);
}
/**
@ -132,11 +145,11 @@ class PageviewsPerPageTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Page 3',
'Page 2',
], $result['labels']);
static::assertCount(2, $result['datasets'][0]['data']);
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
@ -161,13 +174,13 @@ class PageviewsPerPageTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Page 10',
'Page 9',
'Page 8',
'Page 7',
], $result['labels']);
static::assertCount(4, $result['datasets'][0]['data']);
self::assertCount(4, $result['datasets'][0]['data']);
}
/**
@ -193,13 +206,13 @@ class PageviewsPerPageTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Page 10',
'Page 9',
'Page 8',
'Page 7',
], $result['labels']);