diff --git a/Build/.php-cs-fixer.dist.php b/Build/.php-cs-fixer.dist.php index 58818f6f..f33cf71a 100644 --- a/Build/.php-cs-fixer.dist.php +++ b/Build/.php-cs-fixer.dist.php @@ -11,6 +11,11 @@ (new PhpCsFixer\Finder()) ->ignoreVCSIgnored(true) ->in(__DIR__ . '/../') + ->exclude( + [ + 'var/', + ] + ) ) ->setRiskyAllowed(true) ->setRules([ diff --git a/Build/phpstan-baseline.neon b/Build/phpstan-baseline.neon index a93ad23f..b9fbd0f3 100644 --- a/Build/phpstan-baseline.neon +++ b/Build/phpstan-baseline.neon @@ -2436,6 +2436,12 @@ parameters: count: 1 path: ../Classes/Domain/Validator/OrderItemValidator.php + - + message: '#^Parameter \#2 \$validators of method Extcode\\Cart\\Domain\\Validator\\OrderItemValidator\:\:checkProperty\(\) expects Traversable\, iterable\&SplObjectStorage given\.$#' + identifier: argument.type + count: 1 + path: ../Classes/Domain/Validator/OrderItemValidator.php + - message: '#^Property TYPO3\\CMS\\Extbase\\Validation\\Validator\\AbstractGenericObjectValidator\:\:\$propertyValidators \(array\&SplObjectStorage\>\) does not accept array\&SplObjectStorage\)\|SplObjectStorage\\>\.$#' identifier: assign.propertyType @@ -5555,10 +5561,3 @@ parameters: identifier: argument.templateType count: 1 path: ../Tests/Unit/Validation/Validator/EmptyValidatorTest.php - - - - message: '#^Cannot access offset ''cart'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: ../ext_emconf.php - diff --git a/Build/phpstan.neon b/Build/phpstan.neon index 06ce5b1c..f582a280 100644 --- a/Build/phpstan.neon +++ b/Build/phpstan.neon @@ -8,7 +8,6 @@ parameters: - ../Classes - ../Configuration - ../Tests - - ../ext_emconf.php - ../ext_localconf.php disallowedFunctionCalls: diff --git a/Classes/Service/OrderItemCleanupService.php b/Classes/Service/OrderItemCleanupService.php index 8b23654e..3f4933fe 100644 --- a/Classes/Service/OrderItemCleanupService.php +++ b/Classes/Service/OrderItemCleanupService.php @@ -74,7 +74,7 @@ private function deleteRecordsFromTable(string $tableName, array $recordUids): v if ($dataHandler->errorLog !== []) { throw new RuntimeException( - 'Could not properly delete records for table: ' . $tableName . ', got the following errors: ' . implode(', ', array_filter($dataHandler->errorLog, 'is_string')), + 'Could not properly delete records for table: ' . $tableName . ', got the following errors: ' . implode(', ', array_filter($dataHandler->errorLog, is_string(...))), 1751526777 ); } diff --git a/Tests/Fixtures/BackendUser.php b/Tests/Fixtures/BackendUser.php new file mode 100644 index 00000000..6578a28c --- /dev/null +++ b/Tests/Fixtures/BackendUser.php @@ -0,0 +1,15 @@ + [ + 0 => [ + 'uid' => '1', + 'pid' => '0', + 'username' => 'admin', + 'password' => '$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1', + 'admin' => 1, + ], + ], +]; diff --git a/Tests/Fixtures/BaseDatabase.php b/Tests/Fixtures/BaseDatabase.php index 8b7f86d4..03b4bac8 100644 --- a/Tests/Fixtures/BaseDatabase.php +++ b/Tests/Fixtures/BaseDatabase.php @@ -16,5 +16,23 @@ 'deleted' => '0', 'is_siteroot' => '1', ], + 100 => [ + 'uid' => '101', + 'pid' => '0', + 'title' => 'Shop', + 'doktype' => PageRepository::DOKTYPE_SYSFOLDER, + 'slug' => '/shop-folder', + 'sorting' => '128', + 'deleted' => '0', + ], + 104 => [ + 'uid' => '105', + 'pid' => '101', + 'title' => 'Orders', + 'doktype' => PageRepository::DOKTYPE_SYSFOLDER, + 'slug' => '/orders-folder', + 'sorting' => '128', + 'deleted' => '0', + ], ], ]; diff --git a/Tests/Functional/Command/AbstractCommandTestCase.php b/Tests/Functional/Command/AbstractCommandTestCase.php index 99953e37..a8f90bda 100644 --- a/Tests/Functional/Command/AbstractCommandTestCase.php +++ b/Tests/Functional/Command/AbstractCommandTestCase.php @@ -11,12 +11,16 @@ * LICENSE file that was distributed with this source code. */ -use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; +use Codappix\Typo3PhpDatasets\TestingFramework; use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; abstract class AbstractCommandTestCase extends FunctionalTestCase { + use TestingFramework; + + private const FORM_PROTECTION_SESSION_TOKEN = 'testtoken'; + protected function setUp(): void { $this->testExtensionsToLoad = [ @@ -25,28 +29,26 @@ protected function setUp(): void $this->coreExtensionsToLoad = [ 'typo3/cms-beuser', + 'typo3/cms-core', ]; $this->pathsToLinkInTestInstance['typo3conf/ext/cart/Tests/Functional/Fixtures/Import/Sites/'] = 'typo3conf/sites'; parent::setUp(); - $backendUser = self::createStub(BackendUserAuthentication::class); - $backendUser->method('isAdmin')->willReturn(true); - $backendUser->method('recordEditAccessInternals')->willReturn(true); - $backendUser->workspace = 0; - $backendUser->user = [ - 'uid' => 1, - 'admin' => true, - ]; - $GLOBALS['BE_USER'] = $backendUser; + $this->importPHPDataSet(__DIR__ . '/../../Fixtures/BaseDatabase.php'); + $this->importPHPDataSet(__DIR__ . '/../../Fixtures/BackendUser.php'); + + $this->setUpBackendUser(1) + ->getSession() + ->set('formProtectionSessionToken', self::FORM_PROTECTION_SESSION_TOKEN); + $GLOBALS['LANG'] = $this->get(LanguageServiceFactory::class)->create('en'); } protected function tearDown(): void { unset( - $GLOBALS['BE_USER'], $GLOBALS['LANG'] ); diff --git a/Tests/Functional/EventListener/Mail/AttachmentFromOrderItemTest.php b/Tests/Functional/EventListener/Mail/AttachmentFromOrderItemTest.php index e7037257..713d6b30 100644 --- a/Tests/Functional/EventListener/Mail/AttachmentFromOrderItemTest.php +++ b/Tests/Functional/EventListener/Mail/AttachmentFromOrderItemTest.php @@ -24,8 +24,15 @@ class AttachmentFromOrderItemTest extends FunctionalTestCase public function setUp(): void { - $this->testExtensionsToLoad[] = 'extcode/cart'; - $this->testExtensionsToLoad[] = 'typo3conf/ext/cart/Tests/Fixtures/cart_example'; + $this->testExtensionsToLoad = [ + 'extcode/cart', + 'typo3conf/ext/cart/Tests/Fixtures/cart_example', + ]; + + $this->coreExtensionsToLoad = [ + 'typo3/cms-beuser', + 'typo3/cms-core', + ]; parent::setUp(); diff --git a/Tests/Functional/EventListener/Mail/AttachmentFromTypoScriptTest.php b/Tests/Functional/EventListener/Mail/AttachmentFromTypoScriptTest.php index 1a6a277d..f5d8153d 100644 --- a/Tests/Functional/EventListener/Mail/AttachmentFromTypoScriptTest.php +++ b/Tests/Functional/EventListener/Mail/AttachmentFromTypoScriptTest.php @@ -26,8 +26,15 @@ class AttachmentFromTypoScriptTest extends FunctionalTestCase public function setUp(): void { - $this->testExtensionsToLoad[] = 'extcode/cart'; - $this->testExtensionsToLoad[] = 'typo3conf/ext/cart/Tests/Fixtures/cart_example'; + $this->testExtensionsToLoad = [ + 'extcode/cart', + 'typo3conf/ext/cart/Tests/Fixtures/cart_example', + ]; + + $this->coreExtensionsToLoad = [ + 'typo3/cms-beuser', + 'typo3/cms-core', + ]; parent::setUp(); diff --git a/Tests/Functional/Service/MailHandlerTest.php b/Tests/Functional/Service/MailHandlerTest.php index cf1b3eb9..80f9d4ec 100644 --- a/Tests/Functional/Service/MailHandlerTest.php +++ b/Tests/Functional/Service/MailHandlerTest.php @@ -34,8 +34,15 @@ class MailHandlerTest extends FunctionalTestCase public function setUp(): void { - $this->testExtensionsToLoad[] = 'extcode/cart'; - $this->testExtensionsToLoad[] = 'typo3conf/ext/cart/Tests/Fixtures/cart_example'; + $this->testExtensionsToLoad = [ + 'extcode/cart', + 'typo3conf/ext/cart/Tests/Fixtures/cart_example', + ]; + + $this->coreExtensionsToLoad = [ + 'typo3/cms-beuser', + 'typo3/cms-core', + ]; $this->configurationToUseInTestInstance = [ 'LOG' => [ @@ -346,7 +353,7 @@ private function getMockBuilderForMailHandlerClass(bool $mailerThrowException = $mailer->method('send')->willThrowException(new Exception()); } - $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__); + $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(self::class); $logService = GeneralUtility::makeInstance( LogService::class, $logger, diff --git a/Tests/Functional/ViewHelpers/CsvHeaderViewHelperTest.php b/Tests/Functional/ViewHelpers/CsvHeaderViewHelperTest.php index fce4bbd8..88366219 100644 --- a/Tests/Functional/ViewHelpers/CsvHeaderViewHelperTest.php +++ b/Tests/Functional/ViewHelpers/CsvHeaderViewHelperTest.php @@ -25,7 +25,14 @@ final class CsvHeaderViewHelperTest extends FunctionalTestCase public function setUp(): void { - $this->testExtensionsToLoad[] = 'extcode/cart'; + $this->testExtensionsToLoad = [ + 'extcode/cart', + ]; + + $this->coreExtensionsToLoad = [ + 'typo3/cms-beuser', + 'typo3/cms-core', + ]; parent::setUp(); } diff --git a/Tests/Functional/ViewHelpers/CsvValuesViewHelperTest.php b/Tests/Functional/ViewHelpers/CsvValuesViewHelperTest.php index 9ccb78f9..9550ca16 100644 --- a/Tests/Functional/ViewHelpers/CsvValuesViewHelperTest.php +++ b/Tests/Functional/ViewHelpers/CsvValuesViewHelperTest.php @@ -29,7 +29,14 @@ final class CsvValuesViewHelperTest extends FunctionalTestCase public function setUp(): void { - $this->testExtensionsToLoad[] = 'extcode/cart'; + $this->testExtensionsToLoad = [ + 'extcode/cart', + ]; + + $this->coreExtensionsToLoad = [ + 'typo3/cms-beuser', + 'typo3/cms-core', + ]; parent::setUp(); diff --git a/Tests/Unit/Domain/Model/Cart/CartCouponFixTest.php b/Tests/Unit/Domain/Model/Cart/CartCouponFixTest.php index 368eb21e..8314dab6 100644 --- a/Tests/Unit/Domain/Model/Cart/CartCouponFixTest.php +++ b/Tests/Unit/Domain/Model/Cart/CartCouponFixTest.php @@ -245,7 +245,7 @@ private function createCartMock(array $methods = ['getGross']): Cart|MockObject ); return $this->getMockBuilder(Cart::class) - ->onlyMethods(array_values(array_filter(array_filter($methods, 'is_string')))) + ->onlyMethods(array_values(array_filter(array_filter($methods, is_string(...))))) ->setConstructorArgs([[$this->taxClass]]) ->getMock(); } diff --git a/Tests/Unit/Domain/Model/Cart/CartCouponPercentageTest.php b/Tests/Unit/Domain/Model/Cart/CartCouponPercentageTest.php index d54041cd..3003dc3d 100644 --- a/Tests/Unit/Domain/Model/Cart/CartCouponPercentageTest.php +++ b/Tests/Unit/Domain/Model/Cart/CartCouponPercentageTest.php @@ -275,7 +275,7 @@ private function createCartMock(array $methods = ['getGross']): Cart|MockObject ); return $this->getMockBuilder(Cart::class) - ->onlyMethods(array_values(array_filter(array_filter($methods, 'is_string')))) + ->onlyMethods(array_values(array_filter(array_filter($methods, is_string(...))))) ->setConstructorArgs([[$this->taxClass]]) ->getMock(); } diff --git a/Tests/Unit/Domain/Model/Cart/ServiceTest.php b/Tests/Unit/Domain/Model/Cart/ServiceTest.php index 3b0a6b6a..579c0aa8 100644 --- a/Tests/Unit/Domain/Model/Cart/ServiceTest.php +++ b/Tests/Unit/Domain/Model/Cart/ServiceTest.php @@ -475,7 +475,7 @@ private function createCartMock(array $methods = ['getGross']): Cart|MockObject ); return $this->getMockBuilder(Cart::class) - ->onlyMethods(array_values(array_filter(array_filter($methods, 'is_string')))) + ->onlyMethods(array_values(array_filter(array_filter($methods, is_string(...))))) ->setConstructorArgs([$this->taxClasses]) ->getMock(); } diff --git a/composer.json b/composer.json index c493dee0..44bf2bfb 100644 --- a/composer.json +++ b/composer.json @@ -38,9 +38,10 @@ "allow-plugins": { "typo3/class-alias-loader": true, "typo3/cms-composer-installers": true, - "sbuerk/typo3-cmscomposerinstallers-testingframework-bridge": true, "phpstan/extension-installer": true - } + }, + "lock": false, + "sort-packages": true }, "version": "12.0.0", "extra": { @@ -53,11 +54,10 @@ "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", "ext-json": "*", "ext-openssl": "*", - "typo3/cms-core": "^14.0", - "typo3/cms-extbase": "^14.0", - "typo3/cms-fluid": "^14.0", - "typo3/cms-form": "^14.0", - "typo3/cms-frontend": "^14.0" + "typo3/cms-core": "^14.2", + "typo3/cms-extbase": "^14.2", + "typo3/cms-fluid": "^14.2", + "typo3/cms-frontend": "^14.2" }, "require-dev": { "codappix/typo3-php-datasets": "^2.1", @@ -68,55 +68,14 @@ "phpstan/phpstan-phpunit": "^2.0", "spaze/phpstan-disallowed-calls": "^4.7", "staabm/phpstan-todo-by": "^0.3", - "typo3/cms-beuser": "^14.0", - "typo3/cms-dashboard": "^14.0", - "typo3/cms-form": "^14.0", - "typo3/testing-framework": "^9.0", + "typo3/cms-beuser": "^14.2", + "typo3/cms-dashboard": "^14.2", + "typo3/cms-form": "^14.2", + "typo3/testing-framework": "^9.5", "ssch/typo3-rector": "^3.11" }, - "scripts": { - "test:cgl": [ - ".build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --using-cache=no --path-mode=intersection ./" - ], - "test:cgl:dry-run": [ - ".build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./" - ], - "test:php:lint": [ - "find *.php Classes Configuration Tests -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l" - ], - "test:php:unit": [ - ".build/bin/phpunit -c Build/UnitTests.xml" - ], - "test:php:functional": [ - "typo3DatabaseDriver=\"pdo_sqlite\" .build/bin/phpunit -c Build/phpunit.xml.dist" - ], - "test:phpstan:analyse": [ - ".build/bin/phpstan analyse -c Build/phpstan.neon --memory-limit 256M" - ], - "test:rector:process": [ - ".build/bin/rector process *" - ], - "test:rector:process:dry-run": [ - ".build/bin/rector process * --dry-run" - ], - "test:typoscript:lint": [ - ".build/bin/typoscript-lint -c Build/typoscriptlint.yaml Configuration" - ], - "test:php": [ - "@test:php:lint", - "@test:php:unit", - "@test:php:functional" - ], - "test:all": [ - "@test:phpstan:analyse", - "@test:rector:process", - "@test:cgl", - "@test:typoscript:lint", - "@test:php" - ] - }, "suggest": { - "typo3/cms-dashboard": "^14.0", - "typo3/cms-form": "^14.0" + "typo3/cms-dashboard": "^14.2", + "typo3/cms-form": "^14.2" } } diff --git a/ext_emconf.php b/ext_emconf.php deleted file mode 100644 index 105ca46a..00000000 --- a/ext_emconf.php +++ /dev/null @@ -1,22 +0,0 @@ - 'Cart', - 'description' => 'Shopping Cart(s) for TYPO3', - 'category' => 'plugin', - 'version' => '12.0.0', - 'state' => 'stable', - 'author' => 'Daniel Gohlke', - 'author_email' => 'ext@extco.de', - 'author_company' => 'extco.de UG (haftungsbeschränkt)', - 'constraints' => [ - 'depends' => [ - 'php' => '8.2.0-8.4.99', - 'typo3' => '14.1.0-14.4.99', - 'extbase' => '14.1.0-14.1.99', - 'fluid' => '14.1.0-14.1.99', - ], - 'conflicts' => [], - 'suggests' => [], - ], -]; diff --git a/rector.php b/rector.php index 22291b6b..1ac2c13a 100644 --- a/rector.php +++ b/rector.php @@ -19,7 +19,6 @@ __DIR__ . '/Classes', __DIR__ . '/Configuration', __DIR__ . '/Tests', - __DIR__ . '/ext_emconf.php', __DIR__ . '/ext_localconf.php', ]) // uncomment to reach your current PHP version