* Rector result with cgl applied
* Fix constructor multi line by hand
* Migrate away from prophecy.
This commit is contained in:
Daniel Siepmann 2024-02-05 11:25:00 +01:00
parent 6320129313
commit 413afa1851
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
56 changed files with 1242 additions and 1479 deletions

View file

@ -1,63 +1,365 @@
<?php
$finder = (new PhpCsFixer\Finder())
->ignoreVCSIgnored(true)
->in(realpath(__DIR__))
;
return (new \PhpCsFixer\Config())
declare(strict_types=1);
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Fixer\Alias\MbStrFunctionsFixer;
use PhpCsFixer\Fixer\Alias\NoAliasFunctionsFixer;
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use PhpCsFixer\Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer;
use PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer;
use PhpCsFixer\Fixer\ArrayNotation\NormalizeIndexBraceFixer;
use PhpCsFixer\Fixer\ArrayNotation\ReturnToYieldFromFixer;
use PhpCsFixer\Fixer\ArrayNotation\TrimArraySpacesFixer;
use PhpCsFixer\Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer;
use PhpCsFixer\Fixer\ArrayNotation\YieldFromArrayToYieldsFixer;
use PhpCsFixer\Fixer\AttributeNotation\AttributeEmptyParenthesesFixer;
use PhpCsFixer\Fixer\Basic\NoMultipleStatementsPerLineFixer;
use PhpCsFixer\Fixer\Basic\NoTrailingCommaInSinglelineFixer;
use PhpCsFixer\Fixer\Basic\NonPrintableCharacterFixer;
use PhpCsFixer\Fixer\Basic\NumericLiteralSeparatorFixer;
use PhpCsFixer\Fixer\Casing\ClassReferenceNameCasingFixer;
use PhpCsFixer\Fixer\Casing\NativeFunctionCasingFixer;
use PhpCsFixer\Fixer\Casing\NativeTypeDeclarationCasingFixer;
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\OrderedClassElementsFixer;
use PhpCsFixer\Fixer\ClassNotation\OrderedInterfacesFixer;
use PhpCsFixer\Fixer\ClassNotation\OrderedTraitsFixer;
use PhpCsFixer\Fixer\ClassNotation\OrderedTypesFixer;
use PhpCsFixer\Fixer\ClassNotation\SelfAccessorFixer;
use PhpCsFixer\Fixer\Comment\MultilineCommentOpeningClosingFixer;
use PhpCsFixer\Fixer\Comment\NoEmptyCommentFixer;
use PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer;
use PhpCsFixer\Fixer\ControlStructure\NoSuperfluousElseifFixer;
use PhpCsFixer\Fixer\ControlStructure\NoUnneededBracesFixer;
use PhpCsFixer\Fixer\ControlStructure\NoUnneededControlParenthesesFixer;
use PhpCsFixer\Fixer\ControlStructure\NoUselessElseFixer;
use PhpCsFixer\Fixer\ControlStructure\SimplifiedIfReturnFixer;
use PhpCsFixer\Fixer\ControlStructure\TrailingCommaInMultilineFixer;
use PhpCsFixer\Fixer\FunctionNotation\DateTimeCreateFromFormatCallFixer;
use PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer;
use PhpCsFixer\Fixer\FunctionNotation\NoUnreachableDefaultArgumentValueFixer;
use PhpCsFixer\Fixer\FunctionNotation\NoUselessSprintfFixer;
use PhpCsFixer\Fixer\FunctionNotation\NullableTypeDeclarationForDefaultNullValueFixer;
use PhpCsFixer\Fixer\FunctionNotation\PhpdocToParamTypeFixer;
use PhpCsFixer\Fixer\FunctionNotation\PhpdocToPropertyTypeFixer;
use PhpCsFixer\Fixer\FunctionNotation\PhpdocToReturnTypeFixer;
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\ClassKeywordFixer;
use PhpCsFixer\Fixer\LanguageConstruct\CombineConsecutiveIssetsFixer;
use PhpCsFixer\Fixer\LanguageConstruct\CombineConsecutiveUnsetsFixer;
use PhpCsFixer\Fixer\LanguageConstruct\NullableTypeDeclarationFixer;
use PhpCsFixer\Fixer\LanguageConstruct\SingleSpaceAroundConstructFixer;
use PhpCsFixer\Fixer\ListNotation\ListSyntaxFixer;
use PhpCsFixer\Fixer\NamespaceNotation\BlankLinesBeforeNamespaceFixer;
use PhpCsFixer\Fixer\Naming\NoHomoglyphNamesFixer;
use PhpCsFixer\Fixer\Operator\ConcatSpaceFixer;
use PhpCsFixer\Fixer\Operator\IncrementStyleFixer;
use PhpCsFixer\Fixer\Operator\LongToShorthandOperatorFixer;
use PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer;
use PhpCsFixer\Fixer\Operator\NoUselessConcatOperatorFixer;
use PhpCsFixer\Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer;
use PhpCsFixer\Fixer\Operator\OperatorLinebreakFixer;
use PhpCsFixer\Fixer\Operator\StandardizeIncrementFixer;
use PhpCsFixer\Fixer\Operator\TernaryOperatorSpacesFixer;
use PhpCsFixer\Fixer\Operator\TernaryToElvisOperatorFixer;
use PhpCsFixer\Fixer\Operator\TernaryToNullCoalescingFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitConstructFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitDataProviderReturnTypeFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitDataProviderStaticFixer;
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\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\PhpdocParamOrderFixer;
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\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\Strict\DeclareStrictTypesFixer;
use PhpCsFixer\Fixer\StringNotation\NoTrailingWhitespaceInStringFixer;
use PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer;
use PhpCsFixer\Fixer\StringNotation\StringImplicitBackslashesFixer;
use PhpCsFixer\Fixer\StringNotation\StringLengthToEmptyFixer;
use PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer;
use PhpCsFixer\Fixer\Whitespace\CompactNullableTypeDeclarationFixer;
use PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer;
use PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer;
use PhpCsFixer\Fixer\Whitespace\NoSpacesAroundOffsetFixer;
use PhpCsFixer\Fixer\Whitespace\StatementIndentationFixer;
use PhpCsFixer\Fixer\Whitespace\TypeDeclarationSpacesFixer;
use PhpCsFixer\Fixer\Whitespace\TypesSpacesFixer;
use PhpCsFixer\Preg;
/**
* Transforms a given class to php-cs-fixer rule name.
* That way we can use auto completion, phpstan, etc.
*
* @param class-string $className
*/
function transform(string $className): string
{
$nameParts = explode('\\', $className);
$name = mb_substr(end($nameParts), 0, -mb_strlen('Fixer'));
return mb_strtolower(Preg::replace(
'/(?<!^)((?=[\p{Lu}][^\p{Lu}])|(?<![\p{Lu}])(?=[\p{Lu}]))/',
'_',
$name
));
}
return (new Config())
->setRiskyAllowed(true)
->setFinder(
(new Finder())
->ignoreVCSIgnored(true)
->in(realpath(__DIR__))
)
->setRules([
'@DoctrineAnnotation' => true,
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_opening_tag' => true,
'braces' => ['allow_single_line_closure' => true],
'cast_spaces' => ['space' => 'none'],
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'dir_constant' => true,
'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']],
'function_typehint_space' => true,
'lowercase_cast' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'modernize_strpos' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'new_with_braces' => true,
'no_alias_functions' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_null_property_initialization' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_superfluous_elseif' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unneeded_control_parentheses' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
'php_unit_mock_short_will_return' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'phpdoc_no_access' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_scalar' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'return_type_declaration' => ['space_before' => 'none'],
'single_quote' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'single_trait_insert_per_statement' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'whitespace_after_comma_in_array' => true,
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
'@PSR12' => true,
transform(ArrayIndentationFixer::class) => true,
transform(ArraySyntaxFixer::class) => [
'syntax' => 'short',
],
transform(AttributeEmptyParenthesesFixer::class) => true,
transform(BlankLinesBeforeNamespaceFixer::class) => true,
transform(CastSpacesFixer::class) => true,
transform(ClassAttributesSeparationFixer::class) => [
'elements' => [
'const' => 'one',
'method' => 'one',
'property' => 'one',
'trait_import' => 'one',
],
],
transform(ClassKeywordFixer::class) => true,
transform(ClassReferenceNameCasingFixer::class) => true,
transform(CombineConsecutiveIssetsFixer::class) => true,
transform(CombineConsecutiveUnsetsFixer::class) => true,
transform(CompactNullableTypeDeclarationFixer::class) => true,
transform(ConcatSpaceFixer::class) => [
'spacing' => 'one',
],
transform(DateTimeCreateFromFormatCallFixer::class) => true,
transform(DeclareStrictTypesFixer::class) => true,
transform(FullyQualifiedStrictTypesFixer::class) => [
'import_symbols' => true,
'leading_backslash_in_global_namespace' => true,
],
transform(GlobalNamespaceImportFixer::class) => true,
transform(IncrementStyleFixer::class) => [
'style' => 'post',
],
transform(ListSyntaxFixer::class) => true,
transform(LongToShorthandOperatorFixer::class) => true,
transform(MbStrFunctionsFixer::class) => true,
transform(MethodArgumentSpaceFixer::class) => [
'on_multiline' => 'ensure_fully_multiline',
'attribute_placement' => 'standalone',
],
transform(MethodChainingIndentationFixer::class) => true,
transform(ModernizeTypesCastingFixer::class) => true,
transform(MultilineCommentOpeningClosingFixer::class) => true,
transform(MultilineWhitespaceBeforeSemicolonsFixer::class) => [
'strategy' => 'new_line_for_chained_calls',
],
transform(NativeFunctionCasingFixer::class) => true,
transform(NativeTypeDeclarationCasingFixer::class) => true,
transform(NewWithParenthesesFixer::class) => [
'anonymous_class' => false,
'named_class' => true,
],
transform(NoAliasFunctionsFixer::class) => true,
transform(NoBlankLinesAfterPhpdocFixer::class) => true,
transform(NoEmptyCommentFixer::class) => true,
transform(NoEmptyPhpdocFixer::class) => true,
transform(NoEmptyStatementFixer::class) => true,
transform(NoExtraBlankLinesFixer::class) => true,
transform(NoHomoglyphNamesFixer::class) => true,
transform(NoMultilineWhitespaceAroundDoubleArrowFixer::class) => true,
transform(NoMultipleStatementsPerLineFixer::class) => true,
transform(NoNullPropertyInitializationFixer::class) => true,
transform(NoSinglelineWhitespaceBeforeSemicolonsFixer::class) => true,
transform(NoSpacesAroundOffsetFixer::class) => true,
transform(NoSuperfluousElseifFixer::class) => true,
transform(NoSuperfluousPhpdocTagsFixer::class) => [
'allow_mixed' => true,
],
transform(NoTrailingCommaInSinglelineFixer::class) => true,
transform(NoTrailingWhitespaceInStringFixer::class) => true,
transform(NoUnneededBracesFixer::class) => true,
transform(NoUnneededControlParenthesesFixer::class) => true,
transform(NoUnneededImportAliasFixer::class) => true,
transform(NoUnreachableDefaultArgumentValueFixer::class) => true,
transform(NoUnsetCastFixer::class) => true,
transform(NoUnusedImportsFixer::class) => true,
transform(NoUselessConcatOperatorFixer::class) => true,
transform(NoUselessElseFixer::class) => true,
transform(NoUselessReturnFixer::class) => true,
transform(NoUselessSprintfFixer::class) => true,
transform(NoWhitespaceBeforeCommaInArrayFixer::class) => true,
transform(NonPrintableCharacterFixer::class) => true,
transform(NormalizeIndexBraceFixer::class) => true,
transform(NullableTypeDeclarationFixer::class) => true,
transform(NullableTypeDeclarationForDefaultNullValueFixer::class) => true,
transform(NumericLiteralSeparatorFixer::class) => [
'strategy' => NumericLiteralSeparatorFixer::STRATEGY_NO_SEPARATOR,
],
transform(ObjectOperatorWithoutWhitespaceFixer::class) => true,
transform(OperatorLinebreakFixer::class) => [
'position' => 'beginning', ],
transform(OrderedClassElementsFixer::class) => [
'order' => [
'use_trait',
'case',
'constant_public',
'constant_protected',
'constant_private',
'property_public',
'property_protected',
'property_private',
'construct',
'destruct',
'phpunit',
'method_public',
'method_protected',
'method_private',
'magic',
],
'case_sensitive' => true,
],
transform(OrderedImportsFixer::class) => [
'sort_algorithm' => 'alpha',
'case_sensitive' => true,
],
transform(OrderedInterfacesFixer::class) => [
'case_sensitive' => true,
],
transform(OrderedTraitsFixer::class) => [
'case_sensitive' => true,
],
transform(OrderedTypesFixer::class) => [
'case_sensitive' => true,
],
transform(PhpUnitConstructFixer::class) => true,
transform(PhpUnitDataProviderReturnTypeFixer::class) => true,
transform(PhpUnitDataProviderStaticFixer::class) => [
'force' => true,
],
transform(PhpUnitDedicateAssertFixer::class) => true,
transform(PhpUnitDedicateAssertInternalTypeFixer::class) => true,
transform(PhpUnitFqcnAnnotationFixer::class) => true,
transform(PhpUnitMethodCasingFixer::class) => true,
transform(PhpUnitMockFixer::class) => true,
transform(PhpUnitMockShortWillReturnFixer::class) => true,
transform(PhpUnitNamespacedFixer::class) => true,
transform(PhpUnitNoExpectationAnnotationFixer::class) => true,
transform(PhpUnitSetUpTearDownVisibilityFixer::class) => true,
transform(PhpUnitStrictFixer::class) => true,
transform(PhpUnitTestAnnotationFixer::class) => [
'style' => 'annotation',
],
transform(PhpUnitTestCaseStaticMethodCallsFixer::class) => [
'call_type' => 'self',
],
transform(PhpdocAlignFixer::class) => [
'align' => 'left',
],
transform(PhpdocIndentFixer::class) => true,
transform(PhpdocLineSpanFixer::class) => true,
transform(PhpdocNoAccessFixer::class) => true,
transform(PhpdocOrderByValueFixer::class) => [
'annotations' => [
'covers', 'throws',
],
],
transform(PhpdocOrderFixer::class) => true,
transform(PhpdocParamOrderFixer::class) => true,
transform(PhpdocScalarFixer::class) => true,
transform(PhpdocSeparationFixer::class) => [
'groups' => [
['see'],
['throw'],
['param'],
['return'],
],
],
transform(PhpdocToCommentFixer::class) => true,
transform(PhpdocToParamTypeFixer::class) => true,
transform(PhpdocToPropertyTypeFixer::class) => true,
transform(PhpdocToReturnTypeFixer::class) => true,
transform(PhpdocTrimConsecutiveBlankLineSeparationFixer::class) => true,
transform(PhpdocTrimFixer::class) => true,
transform(PhpdocTypesFixer::class) => true,
transform(PhpdocTypesOrderFixer::class) => [
'case_sensitive' => true,
],
transform(PhpdocVarAnnotationCorrectOrderFixer::class) => true,
transform(PhpdocVarWithoutNameFixer::class) => true,
transform(RegularCallableCallFixer::class) => true,
transform(ReturnToYieldFromFixer::class) => true,
transform(SelfAccessorFixer::class) => true,
transform(SemicolonAfterInstructionFixer::class) => true,
transform(SimplifiedIfReturnFixer::class) => true,
transform(SingleLineCommentStyleFixer::class) => true,
transform(SingleQuoteFixer::class) => true,
transform(SingleSpaceAroundConstructFixer::class) => true,
transform(StandardizeIncrementFixer::class) => true,
transform(StatementIndentationFixer::class) => true,
transform(StaticLambdaFixer::class) => true,
transform(StringImplicitBackslashesFixer::class) => [
'single_quoted' => 'ignore',
],
transform(StringLengthToEmptyFixer::class) => true,
transform(TernaryOperatorSpacesFixer::class) => true,
transform(TernaryToElvisOperatorFixer::class) => true,
transform(TernaryToNullCoalescingFixer::class) => true,
transform(TrailingCommaInMultilineFixer::class) => true,
transform(TrimArraySpacesFixer::class) => true,
transform(TypeDeclarationSpacesFixer::class) => true,
transform(TypesSpacesFixer::class) => true,
transform(WhitespaceAfterCommaInArrayFixer::class) => [
'ensure_single_space' => true,
],
transform(YieldFromArrayToYieldsFixer::class) => true,
])
->setFinder($finder);
;

