From 3cbf4116c528002751cddbbb6130e32f490215d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Thu, 18 Jul 2024 15:00:40 +0200 Subject: [PATCH 01/17] OP-372 - Migration from Gulp to Webpack --- composer.json | 7 ++- tests/Application/.babelrc | 15 ----- tests/Application/assets/admin/entry.js | 1 + tests/Application/assets/shop/entry.js | 1 + tests/Application/config/bootstrap.php | 2 +- tests/Application/config/bundles.php | 1 + tests/Application/config/packages/assets.yaml | 7 +++ .../config/packages/webpackl_encore.yml | 5 ++ tests/Application/config/routes/dev/twig.yaml | 3 - tests/Application/gulpfile.babel.js | 60 ------------------- tests/Application/package.json | 9 ++- tests/Application/public/index.php | 2 +- .../Application/public/media/image/.gitignore | 0 .../SyliusAdminBundle/Layout/_logo.html.twig | 5 ++ .../Security/_content.html.twig | 6 ++ .../SyliusAdminBundle/_scripts.html.twig | 1 + .../SyliusAdminBundle/_styles.html.twig | 1 + .../Layout/Header/_logo.html.twig | 5 ++ .../SyliusShopBundle/_scripts.html.twig | 1 + .../SyliusShopBundle/_styles.html.twig | 1 + tests/Application/webpack.config.js | 47 +++++++++++++++ 21 files changed, 95 insertions(+), 85 deletions(-) delete mode 100755 tests/Application/.babelrc create mode 100644 tests/Application/assets/admin/entry.js create mode 100644 tests/Application/assets/shop/entry.js create mode 100644 tests/Application/config/packages/assets.yaml create mode 100644 tests/Application/config/packages/webpackl_encore.yml delete mode 100755 tests/Application/config/routes/dev/twig.yaml delete mode 100644 tests/Application/gulpfile.babel.js delete mode 100755 tests/Application/public/media/image/.gitignore create mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/Layout/_logo.html.twig create mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/Security/_content.html.twig create mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig create mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig create mode 100644 tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig create mode 100644 tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig create mode 100644 tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig create mode 100644 tests/Application/webpack.config.js diff --git a/composer.json b/composer.json index 5932358..97ef054 100644 --- a/composer.json +++ b/composer.json @@ -15,10 +15,10 @@ ], "require": { "php": "^7.4 || ^8.0", + "ext-soap": "*", "bitbag/shipping-export-plugin": "^3.0", "printu/elektroniczny-nadawca": "dev-master", - "sylius/sylius": "~1.10.0 || ~1.11.0", - "ext-soap": "*" + "sylius/sylius": "~1.10.0 || ~1.11.0" }, "require-dev": { "behat/behat": "^3.6.1", @@ -49,7 +49,8 @@ "symfony/dotenv": "^4.4 || ^5.2", "symfony/intl": "^4.4 || ^5.2", "symfony/web-profiler-bundle": "^4.4 || ^5.2", - "vimeo/psalm": "4.7.1" + "vimeo/psalm": "4.7.1", + "symfony/webpack-encore-bundle": "^1.17" }, "config": { "sort-packages": true, diff --git a/tests/Application/.babelrc b/tests/Application/.babelrc deleted file mode 100755 index e563a62..0000000 --- a/tests/Application/.babelrc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "presets": [ - ["env", { - "targets": { - "node": "6" - }, - "useBuiltIns": true - }] - ], - "plugins": [ - ["transform-object-rest-spread", { - "useBuiltIns": true - }] - ] -} diff --git a/tests/Application/assets/admin/entry.js b/tests/Application/assets/admin/entry.js new file mode 100644 index 0000000..635f5ac --- /dev/null +++ b/tests/Application/assets/admin/entry.js @@ -0,0 +1 @@ +import 'sylius/bundle/AdminBundle/Resources/private/entry'; diff --git a/tests/Application/assets/shop/entry.js b/tests/Application/assets/shop/entry.js new file mode 100644 index 0000000..aadc317 --- /dev/null +++ b/tests/Application/assets/shop/entry.js @@ -0,0 +1 @@ +import 'sylius/bundle/ShopBundle/Resources/private/entry'; diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index e23eca0..ae509ac 100755 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -15,7 +15,7 @@ throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); } else { // load all the .env files - (new Dotenv(true))->loadEnv(dirname(__DIR__) . '/.env'); + (new Dotenv())->loadEnv(dirname(__DIR__) . '/.env'); } $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 1a6861b..9bb3ec6 100755 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -53,6 +53,7 @@ Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true], SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], + Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], BitBag\SyliusShippingExportPlugin\BitBagSyliusShippingExportPlugin::class => ['all' => true], BitBag\SyliusPocztaPolskaShippingExportPlugin\BitBagSyliusPocztaPolskaShippingExportPlugin::class => ['all' => true], ]; diff --git a/tests/Application/config/packages/assets.yaml b/tests/Application/config/packages/assets.yaml new file mode 100644 index 0000000..2468901 --- /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/webpackl_encore.yml b/tests/Application/config/packages/webpackl_encore.yml new file mode 100644 index 0000000..9bee248 --- /dev/null +++ b/tests/Application/config/packages/webpackl_encore.yml @@ -0,0 +1,5 @@ +webpack_encore: + output_path: '%kernel.project_dir%/public/build/default' + builds: + shop: '%kernel.project_dir%/public/build/shop' + admin: '%kernel.project_dir%/public/build/admin' diff --git a/tests/Application/config/routes/dev/twig.yaml b/tests/Application/config/routes/dev/twig.yaml deleted file mode 100755 index f4ee839..0000000 --- a/tests/Application/config/routes/dev/twig.yaml +++ /dev/null @@ -1,3 +0,0 @@ -_errors: - resource: '@TwigBundle/Resources/config/routing/errors.xml' - prefix: /_error diff --git a/tests/Application/gulpfile.babel.js b/tests/Application/gulpfile.babel.js deleted file mode 100644 index 5920316..0000000 --- a/tests/Application/gulpfile.babel.js +++ /dev/null @@ -1,60 +0,0 @@ -import chug from 'gulp-chug'; -import gulp from 'gulp'; -import yargs from 'yargs'; - -const { argv } = yargs - .options({ - rootPath: { - description: ' path to public assets directory', - type: 'string', - requiresArg: true, - required: false, - }, - nodeModulesPath: { - description: ' path to node_modules directory', - type: 'string', - requiresArg: true, - required: false, - }, - }); - -const config = [ - '--rootPath', - argv.rootPath || '../../../../../../../tests/Application/public/assets', - '--nodeModulesPath', - argv.nodeModulesPath || '../../../../../../../tests/Application/node_modules', -]; - -export const buildAdmin = function buildAdmin() { - return gulp.src('../../vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/gulpfile.babel.js', { read: false }) - .pipe(chug({ args: config, tasks: 'build' })); -}; -buildAdmin.description = 'Build admin assets.'; - -export const watchAdmin = function watchAdmin() { - return gulp.src('../../vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/gulpfile.babel.js', { read: false }) - .pipe(chug({ args: config, tasks: 'watch' })); -}; -watchAdmin.description = 'Watch admin asset sources and rebuild on changes.'; - -export const buildShop = function buildShop() { - return gulp.src('../../vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/gulpfile.babel.js', { read: false }) - .pipe(chug({ args: config, tasks: 'build' })); -}; -buildShop.description = 'Build shop assets.'; - -export const watchShop = function watchShop() { - return gulp.src('../../vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/gulpfile.babel.js', { read: false }) - .pipe(chug({ args: config, tasks: 'watch' })); -}; -watchShop.description = 'Watch shop asset sources and rebuild on changes.'; - -export const build = gulp.parallel(buildAdmin, buildShop); -build.description = 'Build assets.'; - -gulp.task('admin', buildAdmin); -gulp.task('admin-watch', watchAdmin); -gulp.task('shop', buildShop); -gulp.task('shop-watch', watchShop); - -export default build; diff --git a/tests/Application/package.json b/tests/Application/package.json index e893a2e..90ec3b6 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,11 +1,14 @@ { "dependencies": { "babel-polyfill": "^6.26.0", + "chart.js": "^2.0", "jquery": "^3.2.0", + "jquery.dirtyforms": "^2.0.0", "lightbox2": "^2.9.0", "semantic-ui-css": "^2.2.0" }, "devDependencies": { + "@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", @@ -35,13 +38,15 @@ "rollup-plugin-inject": "^2.0.0", "rollup-plugin-node-resolve": "^3.3.0", "rollup-plugin-uglify": "^4.0.0", + "sass-loader": "^12.0.0", "slick-carousel": "^1.8.1", "upath": "^1.1.0", "yargs": "^6.4.0" }, "scripts": { - "build": "gulp build", - "gulp": "gulp build", + "dev": "yarn encore dev", + "watch": "yarn encore dev --watch", + "prod": "yarn encore prod", "lint": "yarn lint:js", "lint:js": "eslint gulpfile.babel.js" }, diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php index 6be0f5e..b0ca526 100755 --- a/tests/Application/public/index.php +++ b/tests/Application/public/index.php @@ -2,8 +2,8 @@ declare(strict_types=1); +use Symfony\Component\ErrorHandler\Debug; use Tests\BitBag\SyliusPocztaPolskaShippingExportPlugin\Application\Kernel; -use Symfony\Component\Debug\Debug; use Symfony\Component\HttpFoundation\Request; require dirname(__DIR__).'/config/bootstrap.php'; diff --git a/tests/Application/public/media/image/.gitignore b/tests/Application/public/media/image/.gitignore deleted file mode 100755 index e69de29..0000000 diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_logo.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_logo.html.twig new file mode 100644 index 0000000..1d9fa7d --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_logo.html.twig @@ -0,0 +1,5 @@ + +
+ +
+
diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Security/_content.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Security/_content.html.twig new file mode 100644 index 0000000..ce17621 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/Security/_content.html.twig @@ -0,0 +1,6 @@ +{% include '@SyliusUi/Security/_login.html.twig' + with { + 'action': path('sylius_admin_login_check'), + 'paths': {'logo': asset('build/admin/images/logo.png', 'admin')} +} +%} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig new file mode 100644 index 0000000..f5f9835 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig @@ -0,0 +1 @@ +{{ encore_entry_script_tags('admin-entry', null, 'admin') }} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig new file mode 100644 index 0000000..a96144c --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig @@ -0,0 +1 @@ +{{ encore_entry_link_tags('admin-entry', null, 'admin') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig new file mode 100644 index 0000000..84b8df5 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig @@ -0,0 +1,5 @@ + diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig new file mode 100644 index 0000000..d1655bb --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig @@ -0,0 +1 @@ +{{ encore_entry_script_tags('shop-entry', null, 'shop') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig new file mode 100644 index 0000000..fd2c7cb --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig @@ -0,0 +1 @@ +{{ encore_entry_link_tags('shop-entry', null, 'shop') }} diff --git a/tests/Application/webpack.config.js b/tests/Application/webpack.config.js new file mode 100644 index 0000000..58917fe --- /dev/null +++ b/tests/Application/webpack.config.js @@ -0,0 +1,47 @@ +const path = require('path'); +const Encore = require('@symfony/webpack-encore'); + +const syliusBundles = path.resolve(__dirname, '../../vendor/sylius/sylius/src/Sylius/Bundle/'); +const uiBundleScripts = path.resolve(syliusBundles, 'UiBundle/Resources/private/js/'); +const uiBundleResources = path.resolve(syliusBundles, 'UiBundle/Resources/private/'); + +// Shop config +Encore + .setOutputPath('public/build/shop/') + .setPublicPath('/build/shop') + .addEntry('shop-entry', './assets/shop/entry.js') + .disableSingleRuntimeChunk() + .cleanupOutputBeforeBuild() + .enableSourceMaps(!Encore.isProduction()) + .enableVersioning(Encore.isProduction()) + .enableSassLoader(); + +const shopConfig = Encore.getWebpackConfig(); + +shopConfig.resolve.alias['sylius/ui'] = uiBundleScripts; +shopConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources; +shopConfig.resolve.alias['sylius/bundle'] = syliusBundles; +shopConfig.name = 'shop'; + +Encore.reset(); + +// Admin config +Encore + .setOutputPath('public/build/admin/') + .setPublicPath('/build/admin') + .addEntry('admin-entry', './assets/admin/entry.js') + .disableSingleRuntimeChunk() + .cleanupOutputBeforeBuild() + .enableSourceMaps(!Encore.isProduction()) + .enableVersioning(Encore.isProduction()) + .enableSassLoader(); + +const adminConfig = Encore.getWebpackConfig(); + +adminConfig.resolve.alias['sylius/ui'] = uiBundleScripts; +adminConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources; +adminConfig.resolve.alias['sylius/bundle'] = syliusBundles; +adminConfig.externals = Object.assign({}, adminConfig.externals, { window: 'window', document: 'document' }); +adminConfig.name = 'admin'; + +module.exports = [shopConfig, adminConfig]; From a7359d7c62bfc5d725a9762e661ba4462aeba6ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Thu, 18 Jul 2024 16:01:29 +0200 Subject: [PATCH 02/17] OP-372 - Added Sylius 1.12 support --- composer.json | 15 +- tests/Application/Kernel.php | 18 +- tests/Application/config/bundles.php | 2 +- .../config/packages/dev/swiftmailer.yaml | 2 - tests/Application/config/packages/mailer.yaml | 4 + .../config/packages/security_checker.yaml | 9 - .../config/packages/staging/swiftmailer.yaml | 2 - .../config/packages/swiftmailer.yaml | 2 - .../config/packages/test/swiftmailer.yaml | 6 - .../packages/test_cached/swiftmailer.yaml | 6 - .../config/sylius/1.10/packages/security.yaml | 148 ---------------- .../config/sylius/{1.10 => 1.12}/bundles.php | 1 + .../config/sylius/1.12/packages/security.yaml | 124 ++++++++++++++ .../Application/config/sylius/1.8/bundles.php | 8 - .../config/sylius/1.8/packages/_sylius.yaml | 2 - .../config/sylius/1.8/packages/security.yaml | 159 ------------------ .../sylius/1.8/routes/sylius_admin_api.yaml | 3 - .../Application/config/sylius/1.9/bundles.php | 8 - .../config/sylius/1.9/packages/_sylius.yaml | 2 - .../config/sylius/1.9/packages/security.yaml | 159 ------------------ .../sylius/1.9/routes/sylius_admin_api.yaml | 3 - tests/Application/package.json | 13 +- .../SyliusAdminBundle/Layout/_logo.html.twig | 5 - .../Security/_content.html.twig | 6 - .../Layout/Header/_logo.html.twig | 5 - 25 files changed, 151 insertions(+), 561 deletions(-) delete mode 100755 tests/Application/config/packages/dev/swiftmailer.yaml create mode 100644 tests/Application/config/packages/mailer.yaml delete mode 100755 tests/Application/config/packages/security_checker.yaml delete mode 100755 tests/Application/config/packages/staging/swiftmailer.yaml delete mode 100755 tests/Application/config/packages/swiftmailer.yaml delete mode 100755 tests/Application/config/packages/test/swiftmailer.yaml delete mode 100755 tests/Application/config/packages/test_cached/swiftmailer.yaml delete mode 100644 tests/Application/config/sylius/1.10/packages/security.yaml rename tests/Application/config/sylius/{1.10 => 1.12}/bundles.php (75%) create mode 100644 tests/Application/config/sylius/1.12/packages/security.yaml delete mode 100644 tests/Application/config/sylius/1.8/bundles.php delete mode 100644 tests/Application/config/sylius/1.8/packages/_sylius.yaml delete mode 100644 tests/Application/config/sylius/1.8/packages/security.yaml delete mode 100644 tests/Application/config/sylius/1.8/routes/sylius_admin_api.yaml delete mode 100644 tests/Application/config/sylius/1.9/bundles.php delete mode 100644 tests/Application/config/sylius/1.9/packages/_sylius.yaml delete mode 100644 tests/Application/config/sylius/1.9/packages/security.yaml delete mode 100644 tests/Application/config/sylius/1.9/routes/sylius_admin_api.yaml delete mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/Layout/_logo.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/Security/_content.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig diff --git a/composer.json b/composer.json index 97ef054..c35306d 100644 --- a/composer.json +++ b/composer.json @@ -14,11 +14,11 @@ } ], "require": { - "php": "^7.4 || ^8.0", + "php": "^8.0", "ext-soap": "*", "bitbag/shipping-export-plugin": "^3.0", "printu/elektroniczny-nadawca": "dev-master", - "sylius/sylius": "~1.10.0 || ~1.11.0" + "sylius/sylius": "~1.12.0" }, "require-dev": { "behat/behat": "^3.6.1", @@ -43,12 +43,11 @@ "phpstan/phpstan-webmozart-assert": "0.12.12", "phpunit/phpunit": "^9.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "sensiolabs/security-checker": "^6.0", - "symfony/browser-kit": "^4.4 || ^5.2", - "symfony/debug-bundle": "^4.4 || ^5.2", - "symfony/dotenv": "^4.4 || ^5.2", - "symfony/intl": "^4.4 || ^5.2", - "symfony/web-profiler-bundle": "^4.4 || ^5.2", + "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", "vimeo/psalm": "4.7.1", "symfony/webpack-encore-bundle": "^1.17" }, diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index 8180f11..fef19d9 100755 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -1,5 +1,11 @@ getConfigurationDirectories() as $confDir) { $this->loadRoutesConfiguration($routes, $confDir); @@ -87,11 +93,11 @@ private function loadContainerConfiguration(LoaderInterface $loader, string $con $loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); } - private function loadRoutesConfiguration(RouteCollectionBuilder $routes, string $confDir): void + private function loadRoutesConfiguration(RoutingConfigurator $routes, string $confDir): void { - $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS); + $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS); + $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS); } /** diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 9bb3ec6..5444295 100755 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -4,7 +4,6 @@ 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], @@ -53,6 +52,7 @@ 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], BitBag\SyliusShippingExportPlugin\BitBagSyliusShippingExportPlugin::class => ['all' => true], BitBag\SyliusPocztaPolskaShippingExportPlugin\BitBagSyliusPocztaPolskaShippingExportPlugin::class => ['all' => true], diff --git a/tests/Application/config/packages/dev/swiftmailer.yaml b/tests/Application/config/packages/dev/swiftmailer.yaml deleted file mode 100755 index f438078..0000000 --- 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.yaml b/tests/Application/config/packages/mailer.yaml new file mode 100644 index 0000000..225ed59 --- /dev/null +++ b/tests/Application/config/packages/mailer.yaml @@ -0,0 +1,4 @@ +framework: + mailer: + dsn: '%env(MAILER_DSN)%' + diff --git a/tests/Application/config/packages/security_checker.yaml b/tests/Application/config/packages/security_checker.yaml deleted file mode 100755 index 0f9cf00..0000000 --- a/tests/Application/config/packages/security_checker.yaml +++ /dev/null @@ -1,9 +0,0 @@ -services: - SensioLabs\Security\SecurityChecker: - public: false - - SensioLabs\Security\Command\SecurityCheckerCommand: - arguments: ['@SensioLabs\Security\SecurityChecker'] - public: false - tags: - - { name: console.command, command: 'security:check' } diff --git a/tests/Application/config/packages/staging/swiftmailer.yaml b/tests/Application/config/packages/staging/swiftmailer.yaml deleted file mode 100755 index f438078..0000000 --- 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.yaml b/tests/Application/config/packages/swiftmailer.yaml deleted file mode 100755 index 3bab0d3..0000000 --- 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/swiftmailer.yaml b/tests/Application/config/packages/test/swiftmailer.yaml deleted file mode 100755 index c438f4b..0000000 --- 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/swiftmailer.yaml b/tests/Application/config/packages/test_cached/swiftmailer.yaml deleted file mode 100755 index c438f4b..0000000 --- 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/sylius/1.10/packages/security.yaml b/tests/Application/config/sylius/1.10/packages/security.yaml deleted file mode 100644 index 1062810..0000000 --- a/tests/Application/config/sylius/1.10/packages/security.yaml +++ /dev/null @@ -1,148 +0,0 @@ -parameters: - sylius.security.admin_regex: "^/%sylius_admin.path_name%" - sylius.security.api_regex: "^/api" - sylius.security.shop_regex: "^/(?!%sylius_admin.path_name%|new-api|api/.*|api$|media/.*)[^/]++" - sylius.security.new_api_route: "/new-api" - sylius.security.new_api_regex: "^%sylius.security.new_api_route%" - sylius.security.new_api_admin_route: "%sylius.security.new_api_route%/admin" - sylius.security.new_api_admin_regex: "^%sylius.security.new_api_admin_route%" - sylius.security.new_api_shop_route: "%sylius.security.new_api_route%/shop" - sylius.security.new_api_shop_regex: "^%sylius.security.new_api_shop_route%" - -security: - always_authenticate_before_granting: 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 - sylius_api_chain_provider: - chain: - providers: [sylius_api_shop_user_provider, sylius_api_admin_user_provider] - - encoders: - 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 - csrf_token_generator: security.csrf.token_manager - 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 - anonymous: true - - new_api_admin_user: - pattern: "%sylius.security.new_api_route%/admin-user-authentication-token" - provider: sylius_admin_user_provider - stateless: true - anonymous: true - json_login: - check_path: "%sylius.security.new_api_route%/admin-user-authentication-token" - username_path: email - 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 - - new_api_shop_user: - pattern: "%sylius.security.new_api_route%/shop-user-authentication-token" - provider: sylius_shop_user_provider - stateless: true - anonymous: true - json_login: - check_path: "%sylius.security.new_api_route%/shop-user-authentication-token" - username_path: email - 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 - - new_api: - pattern: "%sylius.security.new_api_regex%/*" - provider: sylius_api_chain_provider - stateless: true - anonymous: lazy - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - 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 - csrf_token_generator: security.csrf.token_manager - 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_login - invalidate_session: false - success_handler: sylius.handler.shop_user_logout - anonymous: true - - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - - access_control: - - { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } - - - { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } - - - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - - { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } - - - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY } diff --git a/tests/Application/config/sylius/1.10/bundles.php b/tests/Application/config/sylius/1.12/bundles.php similarity index 75% rename from tests/Application/config/sylius/1.10/bundles.php rename to tests/Application/config/sylius/1.12/bundles.php index bd33f4a..ce7c123 100644 --- a/tests/Application/config/sylius/1.10/bundles.php +++ b/tests/Application/config/sylius/1.12/bundles.php @@ -3,4 +3,5 @@ return [ BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], + Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], ]; diff --git a/tests/Application/config/sylius/1.12/packages/security.yaml b/tests/Application/config/sylius/1.12/packages/security.yaml new file mode 100644 index 0000000..d12295b --- /dev/null +++ b/tests/Application/config/sylius/1.12/packages/security.yaml @@ -0,0 +1,124 @@ +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.8/bundles.php b/tests/Application/config/sylius/1.8/bundles.php deleted file mode 100644 index c3c8ea4..0000000 --- a/tests/Application/config/sylius/1.8/bundles.php +++ /dev/null @@ -1,8 +0,0 @@ - ['all' => true], - WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle::class => ['all' => true], - FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true], - Sylius\Bundle\AdminApiBundle\SyliusAdminApiBundle::class => ['all' => true], -]; diff --git a/tests/Application/config/sylius/1.8/packages/_sylius.yaml b/tests/Application/config/sylius/1.8/packages/_sylius.yaml deleted file mode 100644 index 1674a97..0000000 --- a/tests/Application/config/sylius/1.8/packages/_sylius.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" } diff --git a/tests/Application/config/sylius/1.8/packages/security.yaml b/tests/Application/config/sylius/1.8/packages/security.yaml deleted file mode 100644 index 8161bda..0000000 --- a/tests/Application/config/sylius/1.8/packages/security.yaml +++ /dev/null @@ -1,159 +0,0 @@ -parameters: - sylius.security.admin_regex: "^/%sylius_admin.path_name%" - sylius.security.api_regex: "^/api" - sylius.security.shop_regex: "^/(?!%sylius_admin.path_name%|new-api|api/.*|api$|media/.*)[^/]++" - sylius.security.new_api_route: "/new-api" - sylius.security.new_api_regex: "^%sylius.security.new_api_route%" - sylius.security.new_api_admin_route: "%sylius.security.new_api_route%/admin" - sylius.security.new_api_admin_regex: "^%sylius.security.new_api_admin_route%" - sylius.security.new_api_shop_route: "%sylius.security.new_api_route%/shop" - sylius.security.new_api_shop_regex: "^%sylius.security.new_api_shop_route%" - -security: - always_authenticate_before_granting: 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 - sylius_api_chain_provider: - chain: - providers: [sylius_api_shop_user_provider, sylius_api_admin_user_provider] - - encoders: - 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 - csrf_token_generator: security.csrf.token_manager - 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 - anonymous: true - - oauth_token: - pattern: "%sylius.security.api_regex%/oauth/v2/token" - security: false - - new_api_admin_user: - pattern: "%sylius.security.new_api_route%/admin-user-authentication-token" - provider: sylius_admin_user_provider - stateless: true - anonymous: true - json_login: - check_path: "%sylius.security.new_api_route%/admin-user-authentication-token" - username_path: email - 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 - - new_api_shop_user: - pattern: "%sylius.security.new_api_route%/shop-user-authentication-token" - provider: sylius_shop_user_provider - stateless: true - anonymous: true - json_login: - check_path: "%sylius.security.new_api_route%/shop-user-authentication-token" - username_path: email - 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 - - new_api: - pattern: "%sylius.security.new_api_regex%/*" - provider: sylius_api_chain_provider - stateless: true - anonymous: lazy - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - api: - pattern: "%sylius.security.api_regex%/.*" - provider: sylius_admin_user_provider - fos_oauth: true - stateless: true - anonymous: 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 - csrf_token_generator: security.csrf.token_manager - 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_login - invalidate_session: false - success_handler: sylius.handler.shop_user_logout - anonymous: true - - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - - access_control: - - { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } - - - { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } - - - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - - { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } - - - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY } diff --git a/tests/Application/config/sylius/1.8/routes/sylius_admin_api.yaml b/tests/Application/config/sylius/1.8/routes/sylius_admin_api.yaml deleted file mode 100644 index 80aed45..0000000 --- a/tests/Application/config/sylius/1.8/routes/sylius_admin_api.yaml +++ /dev/null @@ -1,3 +0,0 @@ -sylius_admin_api: - resource: "@SyliusAdminApiBundle/Resources/config/routing.yml" - prefix: /api diff --git a/tests/Application/config/sylius/1.9/bundles.php b/tests/Application/config/sylius/1.9/bundles.php deleted file mode 100644 index 66f523d..0000000 --- a/tests/Application/config/sylius/1.9/bundles.php +++ /dev/null @@ -1,8 +0,0 @@ - ['all' => true], - SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], - FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true], - Sylius\Bundle\AdminApiBundle\SyliusAdminApiBundle::class => ['all' => true], -]; diff --git a/tests/Application/config/sylius/1.9/packages/_sylius.yaml b/tests/Application/config/sylius/1.9/packages/_sylius.yaml deleted file mode 100644 index 1674a97..0000000 --- a/tests/Application/config/sylius/1.9/packages/_sylius.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" } diff --git a/tests/Application/config/sylius/1.9/packages/security.yaml b/tests/Application/config/sylius/1.9/packages/security.yaml deleted file mode 100644 index 8161bda..0000000 --- a/tests/Application/config/sylius/1.9/packages/security.yaml +++ /dev/null @@ -1,159 +0,0 @@ -parameters: - sylius.security.admin_regex: "^/%sylius_admin.path_name%" - sylius.security.api_regex: "^/api" - sylius.security.shop_regex: "^/(?!%sylius_admin.path_name%|new-api|api/.*|api$|media/.*)[^/]++" - sylius.security.new_api_route: "/new-api" - sylius.security.new_api_regex: "^%sylius.security.new_api_route%" - sylius.security.new_api_admin_route: "%sylius.security.new_api_route%/admin" - sylius.security.new_api_admin_regex: "^%sylius.security.new_api_admin_route%" - sylius.security.new_api_shop_route: "%sylius.security.new_api_route%/shop" - sylius.security.new_api_shop_regex: "^%sylius.security.new_api_shop_route%" - -security: - always_authenticate_before_granting: 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 - sylius_api_chain_provider: - chain: - providers: [sylius_api_shop_user_provider, sylius_api_admin_user_provider] - - encoders: - 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 - csrf_token_generator: security.csrf.token_manager - 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 - anonymous: true - - oauth_token: - pattern: "%sylius.security.api_regex%/oauth/v2/token" - security: false - - new_api_admin_user: - pattern: "%sylius.security.new_api_route%/admin-user-authentication-token" - provider: sylius_admin_user_provider - stateless: true - anonymous: true - json_login: - check_path: "%sylius.security.new_api_route%/admin-user-authentication-token" - username_path: email - 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 - - new_api_shop_user: - pattern: "%sylius.security.new_api_route%/shop-user-authentication-token" - provider: sylius_shop_user_provider - stateless: true - anonymous: true - json_login: - check_path: "%sylius.security.new_api_route%/shop-user-authentication-token" - username_path: email - 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 - - new_api: - pattern: "%sylius.security.new_api_regex%/*" - provider: sylius_api_chain_provider - stateless: true - anonymous: lazy - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - api: - pattern: "%sylius.security.api_regex%/.*" - provider: sylius_admin_user_provider - fos_oauth: true - stateless: true - anonymous: 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 - csrf_token_generator: security.csrf.token_manager - 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_login - invalidate_session: false - success_handler: sylius.handler.shop_user_logout - anonymous: true - - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - - access_control: - - { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } - - - { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } - - - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - - { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } - - - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY } diff --git a/tests/Application/config/sylius/1.9/routes/sylius_admin_api.yaml b/tests/Application/config/sylius/1.9/routes/sylius_admin_api.yaml deleted file mode 100644 index 80aed45..0000000 --- a/tests/Application/config/sylius/1.9/routes/sylius_admin_api.yaml +++ /dev/null @@ -1,3 +0,0 @@ -sylius_admin_api: - resource: "@SyliusAdminApiBundle/Resources/config/routing.yml" - prefix: /api diff --git a/tests/Application/package.json b/tests/Application/package.json index 90ec3b6..09a1b19 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,7 +1,7 @@ { "dependencies": { "babel-polyfill": "^6.26.0", - "chart.js": "^2.0", + "chart.js": "^4.0", "jquery": "^3.2.0", "jquery.dirtyforms": "^2.0.0", "lightbox2": "^2.9.0", @@ -21,16 +21,6 @@ "eslint-import-resolver-babel-module": "^4.0.0", "eslint-plugin-import": "^2.12.0", "fast-async": "^6.3.7", - "gulp": "^4.0.0", - "gulp-chug": "^0.5", - "gulp-concat": "^2.6.0", - "gulp-debug": "^2.1.2", - "gulp-if": "^2.0.0", - "gulp-livereload": "^3.8.1", - "gulp-order": "^1.1.1", - "gulp-sass": "^4.0.1", - "gulp-sourcemaps": "^1.6.0", - "gulp-uglifycss": "^1.0.5", "merge-stream": "^1.0.0", "rollup": "^0.60.7", "rollup-plugin-babel": "^3.0.4", @@ -38,6 +28,7 @@ "rollup-plugin-inject": "^2.0.0", "rollup-plugin-node-resolve": "^3.3.0", "rollup-plugin-uglify": "^4.0.0", + "sass": "^1.77.8", "sass-loader": "^12.0.0", "slick-carousel": "^1.8.1", "upath": "^1.1.0", diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_logo.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_logo.html.twig deleted file mode 100644 index 1d9fa7d..0000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_logo.html.twig +++ /dev/null @@ -1,5 +0,0 @@ - -
- -
-
diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Security/_content.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Security/_content.html.twig deleted file mode 100644 index ce17621..0000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/Security/_content.html.twig +++ /dev/null @@ -1,6 +0,0 @@ -{% include '@SyliusUi/Security/_login.html.twig' - with { - 'action': path('sylius_admin_login_check'), - 'paths': {'logo': asset('build/admin/images/logo.png', 'admin')} -} -%} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig deleted file mode 100644 index 84b8df5..0000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig +++ /dev/null @@ -1,5 +0,0 @@ - From 726546acb4f8c12d21275d117f7dbb4ddfd1cafc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Fri, 19 Jul 2024 10:10:01 +0200 Subject: [PATCH 03/17] OP-372 - Error with locale_switch:switchAction fixed --- .../Application/config/routes/sylius_shop.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/Application/config/routes/sylius_shop.yaml b/tests/Application/config/routes/sylius_shop.yaml index 92eeae0..1a355ae 100755 --- a/tests/Application/config/routes/sylius_shop.yaml +++ b/tests/Application/config/routes/sylius_shop.yaml @@ -1,14 +1,14 @@ sylius_shop: - resource: "@SyliusShopBundle/Resources/config/routing.yml" - prefix: /{_locale} - requirements: - _locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$ + resource: "@SyliusShopBundle/Resources/config/routing.yml" + prefix: /{_locale} + requirements: + _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: "@SyliusShopBundle/Resources/config/routing/payum.yml" sylius_shop_default_locale: - path: / - methods: [GET] - defaults: - _controller: sylius.controller.shop.locale_switch:switchAction + path: / + methods: [GET] + defaults: + _controller: sylius.controller.shop.locale_switch::switchAction From c75be62af90ec08e2462df98502f9f8ead3daa39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Fri, 19 Jul 2024 11:04:42 +0200 Subject: [PATCH 04/17] OP-372 - FlashBag -> RequestStack --- src/EventListener/ShippingExportEventListener.php | 12 ++++++------ src/Resources/config/services.yml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/EventListener/ShippingExportEventListener.php b/src/EventListener/ShippingExportEventListener.php index 3eec300..2ec6835 100644 --- a/src/EventListener/ShippingExportEventListener.php +++ b/src/EventListener/ShippingExportEventListener.php @@ -19,7 +19,7 @@ use SoapFault; use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent; use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; +use Symfony\Component\HttpFoundation\RequestStack; use Webmozart\Assert\Assert; final class ShippingExportEventListener @@ -34,7 +34,7 @@ final class ShippingExportEventListener private WebClientInterface $webClient; - private FlashBagInterface $flashBag; + private RequestStack $requestStack; private FileNameGeneratorInterface $fileNameGenerator; @@ -43,14 +43,14 @@ public function __construct( ShippingExportRepository $shippingExportRepository, string $shippingLabelsPath, WebClientInterface $webClient, - FlashBagInterface $flashBag, + RequestStack $requestStack, fileNameGeneratorInterface $fileNameGenerator ) { $this->filesystem = $filesystem; $this->shippingExportRepository = $shippingExportRepository; $this->shippingLabelsPath = $shippingLabelsPath; $this->webClient = $webClient; - $this->flashBag = $flashBag; + $this->requestStack = $requestStack; $this->fileNameGenerator = $fileNameGenerator; } @@ -82,7 +82,7 @@ public function exportShipment(ResourceControllerEvent $event): void $this->saveShippingLabel($shippingExport, $labelContent, 'pdf'); } catch (SoapFault $exception) { - $this->flashBag->add( + $this->requestStack->getSession()->getFlashBag()->add( 'error', sprintf( 'Poczta Polska Web Service for #%s order: %s', @@ -94,7 +94,7 @@ public function exportShipment(ResourceControllerEvent $event): void return; } - $this->flashBag->add('success', 'bitbag.ui.shipment_data_has_been_exported'); + $this->requestStack->getSession()->getFlashBag()->add('success', 'bitbag.ui.shipment_data_has_been_exported'); $this->markShipmentAsExported($shippingExport); } diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index df59882..2e95d78 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -11,7 +11,7 @@ services: - '@bitbag.repository.shipping_export' - '%bitbag.shipping_labels_path%' - '@bitbag.poczta_polska_shipping_export_plugin.api.web_client' - - '@session.flash_bag' + - '@request_stack' - '@bitbag.poczta_polska_shipping_export_plugin.file_name_generator' tags: - { name: kernel.event_listener, event: 'bitbag.shipping_export.export_shipment', method: exportShipment } From a641a0a3e7a74c4bc182a341abf211f2576858a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Fri, 19 Jul 2024 11:05:25 +0200 Subject: [PATCH 05/17] OP-372 - Fixes related to compatibility with Sylius 1.12 --- composer.json | 139 +++++++++--------- .../Application/config/packages/_sylius.yaml | 6 +- .../config/packages/parameters.yaml | 4 + .../config/packages/test/framework.yaml | 2 +- .../config/packages/test/security.yaml | 3 - .../packages/test_cached/framework.yaml | 2 +- .../config/packages/test_cached/security.yaml | 3 - 7 files changed, 74 insertions(+), 85 deletions(-) create mode 100644 tests/Application/config/packages/parameters.yaml delete mode 100644 tests/Application/config/packages/test/security.yaml delete mode 100644 tests/Application/config/packages/test_cached/security.yaml diff --git a/composer.json b/composer.json index c35306d..508937d 100644 --- a/composer.json +++ b/composer.json @@ -1,76 +1,69 @@ { - "name": "bitbag/poczta-polska-shipping-export-plugin", - "type": "sylius-plugin", - "description": "Poczta polska shipping export plugin for Sylius based applications.", - "keywords": [ - "sylius", - "sylius-plugin" - ], - "license": "MIT", - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/damonsson/ElektronicznyNadawca" - } - ], - "require": { - "php": "^8.0", - "ext-soap": "*", - "bitbag/shipping-export-plugin": "^3.0", - "printu/elektroniczny-nadawca": "dev-master", - "sylius/sylius": "~1.12.0" - }, - "require-dev": { - "behat/behat": "^3.6.1", - "behat/mink-selenium2-driver": "^1.4", - "bitbag/coding-standard": "^1.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.0", - "friends-of-behat/mink-extension": "^2.4", - "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", - "friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev", - "phpspec/phpspec": "^7.0", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "0.12.99", - "phpstan/phpstan-doctrine": "0.12.33", - "phpstan/phpstan-strict-rules": "^0.12.0", - "phpstan/phpstan-webmozart-assert": "0.12.12", - "phpunit/phpunit": "^9.5", - "polishsymfonycommunity/symfony-mocker-container": "^1.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", - "vimeo/psalm": "4.7.1", - "symfony/webpack-encore-bundle": "^1.17" - }, - "config": { - "sort-packages": true, - "allow-plugins": { - "phpstan/extension-installer": true, - "composer/package-versions-deprecated": true, - "dealerdirect/phpcodesniffer-composer-installer": true, - "symfony/thanks": true, - "symfony/flex": true - } - }, - "prefer-stable": true, - "autoload": { - "psr-4": { - "BitBag\\SyliusPocztaPolskaShippingExportPlugin\\": "src/", - "Tests\\BitBag\\SyliusPocztaPolskaShippingExportPlugin\\": "tests/" - } - }, - "autoload-dev": { - "classmap": [ - "tests/Application/Kernel.php" - ] + "name": "bitbag/poczta-polska-shipping-export-plugin", + "type": "sylius-plugin", + "description": "Poczta polska shipping export plugin for Sylius based applications.", + "keywords": [ + "sylius", + "sylius-plugin" + ], + "license": "MIT", + "require": { + "php": "^8.0", + "ext-soap": "*", + "bitbag/shipping-export-plugin": "^3.0", + "printu/elektroniczny-nadawca": "^1.0.64", + "sylius/sylius": "~1.12.0" + }, + "require-dev": { + "behat/behat": "^3.7", + "behat/mink-selenium2-driver": "~1.6", + "bitbag/coding-standard": "^1.0.0 || ^2.0.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.0", + "friends-of-behat/mink-extension": "^2.4", + "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", + "phpspec/phpspec": "^7.0", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "0.12.99", + "phpstan/phpstan-doctrine": "0.12.33", + "phpstan/phpstan-strict-rules": "^0.12.0", + "phpstan/phpstan-webmozart-assert": "0.12.12", + "phpunit/phpunit": "^9.5", + "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", + "vimeo/psalm": "4.7.1", + "symfony/webpack-encore-bundle": "^1.17" + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "phpstan/extension-installer": true, + "composer/package-versions-deprecated": true, + "dealerdirect/phpcodesniffer-composer-installer": true, + "symfony/thanks": true, + "symfony/flex": true } + }, + "prefer-stable": true, + "autoload": { + "psr-4": { + "BitBag\\SyliusPocztaPolskaShippingExportPlugin\\": "src/", + "Tests\\BitBag\\SyliusPocztaPolskaShippingExportPlugin\\": "tests/" + } + }, + "autoload-dev": { + "classmap": [ + "tests/Application/Kernel.php" + ] + } } + diff --git a/tests/Application/config/packages/_sylius.yaml b/tests/Application/config/packages/_sylius.yaml index 4733eb5..6c87cee 100755 --- a/tests/Application/config/packages/_sylius.yaml +++ b/tests/Application/config/packages/_sylius.yaml @@ -9,10 +9,8 @@ imports: - { resource: "@BitBagSyliusShippingExportPlugin/Resources/config/config.yml" } -parameters: - sylius_core.public_dir: '%kernel.project_dir%/public' - bitbag.shipping_gateway.validation_groups: [ 'bitbag' ] - bitbag.shipping_labels_path: '%kernel.project_dir%/shipping_labels' +sylius_api: + enabled: true sylius_shop: product_grid: diff --git a/tests/Application/config/packages/parameters.yaml b/tests/Application/config/packages/parameters.yaml new file mode 100644 index 0000000..9047206 --- /dev/null +++ b/tests/Application/config/packages/parameters.yaml @@ -0,0 +1,4 @@ +parameters: + sylius_core.public_dir: '%kernel.project_dir%/public' + bitbag.shipping_gateway.validation_groups: [ 'bitbag' ] + bitbag.shipping_labels_path: '%kernel.project_dir%/shipping_labels' diff --git a/tests/Application/config/packages/test/framework.yaml b/tests/Application/config/packages/test/framework.yaml index 76d7e5e..daf04d4 100755 --- 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 + handler_id: ~ diff --git a/tests/Application/config/packages/test/security.yaml b/tests/Application/config/packages/test/security.yaml deleted file mode 100644 index 21cc377..0000000 --- a/tests/Application/config/packages/test/security.yaml +++ /dev/null @@ -1,3 +0,0 @@ -security: - encoders: - sha512: sha512 diff --git a/tests/Application/config/packages/test_cached/framework.yaml b/tests/Application/config/packages/test_cached/framework.yaml index 76d7e5e..daf04d4 100755 --- 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 + handler_id: ~ diff --git a/tests/Application/config/packages/test_cached/security.yaml b/tests/Application/config/packages/test_cached/security.yaml deleted file mode 100644 index 21cc377..0000000 --- a/tests/Application/config/packages/test_cached/security.yaml +++ /dev/null @@ -1,3 +0,0 @@ -security: - encoders: - sha512: sha512 From c0aac938c5f08580923cad58f00eacc12361a1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Fri, 19 Jul 2024 11:51:52 +0200 Subject: [PATCH 06/17] OP-372 - Added Sylius 1.13 support --- composer.json | 2 +- .../config/sylius/{1.11 => 1.13}/bundles.php | 1 + .../{1.11 => 1.13}/packages/security.yaml | 100 ++++++++---------- 3 files changed, 45 insertions(+), 58 deletions(-) rename tests/Application/config/sylius/{1.11 => 1.13}/bundles.php (73%) rename tests/Application/config/sylius/{1.11 => 1.13}/packages/security.yaml (58%) diff --git a/composer.json b/composer.json index 508937d..cfd239c 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "ext-soap": "*", "bitbag/shipping-export-plugin": "^3.0", "printu/elektroniczny-nadawca": "^1.0.64", - "sylius/sylius": "~1.12.0" + "sylius/sylius": "~1.12.0 || ~1.13.0" }, "require-dev": { "behat/behat": "^3.7", diff --git a/tests/Application/config/sylius/1.11/bundles.php b/tests/Application/config/sylius/1.13/bundles.php similarity index 73% rename from tests/Application/config/sylius/1.11/bundles.php rename to tests/Application/config/sylius/1.13/bundles.php index ce7c123..6d9f8ee 100644 --- a/tests/Application/config/sylius/1.11/bundles.php +++ b/tests/Application/config/sylius/1.13/bundles.php @@ -4,4 +4,5 @@ BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], + Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class => ['all' => true], ]; diff --git a/tests/Application/config/sylius/1.11/packages/security.yaml b/tests/Application/config/sylius/1.13/packages/security.yaml similarity index 58% rename from tests/Application/config/sylius/1.11/packages/security.yaml rename to tests/Application/config/sylius/1.13/packages/security.yaml index c4d0aa1..d12295b 100644 --- a/tests/Application/config/sylius/1.11/packages/security.yaml +++ b/tests/Application/config/sylius/1.13/packages/security.yaml @@ -1,11 +1,5 @@ -parameters: - sylius.security.admin_regex: "^/admin" - sylius.security.shop_regex: "^/(?!admin|new-api|api/.*|api$|media/.*)[^/]++" - sylius.security.new_api_route: "/new-api" - sylius.security.new_api_regex: "^%sylius.security.new_api_route%" - security: - always_authenticate_before_granting: true + enable_authenticator_manager: true providers: sylius_admin_user_provider: id: sylius.admin_user_provider.email_or_name_based @@ -15,11 +9,8 @@ security: id: sylius.shop_user_provider.email_or_name_based sylius_api_shop_user_provider: id: sylius.shop_user_provider.email_or_name_based - sylius_api_chain_provider: - chain: - providers: [sylius_api_shop_user_provider, sylius_api_admin_user_provider] - - encoders: + + password_hashers: Sylius\Component\User\Model\UserInterface: argon2i firewalls: admin: @@ -35,59 +26,45 @@ 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: secret: "%env(APP_SECRET)%" - path: /admin + 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 - anonymous: true - + new_api_admin_user: - pattern: "%sylius.security.new_api_route%/admin-user-authentication-token" - provider: sylius_admin_user_provider + pattern: "%sylius.security.new_api_admin_regex%/.*" + provider: sylius_api_admin_user_provider stateless: true - anonymous: true + entry_point: jwt json_login: - check_path: "%sylius.security.new_api_route%/admin-user-authentication-token" + 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 - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - + jwt: true + new_api_shop_user: - pattern: "%sylius.security.new_api_route%/shop-user-authentication-token" - provider: sylius_shop_user_provider + pattern: "%sylius.security.new_api_shop_regex%/.*" + provider: sylius_api_shop_user_provider stateless: true - anonymous: true + entry_point: jwt json_login: - check_path: "%sylius.security.new_api_route%/shop-user-authentication-token" + 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 - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - new_api: - pattern: "%sylius.security.new_api_regex%/*" - provider: sylius_api_chain_provider - stateless: true - anonymous: lazy - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - + jwt: true + shop: switch_user: { role: ROLE_ALLOWED_TO_SWITCH } context: shop @@ -103,7 +80,7 @@ security: default_target_path: sylius_shop_homepage use_forward: false use_referer: true - csrf_token_generator: security.csrf.token_manager + enable_csrf: true csrf_parameter: _csrf_shop_security_token csrf_token_id: shop_authenticate remember_me: @@ -113,26 +90,35 @@ security: remember_me_parameter: _remember_me logout: path: sylius_shop_logout - target: sylius_shop_login + target: sylius_shop_homepage invalidate_session: false - success_handler: sylius.handler.shop_user_logout - anonymous: true - + dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ + 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: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } + - { 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: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } + - { 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: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } - + + - { 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 } From 77a18f1f28f3c275885af4bd66e15a1142f8313e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Fri, 19 Jul 2024 12:29:09 +0200 Subject: [PATCH 07/17] OP-372 - Added ECS fixes --- composer.json | 10 ++--- ecs.php | 15 +++---- src/Api/WebClient.php | 15 +++---- src/Api/WebClientInterface.php | 9 ++-- ...SyliusPocztaPolskaShippingExportPlugin.php | 9 ++-- src/Checker/PaymentChecker.php | 9 ++-- src/Checker/PaymentCheckerInterface.php | 9 ++-- ...iusPocztaPolskaShippingExportExtension.php | 9 ++-- .../ShippingExportEventListener.php | 17 ++++---- src/Factory/AddressFactory.php | 9 ++-- src/Factory/AddressFactoryInterface.php | 9 ++-- src/Factory/LabelParametersFactory.php | 9 ++-- .../LabelParametersFactoryInterface.php | 9 ++-- src/Factory/PackageFactory.php | 11 ++--- src/Factory/PackageFactoryInterface.php | 11 ++--- src/Factory/ShipmentFactory.php | 9 ++-- src/Factory/ShipmentFactoryInterface.php | 9 ++-- src/Form/Type/ShippingGatewayType.php | 9 ++-- src/Generator/FileNameGenerator.php | 11 ++--- src/Generator/FileNameGeneratorInterface.php | 9 ++-- src/Generator/GuidGenerator.php | 9 ++-- src/Generator/GuidGeneratorInterface.php | 9 ++-- tests/Application/config/bootstrap.php | 9 +++- tests/Application/config/bundles.php | 9 ++++ .../config/sylius/1.12/bundles.php | 9 ++++ .../config/sylius/1.13/bundles.php | 9 ++++ tests/Application/public/index.php | 11 ++++- .../Context/Setup/ShippingGatewayContext.php | 42 +++++++------------ .../Ui/Admin/ShippingExportContext.php | 26 ++++++------ .../Ui/Admin/ShippingGatewayContext.php | 39 ++++++++--------- tests/Behat/Mocker/PocztaPolskaApiMocker.php | 30 ++++++------- .../Page/Admin/ShippingGateway/CreatePage.php | 19 ++++++--- .../ShippingGateway/CreatePageInterface.php | 9 ++++ 33 files changed, 251 insertions(+), 186 deletions(-) diff --git a/composer.json b/composer.json index cfd239c..4816905 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "require-dev": { "behat/behat": "^3.7", "behat/mink-selenium2-driver": "~1.6", - "bitbag/coding-standard": "^1.0.0 || ^2.0.0 ", + "bitbag/coding-standard": "^3.0.0 ", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", "friends-of-behat/mink": "^1.8", @@ -30,10 +30,10 @@ "friends-of-behat/variadic-extension": "^1.3", "phpspec/phpspec": "^7.0", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "0.12.99", - "phpstan/phpstan-doctrine": "0.12.33", - "phpstan/phpstan-strict-rules": "^0.12.0", - "phpstan/phpstan-webmozart-assert": "0.12.12", + "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", "symfony/browser-kit": "^5.4 || ^6.0", "symfony/debug-bundle": "^5.4 || ^6.0", diff --git a/ecs.php b/ecs.php index b088160..abcfbcf 100644 --- a/ecs.php +++ b/ecs.php @@ -2,15 +2,12 @@ declare(strict_types=1); -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\EasyCodingStandard\ValueObject\Option; +use Symplify\EasyCodingStandard\Config\ECSConfig; -return static function (ContainerConfigurator $containerConfigurator): void { - $containerConfigurator->import('vendor/bitbag/coding-standard/ecs.php'); +return static function (ECSConfig $config): void { - $parameters = $containerConfigurator->parameters(); - $parameters->set(Option::PATHS, [ - __DIR__ . '/src', - __DIR__ . '/tests', - ]); + putenv('ALLOW_BITBAG_OS_HEADER=1'); + + $config->import('vendor/bitbag/coding-standard/ecs.php'); + $config->paths(['src', 'tests']); }; diff --git a/src/Api/WebClient.php b/src/Api/WebClient.php index 2c6f525..a2eda61 100644 --- a/src/Api/WebClient.php +++ b/src/Api/WebClient.php @@ -1,10 +1,11 @@ guidGenerator = $guidGenerator; $this->labelParametersFactory = $labelParametersFactory; @@ -79,7 +80,7 @@ public function createLabel(): getAddresLabelByGuidResponse $this->addressFactory->createNew($this->getOrder()), $this->shippingGateway, $guid, - $this->shipment + $this->shipment, ); $this->connection->addShipment($this->shipmentFactory->createNew($package)); @@ -138,7 +139,7 @@ private function connect(): ElektronicznyNadawca [ 'login' => $this->getShippingGatewayConfig('login'), 'password' => $this->getShippingGatewayConfig('password'), - ] + ], ); } diff --git a/src/Api/WebClientInterface.php b/src/Api/WebClientInterface.php index 4ee01db..3007430 100644 --- a/src/Api/WebClientInterface.php +++ b/src/Api/WebClientInterface.php @@ -1,10 +1,11 @@ filesystem = $filesystem; $this->shippingExportRepository = $shippingExportRepository; @@ -87,8 +88,8 @@ public function exportShipment(ResourceControllerEvent $event): void sprintf( 'Poczta Polska Web Service for #%s order: %s', $shipment->getOrder()->getNumber(), - $exception->getMessage() - ) + $exception->getMessage(), + ), ); return; @@ -101,7 +102,7 @@ public function exportShipment(ResourceControllerEvent $event): void public function saveShippingLabel( ShippingExportInterface $shippingExport, string $labelContent, - string $labelExtension + string $labelExtension, ): void { $labelPath = $this->shippingLabelsPath . '/' . $this->fileNameGenerator->generate($shippingExport) diff --git a/src/Factory/AddressFactory.php b/src/Factory/AddressFactory.php index abd72b7..d075f89 100644 --- a/src/Factory/AddressFactory.php +++ b/src/Factory/AddressFactory.php @@ -1,10 +1,11 @@ getOrder(); diff --git a/src/Factory/PackageFactoryInterface.php b/src/Factory/PackageFactoryInterface.php index 760a9fe..aab6a2b 100644 --- a/src/Factory/PackageFactoryInterface.php +++ b/src/Factory/PackageFactoryInterface.php @@ -1,10 +1,11 @@ =1.2) diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 5444295..f551d74 100755 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -1,5 +1,14 @@ ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], diff --git a/tests/Application/config/sylius/1.12/bundles.php b/tests/Application/config/sylius/1.12/bundles.php index ce7c123..cf5d321 100644 --- a/tests/Application/config/sylius/1.12/bundles.php +++ b/tests/Application/config/sylius/1.12/bundles.php @@ -1,5 +1,14 @@ ['all' => true], SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], diff --git a/tests/Application/config/sylius/1.13/bundles.php b/tests/Application/config/sylius/1.13/bundles.php index 6d9f8ee..b08301a 100644 --- a/tests/Application/config/sylius/1.13/bundles.php +++ b/tests/Application/config/sylius/1.13/bundles.php @@ -1,5 +1,14 @@ ['all' => true], SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php index b0ca526..5800cbf 100755 --- a/tests/Application/public/index.php +++ b/tests/Application/public/index.php @@ -1,12 +1,19 @@ defaultVariantResolver = $productVariantResolver; $this->shipmentRepository = $shipmentRepository; $this->orderRepository = $orderRepository; @@ -65,7 +57,6 @@ public function __construct( $this->sharedStorage = $sharedStorage; } - /** * @Given /^the customer set the shipping address ("[^"]+" addressed it to "[^"]+", "[^"]+" "[^"]+" in the "[^"]+"(?:|, "[^"]+")) to orders$/ */ @@ -104,7 +95,6 @@ public function setUnitsToTheShipment() /** @var ShipmentInterface $shipment */ foreach ($shipments as $shipment) { - /** @var OrderItemInterface $orderItem */ foreach ($shipment->getOrder()->getItems() as $orderItem) { foreach ($orderItem->getUnits() as $itemUnit) { diff --git a/tests/Behat/Context/Ui/Admin/ShippingExportContext.php b/tests/Behat/Context/Ui/Admin/ShippingExportContext.php index 5b05e7d..5b5afa0 100644 --- a/tests/Behat/Context/Ui/Admin/ShippingExportContext.php +++ b/tests/Behat/Context/Ui/Admin/ShippingExportContext.php @@ -1,5 +1,14 @@ PocztaPolskaApiMocker = $PocztaPolskaApiMocker; $this->indexPage = $indexPage; } diff --git a/tests/Behat/Context/Ui/Admin/ShippingGatewayContext.php b/tests/Behat/Context/Ui/Admin/ShippingGatewayContext.php index e5c5a44..dc1fe90 100644 --- a/tests/Behat/Context/Ui/Admin/ShippingGatewayContext.php +++ b/tests/Behat/Context/Ui/Admin/ShippingGatewayContext.php @@ -1,5 +1,14 @@ createPage = $createPage; $this->currentPageResolver = $currentPageResolver; $this->notificationChecker = $notificationChecker; @@ -73,7 +70,7 @@ public function iFillTheFieldWith($field, $value) */ public function iClearTheField($field) { - $this->resolveCurrentPage()->fillField($field, ""); + $this->resolveCurrentPage()->fillField($field, ''); } /** @@ -92,8 +89,8 @@ public function iTryToAddIt() public function iShouldBeNotifiedThatTheShippingGatewayWasCreated() { $this->notificationChecker->checkNotification( - "Shipping gateway has been successfully", - NotificationType::success() + 'Shipping gateway has been successfully', + NotificationType::success(), ); } diff --git a/tests/Behat/Mocker/PocztaPolskaApiMocker.php b/tests/Behat/Mocker/PocztaPolskaApiMocker.php index be30318..b3942c7 100644 --- a/tests/Behat/Mocker/PocztaPolskaApiMocker.php +++ b/tests/Behat/Mocker/PocztaPolskaApiMocker.php @@ -1,5 +1,14 @@ mocker = $mocker; } - /** - * @param callable $action - */ public function performActionInApiSuccessfulScope(callable $action) { $this->mockApiSuccessfulPocztaPolskaResponse(); $action(); $this->mocker->unmockAll(); - } private function mockApiSuccessfulPocztaPolskaResponse() { - $createShipmentResult = (object)[ - 'createShipmentResult' => (object)[ - 'label' => (object)[ + $createShipmentResult = (object) [ + 'createShipmentResult' => (object) [ + 'label' => (object) [ 'labelContent' => 'test', - 'labelType' => 't' - ] + 'labelType' => 't', + ], ], ]; @@ -47,7 +49,7 @@ private function mockApiSuccessfulPocztaPolskaResponse() ->mocker ->mockService( 'bitbag.poczta_polska_shipping_export_plugin.api.soap_client', - SoapClientInterface::class + SoapClientInterface::class, ) ->shouldReceive('createShipment') ->andReturn($createShipmentResult) diff --git a/tests/Behat/Page/Admin/ShippingGateway/CreatePage.php b/tests/Behat/Page/Admin/ShippingGateway/CreatePage.php index 87f3819..00425ad 100644 --- a/tests/Behat/Page/Admin/ShippingGateway/CreatePage.php +++ b/tests/Behat/Page/Admin/ShippingGateway/CreatePage.php @@ -1,5 +1,14 @@ getDocument()->selectFieldOption("Shipping method", $name); + $this->getDocument()->selectFieldOption('Shipping method', $name); } /** - * {@inheritdoc} + * @inheritdoc */ public function selectFieldOption($field, $option) { @@ -26,7 +35,7 @@ public function selectFieldOption($field, $option) } /** - * {@inheritdoc} + * @inheritdoc */ public function fillField($field, $value) { @@ -34,7 +43,7 @@ public function fillField($field, $value) } /** - * {@inheritdoc} + * @inheritdoc */ public function submit() { diff --git a/tests/Behat/Page/Admin/ShippingGateway/CreatePageInterface.php b/tests/Behat/Page/Admin/ShippingGateway/CreatePageInterface.php index 74bf263..ab77ce8 100644 --- a/tests/Behat/Page/Admin/ShippingGateway/CreatePageInterface.php +++ b/tests/Behat/Page/Admin/ShippingGateway/CreatePageInterface.php @@ -1,5 +1,14 @@ Date: Fri, 19 Jul 2024 14:00:41 +0200 Subject: [PATCH 08/17] OP-372 - PHPSpec --- .../ShippingExportEventListenerSpec.php | 14 ++++++++++++-- src/EventListener/ShippingExportEventListener.php | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/spec/EventListener/ShippingExportEventListenerSpec.php b/spec/EventListener/ShippingExportEventListenerSpec.php index 2593cd7..eefed12 100644 --- a/spec/EventListener/ShippingExportEventListenerSpec.php +++ b/spec/EventListener/ShippingExportEventListenerSpec.php @@ -23,7 +23,9 @@ use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Core\Model\ShipmentInterface; use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; +use Symfony\Component\HttpFoundation\Session\SessionInterface; final class ShippingExportEventListenerSpec extends ObjectBehavior { @@ -39,7 +41,7 @@ function let( Filesystem $filesystem, ShippingExportRepository $shippingExportRepository, WebClientInterface $webClient, - FlashBagInterface $flashBag, + RequestStack $requestStack, FileNameGeneratorInterface $fileNameGenerator ): void { $shippingLabelsPath = 'labels'; @@ -48,7 +50,7 @@ function let( $shippingExportRepository, $shippingLabelsPath, $webClient, - $flashBag, + $requestStack, $fileNameGenerator ); } @@ -66,6 +68,8 @@ function it_exports_shipment_successfully( ShippingExportInterface $shippingExport, OrderInterface $order, FileNameGeneratorInterface $fileNameGenerator, + RequestStack $requestStack, + SessionInterface $session, FlashBagInterface $flashBag, getAddresLabelByGuidResponse $guidResponse ): void { @@ -89,6 +93,8 @@ function it_exports_shipment_successfully( self::ORDER_NUMBER ) )->shouldBeCalled(); + $requestStack->getSession()->willReturn($session); + $session->getBag('flashes')->willReturn($flashBag); $flashBag->add( 'success', 'bitbag.ui.shipment_data_has_been_exported' @@ -122,6 +128,8 @@ function it_should_handle_exception_when_webclient_fails( WebClientInterface $webClient, ShippingExportInterface $shippingExport, OrderInterface $order, + RequestStack $requestStack, + SessionInterface $session, FlashBagInterface $flashBag ): void { $event->getSubject()->willReturn($shippingExport); @@ -137,6 +145,8 @@ function it_should_handle_exception_when_webclient_fails( $webClient->setShippingGateway($shippingGateway)->shouldBeCalled(); $webClient->setShipment($shipment)->shouldBeCalled(); + $requestStack->getSession()->willReturn($session); + $session->getBag('flashes')->willReturn($flashBag); $flashBag->add( 'error', sprintf( diff --git a/src/EventListener/ShippingExportEventListener.php b/src/EventListener/ShippingExportEventListener.php index b969ca0..9ee3175 100644 --- a/src/EventListener/ShippingExportEventListener.php +++ b/src/EventListener/ShippingExportEventListener.php @@ -83,7 +83,7 @@ public function exportShipment(ResourceControllerEvent $event): void $this->saveShippingLabel($shippingExport, $labelContent, 'pdf'); } catch (SoapFault $exception) { - $this->requestStack->getSession()->getFlashBag()->add( + $this->requestStack->getSession()->getBag('flashes')->add( 'error', sprintf( 'Poczta Polska Web Service for #%s order: %s', @@ -95,7 +95,7 @@ public function exportShipment(ResourceControllerEvent $event): void return; } - $this->requestStack->getSession()->getFlashBag()->add('success', 'bitbag.ui.shipment_data_has_been_exported'); + $this->requestStack->getSession()->getBag('flashes')->add('success', 'bitbag.ui.shipment_data_has_been_exported'); $this->markShipmentAsExported($shippingExport); } From bd04238616492dc4110451f5e64e1c4b1e560b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Fri, 19 Jul 2024 14:21:46 +0200 Subject: [PATCH 09/17] OP-372 - Behat tests --- behat.yml.dist | 2 +- composer.json | 1 + .../exporting_shipping_data_to_api_poczta_polska.feature | 2 +- tests/Application/config/packages/cache.yaml | 5 +++++ tests/Application/config/packages/mailer.yaml | 1 - .../config/sylius/1.12/packages/test/mailer.yaml | 7 +++++++ .../config/sylius/1.12/packages/test/security.yaml | 3 +++ .../config/sylius/1.13/packages/test/mailer.yaml | 7 +++++++ .../config/sylius/1.13/packages/test/security.yaml | 3 +++ tests/Behat/Context/Setup/ShippingGatewayContext.php | 6 +++++- 10 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 tests/Application/config/packages/cache.yaml create mode 100644 tests/Application/config/sylius/1.12/packages/test/mailer.yaml create mode 100644 tests/Application/config/sylius/1.12/packages/test/security.yaml create mode 100644 tests/Application/config/sylius/1.13/packages/test/mailer.yaml create mode 100644 tests/Application/config/sylius/1.13/packages/test/security.yaml diff --git a/behat.yml.dist b/behat.yml.dist index 5561c4b..cc0d2ff 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -1,6 +1,6 @@ imports: - - vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml - tests/Behat/Resources/config/suites.yml + - vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml default: extensions: diff --git a/composer.json b/composer.json index 4816905..30ba5c4 100644 --- a/composer.json +++ b/composer.json @@ -28,6 +28,7 @@ "friends-of-behat/suite-settings-extension": "^1.0", "friends-of-behat/symfony-extension": "^2.1", "friends-of-behat/variadic-extension": "^1.3", + "polishsymfonycommunity/symfony-mocker-container": "^1.0", "phpspec/phpspec": "^7.0", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^1.8.1", diff --git a/features/exporting_shipping_data_to_api_poczta_polska.feature b/features/exporting_shipping_data_to_api_poczta_polska.feature index fb7b3c8..315b8a8 100644 --- a/features/exporting_shipping_data_to_api_poczta_polska.feature +++ b/features/exporting_shipping_data_to_api_poczta_polska.feature @@ -41,7 +41,7 @@ Feature: Managing shipping gateway And set product weight to "10" And set units to the shipment - @ui + @ui @test Scenario: Seeing shipments to export When I go to the shipping export page Then I should see 5 shipments with "New" state diff --git a/tests/Application/config/packages/cache.yaml b/tests/Application/config/packages/cache.yaml new file mode 100644 index 0000000..ca10f9d --- /dev/null +++ b/tests/Application/config/packages/cache.yaml @@ -0,0 +1,5 @@ +framework: + cache: + pools: + test.mailer_pool: + adapter: cache.adapter.filesystem diff --git a/tests/Application/config/packages/mailer.yaml b/tests/Application/config/packages/mailer.yaml index 225ed59..0a0697c 100644 --- a/tests/Application/config/packages/mailer.yaml +++ b/tests/Application/config/packages/mailer.yaml @@ -1,4 +1,3 @@ framework: mailer: dsn: '%env(MAILER_DSN)%' - diff --git a/tests/Application/config/sylius/1.12/packages/test/mailer.yaml b/tests/Application/config/sylius/1.12/packages/test/mailer.yaml new file mode 100644 index 0000000..56cc28f --- /dev/null +++ b/tests/Application/config/sylius/1.12/packages/test/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.12/packages/test/security.yaml b/tests/Application/config/sylius/1.12/packages/test/security.yaml new file mode 100644 index 0000000..a6f2ff7 --- /dev/null +++ b/tests/Application/config/sylius/1.12/packages/test/security.yaml @@ -0,0 +1,3 @@ +security: + password_hashers: + sha512: sha512 diff --git a/tests/Application/config/sylius/1.13/packages/test/mailer.yaml b/tests/Application/config/sylius/1.13/packages/test/mailer.yaml new file mode 100644 index 0000000..56cc28f --- /dev/null +++ b/tests/Application/config/sylius/1.13/packages/test/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/test/security.yaml b/tests/Application/config/sylius/1.13/packages/test/security.yaml new file mode 100644 index 0000000..a6f2ff7 --- /dev/null +++ b/tests/Application/config/sylius/1.13/packages/test/security.yaml @@ -0,0 +1,3 @@ +security: + password_hashers: + sha512: sha512 diff --git a/tests/Behat/Context/Setup/ShippingGatewayContext.php b/tests/Behat/Context/Setup/ShippingGatewayContext.php index 20ed234..0d2332b 100644 --- a/tests/Behat/Context/Setup/ShippingGatewayContext.php +++ b/tests/Behat/Context/Setup/ShippingGatewayContext.php @@ -75,12 +75,16 @@ public function theCustomerSetTheAddressAddressedItToInTheToOrders(AddressInterf */ public function setProductWeightTo($weight) { + if (!is_numeric($weight)) { + throw new \InvalidArgumentException('Weight must be a numeric value.'); + } + $weight = (float) $weight; + /** @var ProductInterface $product */ $product = $this->sharedStorage->get('product'); /** @var ProductVariantInterface $productVariant */ $productVariant = $this->defaultVariantResolver->getVariant($product); - $productVariant->setWeight($weight); $this->entityManager->flush(); From f23dba58071654d25993a7628a34f8fdff0d73f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Mon, 22 Jul 2024 12:23:41 +0200 Subject: [PATCH 10/17] OP-372 - build.yml has been updated --- .github/workflows/build.yml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2975610..49017ce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,18 +14,15 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.0"] - symfony: ["^4.4", "^5.2"] - sylius: ["~1.11.0"] + php: ["8.0", "8.1", "8.2"] + symfony: ["^5.4", "^6.0"] + sylius: ["~1.12.0", "~1.13.0"] node: [ "10.x" ] mysql: ["8.0"] - + exclude: - - sylius: ~1.10.0 - symfony: 4.4 - - - sylius: ~1.11.0 - php: 7.4 + - sylius: "~1.13.0" + php: "8.0" env: APP_ENV: test @@ -33,7 +30,7 @@ jobs: steps: - - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP @@ -46,7 +43,7 @@ jobs: - name: Setup Node - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: "${{ matrix.node }}" @@ -176,7 +173,7 @@ jobs: path: etc/build/ if-no-files-found: ignore - - + - name: Failed build Slack notification uses: rtCamp/action-slack-notify@v2 if: ${{ failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }} From 38506c4270c10b90cc4a1a5380c5cddf94aa8c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Wed, 24 Jul 2024 11:32:13 +0200 Subject: [PATCH 11/17] OP-372 - Behat fixed --- composer.json | 2 +- features/exporting_shipping_data_to_api_poczta_polska.feature | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 30ba5c4..6e298b7 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ }, "require-dev": { "behat/behat": "^3.7", - "behat/mink-selenium2-driver": "~1.6", + "behat/mink-selenium2-driver": "~1.6.0", "bitbag/coding-standard": "^3.0.0 ", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", diff --git a/features/exporting_shipping_data_to_api_poczta_polska.feature b/features/exporting_shipping_data_to_api_poczta_polska.feature index 315b8a8..49c0c43 100644 --- a/features/exporting_shipping_data_to_api_poczta_polska.feature +++ b/features/exporting_shipping_data_to_api_poczta_polska.feature @@ -34,7 +34,7 @@ Feature: Managing shipping gateway And it has "package_length" field set to "22" And it has "cod_payment_method_code" field set to "stripe_checkout" And it has "collect_on_delivery_form" field set to "BANK_TRANSFER" - And the store has a product "Chicken" priced at "$2" in "Web-US" channel + And the store has a product "Chicken" priced at "$2.00" in "Web-US" channel And customer "user@bitbag.pl" has placed 5 orders on the "Web-US" channel in each buying 5 "Chicken" products And the customer set the shipping address "Mike Ross" addressed it to "350 5th Ave", "10118" "New York" in the "United States" to orders And those orders were placed with "PocztaPolska Express" shipping method From 7f769d5c110bc7364e5a4170d1dc742ed9bbc3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Wed, 24 Jul 2024 11:39:49 +0200 Subject: [PATCH 12/17] OP-372 - Build fixed --- .github/workflows/build.yml | 6 +++--- composer.json | 4 +++- tests/Application/package.json | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 49017ce..e7f1eea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,8 +17,8 @@ jobs: php: ["8.0", "8.1", "8.2"] symfony: ["^5.4", "^6.0"] sylius: ["~1.12.0", "~1.13.0"] - node: [ "10.x" ] - mysql: ["8.0"] + node: [ "14.x" ] + mysql: ["5.7", "8.0"] exclude: - sylius: "~1.13.0" @@ -123,7 +123,7 @@ jobs: name: Install JS dependencies run: | (cd tests/Application && yarn install) - (cd tests/Application && yarn build) + (cd tests/Application && yarn encore dev) - name: Prepare test application database diff --git a/composer.json b/composer.json index 6e298b7..04e7737 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,6 @@ "symfony/dotenv": "^5.4 || ^6.0", "symfony/intl": "^5.4 || ^6.0", "symfony/web-profiler-bundle": "^5.4 || ^6.0", - "vimeo/psalm": "4.7.1", "symfony/webpack-encore-bundle": "^1.17" }, "config": { @@ -54,6 +53,9 @@ "symfony/flex": true } }, + "conflict": { + "doctrine/persistence": "<3.0" + }, "prefer-stable": true, "autoload": { "psr-4": { diff --git a/tests/Application/package.json b/tests/Application/package.json index 09a1b19..b976ef1 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,7 +1,7 @@ { "dependencies": { "babel-polyfill": "^6.26.0", - "chart.js": "^4.0", + "chart.js": "^3.7.3", "jquery": "^3.2.0", "jquery.dirtyforms": "^2.0.0", "lightbox2": "^2.9.0", From 97c6ae9df65e301b8621c27587e7aeed2e323e83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Wed, 24 Jul 2024 12:35:03 +0200 Subject: [PATCH 13/17] OP-372 - Readme.md updated --- README.md | 57 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index bf2b681..7f8a834 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,7 @@ This **open-source plugin was developed to help the Sylius community**. If you h ## Installation ```bash -$ composer require bitbag/poczta-polska-shipping-export-plugin - +composer require bitbag/poczta-polska-shipping-export-plugin ``` Add plugin dependencies to your config/bundles.php file: @@ -59,20 +58,52 @@ return [ ]; ``` +Import required config in your `config/packages/bitbag_shipping_export_plugin.yaml` file (if it doesn't exist): + +```yaml +# config/packages/bitbag_shipping_export_plugin.yaml + +imports: + ... + + - { resource: "@BitBagSyliusShippingExportPlugin/Resources/config/config.yml" } +``` + +Import routing in your `config/routes/bitbag_shipping_export_plugin.yaml` file (if it doesn't exist): + +```yaml + +# config/routes/bitbag_shipping_export_plugin.yaml +... + +bitbag_shipping_export_plugin: + resource: "@BitBagSyliusShippingExportPlugin/Resources/config/routing.yml" + prefix: /admin +``` + + +Finish the installation by updating the database schema: +``` +bin/console doctrine:migrations:diff +bin/console doctrine:migrations:migrate +bin/console cache:clear +``` + ## Testing +Recommended Node version for testing = 14.* ```bash -$ composer install -$ cd tests/Application -$ yarn install -$ yarn run gulp -$ bin/console doctrine:database:create --env=test -$ bin/console doctrine:schema:create --env=test -$ bin/console sylius:fixtures:load --env=test -$ APP_ENV=test symfony server:start --dir=public/ -$ cd ../.. -$ vendor/bin/behat -$ vendor/bin/phpspec run +composer install +cd tests/Application +yarn install +yarn run encore dev +bin/console doctrine:database:create --env=test +bin/console doctrine:schema:create --env=test +bin/console sylius:fixtures:load --env=test +APP_ENV=test symfony server:start --dir=public/ +cd ../.. +vendor/bin/behat +vendor/bin/phpspec run ``` # About us From e401d7060cb8871b767b0dd7534a71bf547ae52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Fri, 26 Jul 2024 08:29:42 +0200 Subject: [PATCH 14/17] OP-372 - Behat features fixed --- features/exporting_shipping_data_to_api_poczta_polska.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/exporting_shipping_data_to_api_poczta_polska.feature b/features/exporting_shipping_data_to_api_poczta_polska.feature index 49c0c43..82aa422 100644 --- a/features/exporting_shipping_data_to_api_poczta_polska.feature +++ b/features/exporting_shipping_data_to_api_poczta_polska.feature @@ -41,7 +41,7 @@ Feature: Managing shipping gateway And set product weight to "10" And set units to the shipment - @ui @test + @ui Scenario: Seeing shipments to export When I go to the shipping export page Then I should see 5 shipments with "New" state From ad10ff848c11bef99577d0da91e818e6e5aa8ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Fri, 26 Jul 2024 08:36:21 +0200 Subject: [PATCH 15/17] OP-372 - ShippingExportEventListener - refactoring --- src/EventListener/ShippingExportEventListener.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/EventListener/ShippingExportEventListener.php b/src/EventListener/ShippingExportEventListener.php index 9ee3175..2fffffa 100644 --- a/src/EventListener/ShippingExportEventListener.php +++ b/src/EventListener/ShippingExportEventListener.php @@ -72,6 +72,8 @@ public function exportShipment(ResourceControllerEvent $event): void return; } + $flashBag = $this->requestStack->getSession()->getBag('flashes'); + try { $this->webClient->setShippingGateway($shippingGateway); $this->webClient->setShipment($shipment); @@ -83,7 +85,7 @@ public function exportShipment(ResourceControllerEvent $event): void $this->saveShippingLabel($shippingExport, $labelContent, 'pdf'); } catch (SoapFault $exception) { - $this->requestStack->getSession()->getBag('flashes')->add( + $flashBag->add( 'error', sprintf( 'Poczta Polska Web Service for #%s order: %s', @@ -91,11 +93,9 @@ public function exportShipment(ResourceControllerEvent $event): void $exception->getMessage(), ), ); - return; } - - $this->requestStack->getSession()->getBag('flashes')->add('success', 'bitbag.ui.shipment_data_has_been_exported'); + $flashBag->add('success', 'bitbag.ui.shipment_data_has_been_exported'); $this->markShipmentAsExported($shippingExport); } From 5cec4636472a3a5326d9da793982a32345493ddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Fri, 26 Jul 2024 08:41:07 +0200 Subject: [PATCH 16/17] OP-372 - A typo in file name - fixed --- .../config/packages/{webpackl_encore.yml => webpack_encore.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/Application/config/packages/{webpackl_encore.yml => webpack_encore.yml} (100%) diff --git a/tests/Application/config/packages/webpackl_encore.yml b/tests/Application/config/packages/webpack_encore.yml similarity index 100% rename from tests/Application/config/packages/webpackl_encore.yml rename to tests/Application/config/packages/webpack_encore.yml From 3a3ccb285140f79805b98be2ff76ffebc40c7ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kali=C5=84ski?= Date: Wed, 7 Aug 2024 12:49:01 +0200 Subject: [PATCH 17/17] OP-372 - ECS fix --- src/EventListener/ShippingExportEventListener.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EventListener/ShippingExportEventListener.php b/src/EventListener/ShippingExportEventListener.php index 2fffffa..8f312da 100644 --- a/src/EventListener/ShippingExportEventListener.php +++ b/src/EventListener/ShippingExportEventListener.php @@ -93,6 +93,7 @@ public function exportShipment(ResourceControllerEvent $event): void $exception->getMessage(), ), ); + return; } $flashBag->add('success', 'bitbag.ui.shipment_data_has_been_exported');