diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8fcfa67..0a73e22 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,19 +20,12 @@ jobs: strategy: fail-fast: false matrix: - php: [ "8.0", "8.1", "8.2", "8.3" ] - symfony: [ "^5.4", "^6.4" ] - sylius: [ "^1.12", "^1.13" ] - node: [ "18.x", "20.x" ] + php: [ "8.2", "8.3" ] + symfony: ["^6.4", "^7.1" ] + sylius: [ "~2.0.0" ] + node: [ "20.x", "22.x" ] mysql: [ "8.0" ] - exclude: - - sylius: ^1.13 - php: 8.0 - - sylius: ^1.12 - php: 8.0 - symfony: ^6.4 - env: APP_ENV: test DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" diff --git a/.github/workflows/coding_standard.yml b/.github/workflows/coding_standard.yml index eb9c8e9..4ff1d25 100644 --- a/.github/workflows/coding_standard.yml +++ b/.github/workflows/coding_standard.yml @@ -18,17 +18,11 @@ jobs: strategy: fail-fast: false matrix: - php: [ "8.0", "8.1", "8.2", "8.3" ] - symfony: [ "^5.4", "^6.4" ] - sylius: [ "^1.12", "^1.13" ] - node: [ "18.x", "20.x" ] - - exclude: - - sylius: ^1.13 - php: 8.0 - - sylius: ^1.12 - php: 8.0 - symfony: ^6.4 + php: [ "8.2", "8.3" ] + symfony: ["^6.4", "^7.1" ] + sylius: [ "~2.0.0" ] + node: [ "20.x", "22.x" ] + mysql: [ "8.0" ] steps: - uses: actions/checkout@v3 diff --git a/README.md b/README.md index d719330..a9cdb38 100644 --- a/README.md +++ b/README.md @@ -80,12 +80,12 @@ For the full installation guide, please go [here](doc/installation.md). We work on stable, supported and up-to-date versions of packages. We recommend you to do the same. -| Package | Version | -|---------------|-----------------| -| PHP | \>=8.0 | -| sylius/sylius | 1.12.x - 1.13.x | -| MySQL | \>= 5.7 | -| NodeJS | \>= 18.x | +| Package | Version | +|---------------|---------------| +| PHP | \>=8.2 | +| sylius/sylius | 2.0.x | +| MySQL | \>= 8.0 | +| NodeJS | \>=20.x, 22.x | ---- diff --git a/composer.json b/composer.json index 234e10d..612929a 100644 --- a/composer.json +++ b/composer.json @@ -4,42 +4,50 @@ "description": "Shipping data export environment for Sylius platform applications", "license": "MIT", "require": { - "php": "^8.0", - "doctrine/dbal": "^2.7 || ^3.0", - "sylius/sylius": "~1.12.0 || ~1.13.0" + "php": "^8.2", + "sylius/sylius": "~2.0.0", + "dompdf/dompdf": "^2.0", + "sylius/twig-hooks": "^0.5", + "sylius/twig-extra": "^0.5", + "symfony/ux-autocomplete": "^2.17", + "symfony/ux-live-component": "^2.20", + "symfony/ux-twig-component": "^2.20", + "symfony/webpack-encore-bundle": "^2.1", + "symfony/stimulus-bundle": "^2.12" }, "require-dev": { - "behat/behat": "^3.7", - "behat/mink-selenium2-driver": "~1.6.0", - "symfony/webpack-encore-bundle": "^1.15", - "bitbag/coding-standard": "^3.0", - "dmore/behat-chrome-extension": "^1.3", - "dmore/chrome-mink-driver": "^2.7", - "friends-of-behat/mink": "^1.8", - "friends-of-behat/mink-browserkit-driver": "^1.4", - "friends-of-behat/mink-debug-extension": "^2.0", - "friends-of-behat/mink-extension": "^2.4", + "behat/behat": "^3.14", + "behat/mink-selenium2-driver": "^1.7", + "bitbag/coding-standard": "^3.0.0", + "dmore/behat-chrome-extension": "^1.4", + "friends-of-behat/mink": "^1.11", + "friends-of-behat/mink-browserkit-driver": "^1.6", + "friends-of-behat/mink-debug-extension": "^2.1", + "friends-of-behat/mink-extension": "^2.7", "friends-of-behat/page-object-extension": "^0.3", - "friends-of-behat/suite-settings-extension": "^1.0", - "friends-of-behat/symfony-extension": "^2.1", - "friends-of-behat/variadic-extension": "^1.3", + "friends-of-behat/suite-settings-extension": "^1.1", + "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", + "league/flysystem-bundle": "^3.3", + "nelmio/alice": "^3.10", + "nyholm/psr7": "^1.8", "phpspec/phpspec": "^7.0", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^1.8.1", - "phpstan/phpstan-doctrine": "1.3.69", - "phpstan/phpstan-strict-rules": "^1.3.0", - "phpstan/phpstan-webmozart-assert": "^1.2.0", "phpunit/phpunit": "^9.5", - "sylius-labs/coding-standard": "^4.0", - "symfony/browser-kit": "^5.4 || ^6.0", - "symfony/debug-bundle": "^5.4 || ^6.0", - "symfony/dotenv": "^5.4 || ^6.0", - "symfony/intl": "^5.4 || ^6.0", - "symfony/web-profiler-bundle": "^5.4 || ^6.0", - "polishsymfonycommunity/symfony-mocker-container": "^1.0" - }, - "conflict": { - "doctrine/persistence": "<3.0" + "polishsymfonycommunity/symfony-mocker-container": "^1.0", + "robertfausk/behat-panther-extension": "^1.1", + "sylius-labs/coding-standard": "^4.4", + "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" }, "config": { "sort-packages": true, @@ -47,7 +55,8 @@ "symfony/thanks": true, "composer/package-versions-deprecated": true, "dealerdirect/phpcodesniffer-composer-installer": true, - "phpstan/extension-installer": true + "phpstan/extension-installer": true, + "php-http/discovery": true } }, "autoload": { diff --git a/doc/installation.md b/doc/installation.md index 1f79f5c..a5e8a0a 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -13,12 +13,12 @@ ADDITIONAL ## Requirements: We work on stable, supported and up-to-date versions of packages. We recommend you to do the same. -| Package | Version | -|---------------|-----------------| -| PHP | \>=8.0 | -| sylius/sylius | 1.12.x - 1.13.x | -| MySQL | \>= 5.7 | -| NodeJS | \>= 18.x | +| Package | Version | +|---------------|---------------| +| PHP | \>=8.2 | +| sylius/sylius | 2.0.x | +| MySQL | \>= 8.0 | +| NodeJS | \>=20.x, 22.x | ## Composer: ```bash diff --git a/phpstan.neon b/phpstan.neon index 82e343c..dbde899 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,6 +4,9 @@ parameters: paths: - src + reportUnmatchedIgnoredErrors: false + treatPhpDocTypesAsCertain: false + excludePaths: # Makes PHPStan crash - 'src/DependencyInjection/Configuration.php' diff --git a/src/EventListener/Grid/AdminShippingGatewayGridEventListener.php b/src/EventListener/Grid/AdminShippingGatewayGridEventListener.php index 5320f59..3f48690 100644 --- a/src/EventListener/Grid/AdminShippingGatewayGridEventListener.php +++ b/src/EventListener/Grid/AdminShippingGatewayGridEventListener.php @@ -37,7 +37,7 @@ public function editActionLinks(GridDefinitionConverterEvent $event): void foreach ($this->shippingGateways as $shippingGatewayType => $shippingGatewayLabel) { $options['links'][$shippingGatewayType] = [ 'label' => $shippingGatewayLabel, - 'icon' => 'plus', + 'icon' => 'tabler:plus', 'route' => 'bitbag_admin_shipping_gateway_create', 'parameters' => [ 'code' => $shippingGatewayType, diff --git a/src/Repository/ShippingGatewayRepositoryInterface.php b/src/Repository/ShippingGatewayRepositoryInterface.php index f6d9684..8fbb0eb 100644 --- a/src/Repository/ShippingGatewayRepositoryInterface.php +++ b/src/Repository/ShippingGatewayRepositoryInterface.php @@ -19,7 +19,6 @@ /** * @template T of ResourceInterface - * @extends RepositoryInterface */ interface ShippingGatewayRepositoryInterface extends RepositoryInterface { diff --git a/tests/Application/src/assets/admin/entry.js b/src/Resources/assets/admin/entry.js similarity index 100% rename from tests/Application/src/assets/admin/entry.js rename to src/Resources/assets/admin/entry.js diff --git a/tests/Application/src/assets/admin/js/index.js b/src/Resources/assets/admin/js/index.js similarity index 100% rename from tests/Application/src/assets/admin/js/index.js rename to src/Resources/assets/admin/js/index.js diff --git a/tests/Application/src/assets/admin/scss/main.scss b/src/Resources/assets/admin/scss/main.scss similarity index 100% rename from tests/Application/src/assets/admin/scss/main.scss rename to src/Resources/assets/admin/scss/main.scss diff --git a/tests/Application/src/assets/shop/entry.js b/src/Resources/assets/shop/entry.js similarity index 100% rename from tests/Application/src/assets/shop/entry.js rename to src/Resources/assets/shop/entry.js diff --git a/tests/Application/src/assets/shop/js/index.js b/src/Resources/assets/shop/js/index.js similarity index 100% rename from tests/Application/src/assets/shop/js/index.js rename to src/Resources/assets/shop/js/index.js diff --git a/tests/Application/src/assets/shop/scss/main.scss b/src/Resources/assets/shop/scss/main.scss similarity index 100% rename from tests/Application/src/assets/shop/scss/main.scss rename to src/Resources/assets/shop/scss/main.scss diff --git a/src/Resources/config/config.yml b/src/Resources/config/config.yml index 520d894..7fe8fa8 100644 --- a/src/Resources/config/config.yml +++ b/src/Resources/config/config.yml @@ -2,3 +2,4 @@ imports: - { resource: "resource/**/*.yml" } - { resource: "grids/**/*.yml" } - { resource: "services.yml" } + - { resource: "@BitBagSyliusShippingExportPlugin/Resources/config/twig_hooks/twig_hooks.yaml" } diff --git a/src/Resources/config/grids/bitbag_shipping_gateway.yml b/src/Resources/config/grids/bitbag_shipping_gateway.yml index d98fdcb..4858c1d 100644 --- a/src/Resources/config/grids/bitbag_shipping_gateway.yml +++ b/src/Resources/config/grids/bitbag_shipping_gateway.yml @@ -29,9 +29,9 @@ sylius_grid: label: sylius.ui.create options: class: primary - icon: plus + icon: "tabler:plus" header: - icon: cube + icon: "tabler:cube" label: sylius.ui.type links: item: diff --git a/src/Resources/config/routing/bitbag_shipping_export.yml b/src/Resources/config/routing/bitbag_shipping_export.yml index d084ae9..769ef51 100644 --- a/src/Resources/config/routing/bitbag_shipping_export.yml +++ b/src/Resources/config/routing/bitbag_shipping_export.yml @@ -2,7 +2,7 @@ bitbag_admin_shipping_export: resource: | alias: bitbag.shipping_export section: admin - templates: '@SyliusAdmin/Crud' + templates: "@SyliusAdmin\\shared\\crud" only: ['index'] redirect: update grid: bitbag_admin_shipping_export diff --git a/src/Resources/config/routing/bitbag_shipping_gateway.yml b/src/Resources/config/routing/bitbag_shipping_gateway.yml index 3a74f09..910f774 100644 --- a/src/Resources/config/routing/bitbag_shipping_gateway.yml +++ b/src/Resources/config/routing/bitbag_shipping_gateway.yml @@ -2,7 +2,7 @@ bitbag_admin_shipping_gateway: resource: | alias: bitbag.shipping_gateway section: admin - templates: '@SyliusAdmin/Crud' + templates: "@SyliusAdmin\\shared\\crud" except: ['show'] redirect: update grid: bitbag_admin_shipping_gateway @@ -25,7 +25,7 @@ bitbag_admin_shipping_gateway_create: _controller: bitbag.controller.shipping_gateway::createAction _sylius: section: admin - template: '@SyliusAdmin/Crud/create.html.twig' + template: "@SyliusAdmin/shared/crud/create.html.twig" redirect: bitbag_admin_shipping_gateway_index permission: true vars: diff --git a/src/Resources/config/twig_hooks/twig_hooks.yaml b/src/Resources/config/twig_hooks/twig_hooks.yaml new file mode 100644 index 0000000..e8d7c37 --- /dev/null +++ b/src/Resources/config/twig_hooks/twig_hooks.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: "@BitBagSyliusShippingExportPlugin/Resources/config/twig_hooks/**/**/*.yaml" } diff --git a/src/Resources/views/ShippingExport/Action/_exportShipments.html.twig b/src/Resources/views/ShippingExport/Action/_exportShipments.html.twig index ac8fc58..73a8c55 100644 --- a/src/Resources/views/ShippingExport/Action/_exportShipments.html.twig +++ b/src/Resources/views/ShippingExport/Action/_exportShipments.html.twig @@ -1,7 +1,10 @@ -
+ -
diff --git a/src/Resources/views/ShippingExport/Grid/Field/state.html.twig b/src/Resources/views/ShippingExport/Grid/Field/state.html.twig index 2a41765..111ef0d 100644 --- a/src/Resources/views/ShippingExport/Grid/Field/state.html.twig +++ b/src/Resources/views/ShippingExport/Grid/Field/state.html.twig @@ -3,5 +3,8 @@ {% if data.state == 'new' or data.state == 'pending' %} {% include '@BitBagSyliusShippingExportPlugin/ShippingExport/Partial/_exportShipment.html.twig' %} {% else %} - {{ value|trans }} + {% endif %} diff --git a/src/Resources/views/ShippingExport/Partial/_downloadShippingLabel.html.twig b/src/Resources/views/ShippingExport/Partial/_downloadShippingLabel.html.twig index ec4fbe6..91a2dc6 100644 --- a/src/Resources/views/ShippingExport/Partial/_downloadShippingLabel.html.twig +++ b/src/Resources/views/ShippingExport/Partial/_downloadShippingLabel.html.twig @@ -1,5 +1,9 @@ - diff --git a/src/Resources/views/ShippingExport/Partial/_exportShipment.html.twig b/src/Resources/views/ShippingExport/Partial/_exportShipment.html.twig index 055d350..96fc86f 100644 --- a/src/Resources/views/ShippingExport/Partial/_exportShipment.html.twig +++ b/src/Resources/views/ShippingExport/Partial/_exportShipment.html.twig @@ -1,7 +1,18 @@
-
diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index c660c95..a7d155e 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -5,7 +5,6 @@ namespace Tests\BitBag\SyliusShippingExportPlugin\Application; use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; -use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Resource\FileResource; @@ -113,11 +112,7 @@ private function registerBundlesFromFile(string $bundlesFile): iterable private function getConfigurationDirectories(): iterable { yield $this->getProjectDir() . '/config'; - $syliusConfigDir = $this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION; - if (is_dir($syliusConfigDir)) { - yield $syliusConfigDir; - } - $symfonyConfigDir = $this->getProjectDir() . '/config/symfony/' . BaseKernel::MAJOR_VERSION . '.' . BaseKernel::MINOR_VERSION; + $symfonyConfigDir = $this->getProjectDir() . '/config/symfony/' . BaseKernel::MAJOR_VERSION . '.x'; if (is_dir($symfonyConfigDir)) { yield $symfonyConfigDir; } diff --git a/tests/Application/assets/admin/entry.js b/tests/Application/assets/admin/entry.js index 635f5ac..063df3e 100644 --- a/tests/Application/assets/admin/entry.js +++ b/tests/Application/assets/admin/entry.js @@ -1 +1 @@ -import 'sylius/bundle/AdminBundle/Resources/private/entry'; +import 'sylius/bundle/AdminBundle/Resources/assets/entrypoint'; diff --git a/tests/Application/assets/admin/product-entry.js b/tests/Application/assets/admin/product-entry.js new file mode 100644 index 0000000..eda4835 --- /dev/null +++ b/tests/Application/assets/admin/product-entry.js @@ -0,0 +1 @@ +import 'sylius/bundle/AdminBundle/Resources/assets/scripts/product/attribute-tabs-refresher'; diff --git a/tests/Application/assets/controllers.json b/tests/Application/assets/controllers.json new file mode 100644 index 0000000..8428b1f --- /dev/null +++ b/tests/Application/assets/controllers.json @@ -0,0 +1,17 @@ +{ + "controllers": { + "@symfony/ux-autocomplete": { + "autocomplete": { + "main": "dist/controller.js", + "webpackMode": "eager", + "fetch": "eager", + "enabled": true, + "autoimport": { + "tom-select/dist/css/tom-select.default.css": false, + "tom-select/dist/css/tom-select.bootstrap5.css": false + } + } + } + }, + "entrypoints": [] +} diff --git a/tests/Application/assets/shop/entry.js b/tests/Application/assets/shop/entry.js index aadc317..dbb7d93 100644 --- a/tests/Application/assets/shop/entry.js +++ b/tests/Application/assets/shop/entry.js @@ -1 +1 @@ -import 'sylius/bundle/ShopBundle/Resources/private/entry'; +import 'sylius/bundle/ShopBundle/Resources/assets/entrypoint'; diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index 2291ab4..450a654 100644 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -1,5 +1,12 @@ ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], + Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class => ['all' => true], Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true], Sylius\Bundle\MoneyBundle\SyliusMoneyBundle::class => ['all' => true], Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle::class => ['all' => true], @@ -36,30 +38,36 @@ Sylius\Bundle\CoreBundle\SyliusCoreBundle::class => ['all' => true], Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true], Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true], - winzou\Bundle\StateMachineBundle\winzouStateMachineBundle::class => ['all' => true], - Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true], - Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle::class => ['all' => true], - JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true], - FOS\RestBundle\FOSRestBundle::class => ['all' => true], Knp\Bundle\GaufretteBundle\KnpGaufretteBundle::class => ['all' => true], Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true], Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true], Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true], Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], + BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Sylius\Bundle\FixturesBundle\SyliusFixturesBundle::class => ['all' => true], Sylius\Bundle\PayumBundle\SyliusPayumBundle::class => ['all' => true], Sylius\Bundle\ThemeBundle\SyliusThemeBundle::class => ['all' => true], Sylius\Bundle\AdminBundle\SyliusAdminBundle::class => ['all' => true], Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true], - BitBag\SyliusShippingExportPlugin\BitBagSyliusShippingExportPlugin::class => ['all' => true], Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], + Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], + Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true], Sylius\Behat\Application\SyliusTestPlugin\SyliusTestPlugin::class => ['test' => true, 'test_cached' => true], - ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], + ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true], SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], + League\FlysystemBundle\FlysystemBundle::class => ['all' => true], Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], + Sylius\TwigHooks\SyliusTwigHooksBundle::class => ['all' => true], + Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true], + Symfony\UX\LiveComponent\LiveComponentBundle::class => ['all' => true], + Symfony\UX\Autocomplete\AutocompleteBundle::class => ['all' => true], + Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true], + Sylius\TwigExtra\Symfony\SyliusTwigExtraBundle::class => ['all' => true], + Symfony\UX\Icons\UXIconsBundle::class => ['all' => true], + BitBag\SyliusShippingExportPlugin\BitBagSyliusShippingExportPlugin::class => ['all' => true], ]; diff --git a/tests/Application/config/packages/_sylius.yaml b/tests/Application/config/packages/_sylius.yaml index 47f7d4e..f3d880f 100644 --- a/tests/Application/config/packages/_sylius.yaml +++ b/tests/Application/config/packages/_sylius.yaml @@ -1,13 +1,11 @@ imports: - { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" } - - { resource: "@SyliusAdminBundle/Resources/config/app/config.yml" } - - { resource: "@SyliusShopBundle/Resources/config/app/config.yml" } - - { resource: "@SyliusApiBundle/Resources/config/app/config.yaml" } - + - { resource: "@SyliusPayumBundle/Resources/config/app/config.yaml" } - { resource: "@BitBagSyliusShippingExportPlugin/Resources/config/config.yml" } + parameters: sylius_core.public_dir: '%kernel.project_dir%/public' diff --git a/tests/Application/config/packages/assets.yaml b/tests/Application/config/packages/assets.yaml new file mode 100644 index 0000000..b1ea48b --- /dev/null +++ b/tests/Application/config/packages/assets.yaml @@ -0,0 +1,7 @@ +framework: + assets: + packages: + shop: + json_manifest_path: '%kernel.project_dir%/public/build/shop/manifest.json' + admin: + json_manifest_path: '%kernel.project_dir%/public/build/admin/manifest.json' diff --git a/tests/Application/config/packages/fos_rest.yaml b/tests/Application/config/packages/fos_rest.yaml deleted file mode 100644 index a72eef7..0000000 --- a/tests/Application/config/packages/fos_rest.yaml +++ /dev/null @@ -1,11 +0,0 @@ -fos_rest: - exception: true - view: - formats: - json: true - xml: true - empty_content: 204 - format_listener: - rules: - - { path: '^/api/.*', priorities: ['json', 'xml'], fallback_format: json, prefer_extension: true } - - { path: '^/', stop: true } diff --git a/tests/Application/config/packages/http_discovery.yaml b/tests/Application/config/packages/http_discovery.yaml new file mode 100644 index 0000000..2a789e7 --- /dev/null +++ b/tests/Application/config/packages/http_discovery.yaml @@ -0,0 +1,10 @@ +services: + Psr\Http\Message\RequestFactoryInterface: '@http_discovery.psr17_factory' + Psr\Http\Message\ResponseFactoryInterface: '@http_discovery.psr17_factory' + Psr\Http\Message\ServerRequestFactoryInterface: '@http_discovery.psr17_factory' + Psr\Http\Message\StreamFactoryInterface: '@http_discovery.psr17_factory' + Psr\Http\Message\UploadedFileFactoryInterface: '@http_discovery.psr17_factory' + Psr\Http\Message\UriFactoryInterface: '@http_discovery.psr17_factory' + + http_discovery.psr17_factory: + class: Http\Discovery\Psr17Factory diff --git a/tests/Application/config/packages/mailer.yaml b/tests/Application/config/packages/mailer.yaml new file mode 100644 index 0000000..092eb28 --- /dev/null +++ b/tests/Application/config/packages/mailer.yaml @@ -0,0 +1,7 @@ +framework: + mailer: + dsn: 'null://null' + cache: + pools: + test.mailer_pool: + adapter: cache.adapter.filesystem diff --git a/tests/Application/config/sylius/1.13/packages/security.yaml b/tests/Application/config/packages/security.yaml similarity index 68% rename from tests/Application/config/sylius/1.13/packages/security.yaml rename to tests/Application/config/packages/security.yaml index 842b093..9d9e96c 100644 --- a/tests/Application/config/sylius/1.13/packages/security.yaml +++ b/tests/Application/config/packages/security.yaml @@ -1,5 +1,4 @@ security: - enable_authenticator_manager: true providers: sylius_admin_user_provider: id: sylius.admin_user_provider.email_or_name_based @@ -9,7 +8,7 @@ security: id: sylius.shop_user_provider.email_or_name_based sylius_api_shop_user_provider: id: sylius.shop_user_provider.email_or_name_based - + password_hashers: Sylius\Component\User\Model\UserInterface: argon2i firewalls: @@ -18,6 +17,7 @@ security: context: admin pattern: "%sylius.security.admin_regex%" provider: sylius_admin_user_provider + user_checker: security.user_checker.chain.admin form_login: provider: sylius_admin_user_provider login_path: sylius_admin_login @@ -38,38 +38,41 @@ security: logout: path: sylius_admin_logout target: sylius_admin_login - - new_api_admin_user: - pattern: "%sylius.security.new_api_admin_regex%/.*" + + api_admin: + pattern: "%sylius.security.api_admin_regex%/.*" provider: sylius_api_admin_user_provider + user_checker: security.user_checker.chain.api_admin stateless: true entry_point: jwt json_login: - check_path: "%sylius.security.new_api_admin_route%/authentication-token" + check_path: "%sylius.security.api_admin_route%/administrators/token" username_path: email password_path: password success_handler: lexik_jwt_authentication.handler.authentication_success failure_handler: lexik_jwt_authentication.handler.authentication_failure jwt: true - - new_api_shop_user: - pattern: "%sylius.security.new_api_shop_regex%/.*" + + api_shop: + pattern: "%sylius.security.api_shop_regex%/.*" provider: sylius_api_shop_user_provider + user_checker: security.user_checker.chain.api_shop stateless: true entry_point: jwt json_login: - check_path: "%sylius.security.new_api_shop_route%/authentication-token" + check_path: "%sylius.security.api_shop_route%/customers/token" username_path: email password_path: password success_handler: lexik_jwt_authentication.handler.authentication_success failure_handler: lexik_jwt_authentication.handler.authentication_failure jwt: true - + shop: switch_user: { role: ROLE_ALLOWED_TO_SWITCH } context: shop pattern: "%sylius.security.shop_regex%" provider: sylius_shop_user_provider + user_checker: security.user_checker.chain.shop form_login: success_handler: sylius.authentication.success_handler failure_handler: sylius.authentication.failure_handler @@ -83,6 +86,12 @@ security: enable_csrf: true csrf_parameter: _csrf_shop_security_token csrf_token_id: shop_authenticate + json_login: + check_path: sylius_shop_json_login_check + username_path: _username + password_path: _password + success_handler: sylius.authentication.success_handler + failure_handler: sylius.authentication.failure_handler remember_me: secret: "%env(APP_SECRET)%" name: APP_SHOP_REMEMBER_ME @@ -92,33 +101,37 @@ security: path: sylius_shop_logout target: sylius_shop_homepage invalidate_session: false - - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - + image_resolver: pattern: ^/media/cache/resolve security: false - + + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + access_control: - - { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } - + - { path: "%sylius.security.admin_regex%/forgotten-password", role: PUBLIC_ACCESS } + - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS } - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } - + - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS } - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS } - + - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } + + - { path: "%sylius.security.api_admin_route%/administrators/reset-password", role: PUBLIC_ACCESS } + - { path: "%sylius.security.api_admin_regex%/.*", role: ROLE_API_ACCESS } + - { path: "%sylius.security.api_admin_route%/administrators/token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.api_shop_account_regex%/.*", role: ROLE_USER } + - { path: "%sylius.security.api_shop_route%/customers/token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.api_shop_regex%/.*", role: PUBLIC_ACCESS } + +when@test: &security_test + security: + password_hashers: + Sylius\Component\User\Model\UserInterface: plaintext - - { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } - - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } +when@test_cached: *security_test diff --git a/tests/Application/config/packages/validator.yaml b/tests/Application/config/packages/validator.yaml index 61807db..8ff7da1 100644 --- a/tests/Application/config/packages/validator.yaml +++ b/tests/Application/config/packages/validator.yaml @@ -1,3 +1,3 @@ framework: validation: - enable_annotations: true + enable_attributes: true diff --git a/tests/Application/config/routes/sylius_admin.yaml b/tests/Application/config/routes/sylius_admin.yaml index 1ba48d6..740d83a 100644 --- a/tests/Application/config/routes/sylius_admin.yaml +++ b/tests/Application/config/routes/sylius_admin.yaml @@ -1,3 +1,4 @@ sylius_admin: resource: "@SyliusAdminBundle/Resources/config/routing.yml" - prefix: /admin + prefix: '/%sylius_admin.path_name%' + diff --git a/tests/Application/config/routes/sylius_api.yaml b/tests/Application/config/routes/sylius_api.yaml index ae01ffc..a7504e8 100644 --- a/tests/Application/config/routes/sylius_api.yaml +++ b/tests/Application/config/routes/sylius_api.yaml @@ -1,3 +1,3 @@ sylius_api: resource: "@SyliusApiBundle/Resources/config/routing.yml" - prefix: "%sylius.security.new_api_route%" + prefix: "%sylius.security.api_route%" diff --git a/tests/Application/config/routes/sylius_resource.yaml b/tests/Application/config/routes/sylius_resource.yaml new file mode 100644 index 0000000..0c8ade2 --- /dev/null +++ b/tests/Application/config/routes/sylius_resource.yaml @@ -0,0 +1,7 @@ +sylius_crud_routes: + resource: 'sylius.routing.loader.crud_routes_attributes' + type: service + +sylius_routes: + resource: 'sylius.routing.loader.routes_attributes' + type: service diff --git a/tests/Application/config/routes/sylius_shop.yaml b/tests/Application/config/routes/sylius_shop.yaml index fae46cb..8e3dd42 100644 --- a/tests/Application/config/routes/sylius_shop.yaml +++ b/tests/Application/config/routes/sylius_shop.yaml @@ -5,10 +5,22 @@ sylius_shop: _locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$ sylius_shop_payum: - resource: "@SyliusShopBundle/Resources/config/routing/payum.yml" + resource: "@SyliusPayumBundle/Resources/config/routing/integrations/sylius_shop.yaml" + +sylius_payment_notify: + resource: "@SyliusPaymentBundle/Resources/config/routing/integrations/sylius.yaml" sylius_shop_default_locale: path: / methods: [GET] defaults: - _controller: sylius.controller.shop.locale_switch::switchAction + _controller: sylius_shop.controller.locale_switch::switchAction + +# see https://web.dev/change-password-url/ +sylius_shop_request_password_reset_token_redirect: + path: /.well-known/change-password + methods: [GET] + controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction + defaults: + route: sylius_shop_request_password_reset_token + permanent: false diff --git a/tests/Application/config/routes/ux_autocomplete.yaml b/tests/Application/config/routes/ux_autocomplete.yaml new file mode 100644 index 0000000..da6b261 --- /dev/null +++ b/tests/Application/config/routes/ux_autocomplete.yaml @@ -0,0 +1,3 @@ +ux_autocomplete: + resource: '@AutocompleteBundle/config/routes.php' + prefix: '/autocomplete' diff --git a/tests/Application/config/routes/ux_live_component.yaml b/tests/Application/config/routes/ux_live_component.yaml new file mode 100644 index 0000000..e56523a --- /dev/null +++ b/tests/Application/config/routes/ux_live_component.yaml @@ -0,0 +1,5 @@ +live_component: + resource: '@LiveComponentBundle/config/routes.php' + prefix: '/_components' + # adjust prefix to add localization to your components + #prefix: '/{_locale}/_components' diff --git a/tests/Application/config/services.yaml b/tests/Application/config/services.yaml index 615506e..433fa02 100644 --- a/tests/Application/config/services.yaml +++ b/tests/Application/config/services.yaml @@ -2,3 +2,22 @@ # https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration parameters: locale: en_US + + bitbag.shipping_gateway.validation_groups: [ 'bitbag' ] + bitbag.shipping_labels_path: '%kernel.project_dir%/shipping_labels' + +services: + app.form.type.frank_martin_shipping_gateway: + class: Tests\BitBag\SyliusShippingExportPlugin\Application\src\Form\Type\FrankMartinShippingGatewayType + tags: + - { name: bitbag.shipping_gateway_configuration_type, type: "frank_martin_shipping_gateway", label: "Transporter Gateway" } + + app.event_listener.frank_martin_shipping_export: + class: Tests\BitBag\SyliusShippingExportPlugin\Application\src\EventListener\FrankMartinShippingExportEventListener + arguments: + - '@request_stack' + - '@filesystem' + - '@bitbag.manager.shipping_export' + - '%bitbag.shipping_labels_path%' + tags: + - { name: kernel.event_listener, event: 'bitbag.shipping_export.export_shipment', method: exportShipment } diff --git a/tests/Application/config/sylius/1.12/bundles.php b/tests/Application/config/sylius/1.12/bundles.php deleted file mode 100644 index 1ad7d83..0000000 --- a/tests/Application/config/sylius/1.12/bundles.php +++ /dev/null @@ -1,15 +0,0 @@ - ['all' => true], - Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], - BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], -]; diff --git a/tests/Application/config/sylius/1.12/packages/mailer.yaml b/tests/Application/config/sylius/1.12/packages/mailer.yaml deleted file mode 100644 index 0a0697c..0000000 --- a/tests/Application/config/sylius/1.12/packages/mailer.yaml +++ /dev/null @@ -1,3 +0,0 @@ -framework: - mailer: - dsn: '%env(MAILER_DSN)%' diff --git a/tests/Application/config/sylius/1.12/packages/security.yaml b/tests/Application/config/sylius/1.12/packages/security.yaml deleted file mode 100644 index 842b093..0000000 --- a/tests/Application/config/sylius/1.12/packages/security.yaml +++ /dev/null @@ -1,124 +0,0 @@ -security: - enable_authenticator_manager: true - providers: - sylius_admin_user_provider: - id: sylius.admin_user_provider.email_or_name_based - sylius_api_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 - sylius_api_shop_user_provider: - id: sylius.shop_user_provider.email_or_name_based - - password_hashers: - Sylius\Component\User\Model\UserInterface: argon2i - firewalls: - admin: - switch_user: true - context: admin - pattern: "%sylius.security.admin_regex%" - provider: sylius_admin_user_provider - form_login: - provider: sylius_admin_user_provider - login_path: sylius_admin_login - check_path: sylius_admin_login_check - failure_path: sylius_admin_login - default_target_path: sylius_admin_dashboard - use_forward: false - use_referer: true - enable_csrf: true - csrf_parameter: _csrf_admin_security_token - csrf_token_id: admin_authenticate - remember_me: - secret: "%env(APP_SECRET)%" - path: "/%sylius_admin.path_name%" - name: APP_ADMIN_REMEMBER_ME - lifetime: 31536000 - remember_me_parameter: _remember_me - logout: - path: sylius_admin_logout - target: sylius_admin_login - - new_api_admin_user: - pattern: "%sylius.security.new_api_admin_regex%/.*" - provider: sylius_api_admin_user_provider - stateless: true - entry_point: jwt - json_login: - check_path: "%sylius.security.new_api_admin_route%/authentication-token" - username_path: email - password_path: password - success_handler: lexik_jwt_authentication.handler.authentication_success - failure_handler: lexik_jwt_authentication.handler.authentication_failure - jwt: true - - new_api_shop_user: - pattern: "%sylius.security.new_api_shop_regex%/.*" - provider: sylius_api_shop_user_provider - stateless: true - entry_point: jwt - json_login: - check_path: "%sylius.security.new_api_shop_route%/authentication-token" - username_path: email - password_path: password - success_handler: lexik_jwt_authentication.handler.authentication_success - failure_handler: lexik_jwt_authentication.handler.authentication_failure - jwt: true - - shop: - switch_user: { role: ROLE_ALLOWED_TO_SWITCH } - context: shop - pattern: "%sylius.security.shop_regex%" - provider: sylius_shop_user_provider - form_login: - success_handler: sylius.authentication.success_handler - failure_handler: sylius.authentication.failure_handler - provider: sylius_shop_user_provider - login_path: sylius_shop_login - check_path: sylius_shop_login_check - failure_path: sylius_shop_login - default_target_path: sylius_shop_homepage - use_forward: false - use_referer: true - enable_csrf: true - csrf_parameter: _csrf_shop_security_token - csrf_token_id: shop_authenticate - remember_me: - secret: "%env(APP_SECRET)%" - name: APP_SHOP_REMEMBER_ME - lifetime: 31536000 - remember_me_parameter: _remember_me - logout: - path: sylius_shop_logout - target: sylius_shop_homepage - invalidate_session: false - - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - - image_resolver: - pattern: ^/media/cache/resolve - security: false - - access_control: - - { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } - - - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS } - - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } - - - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS } - - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS } - - - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } - - - { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } - - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } diff --git a/tests/Application/config/sylius/1.12/packages/test/mailer.yaml b/tests/Application/config/sylius/1.12/packages/test/mailer.yaml deleted file mode 100644 index 56cc28f..0000000 --- a/tests/Application/config/sylius/1.12/packages/test/mailer.yaml +++ /dev/null @@ -1,7 +0,0 @@ -framework: - mailer: - dsn: 'null://null' - cache: - pools: - test.mailer_pool: - adapter: cache.adapter.filesystem diff --git a/tests/Application/config/sylius/1.13/bundles.php b/tests/Application/config/sylius/1.13/bundles.php deleted file mode 100644 index 5f82527..0000000 --- a/tests/Application/config/sylius/1.13/bundles.php +++ /dev/null @@ -1,16 +0,0 @@ - ['all' => true], - Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], - BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], - Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class => ['all' => true], -]; diff --git a/tests/Application/config/sylius/1.13/packages/mailer.yaml b/tests/Application/config/sylius/1.13/packages/mailer.yaml deleted file mode 100644 index 0a0697c..0000000 --- a/tests/Application/config/sylius/1.13/packages/mailer.yaml +++ /dev/null @@ -1,3 +0,0 @@ -framework: - mailer: - dsn: '%env(MAILER_DSN)%' diff --git a/tests/Application/config/sylius/1.13/packages/test/mailer.yaml b/tests/Application/config/sylius/1.13/packages/test/mailer.yaml deleted file mode 100644 index 56cc28f..0000000 --- a/tests/Application/config/sylius/1.13/packages/test/mailer.yaml +++ /dev/null @@ -1,7 +0,0 @@ -framework: - mailer: - dsn: 'null://null' - cache: - pools: - test.mailer_pool: - adapter: cache.adapter.filesystem diff --git a/tests/Application/config/symfony/4.4/packages/framework.yaml b/tests/Application/config/symfony/4.4/packages/framework.yaml deleted file mode 100644 index 62f82d3..0000000 --- a/tests/Application/config/symfony/4.4/packages/framework.yaml +++ /dev/null @@ -1,2 +0,0 @@ -framework: - templating: { engines: ["twig"] } diff --git a/tests/Application/package.json b/tests/Application/package.json index ba0708a..5f6a164 100755 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,42 +1,26 @@ { - "dependencies": { - "@babel/polyfill": "^7.0.0", - "chart.js": "^3.7.1", - "jquery": "^3.5.0", - "jquery.dirtyforms": "^2.0.0", - "lightbox2": "^2.9.0", - "semantic-ui-css": "^2.2.0", - "slick-carousel": "^1.8.1" - }, - "devDependencies": { - "webpack": "^5.76.1", - "@symfony/webpack-encore": "^1.6.1", - "babel-core": "^6.26.3", - "babel-plugin-external-helpers": "^6.22.0", - "babel-plugin-module-resolver": "^3.1.1", - "babel-plugin-transform-object-rest-spread": "^6.26.0", - "babel-preset-env": "^1.7.0", - "babel-register": "^6.26.0", - "dedent": "^0.7.0", - "eslint": "^4.19.1", - "eslint-config-airbnb-base": "^12.1.0", - "eslint-import-resolver-babel-module": "^4.0.0", - "eslint-plugin-import": "^2.11.0", - "merge-stream": "^1.0.0", - "sass": "^1.39.2", - "sass-loader": "^12.1.0" - }, - "scripts": { - "dev": "yarn encore dev", - "watch": "yarn encore dev --watch", - "prod": "yarn encore prod", - "lint": "yarn lint:js", - "lint:js": "eslint gulpfile.babel.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Sylius/Sylius.git" - }, - "author": "Paweł Jędrzejewski", - "license": "MIT" + "license": "MIT", + "scripts": { + "build": "encore dev", + "build:prod": "encore production", + "watch": "encore dev --watch" + }, + "dependencies": { + "@sylius-ui/admin": "file:../../vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle", + "@sylius-ui/shop": "file:../../vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle", + "@symfony/ux-autocomplete": "file:../../vendor/symfony/ux-autocomplete/assets", + "@symfony/ux-live-component": "file:../../vendor/symfony/ux-live-component/assets" + }, + "devDependencies": { + "@hotwired/stimulus": "^3.0.0", + "@symfony/stimulus-bridge": "^3.2.0", + "@symfony/webpack-encore": "^5.0.1", + "tom-select": "^2.2.2", + "babel-core": "^6.26.3", + "babel-plugin-external-helpers": "^6.22.0", + "babel-plugin-module-resolver": "^3.1.1", + "babel-plugin-transform-object-rest-spread": "^6.26.0", + "babel-preset-env": "^1.7.0", + "babel-register": "^6.26.0" + } } diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php index 56d9fc7..26b794f 100644 --- a/tests/Application/public/index.php +++ b/tests/Application/public/index.php @@ -1,10 +1,17 @@ requestStack = $requestStack; + $this->filesystem = $filesystem; + $this->shippingExportManager = $shippingExportManager; + $this->shippingLabelsPath = $shippingLabelsPath; + } + + public function exportShipment(ResourceControllerEvent $event): void + { + /** @var ShippingExportInterface $shippingExport */ + $shippingExport = $event->getSubject(); + Assert::isInstanceOf($shippingExport, ShippingExportInterface::class); + + $shippingGateway = $shippingExport->getShippingGateway(); + Assert::notNull($shippingGateway); + + if ('frank_martin_shipping_gateway' !== $shippingGateway->getCode()) { + return; + } + + $session = $this->requestStack->getSession(); + $flashBag = $session->getBag('flashes'); + + if (false) { + $flashBag->add('error', 'bitbag.ui.shipping_export_error'); // Add an error notification + + return; + } + + $flashBag->add('success', 'bitbag.ui.shipment_data_has_been_exported'); // Add success notification + $this->saveShippingLabel($shippingExport, 'Some label content received from external API', 'pdf'); // Save label + $this->markShipmentAsExported($shippingExport); // Mark shipment as "Exported" + } + + public function saveShippingLabel( + ShippingExportInterface $shippingExport, + string $labelContent, + string $labelExtension, + ): void { + $labelPath = $this->shippingLabelsPath + . '/' . $this->getFilename($shippingExport) + . '.' . $labelExtension; + + $this->filesystem->dumpFile($labelPath, $labelContent); + $shippingExport->setLabelPath($labelPath); + + $this->shippingExportManager->persist($shippingExport); + $this->shippingExportManager->flush(); + } + + private function getFilename(ShippingExportInterface $shippingExport): string + { + $shipment = $shippingExport->getShipment(); + Assert::notNull($shipment); + + $order = $shipment->getOrder(); + Assert::notNull($order); + + $orderNumber = $order->getNumber(); + + $shipmentId = $shipment->getId(); + + return implode( + '_', + [ + $shipmentId, + preg_replace('~[^A-Za-z0-9]~', '', $orderNumber), + ], + ); + } + + private function markShipmentAsExported(ShippingExportInterface $shippingExport): void + { + $shippingExport->setState(ShippingExportInterface::STATE_EXPORTED); + $shippingExport->setExportedAt(new \DateTime()); + + $this->shippingExportManager->persist($shippingExport); + $this->shippingExportManager->flush(); + } +} diff --git a/tests/Application/src/Form/Type/FrankMartinShippingGatewayType.php b/tests/Application/src/Form/Type/FrankMartinShippingGatewayType.php new file mode 100644 index 0000000..2b34951 --- /dev/null +++ b/tests/Application/src/Form/Type/FrankMartinShippingGatewayType.php @@ -0,0 +1,44 @@ +add('iban', TextType::class, [ + 'label' => 'IBAN', + 'constraints' => [ + new NotBlank([ + 'message' => 'IBAN number cannot be blank.', + 'groups' => 'bitbag', + ]), + ], + ]) + ->add('address', TextType::class, [ + 'label' => 'Address', + 'constraints' => [ + new NotBlank([ + 'message' => 'Address cannot be blank.', + 'groups' => 'bitbag', + ]), + ], + ]) + ; + } +} diff --git a/tests/Application/webpack.config.js b/tests/Application/webpack.config.js index 489a416..4fa1b9d 100644 --- a/tests/Application/webpack.config.js +++ b/tests/Application/webpack.config.js @@ -9,6 +9,7 @@ const uiBundleResources = path.resolve(syliusBundles, 'UiBundle/Resources/privat Encore.setOutputPath('public/build/shop/') .setPublicPath('/build/shop') .addEntry('shop-entry', './assets/shop/entry.js') + .enableStimulusBridge('./assets/controllers.json') .disableSingleRuntimeChunk() .cleanupOutputBeforeBuild() .enableSourceMaps(!Encore.isProduction()) @@ -28,6 +29,8 @@ Encore.reset(); Encore.setOutputPath('public/build/admin/') .setPublicPath('/build/admin') .addEntry('admin-entry', './assets/admin/entry.js') + .addEntry('admin-product-entry', './assets/admin/product-entry.js') + .enableStimulusBridge('./assets/controllers.json') .disableSingleRuntimeChunk() .cleanupOutputBeforeBuild() .enableSourceMaps(!Encore.isProduction()) @@ -39,8 +42,7 @@ const adminConfig = Encore.getWebpackConfig(); adminConfig.resolve.alias['sylius/ui'] = uiBundleScripts; adminConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources; adminConfig.resolve.alias['sylius/bundle'] = syliusBundles; -adminConfig.resolve.alias['chart.js/dist/Chart.min'] = path.resolve(__dirname, 'node_modules/chart.js/dist/chart.min.js'); -adminConfig.externals = Object.assign({}, adminConfig.externals, {window: 'window', document: 'document'}); +adminConfig.externals = Object.assign({}, adminConfig.externals, { window: 'window', document: 'document' }); adminConfig.name = 'admin'; module.exports = [shopConfig, adminConfig]; diff --git a/tests/Behat/Behaviour/ContainsError.php b/tests/Behat/Behaviour/ContainsError.php index 97c9a47..f097124 100644 --- a/tests/Behat/Behaviour/ContainsError.php +++ b/tests/Behat/Behaviour/ContainsError.php @@ -1,10 +1,11 @@ getDocument()->findAll('css', $errorClass); Assert::greaterThan(count($errors), 0, sprintf( 'No error node elements with %s class were found.', - $errorClass + $errorClass, )); /** @var NodeElement $error */ diff --git a/tests/Behat/Context/Hook/ShippingExportContext.php b/tests/Behat/Context/Hook/ShippingExportContext.php index cf689bc..7bd9189 100644 --- a/tests/Behat/Context/Hook/ShippingExportContext.php +++ b/tests/Behat/Context/Hook/ShippingExportContext.php @@ -1,10 +1,11 @@ orderRepository = $orderRepository; $this->sharedStorage = $sharedStorage; @@ -108,7 +109,7 @@ public function thoseOrdersWereCompleted(): void $orders = $this->orderRepository->findAll(); foreach ($orders as $order) { - $this->eventDispatcher->dispatch( new GenericEvent($order), 'sylius.order.post_complete'); + $this->eventDispatcher->dispatch(new GenericEvent($order), 'sylius.order.post_complete'); } } diff --git a/tests/Behat/Context/Setup/ShippingGatewayContext.php b/tests/Behat/Context/Setup/ShippingGatewayContext.php index d14fc07..6a6ede9 100644 --- a/tests/Behat/Context/Setup/ShippingGatewayContext.php +++ b/tests/Behat/Context/Setup/ShippingGatewayContext.php @@ -1,10 +1,11 @@ shippingMethodFactory = $shippingMethodFactory; $this->shippingGatewayFactory = $shippingGatewayFactory; diff --git a/tests/Behat/Context/Transform/LexicalContext.php b/tests/Behat/Context/Transform/LexicalContext.php index a5ae24a..13bc470 100644 --- a/tests/Behat/Context/Transform/LexicalContext.php +++ b/tests/Behat/Context/Transform/LexicalContext.php @@ -1,12 +1,10 @@ indexPage = $indexPage; $this->notificationChecker = $notificationChecker; @@ -73,7 +74,7 @@ public function iShouldBeNotifiedThatTheShipmentHasBeenExported(): void { $this->notificationChecker->checkNotification( 'Shipment data has been exported.', - NotificationType::success() + NotificationType::success(), ); } @@ -84,7 +85,7 @@ public function iShouldBeNotifiedThatThereAreNoNewShipmentsToExport(): void { $this->notificationChecker->checkNotification( 'There are no new shipments to export.', - NotificationType::failure() + NotificationType::failure(), ); } @@ -95,7 +96,7 @@ public function iShouldBeNotifiedThatAnErrorOccurredWhileTryingToExportShippingD { $this->notificationChecker->checkNotification( 'An external error occurred while trying to export shipping data.', - NotificationType::failure() + NotificationType::failure(), ); } } diff --git a/tests/Behat/Context/Ui/Admin/ShippingGatewayContext.php b/tests/Behat/Context/Ui/Admin/ShippingGatewayContext.php index 03ac3e8..8508455 100644 --- a/tests/Behat/Context/Ui/Admin/ShippingGatewayContext.php +++ b/tests/Behat/Context/Ui/Admin/ShippingGatewayContext.php @@ -1,10 +1,11 @@ createPage = $createPage; $this->updatePage = $updatePage; @@ -109,7 +110,7 @@ public function iShouldBeNotifiedThatTheShippingGatewayWasCreated(): void { $this->notificationChecker->checkNotification( 'Shipping gateway has been successfully', - NotificationType::success() + NotificationType::success(), ); } diff --git a/tests/Behat/Mock/EventListener/FrankMartinShippingExportEventListener.php b/tests/Behat/Mock/EventListener/FrankMartinShippingExportEventListener.php index c00f580..2497854 100644 --- a/tests/Behat/Mock/EventListener/FrankMartinShippingExportEventListener.php +++ b/tests/Behat/Mock/EventListener/FrankMartinShippingExportEventListener.php @@ -1,10 +1,11 @@ requestStack = $requestStack; $this->filesystem = $filesystem; @@ -88,7 +89,7 @@ public function mockLabelContent(): string public function saveShippingLabel( ShippingExportInterface $shippingExport, string $labelContent, - string $labelExtension + string $labelExtension, ): void { $labelPath = $this->shippingLabelsPath . '/' . $this->getFilename($shippingExport) @@ -118,7 +119,7 @@ private function getFilename(ShippingExportInterface $shippingExport): string [ $shipmentId, preg_replace('~[^A-Za-z0-9]~', '', $orderNumber), - ] + ], ); } diff --git a/tests/Behat/Mock/Form/Type/FrankMartinShippingGatewayType.php b/tests/Behat/Mock/Form/Type/FrankMartinShippingGatewayType.php index 424d37c..ec571bd 100644 --- a/tests/Behat/Mock/Form/Type/FrankMartinShippingGatewayType.php +++ b/tests/Behat/Mock/Form/Type/FrankMartinShippingGatewayType.php @@ -1,10 +1,11 @@