View file

@ -31,15 +31,9 @@ use Symfony\Component\Console\Style\SymfonyStyle;
class UpdateDataCommand extends Command
{
/**
* @var Pageview
*/
private $repository;
public function __construct(Pageview $repository)
{
$this->repository = $repository;
public function __construct(
private readonly Pageview $repository
) {
parent::__construct();
}

View file

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace DanielSiepmann\Tracking\Dashboard\Provider;
use Exception;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Dashboard\Widgets\ListDataProviderInterface;
@ -30,35 +31,14 @@ use TYPO3\CMS\Dashboard\Widgets\ListDataProviderInterface;
class NewestPageviews implements ListDataProviderInterface
{
/**
* @var QueryBuilder
* @param int[] $languageLimitation
*/
private $queryBuilder;
/**
* @var int
*/
private $maxResults;
/**
* @var array
*/
private $pagesToExclude;
/**
* @var array<int>
*/
private $languageLimitation;
public function __construct(
QueryBuilder $queryBuilder,
int $maxResults = 6,
array $pagesToExclude = [],
array $languageLimitation = []
private readonly QueryBuilder $queryBuilder,
private readonly int $maxResults = 6,
private readonly array $pagesToExclude = [],
private readonly array $languageLimitation = []
) {
$this->queryBuilder = $queryBuilder;
$this->maxResults = $maxResults;
$this->pagesToExclude = $pagesToExclude;
$this->languageLimitation = $languageLimitation;
}
public function getItems(): array
@ -98,10 +78,13 @@ class NewestPageviews implements ListDataProviderInterface
$this->queryBuilder->where(...$constraints);
}
$items = $this->queryBuilder->execute()->fetchAll();
$items = $this->queryBuilder->executeQuery()->fetchAllAssociative();
foreach ($items as $item) {
if (is_array($item) === false) {
continue;
if (is_string($item['url']) === false) {
throw new Exception('url of item was not string: ' . var_export($item['url'], true), 1707327319);
}
if (is_string($item['user_agent']) === false) {
throw new Exception('user_agent of item was not string: ' . var_export($item['user_agent'], true), 1707327344);
}
$preparedItems[] = sprintf(

View file

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace DanielSiepmann\Tracking\Dashboard\Provider;
use DanielSiepmann\Tracking\Extension;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Localization\LanguageService;
@ -32,49 +33,20 @@ use TYPO3\CMS\Dashboard\Widgets\ChartDataProviderInterface;
class PageviewsPerDay implements ChartDataProviderInterface
{
/**
* @var LanguageService
*/
private $languageService;
private LanguageService $languageService;
/**
* @var QueryBuilder
* @param int[] $pagesToExclude
* @param int[] $languageLimitation
*/
private $queryBuilder;
/**
* @var int
*/
private $days;
/**
* @var array<int>
*/
private $pagesToExclude;
/**
* @var string
*/
private $dateFormat;
/**
* @var array<int>
*/
private $languageLimitation;
public function __construct(
QueryBuilder $queryBuilder,
int $days = 31,
array $pagesToExclude = [],
array $languageLimitation = [],
string $dateFormat = 'Y-m-d'
private readonly QueryBuilder $queryBuilder,
private readonly int $days = 31,
private readonly array $pagesToExclude = [],
private readonly array $languageLimitation = [],
private readonly string $dateFormat = 'Y-m-d'
) {
$this->languageService = $GLOBALS['LANG'];
$this->queryBuilder = $queryBuilder;
$this->days = $days;
$this->pagesToExclude = $pagesToExclude;
$this->languageLimitation = $languageLimitation;
$this->dateFormat = $dateFormat;
}
public function getChartData(): array
@ -102,16 +74,16 @@ class PageviewsPerDay implements ChartDataProviderInterface
$data = [];
for ($daysBefore = $this->days; $daysBefore >= 0; $daysBefore--) {
$label = date($this->dateFormat, (int)strtotime('-' . $daysBefore . ' day'));
$label = date($this->dateFormat, (int) strtotime('-' . $daysBefore . ' day'));
$labels[$label] = $label;
$data[$label] = 0;
}
$start = (int)strtotime('-' . $this->days . ' day 0:00:00');
$end = (int)strtotime('tomorrow midnight');
$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'];
$data[$day['label']] = (int) $day['count'];
}
return [
@ -154,13 +126,15 @@ class PageviewsPerDay implements ChartDataProviderInterface
->groupBy('label')
->orderBy('label', 'ASC')
;
if ($this->queryBuilder->getConnection()->getDatabasePlatform()->getName() === 'sqlite') {
if (
(class_exists(SqlitePlatform::class) && $this->queryBuilder->getConnection()->getDatabasePlatform() instanceof SqlitePlatform)
|| (method_exists($this->queryBuilder->getConnection()->getDatabasePlatform(), 'getName') && $this->queryBuilder->getConnection()->getDatabasePlatform()->getName() === 'sqlite')
) {
$this->queryBuilder->addSelectLiteral('date(crdate, "unixepoch") as "label"');
} else {
$this->queryBuilder->addSelectLiteral('FROM_UNIXTIME(crdate, "%Y-%m-%d") as "label"');
}
return $this->queryBuilder->execute()->fetchAll();
return $this->queryBuilder->executeQuery()->fetchAllAssociative();
}
}

View file

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace DanielSiepmann\Tracking\Dashboard\Provider;
use Exception;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Dashboard\WidgetApi;
@ -31,35 +32,14 @@ use TYPO3\CMS\Dashboard\Widgets\ChartDataProviderInterface;
class PageviewsPerOperatingSystem implements ChartDataProviderInterface
{
/**
* @var QueryBuilder
* @param int[] $languageLimitation
*/
private $queryBuilder;
/**
* @var int
*/
private $days;
/**
* @var int
*/
private $maxResults;
/**
* @var array<int>
*/
private $languageLimitation;
public function __construct(
QueryBuilder $queryBuilder,
int $days = 31,
int $maxResults = 6,
array $languageLimitation = []
private readonly QueryBuilder $queryBuilder,
private readonly int $days = 31,
private readonly int $maxResults = 6,
private readonly array $languageLimitation = []
) {
$this->queryBuilder = $queryBuilder;
$this->days = $days;
$this->maxResults = $maxResults;
$this->languageLimitation = $languageLimitation;
}
public function getChartData(): array
@ -112,13 +92,13 @@ class PageviewsPerOperatingSystem implements ChartDataProviderInterface
->orderBy('total', 'desc')
->addOrderBy('operating_system', 'asc')
->setMaxResults($this->maxResults)
->execute()
->fetchAll()
->executeQuery()
->fetchAllAssociative()
;
foreach ($result as $row) {
if (is_array($row) === false) {
continue;
if (is_string($row['operating_system']) === false) {
throw new Exception('operating_system of row was not string: ' . var_export($row['operating_system'], true), 1707326866);
}
$labels[] = mb_strimwidth($row['operating_system'], 0, 50, '…');

View file

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace DanielSiepmann\Tracking\Dashboard\Provider;
use Exception;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
@ -33,49 +34,17 @@ use TYPO3\CMS\Dashboard\Widgets\ChartDataProviderInterface;
class PageviewsPerPage implements ChartDataProviderInterface
{
/**
* @var QueryBuilder
* @param int[] $pagesToExclude
* @param int[] $languageLimitation
*/
private $queryBuilder;
/**
* @var PageRepository
*/
private $pageRepository;
/**
* @var int
*/
private $days;
/**
* @var int
*/
private $maxResults;
/**
* @var array<int>
*/
private $pagesToExclude;
/**
* @var array<int>
*/
private $languageLimitation;
public function __construct(
QueryBuilder $queryBuilder,
PageRepository $pageRepository,
int $days = 31,
int $maxResults = 6,
array $pagesToExclude = [],
array $languageLimitation = []
private readonly QueryBuilder $queryBuilder,
private readonly PageRepository $pageRepository,
private readonly int $days = 31,
private readonly int $maxResults = 6,
private readonly array $pagesToExclude = [],
private readonly array $languageLimitation = []
) {
$this->queryBuilder = $queryBuilder;
$this->pageRepository = $pageRepository;
$this->days = $days;
$this->maxResults = $maxResults;
$this->pagesToExclude = $pagesToExclude;
$this->languageLimitation = $languageLimitation;
}
public function getChartData(): array
@ -136,16 +105,16 @@ class PageviewsPerPage implements ChartDataProviderInterface
->orderBy('total', 'desc')
->addOrderBy('latest', 'desc')
->setMaxResults($this->maxResults)
->execute()
->fetchAll()
->executeQuery()
->fetchAllAssociative()
;
foreach ($result as $row) {
if (is_array($row) === false) {
continue;
if (is_numeric($row['pid']) === false) {
throw new Exception('PID of row was not numeric: ' . var_export($row['pid'], true), 1707326783);
}
$labels[] = $this->getRecordTitle((int)$row['pid']);
$labels[] = $this->getRecordTitle((int) $row['pid']);
$data[] = $row['total'];
}
@ -159,13 +128,16 @@ class PageviewsPerPage implements ChartDataProviderInterface
{
$record = BackendUtility::getRecord('pages', $uid);
if (count($this->languageLimitation) === 1 && $record !== null) {
$record = $this->pageRepository->getRecordOverlay('pages', $record, $this->languageLimitation[0]);
$record = $this->pageRepository->getPageOverlay(
$record,
$this->languageLimitation[0]
);
}
if (is_array($record) === false) {
return 'Unkown';
}
return strip_tags(BackendUtility::getRecordTitle('pages', $record, true));
return strip_tags((string) BackendUtility::getRecordTitle('pages', $record, true));
}
}

View file

@ -23,9 +23,10 @@ declare(strict_types=1);
namespace DanielSiepmann\Tracking\Dashboard\Provider;
use DanielSiepmann\Tracking\LanguageAspectFactory;
use Exception;
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\Domain\Repository\PageRepository;
@ -35,63 +36,20 @@ use TYPO3\CMS\Dashboard\Widgets\ChartDataProviderInterface;
class Recordviews implements ChartDataProviderInterface
{
/**
* @var PageRepository
* @param int[] $pagesToExclude
* @param int[] $languageLimitation
*/
private $pageRepository;
/**
* @var QueryBuilder
*/
private $queryBuilder;
/**
* @var int
*/
private $days;
/**
* @var int
*/
private $maxResults;
/**
* @var array<int>
*/
private $pagesToExclude;
/**
* @var array<int>
*/
private $languageLimitation;
/**
* @var array
*/
private $recordTableLimitation;
/**
* @var array
*/
private $recordTypeLimitation;
public function __construct(
PageRepository $pageRepository,
QueryBuilder $queryBuilder,
int $days = 31,
int $maxResults = 6,
array $pagesToExclude = [],
array $languageLimitation = [],
array $recordTableLimitation = [],
array $recordTypeLimitation = []
private readonly PageRepository $pageRepository,
private readonly QueryBuilder $queryBuilder,
private readonly LanguageAspectFactory $languageAspectFactory,
private readonly int $days = 31,
private readonly int $maxResults = 6,
private readonly array $pagesToExclude = [],
private readonly array $languageLimitation = [],
private readonly array $recordTableLimitation = [],
private readonly array $recordTypeLimitation = []
) {
$this->pageRepository = $pageRepository;
$this->queryBuilder = $queryBuilder;
$this->days = $days;
$this->pagesToExclude = $pagesToExclude;
$this->languageLimitation = $languageLimitation;
$this->maxResults = $maxResults;
$this->recordTableLimitation = $recordTableLimitation;
$this->recordTypeLimitation = $recordTypeLimitation;
}
public function getChartData(): array
@ -118,8 +76,13 @@ class Recordviews implements ChartDataProviderInterface
if (is_numeric($recordview['record_uid']) === false) {
continue;
}
if (is_string($recordview['record_table_name']) === false) {
throw new Exception('record_table_name of recordview was not string: ' . var_export($recordview['record_table_name'], true), 1707327404);
}
$record = $this->getRecord(
(int)$recordview['record_uid'],
(int) $recordview['record_uid'],
$recordview['record_table_name']
);
@ -133,7 +96,7 @@ class Recordviews implements ChartDataProviderInterface
continue;
}
$labels[] = mb_strimwidth($record['title'], 0, 25, '…');
$labels[] = mb_strimwidth((string) $record['title'], 0, 25, '…');
$data[] = $recordview['total'];
}
@ -143,6 +106,9 @@ class Recordviews implements ChartDataProviderInterface
];
}
/**
* @return Generator<array>
*/
private function getRecordviewsRecords(): Generator
{
$constraints = [
@ -194,10 +160,10 @@ class Recordviews implements ChartDataProviderInterface
->orderBy('total', 'desc')
->addOrderBy('latest', 'desc')
->setMaxResults($this->maxResults)
->execute()
->executeQuery()
;
while ($row = $result->fetch()) {
while ($row = $result->fetchAssociative()) {
yield $row;
}
}
@ -210,10 +176,10 @@ class Recordviews implements ChartDataProviderInterface
$record = BackendUtility::getRecord($table, $uid);
if (count($this->languageLimitation) === 1 && $record !== null) {
$record = $this->pageRepository->getRecordOverlay(
$record = $this->pageRepository->getLanguageOverlay(
$table,
$record,
$this->createLanguageAspect($this->languageLimitation[0])
$this->languageAspectFactory->createFromLanguageUid($this->languageLimitation[0])
);
}
@ -222,17 +188,8 @@ class Recordviews implements ChartDataProviderInterface
}
return [
'title' => strip_tags(BackendUtility::getRecordTitle($table, $record, true)),
'title' => strip_tags((string) BackendUtility::getRecordTitle($table, $record, true)),
'type' => $record[$recordTypeField] ?? '',
];
}
private function createLanguageAspect(int $languageUid): LanguageAspect
{
return new LanguageAspect(
$languageUid,
null,
LanguageAspect::OVERLAYS_MIXED
);
}
}

View file

@ -61,7 +61,7 @@ class SymfonyExpressionLanguage implements Factory
}
try {
return ArrayUtility::getValueByPath($array, $path);
} catch (MissingArrayPathException $e) {
} catch (MissingArrayPathException) {
return '';
}
}

View file

@ -25,8 +25,5 @@ namespace DanielSiepmann\Tracking\Domain\Model;
interface Expression
{
/**
* @return mixed
*/
public function evaluate();
public function evaluate(): mixed;
}

View file

@ -28,57 +28,15 @@ use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
class Pageview implements HasUserAgent
{
/**
* @var int
*/
private $uid = 0;
/**
* @var int
*/
private $pageUid;
/**
* @var SiteLanguage
*/
private $language;
/**
* @var DateTimeImmutable
*/
private $crdate;
/**
* @var int
*/
private $pageType;
/**
* @var string
*/
private $url;
/**
* @var string
*/
private $userAgent;
public function __construct(
int $pageUid,
SiteLanguage $language,
DateTimeImmutable $crdate,
int $pageType,
string $url,
string $userAgent,
int $uid = 0
private readonly int $pageUid,
private readonly SiteLanguage $language,
private readonly DateTimeImmutable $crdate,
private readonly int $pageType,
private readonly string $url,
private readonly string $userAgent,
private readonly int $uid = 0
) {
$this->uid = $uid;
$this->pageUid = $pageUid;
$this->language = $language;
$this->crdate = $crdate;
$this->pageType = $pageType;
$this->url = $url;
$this->userAgent = $userAgent;
}
public function getUid(): int

View file

@ -25,29 +25,11 @@ namespace DanielSiepmann\Tracking\Domain\Model;
class RecordRule
{
/**
* @var string
*/
private $matches;
/**
* @var string
*/
private $recordUid;
/**
* @var string
*/
private $tableName;
public function __construct(
string $matches,
string $recordUid,
string $tableName
private readonly string $matches,
private readonly string $recordUid,
private readonly string $tableName
) {
$this->matches = $matches;
$this->recordUid = $recordUid;
$this->tableName = $tableName;
}
public static function fromArray(array $config): self

View file

@ -28,57 +28,15 @@ use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
class Recordview implements HasUserAgent
{
/**
* @var int
*/
private $pageUid;
/**
* @var SiteLanguage
*/
private $language;
/**
* @var DateTimeImmutable
*/
private $crdate;
/**
* @var string
*/
private $url;
/**
* @var string
*/
private $userAgent;
/**
* @var int
*/
private $recordUid;
/**
* @var string
*/
private $tableName;
public function __construct(
int $pageUid,
SiteLanguage $language,
DateTimeImmutable $crdate,
string $url,
string $userAgent,
int $recordUid,
string $tableName
private readonly int $pageUid,
private readonly SiteLanguage $language,
private readonly DateTimeImmutable $crdate,
private readonly string $url,
private readonly string $userAgent,
private readonly int $recordUid,
private readonly string $tableName
) {
$this->pageUid = $pageUid;
$this->language = $language;
$this->crdate = $crdate;
$this->url = $url;
$this->userAgent = $userAgent;
$this->recordUid = $recordUid;
$this->tableName = $tableName;
}
public function getPageUid(): int

View file

@ -27,32 +27,14 @@ use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
class SymfonyExpression implements Expression
{
/**
* @var string
*/
private $expression;
/**
* @var array
*/
private $values;
/**
* @var ExpressionLanguage
*/
private $symfonyExpression;
public function __construct(
string $expression,
array $values,
ExpressionLanguage $symfonyExpression
private readonly string $expression,
private readonly array $values,
private readonly ExpressionLanguage $symfonyExpression
) {
$this->expression = $expression;
$this->values = $values;
$this->symfonyExpression = $symfonyExpression;
}
public function evaluate()
public function evaluate(): mixed
{
return $this->symfonyExpression->evaluate(
$this->expression,

View file

@ -33,14 +33,9 @@ use UnexpectedValueException;
class Factory
{
/**
* @var SiteFinder
*/
private $siteFinder;
public function __construct(SiteFinder $siteFinder)
{
$this->siteFinder = $siteFinder;
public function __construct(
private readonly SiteFinder $siteFinder
) {
}
public function fromRequest(ServerRequestInterface $request): Pageview
@ -49,8 +44,8 @@ class Factory
$this->getRouting($request)->getPageId(),
$this->getLanguage($request),
new DateTimeImmutable(),
(int)$this->getRouting($request)->getPageType(),
(string)$request->getUri(),
(int) $this->getRouting($request)->getPageType(),
(string) $request->getUri(),
$request->getHeader('User-Agent')[0] ?? ''
);
}
@ -58,13 +53,13 @@ class Factory
public function fromDbRow(array $dbRow): Pageview
{
return new Pageview(
(int)$dbRow['pid'],
$this->siteFinder->getSiteByPageId((int)$dbRow['pid'])->getLanguageById((int)$dbRow['sys_language_uid']),
(int) $dbRow['pid'],
$this->siteFinder->getSiteByPageId((int) $dbRow['pid'])->getLanguageById((int) $dbRow['sys_language_uid']),
new DateTimeImmutable('@' . $dbRow['crdate']),
(int)$dbRow['type'],
(int) $dbRow['type'],
$dbRow['url'],
$dbRow['user_agent'],
(int)$dbRow['uid']
(int) $dbRow['uid']
);
}

View file

@ -34,15 +34,9 @@ use UnexpectedValueException;
class Factory
{
/**
* @var ExpressionFactory
*/
private $expressionFactory;
public function __construct(
ExpressionFactory $expressionFactory
private readonly ExpressionFactory $expressionFactory
) {
$this->expressionFactory = $expressionFactory;
}
public function fromRequest(
@ -69,9 +63,9 @@ class Factory
self::getRouting($request)->getPageId(),
self::getLanguage($request),
new DateTimeImmutable(),
(string)$request->getUri(),
(string) $request->getUri(),
$request->getHeader('User-Agent')[0] ?? '',
(int)$recordUid,
(int) $recordUid,
$rule->getTableName()
);
}

View file

@ -31,22 +31,10 @@ use TYPO3\CMS\Core\Database\Connection;
class Pageview
{
/**
* @var Connection
*/
private $connection;
/**
* @var Factory
*/
private $factory;
public function __construct(
Connection $connection,
Factory $factory
private readonly Connection $connection,
private readonly Factory $factory
) {
$this->connection = $connection;
$this->factory = $factory;
}
public function countAll(): int
@ -54,27 +42,26 @@ class Pageview
$result = $this->connection->createQueryBuilder()
->count('uid')
->from('tx_tracking_pageview')
->execute()
->executeQuery()
->fetchOne()
;
if (is_numeric($result)) {
return (int)$result;
return (int) $result;
}
return 0;
}
/**
* @return Generator<Model>
*/
public function findAll(): Generator
{
$queryBuilder = $this->connection->createQueryBuilder();
$pageViews = $queryBuilder->select('*')->from('tx_tracking_pageview')->execute();
while ($pageView = $pageViews->fetch()) {
if (is_array($pageView) === false) {
continue;
}
$pageViews = $queryBuilder->select('*')->from('tx_tracking_pageview')->executeQuery();
while ($pageView = $pageViews->fetchAssociative()) {
yield $this->factory->fromDbRow($pageView);
}
}

View file

@ -28,15 +28,9 @@ use TYPO3\CMS\Core\Database\Connection;
class Recordview
{
/**
* @var Connection
*/
private $connection;
public function __construct(
Connection $connection
private readonly Connection $connection
) {
$this->connection = $connection;
}
public function add(Model $recordview): void

View file

@ -55,9 +55,10 @@ class DataHandler
$copyWhichTables = GeneralUtility::trimExplode(',', $dataHandler->copyWhichTables, true);
}
$copyWhichTables = array_filter($copyWhichTables, static function (string $tableName) {
return \str_starts_with($tableName, 'tx_tracking_') === false;
});
$copyWhichTables = array_filter(
$copyWhichTables,
static fn (int|string $tableName): bool => \str_starts_with((string) $tableName, 'tx_tracking_') === false
);
$dataHandler->copyWhichTables = implode(',', $copyWhichTables);
}

View file

@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
/*
* Copyright (C) 2024 Daniel Siepmann <coding@daniel-siepmann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
namespace DanielSiepmann\Tracking;
use TYPO3\CMS\Core\Context\LanguageAspect;
class LanguageAspectFactory
{
public function createFromLanguageUid(int $languageUid): LanguageAspect
{
return new LanguageAspect(
$languageUid,
null,
LanguageAspect::OVERLAYS_MIXED
);
}
}

View file

@ -34,43 +34,13 @@ use TYPO3\CMS\Core\Context\Context;
class Pageview implements MiddlewareInterface
{
/**
* @var Repository
*/
private $repository;
/**
* @var Context
*/
private $context;
/**
* @var Factory
*/
private $factory;
/**
* @var ExpressionFactory
*/
private $expressionFactory;
/**
* @var string
*/
private $rule = '';
public function __construct(
Repository $repository,
Context $context,
Factory $factory,
ExpressionFactory $expressionFactory,
string $rule
private readonly Repository $repository,
private readonly Context $context,
private readonly Factory $factory,
private readonly ExpressionFactory $expressionFactory,
private readonly string $rule
) {
$this->repository = $repository;
$this->context = $context;
$this->factory = $factory;
$this->expressionFactory = $expressionFactory;
$this->rule = $rule;
}
public function process(
@ -88,7 +58,7 @@ class Pageview implements MiddlewareInterface
ServerRequestInterface $request,
Context $context
): bool {
return (bool)$this->expressionFactory->create(
return (bool) $this->expressionFactory->create(
$this->rule,
[
'request' => $request,

View file

@ -35,43 +35,18 @@ use TYPO3\CMS\Core\Context\Context;
class Recordview implements MiddlewareInterface
{
/**
* @var Repository
*/
private $repository;
/**
* @var Context
*/
private $context;
/**
* @var Factory
*/
private $factory;
/**
* @var ExpressionFactory
*/
private $expressionFactory;
/**
* @var array<RecordRule>
*/
private $rules = [];
private array $rules = [];
public function __construct(
Repository $repository,
Context $context,
Factory $factory,
ExpressionFactory $expressionFactory,
private readonly Repository $repository,
private readonly Context $context,
private readonly Factory $factory,
private readonly ExpressionFactory $expressionFactory,
array $rules
) {
$this->repository = $repository;
$this->context = $context;
$this->factory = $factory;
$this->expressionFactory = $expressionFactory;
$this->rules = RecordRule::multipleFromArray($rules);
}
@ -93,7 +68,7 @@ class Recordview implements MiddlewareInterface
Context $context,
RecordRule $rule
): bool {
return (bool)$this->expressionFactory->create(
return (bool) $this->expressionFactory->create(
$rule->getMatchesExpression(),
[
'request' => $request,

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
return [
'tracking' => [
'title' => 'LLL:EXT:tracking/Resources/Private/Language/locallang.xlf:dashboard.widget.group.tracking',

View file

@ -14,7 +14,6 @@ services:
dashboard.widget.danielsiepmann.tracking.pageViewsPerDay:
class: 'TYPO3\CMS\Dashboard\Widgets\BarChartWidget'
arguments:
$view: '@dashboard.views.widget'
$dataProvider: '@DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerDay'
tags:
- name: 'dashboard.widget'
@ -34,7 +33,6 @@ services:
dashboard.widget.danielsiepmann.tracking.pageViewsPerPage:
class: 'TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget'
arguments:
$view: '@dashboard.views.widget'
$dataProvider: '@DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerPage'
tags:
- name: 'dashboard.widget'
@ -54,7 +52,6 @@ services:
dashboard.widget.danielsiepmann.tracking.newestPageviews:
class: 'TYPO3\CMS\Dashboard\Widgets\ListWidget'
arguments:
$view: '@dashboard.views.widget'
$dataProvider: '@DanielSiepmann\Tracking\Dashboard\Provider\NewestPageviews'
tags:
- name: 'dashboard.widget'
@ -74,7 +71,6 @@ services:
dashboard.widget.danielsiepmann.tracking.operatingSystems:
class: 'TYPO3\CMS\Dashboard\Widgets\DoughnutChartWidget'
arguments:
$view: '@dashboard.views.widget'
$dataProvider: '@DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerOperatingSystem'
tags:
- name: 'dashboard.widget'

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
use DanielSiepmann\Tracking\Middleware\Pageview;
use DanielSiepmann\Tracking\Middleware\Recordview;

View file

@ -1,6 +1,8 @@
<?php
$tca = [
declare(strict_types=1);
return [
'ctrl' => [
'label' => 'url',
'label_alt' => 'crdate',
@ -69,16 +71,3 @@ $tca = [
],
],
];
if ((new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion() < 12) {
$tca['ctrl']['cruser_id'] = 'cruser_id';
$tca['columns']['crdate']['config']['type'] = 'input';
$tca['columns']['crdate']['config']['renderType'] = 'inputDateTime';
$tca['columns']['crdate']['config']['eval'] = 'datetime';
$tca['columns']['type']['config']['type'] = 'input';
$tca['columns']['type']['config']['eval'] = 'int';
}
return $tca;

View file

@ -1,6 +1,8 @@
<?php
$tca = [
declare(strict_types=1);
return [
'ctrl' => [
'label' => 'record',
'label_alt' => 'crdate',
@ -72,13 +74,3 @@ $tca = [
],
],
];
if ((new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion() < 12) {
$tca['ctrl']['cruser_id'] = 'cruser_id';
$tca['columns']['crdate']['config']['type'] = 'input';
$tca['columns']['crdate']['config']['renderType'] = 'inputDateTime';
$tca['columns']['crdate']['config']['eval'] = 'datetime';
}
return $tca;

View file

@ -21,21 +21,16 @@ declare(strict_types=1);
* 02110-1301, USA.
*/
namespace DanielSiepmann\Tests\Functional;
namespace DanielSiepmann\Tracking\Tests\Functional;
use Codappix\Typo3PhpDatasets\TestingFramework;
use DanielSiepmann\AbstractFunctional;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
abstract class AbstractFunctionalTest extends FunctionalTestCase
abstract class AbstractFunctionalTestCase extends FunctionalTestCase
{
use TestingFramework;
protected array $testExtensionsToLoad = [
'danielsiepmann/tracking',
];
protected array $testExtensionsToLoad = ['danielsiepmann/tracking'];
protected array $coreExtensionsToLoad = [
'typo3/cms-dashboard',
];
protected array $coreExtensionsToLoad = ['typo3/cms-dashboard'];
}

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Functional\Command;
/*
@ -21,30 +23,21 @@ namespace DanielSiepmann\Tracking\Tests\Functional\Command;
* 02110-1301, USA.
*/
use Codappix\Typo3PhpDatasets\TestingFramework;
use DanielSiepmann\Tracking\Command\UpdateDataCommand;
use DanielSiepmann\Tracking\Tests\Functional\AbstractFunctionalTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Symfony\Component\Console\Tester\CommandTester;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
/**
* @covers \DanielSiepmann\Tracking\Command\UpdateDataCommand
*/
class UpdateDataCommandTest extends FunctionalTestCase
#[CoversClass(UpdateDataCommand::class)]
final class UpdateDataCommandTest extends AbstractFunctionalTestCase
{
use TestingFramework;
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
protected array $pathsToLinkInTestInstance = [
'typo3conf/ext/tracking/Tests/Functional/Fixtures/sites' => 'typo3conf/sites',
];
/**
* @test
*/
#[Test]
public function updatesAllEntriesWithMissingOperatingSystem(): void
{
$this->importPHPDataSet(__DIR__ . '/../Fixtures/UpdateDataCommandTest/PageviewsWithMissingOperatingSystem.php');
@ -61,9 +54,7 @@ class UpdateDataCommandTest extends FunctionalTestCase
self::assertSame('Android', $records[1]['operating_system']);
}
/**
* @test
*/
#[Test]
public function doesNotChangeExistingOperatingSystem(): void
{
$this->importPHPDataSet(__DIR__ . '/../Fixtures/UpdateDataCommandTest/PageviewsWithOperatingSystem.php');
@ -80,9 +71,7 @@ class UpdateDataCommandTest extends FunctionalTestCase
self::assertSame('Android', $records[1]['operating_system']);
}
/**
* @test
*/
#[Test]
public function doesNothingIfNoRecordExists(): void
{
$this->importPHPDataSet(__DIR__ . '/../Fixtures/Pages.php');

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Functional\Dashboard\Provider;
/*
@ -22,22 +24,16 @@ namespace DanielSiepmann\Tracking\Tests\Functional\Dashboard\Provider;
*/
use DanielSiepmann\Tracking\Dashboard\Provider\NewestPageviews;
use DanielSiepmann\Tracking\Tests\Functional\AbstractFunctionalTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
/**
* @covers \DanielSiepmann\Tracking\Dashboard\Provider\NewestPageviews
*/
class NewestPageviewsTest extends FunctionalTestCase
#[CoversClass(NewestPageviews::class)]
final class NewestPageviewsTest extends AbstractFunctionalTestCase
{
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
/**
* @test
*/
#[Test]
public function returnsRecentSixPageviews(): void
{
$connection = $this->getConnectionPool()->getConnectionForTable('tx_tracking_pageview');
@ -64,9 +60,7 @@ class NewestPageviewsTest extends FunctionalTestCase
], $subject->getItems());
}
/**
* @test
*/
#[Test]
public function respectsMaxResults(): void
{
$connection = $this->getConnectionPool()->getConnectionForTable('tx_tracking_pageview');
@ -90,9 +84,7 @@ class NewestPageviewsTest extends FunctionalTestCase
], $subject->getItems());
}
/**
* @test
*/
#[Test]
public function respectsPagesToExclude(): void
{
$connection = $this->getConnectionPool()->getConnectionForTable('tx_tracking_pageview');
@ -121,9 +113,7 @@ class NewestPageviewsTest extends FunctionalTestCase
], $subject->getItems());
}
/**
* @test
*/
#[Test]
public function respectsLimitToLanguages(): void
{
$connection = $this->getConnectionPool()->getConnectionForTable('tx_tracking_pageview');

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Functional\Dashboard\Provider;
/*
@ -21,28 +23,21 @@ namespace DanielSiepmann\Tracking\Tests\Functional\Dashboard\Provider;
* 02110-1301, USA.
*/
use Codappix\Typo3PhpDatasets\TestingFramework;
use DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerDay;
use DanielSiepmann\Tracking\Tests\Functional\AbstractFunctionalTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
/**
* @covers \DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerDay
*/
class PageviewsPerDayTest extends FunctionalTestCase
#[CoversClass(PageviewsPerDay::class)]
final class PageviewsPerDayTest extends AbstractFunctionalTestCase
{
use TestingFramework;
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
protected function setUp(): void
{
parent::setUp();
$GLOBALS['LANG'] = $this->getContainer()->get(LanguageServiceFactory::class)->create('default');
$GLOBALS['LANG'] = $this->get(LanguageServiceFactory::class)->create('default');
}
protected function tearDown(): void
@ -51,9 +46,7 @@ class PageviewsPerDayTest extends FunctionalTestCase
parent::tearDown();
}
/**
* @test
*/
#[Test]
public function listsResultsForLast31DaysByDefault(): void
{
$connection = $this->getConnectionPool()->getConnectionForTable('tx_tracking_pageview');
@ -73,9 +66,7 @@ class PageviewsPerDayTest extends FunctionalTestCase
self::assertCount(32, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectedNumberOfDays(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/Pages.php');
@ -102,9 +93,7 @@ class PageviewsPerDayTest extends FunctionalTestCase
], $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectedExcludedPages(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/Pages.php');
@ -132,9 +121,7 @@ class PageviewsPerDayTest extends FunctionalTestCase
], $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectedDateFormat(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/Pages.php');
@ -156,9 +143,7 @@ class PageviewsPerDayTest extends FunctionalTestCase
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectsLimitToLanguages(): void
{
$connection = $this->getConnectionPool()->getConnectionForTable('tx_tracking_pageview');

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Functional\Dashboard\Provider;
/*
@ -21,26 +23,17 @@ namespace DanielSiepmann\Tracking\Tests\Functional\Dashboard\Provider;
* 02110-1301, USA.
*/
use Codappix\Typo3PhpDatasets\TestingFramework;
use DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerOperatingSystem;
use DanielSiepmann\Tracking\Tests\Functional\AbstractFunctionalTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
/**
* @covers \DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerOperatingSystem
*/
class PageviewsPerOperatingSystemTest extends FunctionalTestCase
#[CoversClass(PageviewsPerOperatingSystem::class)]
final class PageviewsPerOperatingSystemTest extends AbstractFunctionalTestCase
{
use TestingFramework;
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
/**
* @test
*/
#[Test]
public function listsSixResultsForLast31DaysByDefault(): void
{
$connection = $this->getConnectionPool()->getConnectionForTable('tx_tracking_pageview');
@ -68,9 +61,7 @@ class PageviewsPerOperatingSystemTest extends FunctionalTestCase
self::assertCount(6, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectedOrdering(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/Pages.php');
@ -109,9 +100,7 @@ class PageviewsPerOperatingSystemTest extends FunctionalTestCase
self::assertCount(3, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectedNumberOfDays(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/Pages.php');
@ -145,9 +134,7 @@ class PageviewsPerOperatingSystemTest extends FunctionalTestCase
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectedMaxResults(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/Pages.php');
@ -176,9 +163,7 @@ class PageviewsPerOperatingSystemTest extends FunctionalTestCase
self::assertCount(4, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectsLimitToLanguages(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/Pages.php');

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Functional\Dashboard\Provider;
/*
@ -21,40 +23,35 @@ namespace DanielSiepmann\Tracking\Tests\Functional\Dashboard\Provider;
* 02110-1301, USA.
*/
use Codappix\Typo3PhpDatasets\TestingFramework;
use DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerPage;
use DanielSiepmann\Tracking\Tests\Functional\AbstractFunctionalTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
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;
/**
* @covers \DanielSiepmann\Tracking\Dashboard\Provider\PageviewsPerPage
*/
class PageviewsPerPageTest extends FunctionalTestCase
#[CoversClass(PageviewsPerPage::class)]
final class PageviewsPerPageTest extends AbstractFunctionalTestCase
{
use TestingFramework;
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
protected function setUp(): void
{
parent::setUp();
$GLOBALS['LANG'] = $this->getContainer()->get(LanguageServiceFactory::class)->create('default');
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/BackendUser.php');
$GLOBALS['BE_USER'] = $this->setUpBackendUser(1);
$GLOBALS['LANG'] = $this->get(LanguageServiceFactory::class)->create('default');
}
protected function tearDown(): void
{
unset($GLOBALS['LANG']);
unset(
$GLOBALS['BE_USER'],
$GLOBALS['LANG']
);
parent::tearDown();
}
/**
* @test
*/
#[Test]
public function listsSixResultsForLast31DaysByDefault(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/Pages.php');
@ -67,8 +64,8 @@ class PageviewsPerPageTest extends FunctionalTestCase
}
$subject = new PageviewsPerPage(
GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
GeneralUtility::makeInstance(PageRepository::class)
$this->get(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
$this->get(PageRepository::class)
);
$result = $subject->getChartData();
@ -83,9 +80,7 @@ class PageviewsPerPageTest extends FunctionalTestCase
self::assertCount(6, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectedOrdering(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/Pages.php');
@ -108,8 +103,8 @@ class PageviewsPerPageTest extends FunctionalTestCase
]);
$subject = new PageviewsPerPage(
GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
GeneralUtility::makeInstance(PageRepository::class)
$this->get(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
$this->get(PageRepository::class)
);
$result = $subject->getChartData();
@ -121,9 +116,7 @@ class PageviewsPerPageTest extends FunctionalTestCase
self::assertCount(3, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectedNumberOfDays(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/Pages.php');
@ -142,8 +135,8 @@ class PageviewsPerPageTest extends FunctionalTestCase
]);
$subject = new PageviewsPerPage(
GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
GeneralUtility::makeInstance(PageRepository::class),
$this->get(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
$this->get(PageRepository::class),
2
);
@ -155,9 +148,7 @@ class PageviewsPerPageTest extends FunctionalTestCase
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectedMaxResults(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/Pages.php');
@ -170,8 +161,8 @@ class PageviewsPerPageTest extends FunctionalTestCase
}
$subject = new PageviewsPerPage(
GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
GeneralUtility::makeInstance(PageRepository::class),
$this->get(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
$this->get(PageRepository::class),
31,
4
);
@ -186,9 +177,7 @@ class PageviewsPerPageTest extends FunctionalTestCase
self::assertCount(4, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectedExcludedPages(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/Pages.php');
@ -201,8 +190,8 @@ class PageviewsPerPageTest extends FunctionalTestCase
}
$subject = new PageviewsPerPage(
GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
GeneralUtility::makeInstance(PageRepository::class),
$this->get(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
$this->get(PageRepository::class),
31,
6,
[1, 2, 3, 4, 5, 6]
@ -218,9 +207,7 @@ class PageviewsPerPageTest extends FunctionalTestCase
self::assertCount(4, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function localizedRecordTitlesIfLimitedToSingleLanguage(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/Pages.php');
@ -249,8 +236,8 @@ class PageviewsPerPageTest extends FunctionalTestCase
]);
$subject = new PageviewsPerPage(
GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
GeneralUtility::makeInstance(PageRepository::class),
$this->get(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
$this->get(PageRepository::class),
31,
6,
[],
@ -260,14 +247,12 @@ class PageviewsPerPageTest extends FunctionalTestCase
$result = $subject->getChartData();
self::assertSame([
'Page 2',
'Page 1',
'Seite 1',
], $result['labels']);
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function defaultLanguageTitleIsUsedIfMultipleLanguagesAreAllowed(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/Pages.php');
@ -296,12 +281,12 @@ class PageviewsPerPageTest extends FunctionalTestCase
]);
$subject = new PageviewsPerPage(
GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
GeneralUtility::makeInstance(PageRepository::class),
$this->get(ConnectionPool::class)->getQueryBuilderForTable('tx_tracking_pageview'),
$this->get(PageRepository::class),
31,
6,
[],
[1, '0']
[1, 0]
);
$result = $subject->getChartData();

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Functional\Dashboard\Provider;
/*
@ -21,39 +23,35 @@ namespace DanielSiepmann\Tracking\Tests\Functional\Dashboard\Provider;
* 02110-1301, USA.
*/
use Codappix\Typo3PhpDatasets\TestingFramework;
use DanielSiepmann\Tracking\Dashboard\Provider\Recordviews;
use DanielSiepmann\Tracking\LanguageAspectFactory;
use DanielSiepmann\Tracking\Tests\Functional\AbstractFunctionalTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
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;
/**
* @covers \DanielSiepmann\Tracking\Dashboard\Provider\Recordviews
*/
class RecordviewsTest extends FunctionalTestCase
#[CoversClass(Recordviews::class)]
final class RecordviewsTest extends AbstractFunctionalTestCase
{
use TestingFramework;
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
protected function setUp(): void
{
parent::setUp();
$GLOBALS['LANG'] = $this->getContainer()->get(LanguageServiceFactory::class)->create('default');
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/BackendUser.php');
$GLOBALS['BE_USER'] = $this->setUpBackendUser(1);
$GLOBALS['LANG'] = $this->get(LanguageServiceFactory::class)->create('default');
}
protected function tearDown(): void
{
unset($GLOBALS['LANG']);
unset(
$GLOBALS['BE_USER'],
$GLOBALS['LANG']
);
parent::tearDown();
}
/**
* @test
*/
#[Test]
public function listsSixResultsForLast31DaysByDefault(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/SysCategories.php');
@ -68,8 +66,9 @@ class RecordviewsTest extends FunctionalTestCase
}
$subject = new Recordviews(
GeneralUtility::makeInstance(PageRepository::class),
$this->getConnectionPool()->getQueryBuilderForTable('tx_tracking_recordview')
$this->get(PageRepository::class),
$this->getConnectionPool()->getQueryBuilderForTable('tx_tracking_recordview'),
new LanguageAspectFactory()
);
$result = $subject->getChartData();
@ -84,9 +83,7 @@ class RecordviewsTest extends FunctionalTestCase
self::assertCount(6, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectedOrdering(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/SysCategories.php');
@ -117,8 +114,9 @@ class RecordviewsTest extends FunctionalTestCase
]);
$subject = new Recordviews(
GeneralUtility::makeInstance(PageRepository::class),
$this->get(PageRepository::class),
$this->getConnectionPool()->getQueryBuilderForTable('tx_tracking_recordview'),
new LanguageAspectFactory(),
2
);
@ -131,9 +129,7 @@ class RecordviewsTest extends FunctionalTestCase
self::assertCount(3, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectedNumberOfDays(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/SysCategories.php');
@ -158,8 +154,9 @@ class RecordviewsTest extends FunctionalTestCase
]);
$subject = new Recordviews(
GeneralUtility::makeInstance(PageRepository::class),
$this->get(PageRepository::class),
$this->getConnectionPool()->getQueryBuilderForTable('tx_tracking_recordview'),
new LanguageAspectFactory(),
2
);
@ -171,9 +168,7 @@ class RecordviewsTest extends FunctionalTestCase
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectedMaxResults(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/SysCategories.php');
@ -188,8 +183,9 @@ class RecordviewsTest extends FunctionalTestCase
}
$subject = new Recordviews(
GeneralUtility::makeInstance(PageRepository::class),
$this->get(PageRepository::class),
$this->getConnectionPool()->getQueryBuilderForTable('tx_tracking_recordview'),
new LanguageAspectFactory(),
31,
2
);
@ -202,9 +198,7 @@ class RecordviewsTest extends FunctionalTestCase
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectedExcludedPages(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/SysCategories.php');
@ -220,8 +214,9 @@ class RecordviewsTest extends FunctionalTestCase
}
$subject = new Recordviews(
GeneralUtility::makeInstance(PageRepository::class),
$this->get(PageRepository::class),
$this->getConnectionPool()->getQueryBuilderForTable('tx_tracking_recordview'),
new LanguageAspectFactory(),
31,
6,
[1, 2, 3, 4, 5]
@ -238,9 +233,7 @@ class RecordviewsTest extends FunctionalTestCase
self::assertCount(5, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectLimitesTables(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/SysCategories.php');
@ -261,8 +254,9 @@ class RecordviewsTest extends FunctionalTestCase
]);
$subject = new Recordviews(
GeneralUtility::makeInstance(PageRepository::class),
$this->get(PageRepository::class),
$this->getConnectionPool()->getQueryBuilderForTable('tx_tracking_recordview'),
new LanguageAspectFactory(),
31,
6,
[],
@ -279,9 +273,7 @@ class RecordviewsTest extends FunctionalTestCase
self::assertCount(3, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function respectsLimitedTypes(): void
{
$connection = $this->getConnectionPool()->getConnectionForTable('tx_tracking_recordview');
@ -300,8 +292,9 @@ class RecordviewsTest extends FunctionalTestCase
}
$subject = new Recordviews(
GeneralUtility::makeInstance(PageRepository::class),
$this->get(PageRepository::class),
$this->getConnectionPool()->getQueryBuilderForTable('tx_tracking_recordview'),
new LanguageAspectFactory(),
31,
6,
[],
@ -318,9 +311,7 @@ class RecordviewsTest extends FunctionalTestCase
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function localizedRecordTitlesIfLimitedToSingleLanguage(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/SysCategories.php');
@ -348,8 +339,9 @@ class RecordviewsTest extends FunctionalTestCase
]);
$subject = new Recordviews(
GeneralUtility::makeInstance(PageRepository::class),
$this->get(PageRepository::class),
$this->getConnectionPool()->getQueryBuilderForTable('tx_tracking_recordview'),
new LanguageAspectFactory(),
31,
6,
[],
@ -366,9 +358,7 @@ class RecordviewsTest extends FunctionalTestCase
self::assertCount(2, $result['datasets'][0]['data']);
}
/**
* @test
*/
#[Test]
public function defaultLanguageTitleIsUsedIfMultipleLanguagesAreAllowed(): void
{
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/SysCategories.php');
@ -396,8 +386,9 @@ class RecordviewsTest extends FunctionalTestCase
]);
$subject = new Recordviews(
GeneralUtility::makeInstance(PageRepository::class),
$this->get(PageRepository::class),
$this->getConnectionPool()->getQueryBuilderForTable('tx_tracking_recordview'),
new LanguageAspectFactory(),
31,
6,
[],

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Recordview;
/*
@ -24,253 +26,246 @@ 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 DanielSiepmann\Tracking\Tests\Functional\AbstractFunctionalTestCase;
use DateTimeImmutable;
use Prophecy\PhpUnit\ProphecyTrait;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Routing\PageArguments;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
/**
* @covers \DanielSiepmann\Tracking\Domain\Recordview\Factory
*/
class FactoryTest extends FunctionalTestCase
#[CoversClass(Factory::class)]
final class FactoryTest extends AbstractFunctionalTestCase
{
use ProphecyTrait;
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
/**
* @test
*/
#[Test]
public function returnsRecordviewFromRequest(): void
{
$rule = $this->prophesize(RecordRule::class);
$rule->getUidExpression()->willReturn('request.getQueryParams()["category"]');
$rule->getTableName()->willReturn('sys_category');
$rule = $this->createStub(RecordRule::class);
$rule->method('getUidExpression')->willReturn('request.getQueryParams()["category"]');
$rule->method('getTableName')->willReturn('sys_category');
$routing = $this->prophesize(PageArguments::class);
$routing->getPageId()->willReturn(10);
$routing = $this->createStub(PageArguments::class);
$routing->method('getPageId')->willReturn(10);
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('routing')->willReturn($routing->reveal());
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('');
$request->getHeader('User-Agent')->willReturn([]);
$request->getQueryParams()->willReturn([
$request = $this->createStub(ServerRequestInterface::class);
$request->method('getAttribute')->willReturnMap([
['routing', null, $routing],
['language', null, $language],
]);
$request->method('getUri')->willReturn('');
$request->method('getHeader')->willReturn([]);
$request->method('getQueryParams')->willReturn([
'category' => 10,
]);
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
$result = $subject->fromRequest($request, $rule);
self::assertInstanceOf(Recordview::class, $result);
}
/**
* @test
*/
#[Test]
public function returnedRecordviewContainsUserAgent(): void
{
$rule = $this->prophesize(RecordRule::class);
$rule->getUidExpression()->willReturn('request.getQueryParams()["category"]');
$rule->getTableName()->willReturn('sys_category');
$rule = $this->createStub(RecordRule::class);
$rule->method('getUidExpression')->willReturn('request.getQueryParams()["category"]');
$rule->method('getTableName')->willReturn('sys_category');
$routing = $this->prophesize(PageArguments::class);
$routing->getPageId()->willReturn(10);
$routing = $this->createStub(PageArguments::class);
$routing->method('getPageId')->willReturn(10);
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('routing')->willReturn($routing->reveal());
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('');
$request->getHeader('User-Agent')->willReturn(['Some User Agent']);
$request->getQueryParams()->willReturn([
$request = $this->createStub(ServerRequestInterface::class);
$request->method('getAttribute')->willReturnMap([
['routing', null, $routing],
['language', null, $language],
]);
$request->method('getUri')->willReturn('');
$request->method('getHeader')->willReturn(['Some User Agent']);
$request->method('getQueryParams')->willReturn([
'category' => 10,
]);
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
$result = $subject->fromRequest($request, $rule);
self::assertSame('Some User Agent', $result->getUserAgent());
}
/**
* @test
*/
#[Test]
public function returnedRecordviewContainsUri(): void
{
$rule = $this->prophesize(RecordRule::class);
$rule->getUidExpression()->willReturn('request.getQueryParams()["category"]');
$rule->getTableName()->willReturn('sys_category');
$rule = $this->createStub(RecordRule::class);
$rule->method('getUidExpression')->willReturn('request.getQueryParams()["category"]');
$rule->method('getTableName')->willReturn('sys_category');
$routing = $this->prophesize(PageArguments::class);
$routing->getPageId()->willReturn(10);
$routing = $this->createStub(PageArguments::class);
$routing->method('getPageId')->willReturn(10);
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('routing')->willReturn($routing->reveal());
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('https://example.com');
$request->getHeader('User-Agent')->willReturn(['']);
$request->getQueryParams()->willReturn([
$request = $this->createStub(ServerRequestInterface::class);
$request->method('getAttribute')->willReturnMap([
['routing', null, $routing],
['language', null, $language],
]);
$request->method('getUri')->willReturn('https://example.com');
$request->method('getHeader')->willReturn(['']);
$request->method('getQueryParams')->willReturn([
'category' => 10,
]);
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
$result = $subject->fromRequest($request, $rule);
self::assertSame('https://example.com', $result->getUrl());
}
/**
* @test
*/
#[Test]
public function returnedRecordviewContainsDateTime(): void
{
$rule = $this->prophesize(RecordRule::class);
$rule->getUidExpression()->willReturn('request.getQueryParams()["category"]');
$rule->getTableName()->willReturn('sys_category');
$rule = $this->createStub(RecordRule::class);
$rule->method('getUidExpression')->willReturn('request.getQueryParams()["category"]');
$rule->method('getTableName')->willReturn('sys_category');
$routing = $this->prophesize(PageArguments::class);
$routing->getPageId()->willReturn(10);
$routing = $this->createStub(PageArguments::class);
$routing->method('getPageId')->willReturn(10);
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('routing')->willReturn($routing->reveal());
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('https://example.com');
$request->getHeader('User-Agent')->willReturn(['']);
$request->getQueryParams()->willReturn([
$request = $this->createStub(ServerRequestInterface::class);
$request->method('getAttribute')->willReturnMap([
['routing', null, $routing],
['language', null, $language],
]);
$request->method('getUri')->willReturn('https://example.com');
$request->method('getHeader')->willReturn(['']);
$request->method('getQueryParams')->willReturn([
'category' => 10,
]);
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
$result = $subject->fromRequest($request, $rule);
self::assertInstanceOf(DateTimeImmutable::class, $result->getCrdate());
}
/**
* @test
*/
#[Test]
public function returnedRecordviewContainsLanguage(): void
{
$rule = $this->prophesize(RecordRule::class);
$rule->getUidExpression()->willReturn('request.getQueryParams()["category"]');
$rule->getTableName()->willReturn('sys_category');
$rule = $this->createStub(RecordRule::class);
$rule->method('getUidExpression')->willReturn('request.getQueryParams()["category"]');
$rule->method('getTableName')->willReturn('sys_category');
$routing = $this->prophesize(PageArguments::class);
$routing->getPageId()->willReturn(10);
$routing = $this->createStub(PageArguments::class);
$routing->method('getPageId')->willReturn(10);
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('routing')->willReturn($routing->reveal());
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('https://example.com');
$request->getHeader('User-Agent')->willReturn(['']);
$request->getQueryParams()->willReturn([
$request = $this->createStub(ServerRequestInterface::class);
$request->method('getAttribute')->willReturnMap([
['routing', null, $routing],
['language', null, $language],
]);
$request->method('getUri')->willReturn('https://example.com');
$request->method('getHeader')->willReturn(['']);
$request->method('getQueryParams')->willReturn([
'category' => 10,
]);
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
self::assertSame($language->reveal(), $result->getLanguage());
$result = $subject->fromRequest($request, $rule);
self::assertSame($language, $result->getLanguage());
}
/**
* @test
*/
#[Test]
public function returnedRecordviewContainsPageId(): void
{
$rule = $this->prophesize(RecordRule::class);
$rule->getUidExpression()->willReturn('request.getQueryParams()["category"]');
$rule->getTableName()->willReturn('sys_category');
$rule = $this->createStub(RecordRule::class);
$rule->method('getUidExpression')->willReturn('request.getQueryParams()["category"]');
$rule->method('getTableName')->willReturn('sys_category');
$routing = $this->prophesize(PageArguments::class);
$routing->getPageId()->willReturn(10);
$routing = $this->createStub(PageArguments::class);
$routing->method('getPageId')->willReturn(10);
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('routing')->willReturn($routing->reveal());
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('https://example.com');
$request->getHeader('User-Agent')->willReturn(['']);
$request->getQueryParams()->willReturn([
$request = $this->createStub(ServerRequestInterface::class);
$request->method('getAttribute')->willReturnMap([
['routing', null, $routing],
['language', null, $language],
]);
$request->method('getUri')->willReturn('https://example.com');
$request->method('getHeader')->willReturn(['']);
$request->method('getQueryParams')->willReturn([
'category' => 10,
]);
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
$result = $subject->fromRequest($request, $rule);
self::assertSame(10, $result->getPageUid());
}
/**
* @test
*/
#[Test]
public function returnedRecordviewContainsRecordUid(): void
{
$rule = $this->prophesize(RecordRule::class);
$rule->getUidExpression()->willReturn('request.getQueryParams()["category"]');
$rule->getTableName()->willReturn('sys_category');
$rule = $this->createStub(RecordRule::class);
$rule->method('getUidExpression')->willReturn('request.getQueryParams()["category"]');
$rule->method('getTableName')->willReturn('sys_category');
$routing = $this->prophesize(PageArguments::class);
$routing->getPageId()->willReturn(10);
$routing = $this->createStub(PageArguments::class);
$routing->method('getPageId')->willReturn(10);
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('routing')->willReturn($routing->reveal());
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('https://example.com');
$request->getHeader('User-Agent')->willReturn(['']);
$request->getQueryParams()->willReturn([
$request = $this->createStub(ServerRequestInterface::class);
$request->method('getAttribute')->willReturnMap([
['routing', null, $routing],
['language', null, $language],
]);
$request->method('getUri')->willReturn('https://example.com');
$request->method('getHeader')->willReturn(['']);
$request->method('getQueryParams')->willReturn([
'category' => 20,
]);
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
$result = $subject->fromRequest($request, $rule);
self::assertSame(20, $result->getRecordUid());
}
/**
* @test
*/
#[Test]
public function returnedRecordviewContainsTableName(): void
{
$rule = $this->prophesize(RecordRule::class);
$rule->getUidExpression()->willReturn('request.getQueryParams()["category"]');
$rule->getTableName()->willReturn('sys_category');
$rule = $this->createStub(RecordRule::class);
$rule->method('getUidExpression')->willReturn('request.getQueryParams()["category"]');
$rule->method('getTableName')->willReturn('sys_category');
$routing = $this->prophesize(PageArguments::class);
$routing->getPageId()->willReturn(10);
$routing = $this->createStub(PageArguments::class);
$routing->method('getPageId')->willReturn(10);
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('routing')->willReturn($routing->reveal());
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('https://example.com');
$request->getHeader('User-Agent')->willReturn(['']);
$request->getQueryParams()->willReturn([
$request = $this->createStub(ServerRequestInterface::class);
$request->method('getAttribute')->willReturnMap([
['routing', null, $routing],
['language', null, $language],
]);
$request->method('getUri')->willReturn('https://example.com');
$request->method('getHeader')->willReturn(['']);
$request->method('getQueryParams')->willReturn([
'category' => 20,
]);
$subject = $this->get(Factory::class);
$result = $subject->fromRequest($request->reveal(), $rule->reveal());
$result = $subject->fromRequest($request, $rule);
self::assertSame('sys_category', $result->getTableName());
}
}

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
return [
'be_users' => [
[

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
$EM_CONF[$_EXTKEY] = [
'title' => 'TESTING: Tracking recordview',
'description' => 'Used by functional tests',

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
return [
'pages' => [
[

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
return [
'sys_category' => [
[

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
return [
'pages' => [
[

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
return [
'pages' => [
[

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
return [
'pages' => [
[

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Functional;
/*
@ -21,24 +23,17 @@ namespace DanielSiepmann\Tracking\Tests\Functional;
* 02110-1301, USA.
*/
use Codappix\Typo3PhpDatasets\TestingFramework;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox;
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequestContext;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
/**
* @testdox Pageviews are
*
* @coversNothing
*/
class PageviewTest extends FunctionalTestCase
#[TestDox('Pageviews are')]
#[CoversNothing]
final class PageviewTest extends AbstractFunctionalTestCase
{
use TestingFramework;
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
protected array $pathsToLinkInTestInstance = [
'typo3conf/ext/tracking/Tests/Functional/Fixtures/sites' => 'typo3conf/sites',
];
@ -53,31 +48,27 @@ class PageviewTest extends FunctionalTestCase
]);
}
/**
* @test
*/
#[Test]
public function trackedWhenAllowed(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withHeader('User-Agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0');
$response = $this->executeFrontendRequest($request);
$response = $this->executeFrontendSubRequest($request);
self::assertSame(200, $response->getStatusCode());
$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']);
}
/**
* @test
*/
#[Test]
public function notTrackedWhenDisallowed(): void
{
$this->importPHPDataSet(__DIR__ . '/Fixtures/BackendUser.php');
@ -87,7 +78,7 @@ class PageviewTest extends FunctionalTestCase
$request = $request->withPageId(1);
$context = new InternalRequestContext();
$context = $context->withBackendUserId(1);
$response = $this->executeFrontendRequest($request, $context);
$response = $this->executeFrontendSubRequest($request, $context);
self::assertSame(200, $response->getStatusCode());
@ -95,17 +86,14 @@ class PageviewTest extends FunctionalTestCase
self::assertCount(0, $records);
}
/**
* @test
*
* @dataProvider possibleDeniedUserAgents
*/
#[DataProvider('possibleDeniedUserAgents')]
#[Test]
public function preventsTrackingOfUserAgents(string $userAgent): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withHeader('User-Agent', $userAgent);
$response = $this->executeFrontendRequest($request);
$response = $this->executeFrontendSubRequest($request);
self::assertSame(200, $response->getStatusCode());
self::assertCount(0, $this->getAllRecords('tx_tracking_pageview'));

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Functional;
/*
@ -21,24 +23,15 @@ namespace DanielSiepmann\Tracking\Tests\Functional;
* 02110-1301, USA.
*/
use Codappix\Typo3PhpDatasets\TestingFramework;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox;
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
/**
* @testdox Recordviews are
*
* @coversNothing
*/
class RecordviewTest extends FunctionalTestCase
#[TestDox('Recordviews are')]
#[CoversNothing]
final class RecordviewTest extends AbstractFunctionalTestCase
{
use TestingFramework;
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
'typo3conf/ext/tracking/Tests/Functional/Fixtures/Extensions/recordview',
];
protected array $pathsToLinkInTestInstance = [
'typo3conf/ext/tracking/Tests/Functional/Fixtures/sites' => 'typo3conf/sites',
];
@ -53,6 +46,7 @@ class RecordviewTest extends FunctionalTestCase
protected function setUp(): void
{
$this->testExtensionsToLoad[] = 'typo3conf/ext/tracking/Tests/Functional/Fixtures/Extensions/recordview';
parent::setUp();
$this->importPHPDataSet(__DIR__ . '/Fixtures/Pages.php');
@ -61,39 +55,35 @@ class RecordviewTest extends FunctionalTestCase
]);
}
/**
* @test
*/
#[Test]
public function trackedWhenAllowed(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$request = $request->withQueryParameter('topic_id', 1);
$request = $request->withHeader('User-Agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0');
$response = $this->executeFrontendRequest($request);
$response = $this->executeFrontendSubRequest($request);
self::assertSame(200, $response->getStatusCode());
$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']);
}
/**
* @test
*/
#[Test]
public function notTrackedWhenNotDetected(): void
{
$request = new InternalRequest();
$request = $request->withPageId(1);
$response = $this->executeFrontendRequest($request);
$response = $this->executeFrontendSubRequest($request);
self::assertSame(200, $response->getStatusCode());

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Functional;
/*
@ -20,26 +22,15 @@ namespace DanielSiepmann\Tracking\Tests\Functional;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use Codappix\Typo3PhpDatasets\TestingFramework;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
use UnexpectedValueException;
/**
* @covers \DanielSiepmann\Tracking\Functional\CopyingPageWithRecordsWorks
*
* @testdox This extension works with TYPO3 feature:
*/
class Typo3FeaturesTest extends FunctionalTestCase
#[TestDox('This extension works with TYPO3 feature:')]
final class Typo3FeaturesTest extends AbstractFunctionalTestCase
{
use TestingFramework;
protected array $testExtensionsToLoad = [
'typo3conf/ext/tracking',
];
protected function setUp(): void
{
parent::setUp();
@ -47,7 +38,7 @@ class Typo3FeaturesTest extends FunctionalTestCase
$this->importPHPDataSet(__DIR__ . '/Fixtures/BackendUser.php');
$this->importPHPDataSet(__DIR__ . '/Fixtures/Typo3FeaturesTest/PageWithRecords.php');
$this->setUpBackendUser(1);
$languageServiceFactory = $this->getContainer()->get(LanguageServiceFactory::class);
$languageServiceFactory = $this->get(LanguageServiceFactory::class);
if (!$languageServiceFactory instanceof LanguageServiceFactory) {
throw new UnexpectedValueException('Did not retrieve LanguageServiceFactory.', 1637847250);
}
@ -61,11 +52,8 @@ class Typo3FeaturesTest extends FunctionalTestCase
parent::tearDown();
}
/**
* @test
*
* @testdox Copy pages. Tracking records will not be copied.
*/
#[TestDox('Copy pages. Tracking records will not be copied.')]
#[Test]
public function copyContainingRecords(): void
{
$dataHandler = new DataHandler();
@ -84,11 +72,8 @@ class Typo3FeaturesTest extends FunctionalTestCase
);
}
/**
* @test
*
* @testdox Copy individual tables, but always exclude tracking tables.
*/
#[TestDox('Copy individual tables, but always exclude tracking tables.')]
#[Test]
public function copyCustomTablesViaDataHandler(): void
{
$dataHandler = new DataHandler();

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
/*
@ -20,38 +22,32 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use DanielSiepmann\Tracking\Domain\Model\Extractor;
use DanielSiepmann\Tracking\Domain\Model\HasUserAgent;
use Prophecy\PhpUnit\ProphecyTrait;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/**
* @covers \DanielSiepmann\Tracking\Domain\Model\Extractor
*/
#[CoversClass(Extractor::class)]
class ExtractorTest extends UnitTestCase
{
use ProphecyTrait;
/**
* @test
*
* @dataProvider possibleUserStringWithOperatingSystems
*
* @testdox Operating system $expectedOperatingSystem is extracted from UserAgent string: $userAgent
*/
#[DataProvider('possibleUserStringWithOperatingSystems')]
#[TestDox('Operating system $expectedOperatingSystem is extracted from UserAgent string: $userAgent')]
#[Test]
public function returnsOperatingSystem(string $userAgent, string $expectedOperatingSystem): void
{
$model = $this->prophesize(HasUserAgent::class);
$model->getUserAgent()->willReturn($userAgent);
$model = $this->createStub(HasUserAgent::class);
$model->method('getUserAgent')->willReturn($userAgent);
self::assertSame(
$expectedOperatingSystem,
Extractor::getOperatingSystem($model->reveal())
Extractor::getOperatingSystem($model)
);
}
public function possibleUserStringWithOperatingSystems(): array
public static function possibleUserStringWithOperatingSystems(): array
{
return [
[

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
/*
@ -20,30 +22,24 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use DanielSiepmann\Tracking\Domain\Model\Pageview;
use DateTimeImmutable;
use Prophecy\PhpUnit\ProphecyTrait;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/**
* @covers \DanielSiepmann\Tracking\Domain\Model\Pageview
*/
#[CoversClass(Pageview::class)]
class PageviewTest extends UnitTestCase
{
use ProphecyTrait;
/**
* @test
*/
#[Test]
public function canBeCreated(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Pageview(
0,
$language->reveal(),
$language,
new DateTimeImmutable(),
0,
'',
@ -53,16 +49,14 @@ class PageviewTest extends UnitTestCase
self::assertInstanceOf(Pageview::class, $subject);
}
/**
* @test
*/
#[Test]
public function returnsPageUid(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Pageview(
500,
$language->reveal(),
$language,
new DateTimeImmutable(),
0,
'',
@ -72,36 +66,32 @@ class PageviewTest extends UnitTestCase
self::assertSame(500, $subject->getPageUid());
}
/**
* @test
*/
#[Test]
public function returnsLanguage(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Pageview(
0,
$language->reveal(),
$language,
new DateTimeImmutable(),
0,
'',
''
);
self::assertSame($language->reveal(), $subject->getLanguage());
self::assertSame($language, $subject->getLanguage());
}
/**
* @test
*/
#[Test]
public function returnsCrdate(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$crdate = new DateTimeImmutable();
$subject = new Pageview(
0,
$language->reveal(),
$language,
$crdate,
0,
'',
@ -111,16 +101,14 @@ class PageviewTest extends UnitTestCase
self::assertSame($crdate, $subject->getCrdate());
}
/**
* @test
*/
#[Test]
public function returnsPageType(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Pageview(
0,
$language->reveal(),
$language,
new DateTimeImmutable(),
999,
'',
@ -130,16 +118,14 @@ class PageviewTest extends UnitTestCase
self::assertSame(999, $subject->getPageType());
}
/**
* @test
*/
#[Test]
public function returnsUrl(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Pageview(
0,
$language->reveal(),
$language,
new DateTimeImmutable(),
0,
'https://example.com/path.html',
@ -149,16 +135,14 @@ class PageviewTest extends UnitTestCase
self::assertSame('https://example.com/path.html', $subject->getUrl());
}
/**
* @test
*/
#[Test]
public function returnsUserAgent(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Pageview(
0,
$language->reveal(),
$language,
new DateTimeImmutable(),
0,
'',
@ -171,16 +155,14 @@ class PageviewTest extends UnitTestCase
);
}
/**
* @test
*/
#[Test]
public function returnsZeroAsDefaultUid(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Pageview(
0,
$language->reveal(),
$language,
new DateTimeImmutable(),
0,
'',
@ -193,16 +175,14 @@ class PageviewTest extends UnitTestCase
);
}
/**
* @test
*/
#[Test]
public function returnsSetAsUid(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Pageview(
0,
$language->reveal(),
$language,
new DateTimeImmutable(),
0,
'',
@ -216,16 +196,14 @@ class PageviewTest extends UnitTestCase
);
}
/**
* @test
*/
#[Test]
public function returnsOperatingSystem(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Pageview(
0,
$language->reveal(),
$language,
new DateTimeImmutable(),
0,
'',

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
/*
@ -20,18 +22,15 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use DanielSiepmann\Tracking\Domain\Model\RecordRule;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/**
* @covers \DanielSiepmann\Tracking\Domain\Model\RecordRule
*/
#[CoversClass(RecordRule::class)]
class RecordRuleTest extends UnitTestCase
{
/**
* @test
*/
#[Test]
public function canBeCreatedViaConstructor(): void
{
$subject = new RecordRule(
@ -43,9 +42,7 @@ class RecordRuleTest extends UnitTestCase
self::assertInstanceOf(RecordRule::class, $subject);
}
/**
* @test
*/
#[Test]
public function canBeCreatedFromArray(): void
{
$subject = RecordRule::fromArray([
@ -58,9 +55,7 @@ class RecordRuleTest extends UnitTestCase
self::assertInstanceOf(RecordRule::class, $subject);
}
/**
* @test
*/
#[Test]
public function multipleCanBeCratedFromArray(): void
{
$result = RecordRule::multipleFromArray([
@ -81,9 +76,7 @@ class RecordRuleTest extends UnitTestCase
self::assertInstanceOf(RecordRule::class, $result[1]);
}
/**
* @test
*/
#[Test]
public function returnsMatchExpression(): void
{
$subject = new RecordRule(
@ -95,9 +88,7 @@ class RecordRuleTest extends UnitTestCase
self::assertSame('match expression', $subject->getMatchesExpression());
}
/**
* @test
*/
#[Test]
public function returnsUidExpression(): void
{
$subject = new RecordRule(
@ -109,9 +100,7 @@ class RecordRuleTest extends UnitTestCase
self::assertSame('match expression', $subject->getUidExpression());
}
/**
* @test
*/
#[Test]
public function returnsTableName(): void
{
$subject = new RecordRule(

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
/*
@ -20,30 +22,24 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Model;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use DanielSiepmann\Tracking\Domain\Model\Recordview;
use DateTimeImmutable;
use Prophecy\PhpUnit\ProphecyTrait;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/**
* @covers \DanielSiepmann\Tracking\Domain\Model\Recordview
*/
#[CoversClass(Recordview::class)]
class RecordviewTest extends UnitTestCase
{
use ProphecyTrait;
/**
* @test
*/
#[Test]
public function canBeCreated(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Recordview(
0,
$language->reveal(),
$language,
new DateTimeImmutable(),
'',
'',
@ -54,16 +50,14 @@ class RecordviewTest extends UnitTestCase
self::assertInstanceOf(Recordview::class, $subject);
}
/**
* @test
*/
#[Test]
public function returnsPageUid(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Recordview(
500,
$language->reveal(),
$language,
new DateTimeImmutable(),
'',
'',
@ -74,16 +68,14 @@ class RecordviewTest extends UnitTestCase
self::assertSame(500, $subject->getPageUid());
}
/**
* @test
*/
#[Test]
public function returnsLanguage(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Recordview(
0,
$language->reveal(),
$language,
new DateTimeImmutable(),
'',
'',
@ -91,20 +83,18 @@ class RecordviewTest extends UnitTestCase
'sys_category'
);
self::assertSame($language->reveal(), $subject->getLanguage());
self::assertSame($language, $subject->getLanguage());
}
/**
* @test
*/
#[Test]
public function returnsCrdate(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$crdate = new DateTimeImmutable();
$subject = new Recordview(
0,
$language->reveal(),
$language,
$crdate,
'',
'',
@ -115,16 +105,14 @@ class RecordviewTest extends UnitTestCase
self::assertSame($crdate, $subject->getCrdate());
}
/**
* @test
*/
#[Test]
public function returnsUrl(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Recordview(
0,
$language->reveal(),
$language,
new DateTimeImmutable(),
'https://example.com/path.html',
'',
@ -135,16 +123,14 @@ class RecordviewTest extends UnitTestCase
self::assertSame('https://example.com/path.html', $subject->getUrl());
}
/**
* @test
*/
#[Test]
public function returnsUserAgent(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Recordview(
0,
$language->reveal(),
$language,
new DateTimeImmutable(),
'',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0',
@ -158,16 +144,14 @@ class RecordviewTest extends UnitTestCase
);
}
/**
* @test
*/
#[Test]
public function returnsRecordUid(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Recordview(
0,
$language->reveal(),
$language,
new DateTimeImmutable(),
'',
'',
@ -181,16 +165,14 @@ class RecordviewTest extends UnitTestCase
);
}
/**
* @test
*/
#[Test]
public function returnsTableName(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Recordview(
0,
$language->reveal(),
$language,
new DateTimeImmutable(),
'',
'',
@ -204,16 +186,14 @@ class RecordviewTest extends UnitTestCase
);
}
/**
* @test
*/
#[Test]
public function returnsOperatingSystem(): void
{
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$subject = new Recordview(
0,
$language->reveal(),
$language,
new DateTimeImmutable(),
'',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36',

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Pageview;
/*
@ -20,11 +22,11 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Pageview;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use DanielSiepmann\Tracking\Domain\Model\Pageview;
use DanielSiepmann\Tracking\Domain\Pageview\Factory;
use DateTimeImmutable;
use Prophecy\PhpUnit\ProphecyTrait;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Routing\PageArguments;
use TYPO3\CMS\Core\Site\Entity\Site;
@ -32,200 +34,194 @@ use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/**
* @covers \DanielSiepmann\Tracking\Domain\Pageview\Factory
*/
#[CoversClass(Factory::class)]
class FactoryTest extends UnitTestCase
{
use ProphecyTrait;
/**
* @test
*/
#[Test]
public function returnsPageviewFromRequest(): void
{
$routing = $this->prophesize(PageArguments::class);
$routing->getPageId()->willReturn(10);
$routing->getPageType()->willReturn(0);
$routing = $this->createStub(PageArguments::class);
$routing->method('getPageId')->willReturn(10);
$routing->method('getPageType')->willReturn('0');
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('routing')->willReturn($routing->reveal());
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('');
$request->getHeader('User-Agent')->willReturn([]);
$request = $this->createStub(ServerRequestInterface::class);
$request->method('getAttribute')->willReturnMap([
['routing', null, $routing],
['language', null, $language],
]);
$request->method('getUri')->willReturn('');
$request->method('getHeader')->willReturn([]);
$subject = new Factory($this->prophesize(SiteFinder::class)->reveal());
$subject = new Factory($this->createStub(SiteFinder::class));
$result = $subject->fromRequest($request->reveal());
$result = $subject->fromRequest($request);
self::assertInstanceOf(Pageview::class, $result);
}
/**
* @test
*/
#[Test]
public function returnedPageviewContainsUserAgent(): void
{
$routing = $this->prophesize(PageArguments::class);
$routing->getPageId()->willReturn(10);
$routing->getPageType()->willReturn(0);
$routing = $this->createStub(PageArguments::class);
$routing->method('getPageId')->willReturn(10);
$routing->method('getPageType')->willReturn('0');
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('routing')->willReturn($routing->reveal());
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('');
$request->getHeader('User-Agent')->willReturn([
$request = $this->createStub(ServerRequestInterface::class);
$request->method('getAttribute')->willReturnMap([
['routing', null, $routing],
['language', null, $language],
]);
$request->method('getUri')->willReturn('');
$request->method('getHeader')->willReturn([
'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());
$subject = new Factory($this->createStub(SiteFinder::class));
$result = $subject->fromRequest($request->reveal());
$result = $subject->fromRequest($request);
self::assertSame(
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0',
$result->getUserAgent()
);
}
/**
* @test
*/
#[Test]
public function returnedPageviewContainsUri(): void
{
$routing = $this->prophesize(PageArguments::class);
$routing->getPageId()->willReturn(10);
$routing->getPageType()->willReturn(0);
$routing = $this->createStub(PageArguments::class);
$routing->method('getPageId')->willReturn(10);
$routing->method('getPageType')->willReturn('0');
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('routing')->willReturn($routing->reveal());
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('https://example.com/path?query=params&some=more#anchor');
$request->getHeader('User-Agent')->willReturn([]);
$request = $this->createStub(ServerRequestInterface::class);
$request->method('getAttribute')->willReturnMap([
['routing', null, $routing],
['language', null, $language],
]);
$request->method('getUri')->willReturn('https://example.com/path?query=params&some=more#anchor');
$request->method('getHeader')->willReturn([]);
$subject = new Factory($this->prophesize(SiteFinder::class)->reveal());
$subject = new Factory($this->createStub(SiteFinder::class));
$result = $subject->fromRequest($request->reveal());
$result = $subject->fromRequest($request);
self::assertSame(
'https://example.com/path?query=params&some=more#anchor',
$result->getUrl()
);
}
/**
* @test
*/
#[Test]
public function returnedPageviewContainsPageType(): void
{
$routing = $this->prophesize(PageArguments::class);
$routing->getPageId()->willReturn(10);
$routing->getPageType()->willReturn(50);
$routing = $this->createStub(PageArguments::class);
$routing->method('getPageId')->willReturn(10);
$routing->method('getPageType')->willReturn('50');
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('routing')->willReturn($routing->reveal());
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('');
$request->getHeader('User-Agent')->willReturn([]);
$request = $this->createStub(ServerRequestInterface::class);
$request->method('getAttribute')->willReturnMap([
['routing', null, $routing],
['language', null, $language],
]);
$request->method('getUri')->willReturn('');
$request->method('getHeader')->willReturn([]);
$subject = new Factory($this->prophesize(SiteFinder::class)->reveal());
$subject = new Factory($this->createStub(SiteFinder::class));
$result = $subject->fromRequest($request->reveal());
$result = $subject->fromRequest($request);
self::assertSame(
50,
$result->getPageType()
);
}
/**
* @test
*/
#[Test]
public function returnedPageviewContainsDateTime(): void
{
$routing = $this->prophesize(PageArguments::class);
$routing->getPageId()->willReturn(10);
$routing->getPageType()->willReturn(0);
$routing = $this->createStub(PageArguments::class);
$routing->method('getPageId')->willReturn(10);
$routing->method('getPageType')->willReturn('0');
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('routing')->willReturn($routing->reveal());
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('');
$request->getHeader('User-Agent')->willReturn([]);
$request = $this->createStub(ServerRequestInterface::class);
$request->method('getAttribute')->willReturnMap([
['routing', null, $routing],
['language', null, $language],
]);
$request->method('getUri')->willReturn('');
$request->method('getHeader')->willReturn([]);
$subject = new Factory($this->prophesize(SiteFinder::class)->reveal());
$subject = new Factory($this->createStub(SiteFinder::class));
$result = $subject->fromRequest($request->reveal());
$result = $subject->fromRequest($request);
self::assertInstanceOf(DateTimeImmutable::class, $result->getCrdate());
}
/**
* @test
*/
#[Test]
public function returnedPageviewContainsLanguage(): void
{
$routing = $this->prophesize(PageArguments::class);
$routing->getPageId()->willReturn(10);
$routing->getPageType()->willReturn(0);
$routing = $this->createStub(PageArguments::class);
$routing->method('getPageId')->willReturn(10);
$routing->method('getPageType')->willReturn('0');
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('routing')->willReturn($routing->reveal());
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('');
$request->getHeader('User-Agent')->willReturn([]);
$request = $this->createStub(ServerRequestInterface::class);
$request->method('getAttribute')->willReturnMap([
['routing', null, $routing],
['language', null, $language],
]);
$request->method('getUri')->willReturn('');
$request->method('getHeader')->willReturn([]);
$subject = new Factory($this->prophesize(SiteFinder::class)->reveal());
$subject = new Factory($this->createStub(SiteFinder::class));
$result = $subject->fromRequest($request->reveal());
$result = $subject->fromRequest($request);
self::assertInstanceOf(SiteLanguage::class, $result->getLanguage());
}
/**
* @test
*/
#[Test]
public function returnedPageviewContainsPageId(): void
{
$routing = $this->prophesize(PageArguments::class);
$routing->getPageId()->willReturn(10);
$routing->getPageType()->willReturn(0);
$routing = $this->createStub(PageArguments::class);
$routing->method('getPageId')->willReturn(10);
$routing->method('getPageType')->willReturn('0');
$language = $this->prophesize(SiteLanguage::class);
$language = $this->createStub(SiteLanguage::class);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('routing')->willReturn($routing->reveal());
$request->getAttribute('language')->willReturn($language->reveal());
$request->getUri()->willReturn('');
$request->getHeader('User-Agent')->willReturn([]);
$request = $this->createStub(ServerRequestInterface::class);
$request->method('getAttribute')->willReturnMap([
['routing', null, $routing],
['language', null, $language],
]);
$request->method('getUri')->willReturn('');
$request->method('getHeader')->willReturn([]);
$subject = new Factory($this->prophesize(SiteFinder::class)->reveal());
$subject = new Factory($this->createStub(SiteFinder::class));
$result = $subject->fromRequest($request->reveal());
$result = $subject->fromRequest($request);
self::assertSame(
10,
$result->getPageUid()
);
}
/**
* @test
*/
#[Test]
public function returnsPageviewFromDbRow(): void
{
$siteLanguage = $this->prophesize(SiteLanguage::class);
$site = $this->prophesize(Site::class);
$site->getLanguageById(0)->willReturn($siteLanguage->reveal());
$siteFinder = $this->prophesize(SiteFinder::class);
$siteFinder->getSiteByPageId(2)->willReturn($site->reveal());
$siteLanguage = $this->createStub(SiteLanguage::class);
$site = $this->createStub(Site::class);
$site->method('getLanguageById')->willReturn($siteLanguage);
$siteFinder = $this->createStub(SiteFinder::class);
$siteFinder->method('getSiteByPageId')->willReturn($site);
$subject = new Factory($siteFinder->reveal());
$subject = new Factory($siteFinder);
$result = $subject->fromDbRow([
'uid' => 1,
@ -240,7 +236,7 @@ class FactoryTest extends UnitTestCase
self::assertInstanceOf(Pageview::class, $result);
self::assertSame(1, $result->getUid());
self::assertSame(2, $result->getPageUid());
self::assertSame($siteLanguage->reveal(), $result->getLanguage());
self::assertSame($siteLanguage, $result->getLanguage());
self::assertSame('1533906435', $result->getCrdate()->format('U'));
self::assertSame(0, $result->getPageType());
self::assertSame('https://example.com/path', $result->getUrl());

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Repository;
/*
@ -20,122 +22,122 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Repository;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use DanielSiepmann\Tracking\Domain\Model\Pageview as Model;
use DanielSiepmann\Tracking\Domain\Pageview\Factory;
use DanielSiepmann\Tracking\Domain\Repository\Pageview;
use DateTimeImmutable;
use Prophecy\PhpUnit\ProphecyTrait;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/**
* @covers \DanielSiepmann\Tracking\Domain\Repository\Pageview
*/
#[CoversClass(Pageview::class)]
class PageviewTest extends UnitTestCase
{
use ProphecyTrait;
/**
* @test
*/
#[Test]
public function modelCanBeAdded(): void
{
$connection = $this->prophesize(Connection::class);
$factory = $this->prophesize(Factory::class);
$connection = $this->createMock(Connection::class);
$factory = $this->createMock(Factory::class);
$dateTime = $this->prophesize(DateTimeImmutable::class);
$dateTime->format('U')->willReturn(1582660189);
$dateTime = $this->createStub(DateTimeImmutable::class);
$dateTime->method('format')->willReturn('1582660189');
$language = $this->prophesize(SiteLanguage::class);
$language->getLanguageId()->willReturn(2);
$language = $this->createStub(SiteLanguage::class);
$language->method('getLanguageId')->willReturn(2);
$model = $this->prophesize(Model::class);
$model->getPageUid()->willReturn(10);
$model->getCrdate()->willReturn($dateTime->reveal());
$model->getPageType()->willReturn(999);
$model->getLanguage()->willReturn($language->reveal());
$model->getUrl()->willReturn('https://example.com/path.html');
$model->getUserAgent()->willReturn('Mozilla/5.0 (Windows NT 10.0) Gecko/20100101 Firefox/74.0');
$model->getOperatingSystem()->willReturn('Linux');
$model = $this->createStub(Model::class);
$model->method('getPageUid')->willReturn(10);
$model->method('getCrdate')->willReturn($dateTime);
$model->method('getPageType')->willReturn(999);
$model->method('getLanguage')->willReturn($language);
$model->method('getUrl')->willReturn('https://example.com/path.html');
$model->method('getUserAgent')->willReturn('Mozilla/5.0 (Windows NT 10.0) Gecko/20100101 Firefox/74.0');
$model->method('getOperatingSystem')->willReturn('Linux');
$connection->insert(
'tx_tracking_pageview',
[
'pid' => 10,
'crdate' => 1582660189,
'tstamp' => 1582660189,
'type' => 999,
'sys_language_uid' => 2,
'url' => 'https://example.com/path.html',
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0) Gecko/20100101 Firefox/74.0',
'operating_system' => 'Linux',
]
)->willReturn(1)->shouldBeCalledTimes(1);
$connection
->expects(self::once())
->method('insert')
->with(
'tx_tracking_pageview',
[
'pid' => 10,
'crdate' => 1582660189,
'tstamp' => 1582660189,
'type' => 999,
'sys_language_uid' => 2,
'url' => 'https://example.com/path.html',
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0) Gecko/20100101 Firefox/74.0',
'operating_system' => 'Linux',
]
)
->willReturn(1)
;
$subject = new Pageview($connection->reveal(), $factory->reveal());
$subject->add($model->reveal());
$subject = new Pageview($connection, $factory);
$subject->add($model);
}
/**
* @test
*/
#[Test]
public function throwsExceptionIfModelToUodateHasNoUid(): void
{
$connection = $this->prophesize(Connection::class);
$factory = $this->prophesize(Factory::class);
$connection = $this->createMock(Connection::class);
$factory = $this->createMock(Factory::class);
$model = $this->prophesize(Model::class);
$model->getUid()->willReturn(0);
$model = $this->createStub(Model::class);
$model->method('getUid')->willReturn(0);
$subject = new Pageview($connection->reveal(), $factory->reveal());
$subject = new Pageview($connection, $factory);
$this->expectExceptionMessage('Can not update pageview if uid is 0.');
$subject->update($model->reveal());
$subject->update($model);
}
/**
* @test
*/
#[Test]
public function modelCanBeUpdated(): void
{
$connection = $this->prophesize(Connection::class);
$factory = $this->prophesize(Factory::class);
$connection = $this->createMock(Connection::class);
$factory = $this->createMock(Factory::class);
$dateTime = $this->prophesize(DateTimeImmutable::class);
$dateTime->format('U')->willReturn(1582660189);
$dateTime = $this->createStub(DateTimeImmutable::class);
$dateTime->method('format')->willReturn('1582660189');
$language = $this->prophesize(SiteLanguage::class);
$language->getLanguageId()->willReturn(2);
$language = $this->createStub(SiteLanguage::class);
$language->method('getLanguageId')->willReturn(2);
$model = $this->prophesize(Model::class);
$model->getUid()->willReturn(1);
$model->getPageUid()->willReturn(10);
$model->getCrdate()->willReturn($dateTime->reveal());
$model->getPageType()->willReturn(999);
$model->getLanguage()->willReturn($language->reveal());
$model->getUrl()->willReturn('https://example.com/path.html');
$model->getUserAgent()->willReturn('Mozilla/5.0 (Windows NT 10.0) Gecko/20100101 Firefox/74.0');
$model->getOperatingSystem()->willReturn('Linux');
$model = $this->createStub(Model::class);
$model->method('getUid')->willReturn(1);
$model->method('getPageUid')->willReturn(10);
$model->method('getCrdate')->willReturn($dateTime);
$model->method('getPageType')->willReturn(999);
$model->method('getLanguage')->willReturn($language);
$model->method('getUrl')->willReturn('https://example.com/path.html');
$model->method('getUserAgent')->willReturn('Mozilla/5.0 (Windows NT 10.0) Gecko/20100101 Firefox/74.0');
$model->method('getOperatingSystem')->willReturn('Linux');
$connection->update(
'tx_tracking_pageview',
[
'pid' => 10,
'crdate' => 1582660189,
'tstamp' => 1582660189,
'type' => 999,
'sys_language_uid' => 2,
'url' => 'https://example.com/path.html',
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0) Gecko/20100101 Firefox/74.0',
'operating_system' => 'Linux',
],
[
'uid' => 1,
]
)->willReturn(1)->shouldBeCalledTimes(1);
$connection
->expects(self::once())
->method('update')
->with(
'tx_tracking_pageview',
[
'pid' => 10,
'crdate' => 1582660189,
'tstamp' => 1582660189,
'type' => 999,
'sys_language_uid' => 2,
'url' => 'https://example.com/path.html',
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0) Gecko/20100101 Firefox/74.0',
'operating_system' => 'Linux',
],
[
'uid' => 1,
]
)
->willReturn(1)
;
$subject = new Pageview($connection->reveal(), $factory->reveal());
$subject->update($model->reveal());
$subject = new Pageview($connection, $factory);
$subject->update($model);
}
}

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Repository;
/*
@ -20,62 +22,61 @@ namespace DanielSiepmann\Tracking\Tests\Unit\Domain\Repository;
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use DanielSiepmann\Tracking\Domain\Model\Recordview as Model;
use DanielSiepmann\Tracking\Domain\Repository\Recordview;
use DateTimeImmutable;
use Prophecy\PhpUnit\ProphecyTrait;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/**
* @covers \DanielSiepmann\Tracking\Domain\Repository\Recordview
*/
#[CoversClass(Recordview::class)]
class RecordviewTest extends UnitTestCase
{
use ProphecyTrait;
/**
* @test
*/
#[Test]
public function modelCanBeAdded(): void
{
$connection = $this->prophesize(Connection::class);
$connection = $this->createMock(Connection::class);
$dateTime = $this->prophesize(DateTimeImmutable::class);
$dateTime->format('U')->willReturn(1582660189);
$dateTime = $this->createStub(DateTimeImmutable::class);
$dateTime->method('format')->willReturn('1582660189');
$language = $this->prophesize(SiteLanguage::class);
$language->getLanguageId()->willReturn(2);
$language = $this->createStub(SiteLanguage::class);
$language->method('getLanguageId')->willReturn(2);
$model = $this->prophesize(Model::class);
$model->getPageUid()->willReturn(10);
$model->getCrdate()->willReturn($dateTime->reveal());
$model->getLanguage()->willReturn($language->reveal());
$model->getUrl()->willReturn('https://example.com/path.html');
$model->getUserAgent()->willReturn('Mozilla/5.0 (Windows NT 10.0) Gecko/20100101 Firefox/74.0');
$model->getOperatingSystem()->willReturn('Linux');
$model->getRecordUid()->willReturn(10);
$model->getTableName()->willReturn('sys_category');
$model = $this->createStub(Model::class);
$model->method('getPageUid')->willReturn(10);
$model->method('getCrdate')->willReturn($dateTime);
$model->method('getLanguage')->willReturn($language);
$model->method('getUrl')->willReturn('https://example.com/path.html');
$model->method('getUserAgent')->willReturn('Mozilla/5.0 (Windows NT 10.0) Gecko/20100101 Firefox/74.0');
$model->method('getOperatingSystem')->willReturn('Linux');
$model->method('getRecordUid')->willReturn(10);
$model->method('getTableName')->willReturn('sys_category');
$connection->insert(
'tx_tracking_recordview',
[
'pid' => 10,
'crdate' => 1582660189,
'tstamp' => 1582660189,
'sys_language_uid' => 2,
'url' => 'https://example.com/path.html',
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0) Gecko/20100101 Firefox/74.0',
'operating_system' => 'Linux',
'record_uid' => 10,
'record_table_name' => 'sys_category',
'record' => 'sys_category_10',
]
)->willReturn(1)->shouldBeCalledTimes(1);
$connection
->expects(self::once())
->method('insert')
->with(
'tx_tracking_recordview',
[
'pid' => 10,
'crdate' => 1582660189,
'tstamp' => 1582660189,
'sys_language_uid' => 2,
'url' => 'https://example.com/path.html',
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0) Gecko/20100101 Firefox/74.0',
'operating_system' => 'Linux',
'record_uid' => 10,
'record_table_name' => 'sys_category',
'record' => 'sys_category_10',
]
)
->willReturn(1)
;
$subject = new Recordview($connection->reveal());
$subject->add($model->reveal());
$subject = new Recordview($connection);
$subject->add($model);
}
}

View file

@ -28,7 +28,7 @@
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"ext-mbstring": "*",
"doctrine/dbal": "^2.12 || ^3.3 || 4.0.0-RC2@rc",
"doctrine/dbal": "^2.12 || ^3.3 || 4.0.0-RC2",
"psr/http-message": "^1.0",
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0",
@ -39,14 +39,13 @@
"typo3/cms-dashboard": "^12.4 || ^13.0"
},
"require-dev": {
"codappix/typo3-php-datasets": "^1.3",
"codappix/typo3-php-datasets": "^1.5",
"cweagans/composer-patches": "^1.7",
"friendsofphp/php-cs-fixer": "^3.14",
"jangregor/phpstan-prophecy": "^1.0",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.1",
"saschaegerer/phpstan-typo3": "^1.10",
"typo3/testing-framework": "^8.0"
},
"minimum-stability": "dev",

View file

@ -1,3 +1,7 @@
<?php
\DanielSiepmann\Tracking\Hooks\DataHandler::register();
declare(strict_types=1);
use DanielSiepmann\Tracking\Hooks\DataHandler;
DataHandler::register();

View file

@ -1,51 +0,0 @@
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

@ -6,15 +6,6 @@ parameters:
- Classes
- Tests
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false
reportUnmatchedIgnoredErrors: true
ignoreErrors:
# Ignore error for TYPO3 11 and TYPO3 12
- '#Cannot call method fetch\(\) on Doctrine\\DBAL\\Result\|int\.#'
- '#Cannot call method fetchAll\(\) on Doctrine\\DBAL\\Result\|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.$#"
- "#^Parameter .* expects .*, mixed given.$#"
- "#^Cannot call method .* on mixed.$#"

View file

@ -1,8 +1,20 @@
{ pkgs ? import <nixpkgs> { } }:
{
pkgs ? import <nixpkgs> { }
,phps ? import <phps>
}:
let
php = pkgs.php83;
inherit(pkgs.php83Packages) composer;
php = phps.packages.x86_64-linux.php83.buildEnv {
extensions = { enabled, all }: enabled ++ (with all; [
xdebug
]);
extraConfig = ''
xdebug.mode = debug
memory_limit = 4G
'';
};
inherit(php.packages) composer;
projectInstall = pkgs.writeShellApplication {
name = "project-install";