diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b347ddb1..d6641eb2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,8 +21,8 @@ jobs: strategy: fail-fast: false matrix: - php: [ "8.3" ] - symfony: [ "^6.4", "^7.0" ] + php: [ "8.2", "8.3" ] + symfony: [ "^7.1" ] sylius: [ "^2.0" ] node: [ "20.x" ] mysql: [ "8.0" ] @@ -159,6 +159,10 @@ jobs: name: Run PHPUnit run: vendor/bin/phpunit --colors=always + - + name: Cache clear + run: (cd tests/Application && rm -rf var/cache) + - name: Run Behat run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun diff --git a/.github/workflows/coding_standard.yml b/.github/workflows/coding_standard.yml index 94eeeeb5..ca71893b 100644 --- a/.github/workflows/coding_standard.yml +++ b/.github/workflows/coding_standard.yml @@ -18,8 +18,8 @@ jobs: strategy: fail-fast: false matrix: - php: [ "8.3" ] - symfony: [ "^6.4", "^7.0" ] + php: [ "8.2", "8.3" ] + symfony: [ "^7.1" ] sylius: [ "^2.0" ] node: [ "20.x" ] diff --git a/UPGRADE-1.3.md b/UPGRADE-1.3.md deleted file mode 100644 index 9fd41411..00000000 --- a/UPGRADE-1.3.md +++ /dev/null @@ -1,28 +0,0 @@ -# UPGRADE FROM `v1.2.X` TO `v1.3.0` - -## Application - -* Run `composer require sylius/sylius:~1.3.0 --no-update` - -* Add the following code in your `behat.yml(.dist)` file: - - ```yaml - default: - extensions: - FriendsOfBehat\SymfonyExtension: - env_file: ~ - ``` - -* Incorporate changes from the following files into plugin's test application: - - * [`tests/Application/package.json`](https://github.com/Sylius/PluginSkeleton/blob/1.3/tests/Application/package.json) ([see diff](https://github.com/Sylius/PluginSkeleton/pull/134/files#diff-726e1353c14df7d91379c0dea6b30eef)) - * [`tests/Application/.babelrc`](https://github.com/Sylius/PluginSkeleton/blob/1.3/tests/Application/.babelrc) ([see diff](https://github.com/Sylius/PluginSkeleton/pull/134/files#diff-a2527d9d8ad55460b2272274762c9386)) - * [`tests/Application/.eslintrc.js`](https://github.com/Sylius/PluginSkeleton/blob/1.3/tests/Application/.eslintrc.js) ([see diff](https://github.com/Sylius/PluginSkeleton/pull/134/files#diff-396c8c412b119deaa7dd84ae28ae04ca)) - -* Update PHP and JS dependencies by running `composer update` and `(cd tests/Application && yarn upgrade)` - -* Clear cache by running `(cd tests/Application && bin/console cache:clear)` - -* Install assets by `(cd tests/Application && bin/console assets:install web)` and `(cd tests/Application && yarn build)` - -* optionally, remove the build for PHP 7.1. in `.travis.yml` diff --git a/UPGRADE-1.4.md b/UPGRADE-1.4.md deleted file mode 100644 index dc84cad6..00000000 --- a/UPGRADE-1.4.md +++ /dev/null @@ -1,86 +0,0 @@ -# UPGRADE FROM `v1.3.X` TO `v1.4.0` - -First step is upgrading Sylius with composer - -- `composer require sylius/sylius:~1.4.0` - -### Test application database - -#### Migrations - -If you provide migrations with your plugin, take a look at following changes: - -* Change base `AbstractMigration` namespace to `Doctrine\Migrations\AbstractMigration` -* Add `: void` return types to both `up` and `down` functions - -#### Schema update - -If you don't use migrations, just run `(cd tests/Application && bin/console doctrine:schema:update --force)` to update the test application's database schema. - -### Dotenv - -* `composer require symfony/dotenv:^4.2 --dev` -* Follow [Symfony dotenv update guide](https://symfony.com/doc/current/configuration/dot-env-changes.html) to incorporate required changes in `.env` files structure. Remember - they should be done on `tests/Application/` level! Optionally, you can take a look at [corresponding PR](https://github.com/Sylius/PluginSkeleton/pull/156/) introducing these changes in **PluginSkeleton** (this PR also includes changes with Behat - see below) - -Don't forget to clear the cache (`tests/Application/bin/console cache:clear`) to be 100% everything is loaded properly. - ---- - -### Behat - -If you're using Behat and want to be up-to-date with our configuration - -* Update required extensions with `composer require friends-of-behat/symfony-extension:^2.0 friends-of-behat/page-object-extension:^0.3 --dev` -* Remove extensions that are not needed yet with `composer remove friends-of-behat/context-service-extension friends-of-behat/cross-container-extension friends-of-behat/service-container-extension --dev` -* Update your `behat.yml` - look at the diff [here](https://github.com/Sylius/Sylius-Standard/pull/322/files#diff-7bde54db60a6e933518d8b61b929edce) -* Add `SymfonyExtensionBundle` to your `tests/Application/config/bundles.php`: - ```php - return [ - //... - FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true], - ]; - ``` -* If you use our Travis CI configuration, follow [these changes](https://github.com/Sylius/PluginSkeleton/pull/156/files#diff-354f30a63fb0907d4ad57269548329e3) introduced in `.travis.yml` file -* Create `tests/Application/config/services_test.yaml` file with the following code and add these your own Behat services as well: - ```yaml - imports: - - { resource: "../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" } - ``` -* Remove all `__symfony__` prefixes in your Behat services -* Remove all `` tags from your Behat services -* Make your Behat services public by default with `` -* Change `contexts_services ` in your suite definitions to `contexts` -* Take a look at [SymfonyExtension UPGRADE guide](https://github.com/FriendsOfBehat/SymfonyExtension/blob/master/UPGRADE-2.0.md) if you have any more problems - -### Phpstan - -* Fix the container XML path parameter in the `phpstan.neon` file as done [here](https://github.com/Sylius/PluginSkeleton/commit/37fa614dbbcf8eb31b89eaf202b4bd4d89a5c7b3) - -# UPGRADE FROM `v1.2.X` TO `v1.4.0` - -Firstly, check out the [PluginSkeleton 1.3 upgrade guide](https://github.com/Sylius/PluginSkeleton/blob/1.4/UPGRADE-1.3.md) to update Sylius version step by step. -To upgrade to Sylius 1.4 follow instructions from [the previous section](https://github.com/Sylius/PluginSkeleton/blob/1.4/UPGRADE-1.4.md#upgrade-from-v13x-to-v140) with following changes: - -### Doctrine migrations - -* Change namespaces of copied migrations to `Sylius\Migrations` - -### Dotenv - -* These changes are not required, but can be done as well, if you've changed application directory structure in `1.2.x` to `1.3` update - -### Behat - -* Add `\FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle()` to your bundles lists in `tests/Application/AppKernel.php` (preferably only in `test` environment) -* Import Sylius Behat services in `tests/Application/config/config_test.yml` and your own Behat services as well: - ```yaml - imports: - - { resource: "../../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" } - ``` -* Specify test application's kernel path in `behat.yml`: - ```yaml - FriendsOfBehat\SymfonyExtension: - kernel: - class: AppKernel - path: tests/Application/app/AppKernel.php - ``` diff --git a/composer.json b/composer.json index b7278ae9..0b65f5ff 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "description": "Product bundle for Sylius.", "license": "MIT", "require": { - "php": "^8.2", + "php": "~8.2.0 || ~8.3.0", "sylius/sylius": "~2.0.0", "dompdf/dompdf": "^2.0", "sylius/twig-hooks": "^0.5", @@ -31,7 +31,7 @@ "friends-of-behat/symfony-extension": "^2.6", "friends-of-behat/variadic-extension": "^1.6", "gedmo/doctrine-extensions": "^3.9", - "lchrusciel/api-test-case": "^4.1 || ^5.0", + "lchrusciel/api-test-case": "^5.3", "league/flysystem-bundle": "^3.3", "nelmio/alice": "^3.10", "nyholm/psr7": "^1.8", @@ -42,13 +42,13 @@ "sylius-labs/suite-tags-extension": "~0.2", "sylius/mailer-bundle": "^1.8 || ^2.0@beta", "sylius/sylius-rector": "^2.0", - "symfony/browser-kit": "^6.4 || ^7.1", - "symfony/debug-bundle": "^6.4 || ^7.1", - "symfony/dependency-injection": "^6.4 || ^7.1", - "symfony/dotenv": "^6.4 || ^7.1", - "symfony/http-client": "^6.4 || ^7.1", - "symfony/intl": "^6.4 || ^7.1", - "symfony/web-profiler-bundle": "^6.4 || ^7.1" + "symfony/browser-kit": "^7.1", + "symfony/debug-bundle": "^7.1", + "symfony/dependency-injection": "^7.1", + "symfony/dotenv": "^7.1", + "symfony/http-client": "^7.1", + "symfony/intl": "^7.1", + "symfony/web-profiler-bundle": "^7.1" }, "autoload": { "psr-4": { diff --git a/src/Component/Product/AddToCartFormComponent.php b/src/Component/Product/AddToCartFormComponent.php index 0b7ea054..68525f60 100644 --- a/src/Component/Product/AddToCartFormComponent.php +++ b/src/Component/Product/AddToCartFormComponent.php @@ -62,32 +62,32 @@ final class AddToCartFormComponent extends BaseAddToCartFormComponent * @param ProductVariantRepositoryInterface $productVariantRepository */ public function __construct( - protected readonly FormFactoryInterface $formFactory, - protected readonly ObjectManager $manager, - protected readonly RouterInterface $router, - protected readonly RequestStack $requestStack, - protected readonly EventDispatcherInterface $eventDispatcher, - protected readonly CartContextInterface $cartContext, - protected readonly AddToCartCommandFactoryInterface $addToCartCommandFactory, - protected readonly CartItemFactoryInterface $cartItemFactory, - protected readonly string $formClass, + FormFactoryInterface $formFactory, + ObjectManager $manager, + RouterInterface $router, + RequestStack $requestStack, + EventDispatcherInterface $eventDispatcher, + CartContextInterface $cartContext, + AddToCartCommandFactoryInterface $addToCartCommandFactory, + CartItemFactoryInterface $cartItemFactory, + string $formClass, ProductRepositoryInterface $productRepository, ProductVariantRepositoryInterface $productVariantRepository, - private readonly AddProductBundleToCartDtoFactory $addProductBundleToCartDtoFactory, + protected readonly AddProductBundleToCartDtoFactory $addProductBundleToCartDtoFactory, ) { $this->initializeProduct($productRepository); $this->initializeProductVariant($productVariantRepository); parent::__construct( - $this->formFactory, - $this->manager, - $this->router, - $this->requestStack, - $this->eventDispatcher, - $this->cartContext, - $this->addToCartCommandFactory, - $this->cartItemFactory, - $this->formClass, + $formFactory, + $manager, + $router, + $requestStack, + $eventDispatcher, + $cartContext, + $addToCartCommandFactory, + $cartItemFactory, + $formClass, $productRepository, $productVariantRepository, ); diff --git a/src/Resources/config/services/product.xml b/src/Resources/config/services/product.xml index b299279e..a99dd4c8 100644 --- a/src/Resources/config/services/product.xml +++ b/src/Resources/config/services/product.xml @@ -14,9 +14,7 @@ - BitBag\SyliusProductBundlePlugin\Form\Type\AddProductBundleToCartType - diff --git a/tests/Api/AdminJsonApiTestCase.php b/tests/Api/AdminJsonApiTestCase.php index bfd933b0..960e0da3 100644 --- a/tests/Api/AdminJsonApiTestCase.php +++ b/tests/Api/AdminJsonApiTestCase.php @@ -11,19 +11,11 @@ namespace Tests\BitBag\SyliusProductBundlePlugin\Api; -use Composer\InstalledVersions; - abstract class AdminJsonApiTestCase extends JsonApiTestCase { public function getAuthToken(string $email, string $password): string { - $syliusVersion = InstalledVersions::getVersion('sylius/sylius'); - - if (version_compare($syliusVersion, '1.13.0', '>=')) { - $endpoint = '/api/v2/admin/administrators/token'; - } else { - $endpoint = '/api/v2/admin/authentication-token'; - } + $endpoint = '/api/v2/admin/administrators/token'; $this->client->request( 'POST', diff --git a/tests/Application/.gitignore b/tests/Application/.gitignore index b4464856..7fb84dda 100644 --- a/tests/Application/.gitignore +++ b/tests/Application/.gitignore @@ -10,7 +10,6 @@ /node_modules /config/encryption -/config/jwt ###> symfony/framework-bundle ### /.env.*.local diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index c795fbe0..2664dd20 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -112,9 +112,5 @@ private function registerBundlesFromFile(string $bundlesFile): iterable private function getConfigurationDirectories(): iterable { yield $this->getProjectDir() . '/config'; - $symfonyConfigDir = $this->getProjectDir() . '/config/symfony/' . BaseKernel::MAJOR_VERSION . '.x'; - if (is_dir($symfonyConfigDir)) { - yield $symfonyConfigDir; - } } } diff --git a/tests/Application/config/jwt/private.pem b/tests/Application/config/jwt/private.pem new file mode 100644 index 00000000..2bcf0230 --- /dev/null +++ b/tests/Application/config/jwt/private.pem @@ -0,0 +1,54 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIJrTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQIDbthk+aF5EACAggA +MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBA3DYfh2mXByUxFNke/Wf5SBIIJ +UBckIgXeXBWPLQAAq07pN8uNFMUcUirFuEvbmxVe1PupCCAqriNxi1DqeSu/M7c1 +h66y0BqKZu/0G9SVTg63iCKDEiRAM3hLyD2CsjYg8h2LAaqQ9dFYGV0cHRhCXagZ +Sdt9YTfn2rarRbxauMSt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5kRYx +Fe1smlw1Vxl/qNQ32LFWsBIK+XnYBteYmlpVyYrTgXyjnp1rK2zz0118DPFuYiAP +O0r6nnBz0NbwnSKb7S4CjxBKDvDbWTzP35Q5L/vySnO2zRbM64Gw7sjeLiJittWS +gQfbFpEk9k8KVndKM4H50Jp0WznmYpm1Tman8hUOiCvmq0qdI3bJ5Bnj0K+q2zFV ++noGpMFdq1+8WaUFLQFGCPM+yJgCqDgT1RAgfsGcomckGcmenDtHaTbcSFabEdpM +Tsa2qLdg/Kju+7JyGrkmobXl/azuyjYTHfRvSZrvO5WUDFzhChrJpIL4nA3ZGRlS +gvy+OzyyBh4sRyHwLItwUwE81aya3W4llAkhQ7OycmqniJgjtJzLwnxv2RQsB8bF +pyoqQdKVxkqHdbUFeh9igI4ffRAK+8xDER5J+RUoZ4mO8qJebxar54XTb6I/Lepc +g8ITX8bJ/GH+M6JdP7tLCikDTSGS+i1ReMQXE5XuEajYOVbzQdyWU5jleZIx0f6X +mTa4WvMEGNyNxKZZXsy9FAaBkZqrNzEv8k0uFgFMNWQcMMtiqbei86yACdqe+jiW +HqHv8wfoBHR+eIARub2itOJ/cI+oKv96d4it4FqQ9Lml8RUFFZj7Hrd6EjDb6Nq4 +P9ti7eku/xZvS0saBNChvv44GhP6FZJS0i/gidVffLna7Wua98tPZEAXp57k+XUL +PzsRJ4a+hFuQjkyXFoz/v8YuUdyCFUSVVr9ArVu0v4+4euFWpQLav5sXv0Gh9X58 +Ek1KIf7Z/tZAJnSjTjFuSbDX/AoTMTxpRBKKnFW6zY0Nw2pjTVMtTVDkv9xkBpBK +wod7FPD5f0T7y9YOARVZnBxVRSkkcYpEJFy5pLNeadg9 +-----END ENCRYPTED PRIVATE KEY----- diff --git a/tests/Application/config/packages/test_cached/fos_rest.yaml b/tests/Application/config/packages/test_cached/fos_rest.yaml index 2b4189da..c36c93f9 100644 --- a/tests/Application/config/packages/test_cached/fos_rest.yaml +++ b/tests/Application/config/packages/test_cached/fos_rest.yaml @@ -1,3 +1,3 @@ fos_rest: - exception: - debug: true + exception: + debug: true diff --git a/tests/Application/config/packages/test_cached/twig.yaml b/tests/Application/config/packages/test_cached/twig.yaml index 8c6e0b40..2d8d420d 100644 --- a/tests/Application/config/packages/test_cached/twig.yaml +++ b/tests/Application/config/packages/test_cached/twig.yaml @@ -1,2 +1,12 @@ twig: + paths: ['%kernel.project_dir%/templates'] + debug: '%kernel.debug%' strict_variables: true + +services: + _defaults: + public: false + autowire: true + autoconfigure: true + + Twig\Extra\Intl\IntlExtension: ~ diff --git a/tests/Application/config/symfony/6.x/bundles.php b/tests/Application/config/symfony/6.x/bundles.php deleted file mode 100644 index b310d660..00000000 --- a/tests/Application/config/symfony/6.x/bundles.php +++ /dev/null @@ -1,14 +0,0 @@ - ['all' => true], -];