diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c4637640e..cf89085d8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,17 +18,18 @@ jobs: strategy: fail-fast: false matrix: - php: [8.0, 8.1] - node: [16.x] - mysql: [5.7, 8.0] - symfony: [^5.4] - sylius: [~1.11.0] + php: ["8.0", "8.1"] + symfony: ["^5.4"] + sylius: ["~1.11.10", "~1.12.0"] + node: ["16.x"] + mysql: ["5.7", "8.0"] env: APP_ENV: test APP_SECRET: "Dead men tell no tales" DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" MESSENGER_TRANSPORT_DSN: "sync://" + MAILER_DSN: "null://null" steps: - @@ -76,7 +77,7 @@ jobs: name: Restrict Sylius version if: matrix.sylius != '' run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction - + - name: Install PHP dependencies run: composer update --no-interaction @@ -102,3 +103,4 @@ jobs: - name: Run PHPUnit run: vendor/bin/phpunit --colors=always + diff --git a/composer.json b/composer.json index 81e4f2db5..3af785f74 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "MIT", "require": { "php": "^8.0", - "sylius/sylius": "~1.11.0", + "sylius/sylius": "~1.11.10 || ~1.12.0", "lexik/jwt-authentication-bundle": "^2.5", "symfony/messenger": "^5.4", "doctrine/doctrine-bundle": "^2.0" @@ -15,13 +15,14 @@ "matthiasnoback/symfony-config-test": "^4.0", "matthiasnoback/symfony-dependency-injection-test": "^4.0", "phpspec/phpspec": "^7.0", - "phpstan/phpstan": "0.12.96", - "phpstan/phpstan-webmozart-assert": "0.12.12", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-webmozart-assert": "^1.2", "phpunit/phpunit": "^9.0", "sylius-labs/coding-standard": "^4.0", "symfony/debug-bundle": "^5.4", "symfony/dotenv": "^5.4", - "symfony/web-profiler-bundle": "^5.4" + "symfony/web-profiler-bundle": "^5.4", + "symfony/webpack-encore-bundle": "^1.15" }, "autoload": { "psr-4": { @@ -55,7 +56,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.6-dev" } } } diff --git a/src/Resources/config/routing/address_book.yml b/src/Resources/config/routing/address_book.yml index 1555f254f..dbe63e465 100644 --- a/src/Resources/config/routing/address_book.yml +++ b/src/Resources/config/routing/address_book.yml @@ -1,6 +1,6 @@ sylius_shop_api_address_book_create: path: /address-book/ - controller: sylius.controller.address:createAction + controller: sylius.controller.address::createAction methods: [POST] defaults: _sylius: @@ -11,7 +11,7 @@ sylius_shop_api_address_book_create: sylius_shop_api_address_book_index: path: /address-book/ - controller: sylius.controller.address:indexAction + controller: sylius.controller.address::indexAction methods: [GET] defaults: _sylius: @@ -23,7 +23,7 @@ sylius_shop_api_address_book_index: sylius_shop_api_address_book_delete: path: /address-book/{id} - controller: sylius.controller.address:deleteAction + controller: sylius.controller.address::deleteAction methods: [DELETE] defaults: _sylius: @@ -36,7 +36,7 @@ sylius_shop_api_address_book_delete: sylius_shop_api_address_book_update: path: /address-book/{id} - controller: sylius.controller.address:updateAction + controller: sylius.controller.address::updateAction methods: [PUT, PATCH] defaults: _sylius: diff --git a/src/Resources/config/routing/checkout.yml b/src/Resources/config/routing/checkout.yml index 0d03bb2b8..615239e07 100644 --- a/src/Resources/config/routing/checkout.yml +++ b/src/Resources/config/routing/checkout.yml @@ -1,7 +1,7 @@ sylius_shop_api_country_checkout: path: /countries methods: [GET] - controller: sylius.controller.country:indexAction + controller: sylius.controller.country::indexAction defaults: _sylius: paginate: false @@ -15,7 +15,7 @@ sylius_shop_api_country_checkout: sylius_shop_api_country_show_details_by_code_checkout: path: /countries/{code} methods: [GET] - controller: sylius.controller.country:showAction + controller: sylius.controller.country::showAction defaults: _sylius: paginate: false diff --git a/src/Resources/config/routing/customer.yml b/src/Resources/config/routing/customer.yml index 70d7aaaeb..7eff149e5 100644 --- a/src/Resources/config/routing/customer.yml +++ b/src/Resources/config/routing/customer.yml @@ -14,4 +14,4 @@ sylius_shop_api_change_password: path: /me/change-password methods: [PUT] defaults: - _controller: sylius.controller.shop_user:changePasswordAction + _controller: sylius.controller.shop_user::changePasswordAction diff --git a/src/Resources/config/routing/register.yml b/src/Resources/config/routing/register.yml index 5d3ad3c8b..15ae59697 100644 --- a/src/Resources/config/routing/register.yml +++ b/src/Resources/config/routing/register.yml @@ -26,4 +26,4 @@ sylius_shop_api_password_reset: path: /password-reset/{token} methods: [PUT] defaults: - _controller: sylius.controller.shop_user:resetPasswordAction + _controller: sylius.controller.shop_user::resetPasswordAction diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index c82769de3..c33fc01ed 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -9,11 +9,12 @@ declare(strict_types=1); -return [ +use Sylius\Bundle\CoreBundle\Application\Kernel; + +$bundles = [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], - Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true], @@ -61,4 +62,15 @@ Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['all' => true], Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['all' => true], SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], + Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], ]; + +if (Kernel::VERSION_ID < 11200) { + $bundles[Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class] = ['all' => true]; +} + +if (11200 <= Kernel::VERSION_ID) { + $bundles[League\FlysystemBundle\FlysystemBundle::class] = ['all' => true]; +} + +return $bundles; diff --git a/tests/Application/config/packages/dev/swiftmailer.php b/tests/Application/config/packages/dev/swiftmailer.php new file mode 100644 index 000000000..96a4d9ca1 --- /dev/null +++ b/tests/Application/config/packages/dev/swiftmailer.php @@ -0,0 +1,16 @@ += 11200) { + return; +} + +return static function (ContainerConfigurator $containerConfigurator) { + $containerConfigurator->extension('swiftmailer', [ + 'disable_delivery' => true, + ]); +}; diff --git a/tests/Application/config/packages/dev/swiftmailer.yaml b/tests/Application/config/packages/dev/swiftmailer.yaml deleted file mode 100644 index f43807805..000000000 --- a/tests/Application/config/packages/dev/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - disable_delivery: true diff --git a/tests/Application/config/packages/mailer.php b/tests/Application/config/packages/mailer.php new file mode 100644 index 000000000..f92919856 --- /dev/null +++ b/tests/Application/config/packages/mailer.php @@ -0,0 +1,18 @@ +extension('framework', [ + 'mailer' => [ + 'dsn' => '%env(MAILER_DSN)%', + ], + ]); +}; diff --git a/tests/Application/config/packages/security.yaml b/tests/Application/config/packages/security.yaml index 7ba53c9c4..bb8443834 100644 --- a/tests/Application/config/packages/security.yaml +++ b/tests/Application/config/packages/security.yaml @@ -3,13 +3,14 @@ parameters: sylius_shop_api.security.regex: "^/shop-api" security: + enable_authenticator_manager: true providers: sylius_admin_user_provider: id: sylius.admin_user_provider.email_or_name_based sylius_shop_user_provider: id: sylius.shop_user_provider.email_or_name_based - encoders: + password_hashers: Sylius\Component\User\Model\UserInterface: argon2i firewalls: admin: @@ -25,7 +26,7 @@ security: default_target_path: sylius_admin_dashboard use_forward: false use_referer: true - csrf_token_generator: security.csrf.token_manager + enable_csrf: true csrf_parameter: _csrf_admin_security_token csrf_token_id: admin_authenticate remember_me: @@ -37,12 +38,11 @@ security: logout: path: sylius_admin_logout target: sylius_admin_login - anonymous: true sylius_shop_api: pattern: "%sylius_shop_api.security.regex%" stateless: true - anonymous: true + entry_point: jwt provider: sylius_shop_user_provider json_login: check_path: /shop-api/login @@ -50,9 +50,7 @@ security: password_path: password success_handler: lexik_jwt_authentication.handler.authentication_success failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator + jwt: true dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ diff --git a/tests/Application/config/packages/staging/monolog.yaml b/tests/Application/config/packages/staging/monolog.yaml deleted file mode 100644 index 646121143..000000000 --- a/tests/Application/config/packages/staging/monolog.yaml +++ /dev/null @@ -1,10 +0,0 @@ -monolog: - handlers: - main: - type: fingers_crossed - action_level: error - handler: nested - nested: - type: stream - path: "%kernel.logs_dir%/%kernel.environment%.log" - level: debug diff --git a/tests/Application/config/packages/staging/swiftmailer.yaml b/tests/Application/config/packages/staging/swiftmailer.yaml deleted file mode 100644 index f43807805..000000000 --- a/tests/Application/config/packages/staging/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - disable_delivery: true diff --git a/tests/Application/config/packages/swiftmailer.php b/tests/Application/config/packages/swiftmailer.php new file mode 100644 index 000000000..2c291cde7 --- /dev/null +++ b/tests/Application/config/packages/swiftmailer.php @@ -0,0 +1,16 @@ += 11200) { + return; +} + +return static function (ContainerConfigurator $containerConfigurator) { + $containerConfigurator->extension('swiftmailer', [ + 'url' => '%env(MAILER_URL)%', + ]); +}; diff --git a/tests/Application/config/packages/swiftmailer.yaml b/tests/Application/config/packages/swiftmailer.yaml deleted file mode 100644 index 3bab0d32f..000000000 --- a/tests/Application/config/packages/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - url: '%env(MAILER_URL)%' diff --git a/tests/Application/config/packages/test/framework.yaml b/tests/Application/config/packages/test/framework.yaml index 76d7e5e11..fc1d3c13c 100644 --- a/tests/Application/config/packages/test/framework.yaml +++ b/tests/Application/config/packages/test/framework.yaml @@ -1,4 +1,4 @@ framework: test: ~ session: - storage_id: session.storage.mock_file + storage_factory_id: session.storage.factory.mock_file diff --git a/tests/Application/config/packages/test/mailer.php b/tests/Application/config/packages/test/mailer.php new file mode 100644 index 000000000..afd99dfb4 --- /dev/null +++ b/tests/Application/config/packages/test/mailer.php @@ -0,0 +1,22 @@ +extension('framework', [ + 'cache' => [ + 'pools' => [ + 'test.mailer_pool' => [ + 'adapter' => 'cache.adapter.filesystem', + ], + ], + ], + ]); +}; diff --git a/tests/Application/config/packages/test/swiftmailer.php b/tests/Application/config/packages/test/swiftmailer.php new file mode 100644 index 000000000..93e57a145 --- /dev/null +++ b/tests/Application/config/packages/test/swiftmailer.php @@ -0,0 +1,21 @@ += 11200) { + return; +} + +return static function (ContainerConfigurator $containerConfigurator) { + $containerConfigurator->extension('swiftmailer', [ + 'disable_delivery' => true, + 'logging' => true, + 'spool' => [ + 'type' => 'file', + 'path' => '%kernel.cache_dir%/spool', + ], + ]); +}; diff --git a/tests/Application/config/packages/test/swiftmailer.yaml b/tests/Application/config/packages/test/swiftmailer.yaml deleted file mode 100644 index c438f4b25..000000000 --- a/tests/Application/config/packages/test/swiftmailer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -swiftmailer: - disable_delivery: true - logging: true - spool: - type: file - path: "%kernel.cache_dir%/spool" diff --git a/tests/Application/config/packages/test_cached/framework.yaml b/tests/Application/config/packages/test_cached/framework.yaml index 76d7e5e11..fc1d3c13c 100644 --- a/tests/Application/config/packages/test_cached/framework.yaml +++ b/tests/Application/config/packages/test_cached/framework.yaml @@ -1,4 +1,4 @@ framework: test: ~ session: - storage_id: session.storage.mock_file + storage_factory_id: session.storage.factory.mock_file diff --git a/tests/Application/config/packages/test_cached/mailer.php b/tests/Application/config/packages/test_cached/mailer.php new file mode 100644 index 000000000..7a164ae82 --- /dev/null +++ b/tests/Application/config/packages/test_cached/mailer.php @@ -0,0 +1,14 @@ +import(__DIR__ . '/../test/mailer.php'); +}; diff --git a/tests/Application/config/packages/test_cached/swiftmailer.php b/tests/Application/config/packages/test_cached/swiftmailer.php new file mode 100644 index 000000000..6871f1db7 --- /dev/null +++ b/tests/Application/config/packages/test_cached/swiftmailer.php @@ -0,0 +1,14 @@ += 11200) { + return; +} + +return static function (ContainerConfigurator $containerConfigurator) { + $containerConfigurator->import(__DIR__ . '/../test/swiftmailer.php'); +}; diff --git a/tests/Application/config/packages/test_cached/swiftmailer.yaml b/tests/Application/config/packages/test_cached/swiftmailer.yaml deleted file mode 100644 index c438f4b25..000000000 --- a/tests/Application/config/packages/test_cached/swiftmailer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -swiftmailer: - disable_delivery: true - logging: true - spool: - type: file - path: "%kernel.cache_dir%/spool" diff --git a/tests/Application/config/packages/webpack_encore.php b/tests/Application/config/packages/webpack_encore.php new file mode 100644 index 000000000..07c547f16 --- /dev/null +++ b/tests/Application/config/packages/webpack_encore.php @@ -0,0 +1,26 @@ +extension('webpack_encore', [ + 'output_path' => '%kernel.project_dir%/public/build', + 'builds' => [ + 'admin' => '%kernel.project_dir%/public/build/admin', + 'shop' => '%kernel.project_dir%/public/build/shop', + 'app.admin' => '%kernel.project_dir%/public/build/app/admin', + 'app.shop' => '%kernel.project_dir%/public/build/app/shop', + ], + ]); +}; diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php index f97b93b65..a69356ca3 100644 --- a/tests/Application/public/index.php +++ b/tests/Application/public/index.php @@ -9,7 +9,7 @@ declare(strict_types=1); -use Symfony\Component\Debug\Debug; +use Symfony\Component\ErrorHandler\Debug; use Symfony\Component\Dotenv\Dotenv; use Symfony\Component\HttpFoundation\Request; use Tests\Sylius\ShopApiPlugin\Application\Kernel;