diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7b3a952..59156dc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -49,7 +49,7 @@ jobs: run: composer install --prefer-dist --no-progress --no-suggest - name: Coding Guideline - run: vendor/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./ + run: ./.build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./ code-quality: runs-on: ubuntu-latest @@ -74,12 +74,14 @@ jobs: - name: Install dependencies with expected TYPO3 version run: |- composer remove --dev ssch/typo3-rector \ - && composer require typo3/cms-install "*" \ && composer install --no-progress --no-ansi --no-interaction - - name: Code Quality (by PHPStan) - run: vendor/bin/phpstan analyse -c Build/phpstan.neon + - name: Build codeception tester + run: .build/bin/codecept build + - name: Code Quality (by PHPStan) + run: ./.build/bin/phpstan analyse -c Build/phpstan.neon + test-unit-and-functional: runs-on: ubuntu-latest needs: diff --git a/.gitignore b/.gitignore index c33c81b..01f9fa0 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,5 @@ Documentation/_make .DS_Store .idea -var/ -vendor/ - phpunit.coverage.xml phpunit.report.xml diff --git a/Build/UnitTests.xml b/Build/UnitTests.xml deleted file mode 100644 index d69a6b6..0000000 --- a/Build/UnitTests.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - ../Tests/Unit/ - - - - - ../Classes/ - - - diff --git a/Build/phpmd-ruleset.xml b/Build/phpmd-ruleset.xml deleted file mode 100644 index b9d2251..0000000 --- a/Build/phpmd-ruleset.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - The rulesets attempting to respect the TYPO3 best practices :) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/phpstan-baseline.neon b/Build/phpstan-baseline.neon new file mode 100644 index 0000000..74f3814 --- /dev/null +++ b/Build/phpstan-baseline.neon @@ -0,0 +1,229 @@ +parameters: + ignoreErrors: + - + message: '#^Cannot call method getFrontendUserGroup\(\) on object\|null\.$#' + identifier: method.nonObject + count: 2 + path: ../Classes/Domain/Model/Book.php + + - + message: '#^Cannot call method getPrice\(\) on object\|null\.$#' + identifier: method.nonObject + count: 2 + path: ../Classes/Domain/Model/Book.php + + - + message: '#^Cannot call method getUid\(\) on mixed\.$#' + identifier: method.nonObject + count: 1 + path: ../Classes/Domain/Model/Book.php + + - + message: '#^Method Extcode\\CartBooks\\Domain\\Model\\Book\:\:getBestSpecialPrice\(\) has parameter \$frontendUserGroupIds with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: ../Classes/Domain/Model/Book.php + + - + message: '#^Method Extcode\\CartBooks\\Domain\\Model\\Book\:\:getBestSpecialPrice\(\) should return float but returns mixed\.$#' + identifier: return.type + count: 1 + path: ../Classes/Domain/Model/Book.php + + - + message: '#^Method Extcode\\CartBooks\\Domain\\Model\\Book\:\:getSpecialPrices\(\) return type with generic class TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage does not specify its types\: TEntity$#' + identifier: missingType.generics + count: 1 + path: ../Classes/Domain/Model/Book.php + + - + message: '#^Method Extcode\\CartBooks\\Domain\\Model\\Book\:\:setSpecialPrices\(\) has parameter \$specialPrices with generic class TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage but does not specify its types\: TEntity$#' + identifier: missingType.generics + count: 1 + path: ../Classes/Domain/Model/Book.php + + - + message: '#^Binary operation "\+\=" between mixed and int results in an error\.$#' + identifier: assignOp.invalid + count: 1 + path: ../Classes/EventListener/CheckProductAvailability.php + + - + message: '#^Cannot cast mixed to int\.$#' + identifier: cast.int + count: 4 + path: ../Classes/EventListener/RetrieveProductsFromRequest.php + + - + message: '#^Method Extcode\\CartBooks\\EventListener\\RetrieveProductsFromRequest\:\:checkRequestArguments\(\) has parameter \$requestArguments with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: ../Classes/EventListener/RetrieveProductsFromRequest.php + + - + message: '#^Method Extcode\\CartBooks\\EventListener\\RetrieveProductsFromRequest\:\:checkRequestArguments\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: ../Classes/EventListener/RetrieveProductsFromRequest.php + + - + message: '#^Method Extcode\\CartBooks\\EventListener\\RetrieveProductsFromRequest\:\:getCartProductFromBook\(\) has parameter \$taxClasses with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: ../Classes/EventListener/RetrieveProductsFromRequest.php + + - + message: '#^Parameter \#1 \$book of method Extcode\\CartBooks\\EventListener\\RetrieveProductsFromRequest\:\:getCartProductFromBook\(\) expects Extcode\\CartBooks\\Domain\\Model\\Book, TYPO3\\CMS\\Extbase\\DomainObject\\DomainObjectInterface\|null given\.$#' + identifier: argument.type + count: 1 + path: ../Classes/EventListener/RetrieveProductsFromRequest.php + + - + message: '#^Parameter \#2 \$productId of class Extcode\\Cart\\Domain\\Model\\Cart\\Product constructor expects int, int\<1, max\>\|null given\.$#' + identifier: argument.type + count: 1 + path: ../Classes/EventListener/RetrieveProductsFromRequest.php + + - + message: '#^Parameter \#6 \$taxClass of class Extcode\\Cart\\Domain\\Model\\Cart\\Product constructor expects Extcode\\Cart\\Domain\\Model\\Cart\\TaxClass, mixed given\.$#' + identifier: argument.type + count: 1 + path: ../Classes/EventListener/RetrieveProductsFromRequest.php + + - + message: '#^Cannot access offset ''cart'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 2 + path: ../Classes/EventListener/View/ModifyView.php + + - + message: '#^Cannot access offset ''pid'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 2 + path: ../Classes/EventListener/View/ModifyView.php + + - + message: '#^Parameter \#1 \$key of method Extcode\\Cart\\Service\\SessionHandler\:\:restoreCart\(\) expects string, mixed given\.$#' + identifier: argument.type + count: 1 + path: ../Classes/EventListener/View/ModifyView.php + + - + message: '#^Parameter \#1 \$key of method Extcode\\Cart\\Service\\SessionHandler\:\:writeCart\(\) expects string, mixed given\.$#' + identifier: argument.type + count: 1 + path: ../Classes/EventListener/View/ModifyView.php + + - + message: '#^Property Extcode\\CartBooks\\EventListener\\View\\ModifyView\:\:\$cartConfiguration type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: ../Classes/EventListener/View/ModifyView.php + + - + message: '#^Cannot call method getAuthor\(\) on mixed\.$#' + identifier: method.nonObject + count: 1 + path: ../Classes/ViewHelpers/SchemaViewHelper.php + + - + message: '#^Cannot call method getPrice\(\) on mixed\.$#' + identifier: method.nonObject + count: 1 + path: ../Classes/ViewHelpers/SchemaViewHelper.php + + - + message: '#^Cannot call method getTitle\(\) on mixed\.$#' + identifier: method.nonObject + count: 1 + path: ../Classes/ViewHelpers/SchemaViewHelper.php + + - + message: '#^Method Extcode\\CartBooks\\ViewHelpers\\SchemaViewHelper\:\:render\(\) should return string but returns string\|false\.$#' + identifier: return.type + count: 1 + path: ../Classes/ViewHelpers/SchemaViewHelper.php + + - + message: '#^Cannot access an offset on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: ../Configuration/TCA/Overrides/tx_cart_domain_model_order_product.php + + - + message: '#^Cannot access offset ''columns'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: ../Configuration/TCA/Overrides/tx_cart_domain_model_order_product.php + + - + message: '#^Cannot access offset ''config'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: ../Configuration/TCA/Overrides/tx_cart_domain_model_order_product.php + + - + message: '#^Cannot access offset ''items'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: ../Configuration/TCA/Overrides/tx_cart_domain_model_order_product.php + + - + message: '#^Cannot access offset ''product_type'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: ../Configuration/TCA/Overrides/tx_cart_domain_model_order_product.php + + - + message: '#^Cannot access offset ''tx_cart_domain_model_order_product'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: ../Configuration/TCA/Overrides/tx_cart_domain_model_order_product.php + + - + message: '#^Parameter \#1 \$dataSet of method Codappix\\Typo3PhpDatasets\\PhpDataSet\:\:import\(\) expects array\\>\>, mixed given\.$#' + identifier: argument.type + count: 1 + path: ../Tests/Acceptance/Support/Environment.php + + - + message: '#^Property Extcode\\CartBooks\\Tests\\Acceptance\\Support\\Environment\:\:\$localConfig type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: ../Tests/Acceptance/Support/Environment.php + + - + message: '#^Cannot access offset ''cart_books'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: ../ext_emconf.php + + - + message: '#^Cannot access an offset on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: ../ext_localconf.php + + - + message: '#^Cannot access offset ''SYS'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: ../ext_localconf.php + + - + message: '#^Cannot access offset ''cartbooks'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: ../ext_localconf.php + + - + message: '#^Cannot access offset ''fluid'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: ../ext_localconf.php + + - + message: '#^Cannot access offset ''namespaces'' on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: ../ext_localconf.php diff --git a/Build/phpstan.neon b/Build/phpstan.neon index c166ea3..a3c2f8b 100644 --- a/Build/phpstan.neon +++ b/Build/phpstan.neon @@ -1,5 +1,9 @@ +includes: + - 'phpstan-baseline.neon' + parameters: - level: 4 + level: 'max' + paths: - ../Classes - ../Configuration @@ -7,4 +11,28 @@ parameters: - ../ext_emconf.php - ../ext_localconf.php excludePaths: - - ../Tests/Acceptance + - '../Tests/Acceptance/Support/_generated/TesterActions.php' + + disallowedFunctionCalls: + - + function: + - 'var_dump()' + - 'xdebug_break()' + message: 'Do not add debugging' + - + function: 'header()' + message: 'Use API instead' + + disallowedStaticCalls: + - + method: 'TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump()' + message: 'Do not add debugging' + + disallowedSuperglobals: + - + superglobal: + - '$_GET' + - '$_POST' + - '$_FILES' + - '$_SERVER' + message: 'Use API instead' diff --git a/Build/FunctionalTests.xml b/Build/phpunit.xml.dist similarity index 55% rename from Build/FunctionalTests.xml rename to Build/phpunit.xml.dist index 888811b..a9a5a58 100644 --- a/Build/FunctionalTests.xml +++ b/Build/phpunit.xml.dist @@ -3,7 +3,7 @@ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" backupGlobals="true" beStrictAboutTestsThatDoNotTestAnything="false" - bootstrap="../vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php" + bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php" cacheResult="false" colors="true" failOnDeprecation="true" @@ -16,15 +16,18 @@ stopOnIncomplete="false" stopOnSkipped="false" > - - - - ../Tests/Functional/ - - - - - ../Classes/ - - + + + + ../Tests/Functional/ + + + ../Tests/Unit/ + + + + + ../Classes/ + + diff --git a/Configuration/TCA/tx_cartbooks_domain_model_specialprice.php b/Configuration/TCA/tx_cartbooks_domain_model_specialprice.php index 21075d5..233ed95 100644 --- a/Configuration/TCA/tx_cartbooks_domain_model_specialprice.php +++ b/Configuration/TCA/tx_cartbooks_domain_model_specialprice.php @@ -35,7 +35,7 @@ ], 'types' => [ '1' => [ - 'showitem' => 'frontend_user_group,title,price,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.access,--palette--;LLL:EXT:cart_books/Resources/Private/Language/locallang_tca.xlf:palettes.visibility;hiddenonly,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.access;access', + 'showitem' => 'frontend_user_group,title,price,--div--;core.form.tabs:access,--palette--;LLL:EXT:cart_books/Resources/Private/Language/locallang_tca.xlf:palettes.visibility;hiddenonly,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.access;access', ], ], 'palettes' => [ @@ -46,7 +46,7 @@ 'showitem' => 'hidden;' . $_LLL . ':tx_cartbooks_domain_model_specialprice', ], 'access' => [ - 'showitem' => 'starttime;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:starttime_formlabel, endtime;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:endtime_formlabel', + 'showitem' => 'starttime;core.db.general:starttime, endtime;core.db.general:endtime', ], ], 'columns' => [ diff --git a/Tests/Unit/Domain/Model/BookTest.php b/Tests/Unit/Domain/Model/BookTest.php index 9a56cdc..bdb5bea 100644 --- a/Tests/Unit/Domain/Model/BookTest.php +++ b/Tests/Unit/Domain/Model/BookTest.php @@ -16,12 +16,9 @@ class BookTest extends UnitTestCase protected function setUp(): void { - $this->book = new Book(); - } + parent::setUp(); - protected function tearDown(): void - { - unset($this->book); + $this->book = new Book(); } #[Test] @@ -84,7 +81,7 @@ public function getTaxClassIdReturnsValueForTaxClassId(): void ); } - private function setProperty(object $instance, string $propertyName, mixed $propertyValue) + private function setProperty(object $instance, string $propertyName, mixed $propertyValue): void { $reflection = new \ReflectionProperty($instance, $propertyName); $reflection->setValue($instance, $propertyValue); diff --git a/codeception.dist.yml b/codeception.dist.yml index 33354b7..6aaa80d 100644 --- a/codeception.dist.yml +++ b/codeception.dist.yml @@ -3,7 +3,7 @@ namespace: 'Extcode\CartBooks\Tests\Acceptance\Support' paths: tests: 'Tests/Acceptance' data: 'Tests/Acceptance/Data' - output: '.build/web/typo3temp/var/tests/acceptance-reports' + output: '.build/public/typo3temp/var/tests/acceptance-reports' support: 'Tests/Acceptance/Support' settings: @@ -13,8 +13,8 @@ extensions: enabled: - 'Codeception\Extension\RunProcess': - - 'geckodriver > .build/web/typo3temp/var/tests/acceptance-logs/geckodriver.log 2>&1' - - 'TYPO3_PATH_APP="$INSTANCE_PATH" TYPO3_PATH_ROOT="$INSTANCE_PATH" php -S 127.0.0.1:8080 -t "$INSTANCE_PATH" > .build/web/typo3temp/var/tests/acceptance-logs/php.log 2>&1' + - 'geckodriver > .build/public/typo3temp/var/tests/acceptance-logs/geckodriver.log 2>&1' + - 'TYPO3_PATH_APP="$INSTANCE_PATH" TYPO3_PATH_ROOT="$INSTANCE_PATH" php -S 127.0.0.1:8080 -t "$INSTANCE_PATH" > .build/public/typo3temp/var/tests/acceptance-logs/php.log 2>&1' - 'Codeception\Extension\Recorder' - diff --git a/composer.json b/composer.json index e1920e1..6b10e32 100644 --- a/composer.json +++ b/composer.json @@ -1,69 +1,78 @@ { - "name": "extcode/cart-books", - "type": "typo3-cms-extension", - "description": "Shopping Cart(s) for TYPO3 - Book Extension", - "homepage": "https://cart.extco.de", - "license": [ - "GPL-2.0-or-later" - ], - "keywords": [ - "TYPO3 CMS", - "Shopping Cart", - "cart", - "books" - ], - "authors": [ - { - "name": "Daniel Gohlke", - "email": "ext@extco.de", - "role": "Developer" - } - ], - "support": { - "issues": "https://github.com/extcode/cart_books/issues" - }, - "autoload": { - "psr-4": { - "Extcode\\CartBooks\\": "Classes/" - } - }, - "autoload-dev": { - "psr-4": { - "Extcode\\CartBooks\\Tests\\": "Tests/" - } - }, - "config": { - "allow-plugins": { - "typo3/cms-composer-installers": true, - "typo3/class-alias-loader": true - } - }, - "extra": { - "typo3/cms": { - "extension-key": "cart_books", - "web-dir": ".build/web" - } - }, - "require": { - "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", - "ext-json": "*", - "ext-pdo": "*", - "extcode/cart": "^11.0", - "extcode/books": "^1.0", - "typo3/cms-core": "^13.4", - "typo3/cms-extbase": "^13.4", - "typo3/cms-fluid": "^13.4" - }, - "require-dev": { - "codappix/typo3-php-datasets": "^2.1", - "codeception/codeception": "^5.0", - "codeception/module-db": "^3.1", - "codeception/module-webdriver": "^4.0", - "friendsofphp/php-cs-fixer": "^3.16", - "helmich/typo3-typoscript-lint": "^3.1", - "phpstan/phpstan": "^1.10", - "typo3/cms-fluid-styled-content": "^13.4", - "typo3/cms-install": "^13.4", - "typo3/testing-framework": "^8.2" + "name": "extcode/cart-books", + "type": "typo3-cms-extension", + "description": "Shopping Cart(s) for TYPO3 - Book Extension", + "homepage": "https://cart.extco.de", + "license": [ + "GPL-2.0-or-later" + ], + "keywords": [ + "TYPO3 CMS", + "Shopping Cart", + "cart", + "books" + ], + "authors": [ + { + "name": "Daniel Gohlke", + "email": "ext@extco.de", + "role": "Developer" } + ], + "support": { + "issues": "https://github.com/extcode/cart_books/issues" + }, + "autoload": { + "psr-4": { + "Extcode\\CartBooks\\": "Classes/" + } + }, + "autoload-dev": { + "psr-4": { + "Extcode\\CartBooks\\Tests\\": "Tests/" + } + }, + "config": { + "bin-dir": ".build/bin", + "vendor-dir": ".build/vendor", + "allow-plugins": { + "typo3/cms-composer-installers": true, + "typo3/class-alias-loader": true, + "phpstan/extension-installer": true + } + }, + "extra": { + "typo3/cms": { + "extension-key": "cart_books", + "web-dir": ".build/public" + } + }, + "require": { + "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", + "ext-json": "*", + "ext-pdo": "*", + "extcode/cart": "dev-12.x-dev as 12.0.0", + "extcode/books": "dev-main as 2.0.0", + "typo3/cms-core": "^14.1", + "typo3/cms-extbase": "^14.1", + "typo3/cms-fluid": "^14.1" + }, + "require-dev": { + "codappix/typo3-php-datasets": "^2.1", + "codeception/codeception": "^5.0", + "codeception/module-db": "^3.1", + "codeception/module-webdriver": "^4.0", + "friendsofphp/php-cs-fixer": "^3.16", + "helmich/typo3-typoscript-lint": "^3.1", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "spaze/phpstan-disallowed-calls": "^4.7", + "staabm/phpstan-todo-by": "^0.3", + "typo3/cms-fluid-styled-content": "^14.1", + "typo3/cms-install": "^14.1", + "typo3/testing-framework": "^9.3", + "ssch/typo3-rector": "^3.11" + } } diff --git a/ext_emconf.php b/ext_emconf.php index 840fb17..96b9767 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -4,16 +4,16 @@ 'title' => 'Cart - Books', 'description' => 'Shopping Cart(s) for TYPO3 - Book Extension', 'category' => 'plugin', - 'version' => '6.0.0', + 'version' => '7.0.0', 'state' => 'stable', 'author' => 'Daniel Gohlke', 'author_email' => 'ext@extco.de', 'author_company' => 'extco.de UG (haftungsbeschränkt)', 'constraints' => [ 'depends' => [ - 'typo3' => '13.4.0-13.4.99', - 'cart' => '11.0.0', - 'books' => '1.0.0', + 'typo3' => '14.1.0-14.4.99', + 'cart' => '12.0.0', + 'books' => '2.0.0', ], 'conflicts' => [], 'suggests' => [], diff --git a/rector.php b/rector.php index 99f969c..60ec024 100644 --- a/rector.php +++ b/rector.php @@ -7,7 +7,6 @@ use Rector\PostRector\Rector\NameImportingPostRector; use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector; use Rector\ValueObject\PhpVersion; -use Ssch\TYPO3Rector\CodeQuality\General\ConvertImplicitVariablesToExplicitGlobalsRector; use Ssch\TYPO3Rector\CodeQuality\General\ExtEmConfRector; use Ssch\TYPO3Rector\CodeQuality\General\InjectMethodToConstructorInjectionRector; use Ssch\TYPO3Rector\Configuration\Typo3Option; @@ -29,7 +28,7 @@ ->withSets([ Typo3SetList::CODE_QUALITY, Typo3SetList::GENERAL, - Typo3LevelSetList::UP_TO_TYPO3_12, + Typo3LevelSetList::UP_TO_TYPO3_14, ]) // To have a better analysis from PHPStan, we teach it here some more things ->withPHPStanConfigs([ @@ -37,7 +36,6 @@ ]) ->withRules([ AddVoidReturnTypeWhereNoReturnRector::class, - ConvertImplicitVariablesToExplicitGlobalsRector::class, ]) ->withConfiguredRule(ExtEmConfRector::class, [ ExtEmConfRector::PHP_VERSION_CONSTRAINT => '8.2.0-8.3.99', diff --git a/shell.nix b/shell.nix index 2e57aca..8095619 100644 --- a/shell.nix +++ b/shell.nix @@ -23,7 +23,8 @@ let composer ]; text = '' - composer update --prefer-dist --no-progress + rm -rf .build/ composer.lock + composer update --prefer-dist --no-progress --working-dir="$PROJECT_ROOT" ''; }; @@ -35,7 +36,7 @@ let ]; text = '' - ./vendor/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --diff + ./.build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --diff ''; }; @@ -47,12 +48,12 @@ let ]; text = '' - ./vendor/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php + ./.build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php ''; }; - projectLintPhp = pkgs.writeShellApplication { - name = "project-lint-php"; + projectLint = pkgs.writeShellApplication { + name = "project-lint"; runtimeInputs = [ php @@ -63,51 +64,51 @@ let ''; }; - projectLintTypoScript = pkgs.writeShellApplication { - name = "project-lint-typoscript"; + projectPhpstan = pkgs.writeShellApplication { + name = "project-phpstan"; runtimeInputs = [ php ]; text = '' - ./vendor/bin/typoscript-lint -c Build/typoscriptlint.yaml Configuration + ./.build/bin/phpstan analyse -c Build/phpstan.neon --memory-limit 256M ''; }; - projectPhpstan = pkgs.writeShellApplication { - name = "project-phpstan"; - + projectTestUnit = pkgs.writeShellApplication { + name = "project-test-unit"; runtimeInputs = [ php + projectInstall ]; - text = '' - ./vendor/bin/phpstan analyse -c Build/phpstan.neon --memory-limit 256M + project-install + ./.build/bin/phpunit -c Build/phpunit.xml.dist --testsuite unit --display-warnings --display-deprecations --display-errors ''; }; - projectTestUnit = pkgs.writeShellApplication { - name = "project-test-unit"; + projectTestFunctional = pkgs.writeShellApplication { + name = "project-test-functional"; runtimeInputs = [ php projectInstall ]; text = '' project-install - vendor/bin/phpunit -c Build/UnitTests.xml + ./.build/bin/phpunit -c Build/phpunit.xml.dist --testsuite functional --display-warnings --display-deprecations --display-errors ''; }; - projectTestFunctional = pkgs.writeShellApplication { - name = "project-test-functional"; + projectTestWithCoverage = pkgs.writeShellApplication { + name = "project-test-with-coverage"; runtimeInputs = [ php projectInstall ]; text = '' project-install - vendor/bin/phpunit -c Build/FunctionalTests.xml + XDEBUG_MODE=coverage ./.build/bin/phpunit -c Build/phpunit.xml.dist --coverage-html=coverage_result ''; }; @@ -124,36 +125,35 @@ let text = '' project-install - mkdir -p "$PROJECT_ROOT/.build/web/typo3temp/var/tests/acceptance" - mkdir -p "$PROJECT_ROOT/.build/web/typo3temp/var/tests/acceptance-logs" - mkdir -p "$PROJECT_ROOT/.build/web/typo3temp/var/tests/acceptance-reports" - mkdir -p "$PROJECT_ROOT/.build/web/typo3temp/var/tests/acceptance-sqlite-dbs" + mkdir -p "$PROJECT_ROOT/.build/public/typo3temp/var/tests/acceptance" + mkdir -p "$PROJECT_ROOT/.build/public/typo3temp/var/tests/acceptance-logs" + mkdir -p "$PROJECT_ROOT/.build/public/typo3temp/var/tests/acceptance-reports" + mkdir -p "$PROJECT_ROOT/.build/public/typo3temp/var/tests/acceptance-sqlite-dbs" - export INSTANCE_PATH="$PROJECT_ROOT/.build/web/typo3temp/var/tests/acceptance" + export INSTANCE_PATH="$PROJECT_ROOT/.build/public/typo3temp/var/tests/acceptance" - ./vendor/bin/codecept run + ./.build/bin/codecept run pgrep -f "php -S" | xargs -r kill pgrep -f "geckodriver" | xargs -r kill ''; }; -in pkgs.mkShell { - name = "TYPO3 Extension cart-books"; +in pkgs.mkShellNoCC { + name = "TYPO3 Extension extcode/cart-books"; buildInputs = [ php composer projectInstall - projectPhpstan projectCgl projectCglFix - projectLintPhp - projectLintTypoScript + projectLint + projectPhpstan projectTestUnit projectTestFunctional + projectTestWithCoverage projectTestAcceptance ]; - packages = [ pkgs.gnumake pkgs.busybox ]; shellHook = '' export PROJECT_ROOT="$(pwd)"