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'];
}

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']);
static::assertCount(4, $result['datasets'][0]['data']);
self::assertCount(4, $result['datasets'][0]['data']);
}
/**
@ -242,11 +255,11 @@ class PageviewsPerPageTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Page 2',
'Page 1',
], $result['labels']);
static::assertCount(2, $result['datasets'][0]['data']);
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
@ -289,11 +302,11 @@ class PageviewsPerPageTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Page 2',
'Page 1',
'Page 3',
], $result['labels']);
static::assertCount(3, $result['datasets'][0]['data']);
self::assertCount(3, $result['datasets'][0]['data']);
}
}

View file

@ -23,18 +23,31 @@ namespace DanielSiepmann\Tracking\Tests\Functional\Dashboard\Provider;
use DanielSiepmann\Tracking\Dashboard\Provider\Recordviews;
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\Recordviews
* @covers \DanielSiepmann\Tracking\Dashboard\Provider\Recordviews
*/
class RecordviewsTest 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
*/
@ -57,7 +70,7 @@ class RecordviewsTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Category 10',
'Category 9',
'Category 8',
@ -65,7 +78,7 @@ class RecordviewsTest extends TestCase
'Category 6',
'Category 5',
], $result['labels']);
static::assertCount(6, $result['datasets'][0]['data']);
self::assertCount(6, $result['datasets'][0]['data']);
}
/**
@ -107,12 +120,12 @@ class RecordviewsTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Category 2',
'Category 3',
'Category 1',
], $result['labels']);
static::assertCount(3, $result['datasets'][0]['data']);
self::assertCount(3, $result['datasets'][0]['data']);
}
/**
@ -148,11 +161,11 @@ class RecordviewsTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Category 3',
'Category 2',
], $result['labels']);
static::assertCount(2, $result['datasets'][0]['data']);
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
@ -179,11 +192,11 @@ class RecordviewsTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Category 10',
'Category 9',
], $result['labels']);
static::assertCount(2, $result['datasets'][0]['data']);
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
@ -212,14 +225,14 @@ class RecordviewsTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Category 10',
'Category 9',
'Category 8',
'Category 7',
'Category 6',
], $result['labels']);
static::assertCount(5, $result['datasets'][0]['data']);
self::assertCount(5, $result['datasets'][0]['data']);
}
/**
@ -255,12 +268,12 @@ class RecordviewsTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Category 3',
'Category 2',
'Category 1',
], $result['labels']);
static::assertCount(3, $result['datasets'][0]['data']);
self::assertCount(3, $result['datasets'][0]['data']);
}
/**
@ -295,11 +308,11 @@ class RecordviewsTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Content element 2',
'Content element 1',
], $result['labels']);
static::assertCount(2, $result['datasets'][0]['data']);
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
@ -343,11 +356,11 @@ class RecordviewsTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Category 2',
'Kategorie 1',
], $result['labels']);
static::assertCount(2, $result['datasets'][0]['data']);
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
@ -391,10 +404,10 @@ class RecordviewsTest extends TestCase
);
$result = $subject->getChartData();
static::assertSame([
self::assertSame([
'Category 1',
'Category 2',
], $result['labels']);
static::assertCount(2, $result['datasets'][0]['data']);
self::assertCount(2, $result['datasets'][0]['data']);
}
}

View file

@ -24,6 +24,7 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Recordview;
use DanielSiepmann\Tracking\Domain\Model\RecordRule;
use DanielSiepmann\Tracking\Domain\Model\Recordview;
use DanielSiepmann\Tracking\Domain\Recordview\Factory;
use DateTimeImmutable;
use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Routing\PageArguments;
@ -31,13 +32,13 @@ use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
/**
* @covers DanielSiepmann\Tracking\Domain\Recordview\Factory
* @covers \DanielSiepmann\Tracking\Domain\Recordview\Factory
*/
class FactoryTest extends FunctionalTestCase
{
use ProphecyTrait;
protected $testExtensionsToLoad = [
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
@ -67,7 +68,7 @@ class FactoryTest extends FunctionalTestCase
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
static::assertInstanceOf(Recordview::class, $result);
self::assertInstanceOf(Recordview::class, $result);
}
/**
@ -96,7 +97,7 @@ class FactoryTest extends FunctionalTestCase
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
static::assertSame('Some User Agent', $result->getUserAgent());
self::assertSame('Some User Agent', $result->getUserAgent());
}
/**
@ -125,7 +126,7 @@ class FactoryTest extends FunctionalTestCase
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
static::assertSame('https://example.com', $result->getUrl());
self::assertSame('https://example.com', $result->getUrl());
}
/**
@ -154,7 +155,7 @@ class FactoryTest extends FunctionalTestCase
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
static::assertInstanceOf(\DateTimeImmutable::class, $result->getCrdate());
self::assertInstanceOf(DateTimeImmutable::class, $result->getCrdate());
}
/**
@ -183,7 +184,7 @@ class FactoryTest extends FunctionalTestCase
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
static::assertSame($language->reveal(), $result->getLanguage());
self::assertSame($language->reveal(), $result->getLanguage());
}
/**
@ -212,7 +213,7 @@ class FactoryTest extends FunctionalTestCase
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
static::assertSame(10, $result->getPageUid());
self::assertSame(10, $result->getPageUid());
}
/**
@ -241,7 +242,7 @@ class FactoryTest extends FunctionalTestCase
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
static::assertSame(20, $result->getRecordUid());
self::assertSame(20, $result->getRecordUid());
}
/**
@ -270,6 +271,6 @@ class FactoryTest extends FunctionalTestCase
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
static::assertSame('sys_category', $result->getTableName());
self::assertSame('sys_category', $result->getTableName());
}
}

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<dataset>
<be_users>
<uid>1</uid>
<pid>0</pid>
<tstamp>1366642540</tstamp>
<username>admin</username>
<password>$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1</password> <!-- password -->
<admin>1</admin>
<disable>0</disable>
<starttime>0</starttime>
<endtime>0</endtime>
<options>0</options>
<crdate>1366642540</crdate>
<workspace_perms>1</workspace_perms>
<deleted>0</deleted>
<TSconfig>NULL</TSconfig>
<lastlogin>1371033743</lastlogin>
<workspace_id>0</workspace_id>
</be_users>
</dataset>

View file

@ -5,9 +5,6 @@ $EM_CONF[$_EXTKEY] = [
'description' => 'Used by functional tests',
'category' => 'fe',
'state' => 'stable',
'uploadfolder' => 0,
'createDirs' => '',
'clearCacheOnLoad' => 0,
'author' => 'Daniel Siepmann',
'author_email' => 'coding@daniel-siepmann.de',
'author_company' => '',

View file

@ -27,14 +27,16 @@ use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase as TestCase;
/**
* @testdox Pageviews are
*
* @coversNothing
*/
class PageviewTest extends TestCase
{
protected $testExtensionsToLoad = [
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
protected $pathsToLinkInTestInstance = [
protected array $pathsToLinkInTestInstance = [
'typo3conf/ext/tracking/Tests/Functional/Fixtures/sites' => 'typo3conf/sites',
];
@ -62,12 +64,12 @@ class PageviewTest extends TestCase
$records = $this->getAllRecords('tx_tracking_pageview');
self::assertCount(1, $records);
self::assertSame('1', (string)$records[0]['pid']);
self::assertSame('1', (string)$records[0]['uid']);
self::assertSame('1', (string) $records[0]['pid']);
self::assertSame('1', (string) $records[0]['uid']);
self::assertSame('http://localhost/?id=1', $records[0]['url']);
self::assertSame('Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0', $records[0]['user_agent']);
self::assertSame('Macintosh', $records[0]['operating_system']);
self::assertSame('0', (string)$records[0]['type']);
self::assertSame('0', (string) $records[0]['type']);
}
/**
@ -75,7 +77,8 @@ class PageviewTest extends TestCase
*/
public function notTrackedWhenDisallowed(): void
{
$this->setUpBackendUserFromFixture(1);
$this->importDataSet('EXT:tracking/Tests/Functional/Fixtures/BackendUser.xml');
$this->setUpBackendUser(1);
$request = new InternalRequest();
$request = $request->withPageId(1);

View file

@ -22,20 +22,21 @@ namespace DanielSiepmann\Tracking\Tests\Functional;
*/
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequestContext;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase as TestCase;
/**
* @testdox Recordviews are
*
* @coversNothing
*/
class RecordviewTest extends TestCase
{
protected $testExtensionsToLoad = [
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
'typo3conf/ext/tracking/Tests/Functional/Fixtures/Extensions/recordview',
];
protected $pathsToLinkInTestInstance = [
protected array $pathsToLinkInTestInstance = [
'typo3conf/ext/tracking/Tests/Functional/Fixtures/sites' => 'typo3conf/sites',
];
@ -64,13 +65,13 @@ class RecordviewTest extends TestCase
$records = $this->getAllRecords('tx_tracking_recordview');
self::assertCount(1, $records);
self::assertSame('1', (string)$records[0]['pid']);
self::assertSame('1', (string)$records[0]['uid']);
self::assertSame('1', (string) $records[0]['pid']);
self::assertSame('1', (string) $records[0]['uid']);
self::assertSame('http://localhost/?id=1&topic_id=1', $records[0]['url']);
self::assertSame('Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0', $records[0]['user_agent']);
self::assertSame('Macintosh', $records[0]['operating_system']);
self::assertSame('sys_category_1', $records[0]['record']);
self::assertSame('1', (string)$records[0]['record_uid']);
self::assertSame('1', (string) $records[0]['record_uid']);
self::assertSame('sys_category', $records[0]['record_table_name']);
}

View file

@ -21,35 +21,37 @@ namespace DanielSiepmann\Tracking\Tests\Functional;
* 02110-1301, USA.
*/
use DanielSiepmann\Tracking\Functional\CopyingPageWithRecordsWorks;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase as TestCase;
use UnexpectedValueException;
/**
* @covers \DanielSiepmann\Tracking\Functional\CopyingPageWithRecordsWorks
*
* @testdox This extension works with TYPO3 feature:
*/
class Typo3FeaturesTest extends TestCase
{
protected $testExtensionsToLoad = [
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
public function setUp(): void
protected function setUp(): void
{
parent::setUp();
$this->importDataSet('EXT:tracking/Tests/Functional/Fixtures/BackendUser.xml');
$this->importDataSet('EXT:tracking/Tests/Functional/Fixtures/Typo3FeaturesTest/PageWithRecords.xml');
$this->setUpBackendUserFromFixture(1);
$this->setUpBackendUser(1);
$languageServiceFactory = $this->getContainer()->get(LanguageServiceFactory::class);
if (!$languageServiceFactory instanceof LanguageServiceFactory) {
throw new \UnexpectedValueException('Did not retrieve LanguageServiceFactory.', 1637847250);
throw new UnexpectedValueException('Did not retrieve LanguageServiceFactory.', 1637847250);
}
$GLOBALS['LANG'] = $languageServiceFactory->create('default');
}
public function tearDown(): void
protected function tearDown(): void
{
unset($GLOBALS['LANG']);
@ -58,6 +60,7 @@ class Typo3FeaturesTest extends TestCase
/**
* @test
*
* @testdox Copy pages. Tracking records will not be copied.
*/
public function copyContainingRecords(): void
@ -80,6 +83,7 @@ class Typo3FeaturesTest extends TestCase
/**
* @test
*
* @testdox Copy individual tables, but always exclude tracking tables.
*/
public function copyCustomTablesViaDataHandler(): void

View file

@ -27,7 +27,7 @@ use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Domain\Model\Extractor
* @covers \DanielSiepmann\Tracking\Domain\Model\Extractor
*/
class ExtractorTest extends TestCase
{
@ -35,7 +35,9 @@ class ExtractorTest extends TestCase
/**
* @test
*
* @dataProvider possibleUserStringWithOperatingSystems
*
* @testdox Operating system $expectedOperatingSystem is extracted from UserAgent string: $userAgent
*/
public function returnsOperatingSystem(string $userAgent, string $expectedOperatingSystem): void
@ -43,7 +45,7 @@ class ExtractorTest extends TestCase
$model = $this->prophesize(HasUserAgent::class);
$model->getUserAgent()->willReturn($userAgent);
static::assertSame(
self::assertSame(
$expectedOperatingSystem,
Extractor::getOperatingSystem($model->reveal())
);

View file

@ -22,12 +22,13 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
*/
use DanielSiepmann\Tracking\Domain\Model\Pageview;
use DateTimeImmutable;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Domain\Model\Pageview
* @covers \DanielSiepmann\Tracking\Domain\Model\Pageview
*/
class PageviewTest extends TestCase
{
@ -43,13 +44,13 @@ class PageviewTest extends TestCase
$subject = new Pageview(
0,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
0,
'',
''
);
static::assertInstanceOf(Pageview::class, $subject);
self::assertInstanceOf(Pageview::class, $subject);
}
/**
@ -62,13 +63,13 @@ class PageviewTest extends TestCase
$subject = new Pageview(
500,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
0,
'',
''
);
static::assertSame(500, $subject->getPageUid());
self::assertSame(500, $subject->getPageUid());
}
/**
@ -81,13 +82,13 @@ class PageviewTest extends TestCase
$subject = new Pageview(
0,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
0,
'',
''
);
static::assertSame($language->reveal(), $subject->getLanguage());
self::assertSame($language->reveal(), $subject->getLanguage());
}
/**
@ -96,7 +97,7 @@ class PageviewTest extends TestCase
public function returnsCrdate(): void
{
$language = $this->prophesize(SiteLanguage::class);
$crdate = new \DateTimeImmutable();
$crdate = new DateTimeImmutable();
$subject = new Pageview(
0,
@ -107,7 +108,7 @@ class PageviewTest extends TestCase
''
);
static::assertSame($crdate, $subject->getCrdate());
self::assertSame($crdate, $subject->getCrdate());
}
/**
@ -120,13 +121,13 @@ class PageviewTest extends TestCase
$subject = new Pageview(
0,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
999,
'',
''
);
static::assertSame(999, $subject->getPageType());
self::assertSame(999, $subject->getPageType());
}
/**
@ -139,13 +140,13 @@ class PageviewTest extends TestCase
$subject = new Pageview(
0,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
0,
'https://example.com/path.html',
''
);
static::assertSame('https://example.com/path.html', $subject->getUrl());
self::assertSame('https://example.com/path.html', $subject->getUrl());
}
/**
@ -158,13 +159,13 @@ class PageviewTest extends TestCase
$subject = new Pageview(
0,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
0,
'',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0'
);
static::assertSame(
self::assertSame(
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0',
$subject->getUserAgent()
);
@ -180,13 +181,13 @@ class PageviewTest extends TestCase
$subject = new Pageview(
0,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
0,
'',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0'
);
static::assertSame(
self::assertSame(
0,
$subject->getUid()
);
@ -202,14 +203,14 @@ class PageviewTest extends TestCase
$subject = new Pageview(
0,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
0,
'',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0',
10
);
static::assertSame(
self::assertSame(
10,
$subject->getUid()
);
@ -225,13 +226,13 @@ class PageviewTest extends TestCase
$subject = new Pageview(
0,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
0,
'',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36'
);
static::assertSame(
self::assertSame(
'Linux',
$subject->getOperatingSystem()
);

View file

@ -25,7 +25,7 @@ use DanielSiepmann\Tracking\Domain\Model\RecordRule;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Domain\Model\RecordRule
* @covers \DanielSiepmann\Tracking\Domain\Model\RecordRule
*/
class RecordRuleTest extends TestCase
{
@ -40,7 +40,7 @@ class RecordRuleTest extends TestCase
''
);
static::assertInstanceOf(RecordRule::class, $subject);
self::assertInstanceOf(RecordRule::class, $subject);
}
/**
@ -55,7 +55,7 @@ class RecordRuleTest extends TestCase
'tableName' => '',
]);
static::assertInstanceOf(RecordRule::class, $subject);
self::assertInstanceOf(RecordRule::class, $subject);
}
/**
@ -76,9 +76,9 @@ class RecordRuleTest extends TestCase
],
]);
static::assertCount(2, $result);
static::assertInstanceOf(RecordRule::class, $result[0]);
static::assertInstanceOf(RecordRule::class, $result[1]);
self::assertCount(2, $result);
self::assertInstanceOf(RecordRule::class, $result[0]);
self::assertInstanceOf(RecordRule::class, $result[1]);
}
/**
@ -92,7 +92,7 @@ class RecordRuleTest extends TestCase
''
);
static::assertSame('match expression', $subject->getMatchesExpression());
self::assertSame('match expression', $subject->getMatchesExpression());
}
/**
@ -106,7 +106,7 @@ class RecordRuleTest extends TestCase
''
);
static::assertSame('match expression', $subject->getUidExpression());
self::assertSame('match expression', $subject->getUidExpression());
}
/**
@ -120,6 +120,6 @@ class RecordRuleTest extends TestCase
'table_name'
);
static::assertSame('table_name', $subject->getTableName());
self::assertSame('table_name', $subject->getTableName());
}
}

View file

@ -22,12 +22,13 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
*/
use DanielSiepmann\Tracking\Domain\Model\Recordview;
use DateTimeImmutable;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Domain\Model\Recordview
* @covers \DanielSiepmann\Tracking\Domain\Model\Recordview
*/
class RecordviewTest extends TestCase
{
@ -43,14 +44,14 @@ class RecordviewTest extends TestCase
$subject = new Recordview(
0,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
'',
'',
10,
'sys_category'
);
static::assertInstanceOf(Recordview::class, $subject);
self::assertInstanceOf(Recordview::class, $subject);
}
/**
@ -63,14 +64,14 @@ class RecordviewTest extends TestCase
$subject = new Recordview(
500,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
'',
'',
10,
'sys_category'
);
static::assertSame(500, $subject->getPageUid());
self::assertSame(500, $subject->getPageUid());
}
/**
@ -83,14 +84,14 @@ class RecordviewTest extends TestCase
$subject = new Recordview(
0,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
'',
'',
10,
'sys_category'
);
static::assertSame($language->reveal(), $subject->getLanguage());
self::assertSame($language->reveal(), $subject->getLanguage());
}
/**
@ -99,7 +100,7 @@ class RecordviewTest extends TestCase
public function returnsCrdate(): void
{
$language = $this->prophesize(SiteLanguage::class);
$crdate = new \DateTimeImmutable();
$crdate = new DateTimeImmutable();
$subject = new Recordview(
0,
@ -111,7 +112,7 @@ class RecordviewTest extends TestCase
'sys_category'
);
static::assertSame($crdate, $subject->getCrdate());
self::assertSame($crdate, $subject->getCrdate());
}
/**
@ -124,14 +125,14 @@ class RecordviewTest extends TestCase
$subject = new Recordview(
0,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
'https://example.com/path.html',
'',
10,
'sys_category'
);
static::assertSame('https://example.com/path.html', $subject->getUrl());
self::assertSame('https://example.com/path.html', $subject->getUrl());
}
/**
@ -144,14 +145,14 @@ class RecordviewTest extends TestCase
$subject = new Recordview(
0,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
'',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0',
10,
'sys_category'
);
static::assertSame(
self::assertSame(
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0',
$subject->getUserAgent()
);
@ -167,14 +168,14 @@ class RecordviewTest extends TestCase
$subject = new Recordview(
0,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
'',
'',
10,
'sys_category'
);
static::assertSame(
self::assertSame(
10,
$subject->getRecordUid()
);
@ -190,14 +191,14 @@ class RecordviewTest extends TestCase
$subject = new Recordview(
0,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
'',
'',
10,
'sys_category'
);
static::assertSame(
self::assertSame(
'sys_category',
$subject->getTableName()
);
@ -213,14 +214,14 @@ class RecordviewTest extends TestCase
$subject = new Recordview(
0,
$language->reveal(),
new \DateTimeImmutable(),
new DateTimeImmutable(),
'',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36',
10,
'sys_category'
);
static::assertSame(
self::assertSame(
'Linux',
$subject->getOperatingSystem()
);

View file

@ -23,8 +23,8 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Pageview;
use DanielSiepmann\Tracking\Domain\Model\Pageview;
use DanielSiepmann\Tracking\Domain\Pageview\Factory;
use DateTimeImmutable;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophet;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Routing\PageArguments;
use TYPO3\CMS\Core\Site\Entity\Site;
@ -33,7 +33,7 @@ use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Domain\Pageview\Factory
* @covers \DanielSiepmann\Tracking\Domain\Pageview\Factory
*/
class FactoryTest extends TestCase
{
@ -59,7 +59,7 @@ class FactoryTest extends TestCase
$subject = new Factory($this->prophesize(SiteFinder::class)->reveal());
$result = $subject->fromRequest($request->reveal());
static::assertInstanceOf(Pageview::class, $result);
self::assertInstanceOf(Pageview::class, $result);
}
/**
@ -78,13 +78,13 @@ class FactoryTest extends TestCase
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('');
$request->getHeader('User-Agent')->willReturn([
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0'
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0',
]);
$subject = new Factory($this->prophesize(SiteFinder::class)->reveal());
$result = $subject->fromRequest($request->reveal());
static::assertSame(
self::assertSame(
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0',
$result->getUserAgent()
);
@ -110,7 +110,7 @@ class FactoryTest extends TestCase
$subject = new Factory($this->prophesize(SiteFinder::class)->reveal());
$result = $subject->fromRequest($request->reveal());
static::assertSame(
self::assertSame(
'https://example.com/path?query=params&some=more#anchor',
$result->getUrl()
);
@ -136,7 +136,7 @@ class FactoryTest extends TestCase
$subject = new Factory($this->prophesize(SiteFinder::class)->reveal());
$result = $subject->fromRequest($request->reveal());
static::assertSame(
self::assertSame(
50,
$result->getPageType()
);
@ -162,7 +162,7 @@ class FactoryTest extends TestCase
$subject = new Factory($this->prophesize(SiteFinder::class)->reveal());
$result = $subject->fromRequest($request->reveal());
static::assertInstanceOf(\DateTimeImmutable::class, $result->getCrdate());
self::assertInstanceOf(DateTimeImmutable::class, $result->getCrdate());
}
/**
@ -185,7 +185,7 @@ class FactoryTest extends TestCase
$subject = new Factory($this->prophesize(SiteFinder::class)->reveal());
$result = $subject->fromRequest($request->reveal());
static::assertInstanceOf(SiteLanguage::class, $result->getLanguage());
self::assertInstanceOf(SiteLanguage::class, $result->getLanguage());
}
/**
@ -208,7 +208,7 @@ class FactoryTest extends TestCase
$subject = new Factory($this->prophesize(SiteFinder::class)->reveal());
$result = $subject->fromRequest($request->reveal());
static::assertSame(
self::assertSame(
10,
$result->getPageUid()
);
@ -237,13 +237,13 @@ class FactoryTest extends TestCase
'user_agent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36',
]);
static::assertInstanceOf(Pageview::class, $result);
static::assertSame(1, $result->getUid());
static::assertSame(2, $result->getPageUid());
static::assertSame($siteLanguage->reveal(), $result->getLanguage());
static::assertSame('1533906435', $result->getCrdate()->format('U'));
static::assertSame(0, $result->getPageType());
static::assertSame('https://example.com/path', $result->getUrl());
static::assertSame('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36', $result->getUserAgent());
self::assertInstanceOf(Pageview::class, $result);
self::assertSame(1, $result->getUid());
self::assertSame(2, $result->getPageUid());
self::assertSame($siteLanguage->reveal(), $result->getLanguage());
self::assertSame('1533906435', $result->getCrdate()->format('U'));
self::assertSame(0, $result->getPageType());
self::assertSame('https://example.com/path', $result->getUrl());
self::assertSame('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36', $result->getUserAgent());
}
}

View file

@ -24,15 +24,14 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Repository;
use DanielSiepmann\Tracking\Domain\Model\Pageview as Model;
use DanielSiepmann\Tracking\Domain\Pageview\Factory;
use DanielSiepmann\Tracking\Domain\Repository\Pageview;
use Doctrine\DBAL\Statement;
use DateTimeImmutable;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Domain\Repository\Pageview
* @covers \DanielSiepmann\Tracking\Domain\Repository\Pageview
*/
class PageviewTest extends TestCase
{
@ -46,7 +45,7 @@ class PageviewTest extends TestCase
$connection = $this->prophesize(Connection::class);
$factory = $this->prophesize(Factory::class);
$dateTime = $this->prophesize(\DateTimeImmutable::class);
$dateTime = $this->prophesize(DateTimeImmutable::class);
$dateTime->format('U')->willReturn(1582660189);
$language = $this->prophesize(SiteLanguage::class);
@ -103,7 +102,7 @@ class PageviewTest extends TestCase
$connection = $this->prophesize(Connection::class);
$factory = $this->prophesize(Factory::class);
$dateTime = $this->prophesize(\DateTimeImmutable::class);
$dateTime = $this->prophesize(DateTimeImmutable::class);
$dateTime->format('U')->willReturn(1582660189);
$language = $this->prophesize(SiteLanguage::class);
@ -132,100 +131,11 @@ class PageviewTest extends TestCase
'operating_system' => 'Linux',
],
[
'uid' => 1
'uid' => 1,
]
)->willReturn(1)->shouldBeCalledTimes(1);
$subject = new Pageview($connection->reveal(), $factory->reveal());
$subject->update($model->reveal());
}
/**
* @test
*/
public function returnsACountOfAllModels(): void
{
$statement = $this->prophesize(Statement::class);
$statement->fetchColumn()->willReturn(10);
$queryBuilder = $this->prophesize(QueryBuilder::class);
$queryBuilder->count('uid')->willReturn($queryBuilder->reveal());
$queryBuilder->from('tx_tracking_pageview')->willReturn($queryBuilder->reveal());
$queryBuilder->execute()->willReturn($statement->reveal());
$connection = $this->prophesize(Connection::class);
$connection->createQueryBuilder()->willReturn($queryBuilder->reveal());
$factory = $this->prophesize(Factory::class);
$subject = new Pageview($connection->reveal(), $factory->reveal());
static::assertSame(10, $subject->countAll());
}
/**
* @test
*/
public function returnsAllModells(): void
{
$statement = $this->prophesize(Statement::class);
$statement->fetch()->willReturn(
[
'pid' => '10',
'crdate' => '1595948372',
'type' => '0',
'sys_language_uid' => '0',
'url' => 'https://example.com/path/file.html',
'user_agent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36',
],
[
'pid' => '9',
'crdate' => '1595948376',
'type' => '0',
'sys_language_uid' => '0',
'url' => 'https://example.com/path/file.html',
'user_agent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36',
],
false
);
$queryBuilder = $this->prophesize(QueryBuilder::class);
$queryBuilder->select('*')->willReturn($queryBuilder->reveal());
$queryBuilder->from('tx_tracking_pageview')->willReturn($queryBuilder->reveal());
$queryBuilder->execute()->willReturn($statement->reveal());
$connection = $this->prophesize(Connection::class);
$connection->createQueryBuilder()->willReturn($queryBuilder->reveal());
$model1 = $this->prophesize(Model::class);
$model1->getPageUid()->willReturn(10);
$model2 = $this->prophesize(Model::class);
$model2->getPageUid()->willReturn(9);
$factory = $this->prophesize(Factory::class);
$factory->fromDbRow([
'pid' => '10',
'crdate' => '1595948372',
'type' => '0',
'sys_language_uid' => '0',
'url' => 'https://example.com/path/file.html',
'user_agent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36',
])->willReturn($model1->reveal());
$factory->fromDbRow([
'pid' => '9',
'crdate' => '1595948376',
'type' => '0',
'sys_language_uid' => '0',
'url' => 'https://example.com/path/file.html',
'user_agent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36',
])->willReturn($model2->reveal());
$subject = new Pageview($connection->reveal(), $factory->reveal());
static::assertCount(2, $subject->findAll());
$pageUid = 10;
foreach ($subject->findAll() as $model) {
static::assertSame($pageUid, $model->getPageUid());
--$pageUid;
}
}
}

View file

@ -23,13 +23,14 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Repository;
use DanielSiepmann\Tracking\Domain\Model\Recordview as Model;
use DanielSiepmann\Tracking\Domain\Repository\Recordview;
use DateTimeImmutable;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
/**
* @covers DanielSiepmann\Tracking\Domain\Repository\Recordview
* @covers \DanielSiepmann\Tracking\Domain\Repository\Recordview
*/
class RecordviewTest extends TestCase
{
@ -42,7 +43,7 @@ class RecordviewTest extends TestCase
{
$connection = $this->prophesize(Connection::class);
$dateTime = $this->prophesize(\DateTimeImmutable::class);
$dateTime = $this->prophesize(DateTimeImmutable::class);
$dateTime->format('U')->willReturn(1582660189);
$language = $this->prophesize(SiteLanguage::class);

View file

@ -26,28 +26,29 @@
}
},
"require": {
"doctrine/dbal": "^2.12",
"doctrine/dbal": "^2.12 || ^3.3",
"ext-mbstring": "*",
"php": "~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0",
"psr/http-message": "^1.0",
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0",
"symfony/console": "^5.2",
"symfony/expression-language": "^5.2",
"typo3/cms-backend": "^10.4 || ^11.5",
"typo3/cms-core": "^10.4 || ^11.5",
"typo3/cms-dashboard": "^10.4 || ^11.5"
"symfony/console": "^5.2 || ^6.1",
"symfony/expression-language": "^5.2 || ^6.1",
"typo3/cms-backend": "^11.5 || ~12.1.0",
"typo3/cms-core": "^11.5 || ~12.1.0",
"typo3/cms-dashboard": "^11.5 || ~12.1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"phpstan/phpstan": "1.5.4",
"phpstan/phpstan": "^1.8.7",
"phpstan/extension-installer": "^1.1",
"jangregor/phpstan-prophecy": "^1.0",
"phpspec/prophecy-phpunit": "^2.0",
"typo3/testing-framework": "^6.14",
"saschaegerer/phpstan-typo3": "^1.0",
"symplify/easy-coding-standard": "^9.3",
"cweagans/composer-patches": "^1.7"
"typo3/testing-framework": "~7.0@dev",
"symplify/easy-coding-standard": "^11.1",
"cweagans/composer-patches": "^1.7",
"ssch/typo3-rector": "^1.0",
"sbuerk/typo3-cmscomposerinstallers-testingframework-bridge": "^0.1"
},
"minimum-stability": "dev",
"prefer-stable": true,
@ -59,7 +60,7 @@
},
"extra": {
"typo3/cms": {
"cms-package-dir": "{$vendor-dir}/typo3/cms",
"app-dir": ".Build",
"extension-key": "tracking",
"web-dir": ".Build/web"
},
@ -75,7 +76,8 @@
"typo3/class-alias-loader": true,
"typo3/cms-composer-installers": true,
"cweagans/composer-patches": true,
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"sbuerk/typo3-cmscomposerinstallers-testingframework-bridge": true
}
}
}

310
ecs.php
View file

@ -1,16 +1,312 @@
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\ArrayIndentSniff;
use PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\UpperCaseConstantNameSniff;
use PHP_CodeSniffer\Standards\PSR1\Sniffs\Methods\CamelCapsMethodNameSniff;
use PHP_CodeSniffer\Standards\PSR12\Sniffs\ControlStructures\ControlStructureSpacingSniff as PSR12ControlStructureSpacingSniff;
use PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\OperatorSpacingSniff;
use PhpCsFixer\Fixer\Alias\MbStrFunctionsFixer;
use PhpCsFixer\Fixer\Alias\NoAliasFunctionsFixer;
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use PhpCsFixer\Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer;
use PhpCsFixer\Fixer\ArrayNotation\NormalizeIndexBraceFixer;
use PhpCsFixer\Fixer\ArrayNotation\NoTrailingCommaInSinglelineArrayFixer;
use PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer;
use PhpCsFixer\Fixer\ArrayNotation\TrimArraySpacesFixer;
use PhpCsFixer\Fixer\Basic\NoMultipleStatementsPerLineFixer;
use PhpCsFixer\Fixer\Basic\NonPrintableCharacterFixer;
use PhpCsFixer\Fixer\Casing\NativeFunctionCasingFixer;
use PhpCsFixer\Fixer\Casing\NativeFunctionTypeDeclarationCasingFixer;
use PhpCsFixer\Fixer\CastNotation\CastSpacesFixer;
use PhpCsFixer\Fixer\CastNotation\ModernizeTypesCastingFixer;
use PhpCsFixer\Fixer\CastNotation\NoUnsetCastFixer;
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
use PhpCsFixer\Fixer\ClassNotation\NoNullPropertyInitializationFixer;
use PhpCsFixer\Fixer\ClassNotation\SelfAccessorFixer;
use PhpCsFixer\Fixer\Comment\MultilineCommentOpeningClosingFixer;
use PhpCsFixer\Fixer\Comment\NoEmptyCommentFixer;
use PhpCsFixer\Fixer\Comment\SingleLineCommentSpacingFixer;
use PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer;
use PhpCsFixer\Fixer\ControlStructure\NoSuperfluousElseifFixer;
use PhpCsFixer\Fixer\ControlStructure\NoTrailingCommaInListCallFixer;
use PhpCsFixer\Fixer\ControlStructure\NoUnneededControlParenthesesFixer;
use PhpCsFixer\Fixer\ControlStructure\NoUselessElseFixer;
use PhpCsFixer\Fixer\ControlStructure\SimplifiedIfReturnFixer;
use PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer;
use PhpCsFixer\Fixer\FunctionNotation\NoTrailingCommaInSinglelineFunctionCallFixer;
use PhpCsFixer\Fixer\FunctionNotation\NoUnreachableDefaultArgumentValueFixer;
use PhpCsFixer\Fixer\FunctionNotation\NoUselessSprintfFixer;
use PhpCsFixer\Fixer\FunctionNotation\NullableTypeDeclarationForDefaultNullValueFixer;
use PhpCsFixer\Fixer\FunctionNotation\RegularCallableCallFixer;
use PhpCsFixer\Fixer\FunctionNotation\StaticLambdaFixer;
use PhpCsFixer\Fixer\Import\FullyQualifiedStrictTypesFixer;
use PhpCsFixer\Fixer\Import\GlobalNamespaceImportFixer;
use PhpCsFixer\Fixer\Import\NoUnneededImportAliasFixer;
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
use PhpCsFixer\Fixer\LanguageConstruct\CombineConsecutiveIssetsFixer;
use PhpCsFixer\Fixer\LanguageConstruct\CombineConsecutiveUnsetsFixer;
use PhpCsFixer\Fixer\LanguageConstruct\SingleSpaceAfterConstructFixer;
use PhpCsFixer\Fixer\ListNotation\ListSyntaxFixer;
use PhpCsFixer\Fixer\NamespaceNotation\SingleBlankLineBeforeNamespaceFixer;
use PhpCsFixer\Fixer\Naming\NoHomoglyphNamesFixer;
use PhpCsFixer\Fixer\Operator\IncrementStyleFixer;
use PhpCsFixer\Fixer\Operator\NewWithBracesFixer;
use PhpCsFixer\Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer;
use PhpCsFixer\Fixer\Operator\OperatorLinebreakFixer;
use PhpCsFixer\Fixer\Operator\StandardizeIncrementFixer;
use PhpCsFixer\Fixer\Operator\TernaryToElvisOperatorFixer;
use PhpCsFixer\Fixer\Operator\TernaryToNullCoalescingFixer;
use PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer;
use PhpCsFixer\Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer;
use PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocIndentFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocNoAccessFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocOrderByValueFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocOrderFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocScalarFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocSeparationFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocTrimConsecutiveBlankLineSeparationFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocTrimFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesOrderFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocVarAnnotationCorrectOrderFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocVarWithoutNameFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitConstructFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertInternalTypeFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitFqcnAnnotationFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitMethodCasingFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitMockFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitMockShortWillReturnFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitNamespacedFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitNoExpectationAnnotationFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitSetUpTearDownVisibilityFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitStrictFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestCaseStaticMethodCallsFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestClassRequiresCoversFixer;
use PhpCsFixer\Fixer\ReturnNotation\NoUselessReturnFixer;
use PhpCsFixer\Fixer\Semicolon\MultilineWhitespaceBeforeSemicolonsFixer;
use PhpCsFixer\Fixer\Semicolon\NoEmptyStatementFixer;
use PhpCsFixer\Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer;
use PhpCsFixer\Fixer\Semicolon\SemicolonAfterInstructionFixer;
use PhpCsFixer\Fixer\StringNotation\NoTrailingWhitespaceInStringFixer;
use PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer;
use PhpCsFixer\Fixer\StringNotation\StringLengthToEmptyFixer;
use PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer;
use PhpCsFixer\Fixer\Whitespace\CompactNullableTypehintFixer;
use PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer;
use PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer;
use PhpCsFixer\Fixer\Whitespace\NoSpacesAroundOffsetFixer;
use PhpCsFixer\Fixer\Whitespace\StatementIndentationFixer;
use PhpCsFixer\Fixer\Whitespace\TypesSpacesFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(SetList::PSR_12);
return static function (ECSConfig $ecsConfig): void {
$ecsConfig->sets([
SetList::PSR_12,
]);
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
$ecsConfig->paths([
__DIR__ . '/Classes',
__DIR__ . '/Tests',
__DIR__ . '/ecs.php',
__DIR__ . '/ext_emconf.php',
__DIR__ . '/ext_localconf.php',
__DIR__ . '/rector.php',
]);
$ecsConfig->skip([
CamelCapsMethodNameSniff::class => [
__DIR__ . '/Classes/Hooks/DataHandler.php',
],
]);
// Alias
$ecsConfig->rule(MbStrFunctionsFixer::class);
$ecsConfig->rule(NoAliasFunctionsFixer::class);
// ArrayNotation
$ecsConfig->ruleWithConfiguration(ArraySyntaxFixer::class, [
'syntax' => 'short',
]);
$ecsConfig->rule(NoMultilineWhitespaceAroundDoubleArrowFixer::class);
$ecsConfig->rule(NormalizeIndexBraceFixer::class);
$ecsConfig->rule(NoTrailingCommaInSinglelineArrayFixer::class);
$ecsConfig->rule(NoWhitespaceBeforeCommaInArrayFixer::class);
$ecsConfig->rule(TrimArraySpacesFixer::class);
// Basic
$ecsConfig->rule(NoMultipleStatementsPerLineFixer::class);
$ecsConfig->rule(NonPrintableCharacterFixer::class);
// Casing
$ecsConfig->rule(NativeFunctionCasingFixer::class);
$ecsConfig->rule(NativeFunctionTypeDeclarationCasingFixer::class);
// CastNotation
$ecsConfig->rule(CastSpacesFixer::class);
$ecsConfig->rule(ModernizeTypesCastingFixer::class);
$ecsConfig->rule(NoUnsetCastFixer::class);
// ClassNotation
$ecsConfig->ruleWithConfiguration(ClassAttributesSeparationFixer::class, [
'elements' => [
'const' => 'one',
'method' => 'one',
'property' => 'one',
'trait_import' => 'one',
],
]);
$ecsConfig->rule(NoNullPropertyInitializationFixer::class);
$ecsConfig->rule(SelfAccessorFixer::class);
$ecsConfig->rule(MultilineCommentOpeningClosingFixer::class);
$ecsConfig->rule(NoEmptyCommentFixer::class);
$ecsConfig->rule(SinglelineCommentSpacingFixer::class);
$ecsConfig->rule(SingleLineCommentStyleFixer::class);
// ControlStructure
$ecsConfig->rule(NoSuperfluousElseifFixer::class);
$ecsConfig->rule(NoTrailingCommaInListCallFixer::class);
$ecsConfig->rule(NoUnneededControlParenthesesFixer::class);
$ecsConfig->rule(NoUselessElseFixer::class);
$ecsConfig->rule(SimplifiedIfReturnFixer::class);
$ecsConfig->rule(TrailingCommaInMultilineFixer::class);
$ecsConfig->rule(PSR12ControlStructureSpacingSniff::class);
// FunctionNotation
$ecsConfig->rule(NoTrailingCommaInSinglelineFunctionCallFixer::class);
$ecsConfig->rule(NoUnreachableDefaultArgumentValueFixer::class);
$ecsConfig->rule(NoUselessSprintfFixer::class);
$ecsConfig->rule(NullableTypeDeclarationForDefaultNullValueFixer::class);
$ecsConfig->rule(RegularCallableCallFixer::class);
$ecsConfig->rule(StaticLambdaFixer::class);
// Import
$ecsConfig->rule(FullyQualifiedStrictTypesFixer::class);
$ecsConfig->rule(GlobalNamespaceImportFixer::class);
$ecsConfig->rule(NoUnneededImportAliasFixer::class);
$ecsConfig->rule(NoUnusedImportsFixer::class);
$ecsConfig->ruleWithConfiguration(OrderedImportsFixer::class, [
'sort_algorithm' => 'alpha',
]);
// LanguageConstruct
$ecsConfig->rule(CombineConsecutiveIssetsFixer::class);
$ecsConfig->rule(CombineConsecutiveUnsetsFixer::class);
$ecsConfig->rule(SingleSpaceAfterConstructFixer::class);
// ListNotation
$ecsConfig->rule(ListSyntaxFixer::class);
// NamespaceNotation
$ecsConfig->rule(SingleBlankLineBeforeNamespaceFixer::class);
// Naming
$ecsConfig->rule(CamelCapsMethodNameSniff::class);
$ecsConfig->rule(NoHomoglyphNamesFixer::class);
$ecsConfig->rule(UpperCaseConstantNameSniff::class);
// Operator
$ecsConfig->ruleWithConfiguration(IncrementStyleFixer::class, [
'style' => 'post',
]);
$ecsConfig->ruleWithConfiguration(NewWithBracesFixer::class, [
'anonymous_class' => false,
'named_class' => true,
]);
$ecsConfig->rule(ObjectOperatorWithoutWhitespaceFixer::class);
$ecsConfig->ruleWithConfiguration(OperatorLinebreakFixer::class, [
'position' => 'beginning',
]);
$ecsConfig->rule(StandardizeIncrementFixer::class);
$ecsConfig->rule(TernaryToElvisOperatorFixer::class);
$ecsConfig->rule(TernaryToNullCoalescingFixer::class);
$ecsConfig->rule(UnaryOperatorSpacesFixer::class);
// Phpdoc
$ecsConfig->rule(NoBlankLinesAfterPhpdocFixer::class);
$ecsConfig->rule(NoEmptyPhpdocFixer::class);
$ecsConfig->ruleWithConfiguration(NoSuperfluousPhpdocTagsFixer::class, [
'allow_mixed' => true,
]);
$ecsConfig->ruleWithConfiguration(PhpdocAlignFixer::class, [
'align' => 'left',
]);
$ecsConfig->rule(PhpdocIndentFixer::class);
$ecsConfig->rule(PhpdocLineSpanFixer::class);
$ecsConfig->rule(PhpdocNoAccessFixer::class);
$ecsConfig->ruleWithConfiguration(PhpdocOrderByValueFixer::class, [
'annotations' => [
'covers',
'throws',
],
]);
$ecsConfig->rule(PhpdocOrderFixer::class);
$ecsConfig->rule(PhpdocScalarFixer::class);
$ecsConfig->rule(PhpdocSeparationFixer::class);
$ecsConfig->rule(PhpdocToCommentFixer::class);
$ecsConfig->rule(PhpdocTrimConsecutiveBlankLineSeparationFixer::class);
$ecsConfig->rule(PhpdocTrimFixer::class);
$ecsConfig->rule(PhpdocTypesFixer::class);
$ecsConfig->rule(PhpdocTypesOrderFixer::class);
$ecsConfig->rule(PhpdocVarAnnotationCorrectOrderFixer::class);
$ecsConfig->rule(PhpdocVarWithoutNameFixer::class);
// PhpUnit
$ecsConfig->rule(PhpUnitConstructFixer::class);
$ecsConfig->rule(PhpUnitDedicateAssertFixer::class);
$ecsConfig->rule(PhpUnitDedicateAssertInternalTypeFixer::class);
$ecsConfig->rule(PhpUnitFqcnAnnotationFixer::class);
$ecsConfig->rule(PhpUnitMethodCasingFixer::class);
$ecsConfig->rule(PhpUnitMockFixer::class);
$ecsConfig->rule(PhpUnitMockShortWillReturnFixer::class);
$ecsConfig->rule(PhpUnitNamespacedFixer::class);
$ecsConfig->rule(PhpUnitNoExpectationAnnotationFixer::class);
$ecsConfig->rule(PhpUnitSetUpTearDownVisibilityFixer::class);
$ecsConfig->rule(PhpUnitStrictFixer::class);
$ecsConfig->ruleWithConfiguration(PhpUnitTestAnnotationFixer::class, [
'style' => 'annotation',
]);
$ecsConfig->ruleWithConfiguration(PhpUnitTestCaseStaticMethodCallsFixer::class, [
'call_type' => 'self',
]);
$ecsConfig->rule(PhpUnitTestClassRequiresCoversFixer::class);
// ReturnNotation
$ecsConfig->rule(NoUselessReturnFixer::class);
// Semicolon
$ecsConfig->ruleWithConfiguration(MultilineWhitespaceBeforeSemicolonsFixer::class, [
'strategy' => 'new_line_for_chained_calls',
]);
$ecsConfig->rule(NoEmptyStatementFixer::class);
$ecsConfig->rule(NoSinglelineWhitespaceBeforeSemicolonsFixer::class);
$ecsConfig->rule(SemicolonAfterInstructionFixer::class);
// StringNotation
$ecsConfig->rule(NoTrailingWhitespaceInStringFixer::class);
$ecsConfig->rule(SingleQuoteFixer::class);
$ecsConfig->rule(StringLengthToEmptyFixer::class);
// Whitespace
$ecsConfig->rule(ArrayIndentationFixer::class);
$ecsConfig->rule(ArrayIndentSniff::class);
$ecsConfig->rule(CompactNullableTypehintFixer::class);
$ecsConfig->rule(MethodChainingIndentationFixer::class);
$ecsConfig->rule(NoExtraBlankLinesFixer::class);
$ecsConfig->rule(NoSpacesAroundOffsetFixer::class);
$ecsConfig->ruleWithConfiguration(OperatorSpacingSniff::class, [
'ignoreSpacingBeforeAssignments' => false,
'ignoreNewlines' => true,
]);
$ecsConfig->rule(StatementIndentationFixer::class);
$ecsConfig->rule(TypesSpacesFixer::class);
};

View file

@ -5,13 +5,10 @@ $EM_CONF[$_EXTKEY] = [
'description' => 'Tracks page visits in TYPO3.',
'category' => 'fe',
'state' => 'stable',
'uploadfolder' => 0,
'createDirs' => '',
'clearCacheOnLoad' => 0,
'author' => 'Daniel Siepmann',
'author_email' => 'coding@daniel-siepmann.de',
'author_company' => '',
'version' => '1.4.0',
'version' => '2.0.0',
'constraints' => [
'depends' => [
'core' => '',

51
phpstan-baseline.neon Normal file
View file

@ -0,0 +1,51 @@
parameters:
ignoreErrors:
-
message: "#^Call to protected method getRecordOverlay\\(\\) of class TYPO3\\\\CMS\\\\Core\\\\Domain\\\\Repository\\\\PageRepository\\.$#"
count: 1
path: Classes/Dashboard/Provider/PageviewsPerPage.php
-
message: "#^Call to protected method getRecordOverlay\\(\\) of class TYPO3\\\\CMS\\\\Core\\\\Domain\\\\Repository\\\\PageRepository\\.$#"
count: 1
path: Classes/Dashboard/Provider/Recordviews.php
-
message: "#^Parameter \\#2 \\$callback of function array_filter expects callable\\(int\\|string\\)\\: mixed, Closure\\(string\\)\\: bool given\\.$#"
count: 1
path: Classes/Hooks/DataHandler.php
-
message: "#^Parameter \\#1 \\$command of class Symfony\\\\Component\\\\Console\\\\Tester\\\\CommandTester constructor expects Symfony\\\\Component\\\\Console\\\\Command\\\\Command, object given\\.$#"
count: 3
path: Tests/Functional/Command/UpdateDataCommandTest.php
-
message: "#^Call to an undefined method object\\:\\:getQueryBuilderForTable\\(\\)\\.$#"
count: 4
path: Tests/Functional/Dashboard/Provider/NewestPageviewsTest.php
-
message: "#^Call to an undefined method object\\:\\:getQueryBuilderForTable\\(\\)\\.$#"
count: 5
path: Tests/Functional/Dashboard/Provider/PageviewsPerDayTest.php
-
message: "#^Call to an undefined method object\\:\\:getQueryBuilderForTable\\(\\)\\.$#"
count: 5
path: Tests/Functional/Dashboard/Provider/PageviewsPerOperatingSystemTest.php
-
message: "#^Call to an undefined method object\\:\\:getQueryBuilderForTable\\(\\)\\.$#"
count: 7
path: Tests/Functional/Dashboard/Provider/PageviewsPerPageTest.php
-
message: "#^Parameter \\#2 \\$pageRepository of class DanielSiepmann\\\\Tracking\\\\Dashboard\\\\Provider\\\\PageviewsPerPage constructor expects TYPO3\\\\CMS\\\\Core\\\\Domain\\\\Repository\\\\PageRepository, object given\\.$#"
count: 7
path: Tests/Functional/Dashboard/Provider/PageviewsPerPageTest.php
-
message: "#^Parameter \\#1 \\$pageRepository of class DanielSiepmann\\\\Tracking\\\\Dashboard\\\\Provider\\\\Recordviews constructor expects TYPO3\\\\CMS\\\\Core\\\\Domain\\\\Repository\\\\PageRepository, object given\\.$#"
count: 9
path: Tests/Functional/Dashboard/Provider/RecordviewsTest.php

View file

@ -1,3 +1,5 @@
includes:
- phpstan-baseline.neon
parameters:
level: max
paths:
@ -6,16 +8,11 @@ parameters:
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false
ignoreErrors:
# Ignore error for TYPO3 10 and TYPO3 11
- '#Cannot call method fetch\(\) on Doctrine\\DBAL\\Driver\\Statement\|int\.#'
- '#Cannot call method fetch\(\) on Doctrine\\DBAL\\Driver\\ResultStatement\|int\.#'
# Ignore error for TYPO3 11 and TYPO3 12
- '#Cannot call method fetch\(\) on Doctrine\\DBAL\\Result\|int\.#'
- '#Cannot call method fetchAll\(\) on Doctrine\\DBAL\\Driver\\Statement\|int\.#'
- '#Cannot call method fetchAll\(\) on Doctrine\\DBAL\\Driver\\ResultStatement\|int\.#'
- '#Cannot call method fetchAll\(\) on Doctrine\\DBAL\\Result\|int\.#'
- '#Cannot call method fetchColumn\(\) on Doctrine\\DBAL\\Driver\\Statement\|int\.#'
- '#Cannot call method fetchColumn\(\) on Doctrine\\DBAL\\Driver\\ResultStatement\|int\.#'
- '#Cannot call method fetchColumn\(\) on Doctrine\\DBAL\\Result\|int\.#'
- '#Cannot call method fetchOne\(\) on Doctrine\\DBAL\\Result\|int\.#'
- "#^Parameter \\#[0-9] \\.\\.\\.\\$predicates of method TYPO3\\\\CMS\\\\Core\\\\Database\\\\Query\\\\QueryBuilder\\:\\:where\\(\\) expects array\\<int, mixed\\>\\|Doctrine\\\\DBAL\\\\Query\\\\Expression\\\\CompositeExpression, string given\\.$#"
- '#^Variable \$_EXTKEY might not be defined\.$#'
- "#^Cannot access offset '.*' on mixed.$#"

64
rector.php Normal file
View file

@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\PostRector\Rector\NameImportingPostRector;
use Ssch\TYPO3Rector\Configuration\Typo3Option;
use Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v9\v0\FileIncludeToImportStatementTypoScriptRector;
use Ssch\TYPO3Rector\Rector\General\ConvertImplicitVariablesToExplicitGlobalsRector;
use Ssch\TYPO3Rector\Rector\General\ExtEmConfRector;
use Ssch\TYPO3Rector\Set\Typo3LevelSetList;
return static function (RectorConfig $rectorConfig): void {
$parameters = $rectorConfig->parameters();
$rectorConfig->sets([
Typo3LevelSetList::UP_TO_TYPO3_11,
]);
$rectorConfig->paths([
__DIR__ . '/Classes',
__DIR__ . '/Tests',
__DIR__ . '/Configuration',
__DIR__ . '/ext_*.php',
]);
// In order to have a better analysis from phpstan we teach it here some more things
$rectorConfig->phpstanConfig(Typo3Option::PHPSTAN_FOR_RECTOR_PATH);
// FQN classes are not imported by default. If you don't do it manually after every Rector run, enable it by:
$rectorConfig->importNames();
// Disable parallel otherwise non php file processing is not working i.e. typoscript
$rectorConfig->disableParallel();
// this will not import root namespace classes, like \DateTime or \Exception
$rectorConfig->importShortClasses(true);
// Define your target version which you want to support
$rectorConfig->phpVersion(PhpVersion::PHP_74);
$rectorConfig->skip([
__DIR__ . '/.github/*',
NameImportingPostRector::class => [
'ext_localconf.php',
'ext_tables.php',
'ClassAliasMap.php',
__DIR__ . '/**/Configuration/*.php',
__DIR__ . '/**/Configuration/**/*.php',
],
]);
$rectorConfig->rule(StringClassNameToClassConstantRector::class);
// Add some general TYPO3 rules
$rectorConfig->rule(ConvertImplicitVariablesToExplicitGlobalsRector::class);
$rectorConfig->ruleWithConfiguration(ExtEmConfRector::class, [
ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [],
]);
$rectorConfig->rule(FileIncludeToImportStatementTypoScriptRector::class);
};