From 07dd7c95f41de2f4ca1635ab54c3640245f340d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Fri, 21 Nov 2025 14:40:31 +0100 Subject: [PATCH 1/8] Use sylius/test-application --- .gitignore | 4 ++ Makefile | 68 ++++-------------- assets/admin/entrypoint.js | 1 + assets/controllers.json | 2 + assets/shop/entrypoint.js | 1 + composer.json | 58 ++++++++++++--- install/Application/.gitignore | 1 - .../packages/sylius_scheduler_command.yaml | 2 - .../test/sylius_scheduler_command.yaml | 7 -- node_modules | 1 - phpunit.xml.dist | 8 +-- ruleset/phpstan-baseline.neon | 25 +++++++ ruleset/phpstan.neon | 4 +- tests/TestApplication/.env | 7 ++ .../TestApplication/config/config.yaml | 15 ++++ .../TestApplication/config/routing.yaml | 0 tests/TestApplication/public/.htaccess | 70 +++++++++++++++++++ 17 files changed, 194 insertions(+), 80 deletions(-) create mode 100644 assets/admin/entrypoint.js create mode 100644 assets/controllers.json create mode 100644 assets/shop/entrypoint.js delete mode 100644 install/Application/.gitignore delete mode 100644 install/Application/config/packages/sylius_scheduler_command.yaml delete mode 100644 install/Application/config/packages/test/sylius_scheduler_command.yaml delete mode 120000 node_modules create mode 100644 ruleset/phpstan-baseline.neon create mode 100644 tests/TestApplication/.env rename install/Application/config/packages/sylius_fixtures.yaml => tests/TestApplication/config/config.yaml (52%) rename install/Application/config/routes/sylius_scheduler_command.yaml => tests/TestApplication/config/routing.yaml (100%) create mode 100644 tests/TestApplication/public/.htaccess diff --git a/.gitignore b/.gitignore index 1df39740..547af6c2 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,7 @@ /.phpunit.result.cache /.idea/ + +/tests/TestApplication/.env.local +/tests/TestApplication/.env.*.local +/var/ diff --git a/Makefile b/Makefile index ba3cc1d2..ef1bd22f 100644 --- a/Makefile +++ b/Makefile @@ -1,81 +1,41 @@ .DEFAULT_GOAL := help SHELL=/bin/bash COMPOSER_ROOT=composer -TEST_DIRECTORY=tests/Application -INSTALL_DIRECTORY=install/Application -CONSOLE=cd ${TEST_DIRECTORY} && php bin/console -e test -COMPOSER=cd ${TEST_DIRECTORY} && composer -YARN=cd ${TEST_DIRECTORY} && yarn - -SYLIUS_VERSION=2.0 -SYMFONY_VERSION=7.2 -PHP_VERSION=8.2 +CONSOLE=vendor/bin/console +COMPOSER=composer +SYLIUS_VERSION=2.1.0 +SYMFONY_VERSION=6.4 PLUGIN_NAME=synolia/sylius-scheduler-command-plugin ### ### DEVELOPMENT ### ¯¯¯¯¯¯¯¯¯¯¯ -install: sylius ## Install Plugin on Sylius [SYLIUS_VERSION=2.0] [SYMFONY_VERSION=7.2] [PHP_VERSION=8.2] +install: sylius ## Install all dependencies with [SYLIUS_VERSION=2.1.0] [SYMFONY_VERSION=6.4] .PHONY: install reset: ## Remove dependencies -ifneq ("$(wildcard ${TEST_DIRECTORY}/bin/console)","") ${CONSOLE} doctrine:database:drop --force --if-exists || true -endif - rm -rf ${TEST_DIRECTORY} + rm -rf vendor .PHONY: reset -phpunit: phpunit-configure phpunit-run ## Run PHPUnit +phpunit: ## Run PHPUnit tests + ./vendor/bin/phpunit --testdox .PHONY: phpunit ### ### OTHER ### ¯¯¯¯¯¯ -sylius: sylius-standard update-dependencies install-plugin install-sylius +sylius: install-sylius .PHONY: sylius -sylius-standard: -ifeq ($(shell [[ $(SYLIUS_VERSION) == *dev ]] && echo true ),true) - ${COMPOSER_ROOT} create-project sylius/sylius-standard:${SYLIUS_VERSION} ${TEST_DIRECTORY} --no-install --no-scripts -else - ${COMPOSER_ROOT} create-project sylius/sylius-standard ${TEST_DIRECTORY} "~${SYLIUS_VERSION}" --no-install --no-scripts -endif - ${COMPOSER} config allow-plugins true -ifeq ($(shell [[ $(SYLIUS_VERSION) == *dev ]] && echo true ),true) - ${COMPOSER} require --no-update sylius/sylius:"${SYLIUS_VERSION}" -else - ${COMPOSER} require --no-update sylius/sylius:"~${SYLIUS_VERSION}" -endif - -update-dependencies: - ${COMPOSER} config extra.symfony.require "~${SYMFONY_VERSION}" - ${COMPOSER} require symfony/asset:~${SYMFONY_VERSION} --no-scripts --no-update - ${COMPOSER} update --no-progress -n - -install-plugin: - ${COMPOSER} config repositories.plugin '{"type": "path", "url": "../../"}' - ${COMPOSER} config extra.symfony.allow-contrib true - ${COMPOSER} config minimum-stability "dev" - ${COMPOSER} config prefer-stable true - ${COMPOSER} req ${PLUGIN_NAME}:* --prefer-source --no-scripts - cp -r ${INSTALL_DIRECTORY} tests - install-sylius: - ${CONSOLE} doctrine:database:create -n --if-not-exists - ${CONSOLE} doctrine:migrations:migrate -n - ${CONSOLE} messenger:setup-transports -n - ${CONSOLE} sylius:fixtures:load default -n - ${YARN} install - ${YARN} build - ${CONSOLE} cache:clear - -phpunit-configure: - cp phpunit.xml.dist ${TEST_DIRECTORY}/phpunit.xml - -phpunit-run: - cd ${TEST_DIRECTORY} && ./vendor/bin/phpunit --testdox + @echo "Installing Sylius ${SYLIUS_VERSION} using TestApplication" + ${COMPOSER} config extra.symfony.require "^${SYMFONY_VERSION}" + ${COMPOSER} install + ${COMPOSER} require --dev sylius/test-application:"^${SYLIUS_VERSION}@alpha" -n -W # TODO: Remove alpha when stable + ${COMPOSER} test-application:install behat-configure: ## Configure Behat (cd ${TEST_DIRECTORY} && cp behat.yml.dist behat.yml) diff --git a/assets/admin/entrypoint.js b/assets/admin/entrypoint.js new file mode 100644 index 00000000..bbefcaa6 --- /dev/null +++ b/assets/admin/entrypoint.js @@ -0,0 +1 @@ +// Mandatory by test application but useless diff --git a/assets/controllers.json b/assets/controllers.json new file mode 100644 index 00000000..2c63c085 --- /dev/null +++ b/assets/controllers.json @@ -0,0 +1,2 @@ +{ +} diff --git a/assets/shop/entrypoint.js b/assets/shop/entrypoint.js new file mode 100644 index 00000000..bbefcaa6 --- /dev/null +++ b/assets/shop/entrypoint.js @@ -0,0 +1 @@ +// Mandatory by test application but useless diff --git a/composer.json b/composer.json index 2b30f319..71a43335 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "ext-intl": "*", "dragonmantank/cron-expression": "^3.4", "sylius/sylius": "^2.0", - "symfony/framework-bundle": "^5.4|^6.0|^7.0", + "symfony/framework-bundle": "^5.4|^6.4|^7.0", "symfony/lock": "^6.4|^7.0", "symfony/polyfill-intl-icu": "^1.26", "symfony/process": "^6.4|^7.0", @@ -36,7 +36,6 @@ "friends-of-behat/symfony-extension": "^2.4", "friends-of-behat/variadic-extension": "^1.5", "friendsoftwig/twigcs": "6.4.0", - "j13k/yaml-lint": "^1.1", "php-parallel-lint/php-parallel-lint": "^1.4", "phpmd/phpmd": "^2.15.0", "phpro/grumphp": "^2.9", @@ -52,11 +51,13 @@ "slevomat/coding-standard": "^8.7", "squizlabs/php_codesniffer": "^3.11", "sylius-labs/coding-standard": "^4.3", - "symfony/browser-kit": "^6.4", - "symfony/debug-bundle": "^6.4", - "symfony/dotenv": "^6.4", - "symfony/intl": "^6.4", - "symfony/web-profiler-bundle": "^6.4", + "sylius/test-application": "^2.1.0@alpha", + "symfony/apache-pack": "*", + "symfony/browser-kit": "^6.4 || ^7.0", + "symfony/debug-bundle": "^6.4 || ^7.0", + "symfony/dotenv": "^6.4 || ^7.0", + "symfony/intl": "^6.4 || ^7.0", + "symfony/web-profiler-bundle": "^6.4|| ^7.0", "symplify/easy-coding-standard": "^12.5" }, "suggest": { @@ -65,8 +66,12 @@ "prefer-stable": true, "autoload": { "psr-4": { - "Synolia\\SyliusSchedulerCommandPlugin\\": "src/", - "Tests\\Synolia\\SyliusSchedulerCommandPlugin\\": "tests/" + "Synolia\\SyliusSchedulerCommandPlugin\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\Synolia\\SyliusSchedulerCommandPlugin\\": ["tests/", "tests/TestApplication/src/"] } }, "config": { @@ -77,10 +82,43 @@ "php-http/discovery": true, "phpro/grumphp": true, "phpstan/extension-installer": true, + "symfony/flex": true, + "symfony/runtime": true, "symfony/thanks": true } }, "scripts": { - "fix-ecs": "ecs check -c ruleset/ecs.php --fix --ansi --clear-cache" + "ecs": "ecs check -c ruleset/ecs.php --ansi --clear-cache", + "fix-ecs": "@ecs --fix", + "phpmd": "phpmd src ansi ruleset/.php_md.xml", + "phpstan": "phpstan analyse src -c ruleset/phpstan.neon", + "phpunit": "phpunit tests/PHPUnit --colors=always", + "tests": [ + "@ecs", + "@phpmd", + "@phpstan", + "@phpunit" + ], + "test-application:install": [ + "vendor/bin/console doctrine:database:drop --force --if-exists -n", + "vendor/bin/console doctrine:database:create -n", + "vendor/bin/console doctrine:migration:migrate -n", + "vendor/bin/console sylius:payment:generate-key -n", + "vendor/bin/console sylius:fixtures:load -n", + "yarn --cwd vendor/sylius/test-application install --force", + "yarn --cwd vendor/sylius/test-application build", + "vendor/bin/console assets:install --symlink -n vendor/sylius/test-application/public", + "cp tests/TestApplication/public/.htaccess vendor/sylius/test-application/public" + ], + "test-application:front": [ + "yarn --cwd vendor/sylius/test-application install --force", + "yarn --cwd vendor/sylius/test-application build" + ] + }, + "extra": { + "public-dir": "vendor/sylius/test-application/public", + "symfony": { + "require": "^6.4" + } } } diff --git a/install/Application/.gitignore b/install/Application/.gitignore deleted file mode 100644 index 7c191c47..00000000 --- a/install/Application/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.env.test.local diff --git a/install/Application/config/packages/sylius_scheduler_command.yaml b/install/Application/config/packages/sylius_scheduler_command.yaml deleted file mode 100644 index 42c16364..00000000 --- a/install/Application/config/packages/sylius_scheduler_command.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@SynoliaSyliusSchedulerCommandPlugin/config/config.yaml" } diff --git a/install/Application/config/packages/test/sylius_scheduler_command.yaml b/install/Application/config/packages/test/sylius_scheduler_command.yaml deleted file mode 100644 index 0d4b1b5d..00000000 --- a/install/Application/config/packages/test/sylius_scheduler_command.yaml +++ /dev/null @@ -1,7 +0,0 @@ -services: - _defaults: - autowire: true - autoconfigure: true - public: true - - Synolia\SyliusSchedulerCommandPlugin\Checker\SoftLimitThresholdIsDueChecker: ~ diff --git a/node_modules b/node_modules deleted file mode 120000 index 9270531f..00000000 --- a/node_modules +++ /dev/null @@ -1 +0,0 @@ -tests/Application/node_modules \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 370ff9c6..3c68779b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,19 +1,19 @@ + bootstrap="vendor/sylius/test-application/config/bootstrap.php"> - vendor/synolia/sylius-scheduler-command-plugin/tests/PHPUnit + tests/PHPUnit - + diff --git a/ruleset/phpstan-baseline.neon b/ruleset/phpstan-baseline.neon new file mode 100644 index 00000000..2cb5500e --- /dev/null +++ b/ruleset/phpstan-baseline.neon @@ -0,0 +1,25 @@ +parameters: + ignoreErrors: + - + message: '#^Call to method getEntity\(\) on an unknown class Doctrine\\ORM\\Event\\LifecycleEventArgs\.$#' + identifier: class.notFound + count: 1 + path: ../src/DoctrineEvent/ScheduledCommandPostRemoveEvent.php + + - + message: '#^Parameter \$eventArgs of method Synolia\\SyliusSchedulerCommandPlugin\\DoctrineEvent\\ScheduledCommandPostRemoveEvent\:\:postRemove\(\) has invalid type Doctrine\\ORM\\Event\\LifecycleEventArgs\.$#' + identifier: class.notFound + count: 1 + path: ../src/DoctrineEvent/ScheduledCommandPostRemoveEvent.php + + - + message: '#^Cannot call method scalarNode\(\) on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface\|null\.$#' + identifier: method.nonObject + count: 1 + path: ../src/Fixture/SchedulerCommandFixture.php + + - + message: '#^Invalid array key type float\.$#' + identifier: offsetAccess.invalidOffset + count: 2 + path: ../src/Twig/BytesFormatterExtension.php diff --git a/ruleset/phpstan.neon b/ruleset/phpstan.neon index 5eb50ab7..d4e718b5 100644 --- a/ruleset/phpstan.neon +++ b/ruleset/phpstan.neon @@ -1,3 +1,5 @@ +includes: + - phpstan-baseline.neon parameters: level: 8 reportUnmatchedIgnoredErrors: false @@ -6,7 +8,7 @@ parameters: excludePaths: - ../src/DependencyInjection/Configuration.php? - ../src/Migrations? - - ../tests + - ../tests/TestApplication? - ../spec ignoreErrors: diff --git a/tests/TestApplication/.env b/tests/TestApplication/.env new file mode 100644 index 00000000..b18b71fe --- /dev/null +++ b/tests/TestApplication/.env @@ -0,0 +1,7 @@ +DATABASE_URL=mysql://root@127.0.0.1/test_application_%kernel.environment% + +SYLIUS_TEST_APP_CONFIGS_TO_IMPORT="@SynoliaSyliusSchedulerCommandPlugin/tests/TestApplication/config/config.yaml" +SYLIUS_TEST_APP_ROUTES_TO_IMPORT="@SynoliaSyliusSchedulerCommandPlugin/tests/TestApplication/config/routing.yaml" +SYLIUS_TEST_APP_BUNDLES_TO_ENABLE="Synolia\SyliusSchedulerCommandPlugin\SynoliaSyliusSchedulerCommandPlugin" + +SYLIUS_MESSENGER_TRANSPORT_PAYMENT_REQUEST_DSN="sync://" diff --git a/install/Application/config/packages/sylius_fixtures.yaml b/tests/TestApplication/config/config.yaml similarity index 52% rename from install/Application/config/packages/sylius_fixtures.yaml rename to tests/TestApplication/config/config.yaml index f6a146eb..653fefee 100644 --- a/install/Application/config/packages/sylius_fixtures.yaml +++ b/tests/TestApplication/config/config.yaml @@ -1,3 +1,18 @@ +imports: + - { resource: "@SynoliaSyliusSchedulerCommandPlugin/config/config.yaml" } + +# Uncomment if need to override entities with trait for example +#doctrine: +# orm: +# entity_managers: +# default: +# mappings: +# TestApplication: +# is_bundle: false +# type: attribute +# dir: '%kernel.project_dir%/../../../tests/TestApplication/src/Entity' +# prefix: Tests\Synolia\SyliusSchedulerCommandPlugin + sylius_fixtures: suites: default: diff --git a/install/Application/config/routes/sylius_scheduler_command.yaml b/tests/TestApplication/config/routing.yaml similarity index 100% rename from install/Application/config/routes/sylius_scheduler_command.yaml rename to tests/TestApplication/config/routing.yaml diff --git a/tests/TestApplication/public/.htaccess b/tests/TestApplication/public/.htaccess new file mode 100644 index 00000000..082060eb --- /dev/null +++ b/tests/TestApplication/public/.htaccess @@ -0,0 +1,70 @@ +# Use the front controller as index file. It serves as a fallback solution when +# every other rewrite/redirect fails (e.g. in an aliased environment without +# mod_rewrite). Additionally, this reduces the matching process for the +# start page (path "/") because otherwise Apache will apply the rewriting rules +# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl). +DirectoryIndex index.php + +# By default, Apache does not evaluate symbolic links if you did not enable this +# feature in your server configuration. Uncomment the following line if you +# install assets as symlinks or if you experience problems related to symlinks +# when compiling LESS/Sass/CoffeScript assets. +# Options +SymLinksIfOwnerMatch + +# Disabling MultiViews prevents unwanted negotiation, e.g. "/index" should not resolve +# to the front controller "/index.php" but be rewritten to "/index.php/index". + + Options -MultiViews + + + + # This Option needs to be enabled for RewriteRule, otherwise it will show an error like + # 'Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden' + Options +SymLinksIfOwnerMatch + + RewriteEngine On + + # Determine the RewriteBase automatically and set it as environment variable. + # If you are using Apache aliases to do mass virtual hosting or installed the + # project in a subdirectory, the base path will be prepended to allow proper + # resolution of the index.php file and to redirect to the correct URI. It will + # work in environments without path prefix as well, providing a safe, one-size + # fits all solution. But as you do not need it in this case, you can comment + # the following 2 lines to eliminate the overhead. + RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$ + RewriteRule .* - [E=BASE:%1] + + # Sets the HTTP_AUTHORIZATION header removed by Apache + RewriteCond %{HTTP:Authorization} .+ + RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0] + + # Redirect to URI without front controller to prevent duplicate content + # (with and without `/index.php`). Only do this redirect on the initial + # rewrite by Apache and not on subsequent cycles. Otherwise we would get an + # endless redirect loop (request -> rewrite to front controller -> + # redirect -> request -> ...). + # So in case you get a "too many redirects" error or you always get redirected + # to the start page because your Apache does not expose the REDIRECT_STATUS + # environment variable, you have 2 choices: + # - disable this feature by commenting the following 2 lines or + # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the + # following RewriteCond (best solution) + RewriteCond %{ENV:REDIRECT_STATUS} ="" + RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=308,L] + + # If the requested filename exists, simply serve it. + # We only want to let Apache serve files and not directories. + # Rewrite all other queries to the front controller. + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ %{ENV:BASE}/index.php [L] + + + + + # When mod_rewrite is not available, we instruct a temporary redirect of + # the start page to the front controller explicitly so that the website + # and the generated links can still be used. + RedirectMatch 307 ^/$ /index.php/ + # RedirectTemp cannot be used instead + + From 8af453378e5c396bd4967002b8a2e96ad347eb97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Fri, 21 Nov 2025 14:43:09 +0100 Subject: [PATCH 2/8] Remove security-checker --- .github/workflows/analysis.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml index 367367a8..fd38fa30 100644 --- a/.github/workflows/analysis.yaml +++ b/.github/workflows/analysis.yaml @@ -77,6 +77,3 @@ jobs: name: 'GrumPHP - Run' run: 'if [ -f grumphp.yml ]; then vendor/bin/grumphp run ; else echo Grumphp ruleset file does not exist, skipping step ; fi' if: 'always() && steps.end-of-setup.outcome == ''success''' - - - uses: symfonycorp/security-checker-action@v3 - if: 'always() && steps.end-of-setup.outcome == ''success''' From 08a80fe44db5f0c68f8748de2d181e988f3938f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Fri, 21 Nov 2025 15:00:10 +0100 Subject: [PATCH 3/8] =?UTF-8?q?=F0=9F=91=8B=20Bye=20Behat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 8 - behat.yml.dist | 66 ---- composer.json | 12 - features/cli/cli_run_command.feature | 15 - .../ui/admin/adding_scheduled_command.feature | 34 -- features/ui/admin/bulk_clean_log.feature | 23 -- features/ui/admin/bulk_delete.feature | 23 -- features/ui/admin/check_every_fields.feature | 24 -- .../ui/admin/delete_scheduled_command.feature | 17 - features/ui/admin/download_log_file.feature | 20 -- .../ui/admin/update_scheduled_command.feature | 18 -- tests/Behat/Context/Cli/CliContext.php | 183 ----------- tests/Behat/Context/Setup/CommandContext.php | 49 --- .../Context/Setup/ScheduledCommandContext.php | 72 ----- .../Behat/Context/Ui/Admin/CommandContext.php | 306 ------------------ .../Ui/Admin/ScheduledCommandContext.php | 247 -------------- tests/Behat/Page/Admin/Command/CreatePage.php | 15 - .../Admin/Command/CreatePageInterface.php | 12 - tests/Behat/Page/Admin/Command/IndexPage.php | 16 - .../Page/Admin/Command/IndexPageInterface.php | 11 - tests/Behat/Page/Admin/Command/UpdatePage.php | 15 - .../Admin/Command/UpdatePageInterface.php | 12 - .../Page/Admin/SchedulerCommand/IndexPage.php | 16 - .../SchedulerCommand/IndexPageInterface.php | 11 - tests/Behat/Resources/services.yml | 62 ---- tests/Behat/Resources/suites.yml | 43 --- 26 files changed, 1330 deletions(-) delete mode 100644 behat.yml.dist delete mode 100644 features/cli/cli_run_command.feature delete mode 100644 features/ui/admin/adding_scheduled_command.feature delete mode 100644 features/ui/admin/bulk_clean_log.feature delete mode 100644 features/ui/admin/bulk_delete.feature delete mode 100644 features/ui/admin/check_every_fields.feature delete mode 100644 features/ui/admin/delete_scheduled_command.feature delete mode 100644 features/ui/admin/download_log_file.feature delete mode 100644 features/ui/admin/update_scheduled_command.feature delete mode 100644 tests/Behat/Context/Cli/CliContext.php delete mode 100644 tests/Behat/Context/Setup/CommandContext.php delete mode 100644 tests/Behat/Context/Setup/ScheduledCommandContext.php delete mode 100644 tests/Behat/Context/Ui/Admin/CommandContext.php delete mode 100644 tests/Behat/Context/Ui/Admin/ScheduledCommandContext.php delete mode 100644 tests/Behat/Page/Admin/Command/CreatePage.php delete mode 100644 tests/Behat/Page/Admin/Command/CreatePageInterface.php delete mode 100644 tests/Behat/Page/Admin/Command/IndexPage.php delete mode 100644 tests/Behat/Page/Admin/Command/IndexPageInterface.php delete mode 100644 tests/Behat/Page/Admin/Command/UpdatePage.php delete mode 100644 tests/Behat/Page/Admin/Command/UpdatePageInterface.php delete mode 100755 tests/Behat/Page/Admin/SchedulerCommand/IndexPage.php delete mode 100755 tests/Behat/Page/Admin/SchedulerCommand/IndexPageInterface.php delete mode 100644 tests/Behat/Resources/services.yml delete mode 100644 tests/Behat/Resources/suites.yml diff --git a/Makefile b/Makefile index ef1bd22f..e36f4c19 100644 --- a/Makefile +++ b/Makefile @@ -37,14 +37,6 @@ install-sylius: ${COMPOSER} require --dev sylius/test-application:"^${SYLIUS_VERSION}@alpha" -n -W # TODO: Remove alpha when stable ${COMPOSER} test-application:install -behat-configure: ## Configure Behat - (cd ${TEST_DIRECTORY} && cp behat.yml.dist behat.yml) - (cd ${TEST_DIRECTORY} && sed -i "s#vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml#vendor/${PLUGIN_NAME}/tests/Behat/Resources/suites.yml#g" behat.yml) - (cd ${TEST_DIRECTORY} && sed -i "s#vendor/sylius/sylius/features#vendor/${PLUGIN_NAME}/features#g" behat.yml) - (cd ${TEST_DIRECTORY} && sed -i "s#@cli#@javascript#g" behat.yml) - (cd ${TEST_DIRECTORY} && sed -i '2i \ \ \ \ - { resource: "../vendor/${PLUGIN_NAME}/tests/Behat/Resources/services.yml\" }' config/services_test.yaml) - ${CONSOLE} cache:clear - grumphp: ## Run GrumPHP vendor/bin/grumphp run diff --git a/behat.yml.dist b/behat.yml.dist deleted file mode 100644 index f2f3a23c..00000000 --- a/behat.yml.dist +++ /dev/null @@ -1,66 +0,0 @@ -imports: - - vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml - - tests/Behat/Resources/suites.yml - -default: - formatters: - pretty: - verbose: true - paths: false - snippets: false - - extensions: - DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~ - - FriendsOfBehat\MinkDebugExtension: - directory: etc/build - clean_start: false - screenshot: true - - Behat\MinkExtension: - files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/" - base_url: "https://127.0.0.1:8080/" - default_session: symfony - javascript_session: chrome_headless - sessions: - symfony: - symfony: ~ - chrome_headless: - chrome: - api_url: http://127.0.0.1:9222 - validate_certificate: false - chrome: - selenium2: - browser: chrome - capabilities: - browserName: chrome - browser: chrome - version: "" - marionette: null # https://github.com/Behat/MinkExtension/pull/311 - chrome: - switches: - - "start-fullscreen" - - "start-maximized" - - "no-sandbox" - extra_capabilities: - acceptSslCerts: true - acceptInsecureCerts: true - unexpectedAlertBehaviour: accept - goog:chromeOptions: - w3c: false # https://github.com/Sylius/Sylius/issues/10561 - firefox: - selenium2: - browser: firefox - show_auto: false - - FriendsOfBehat\SymfonyExtension: ~ - - FriendsOfBehat\VariadicExtension: ~ - - FriendsOfBehat\SuiteSettingsExtension: - paths: - - "features" - - gherkin: - filters: - tags: "~@todo" diff --git a/composer.json b/composer.json index 71a43335..3aa045ac 100644 --- a/composer.json +++ b/composer.json @@ -23,18 +23,6 @@ "webmozart/assert": "^1.11" }, "require-dev": { - "behat/behat": "^3.12", - "behat/mink-selenium2-driver": "^1.6", - "dmore/behat-chrome-extension": "^1.4", - "dmore/chrome-mink-driver": "^2.9", - "friends-of-behat/mink": "^1.10", - "friends-of-behat/mink-browserkit-driver": "^1.6", - "friends-of-behat/mink-debug-extension": "^2.1", - "friends-of-behat/mink-extension": "^2.7", - "friends-of-behat/page-object-extension": "^0.3", - "friends-of-behat/suite-settings-extension": "^1.1", - "friends-of-behat/symfony-extension": "^2.4", - "friends-of-behat/variadic-extension": "^1.5", "friendsoftwig/twigcs": "6.4.0", "php-parallel-lint/php-parallel-lint": "^1.4", "phpmd/phpmd": "^2.15.0", diff --git a/features/cli/cli_run_command.feature b/features/cli/cli_run_command.feature deleted file mode 100644 index e5aa22b4..00000000 --- a/features/cli/cli_run_command.feature +++ /dev/null @@ -1,15 +0,0 @@ -@cli_run_command -Feature: Run cli command - In order to execute commands - As a developer - I want to be able to run scheduler command - - Background: - Given I have a working command-line interface - - @cli - Scenario: Immediately execution of command - Given I have command "about" named "Displays project information" - And it is executed immediately - When I run scheduled commands - Then I should see "Immediately execution asked for : about" in the output diff --git a/features/ui/admin/adding_scheduled_command.feature b/features/ui/admin/adding_scheduled_command.feature deleted file mode 100644 index b5d1511e..00000000 --- a/features/ui/admin/adding_scheduled_command.feature +++ /dev/null @@ -1,34 +0,0 @@ -@managing_command -Feature: Adding a new command - In order to have command - As an Administrator - I want to add a command to the store - - Background: - Given I am logged in as an administrator - And I have an empty list of command - - @ui - Scenario: Adding a new command - When I go to the create command page - And I fill "Name" with "Test command" - And I fill "Command" with "debug:config" - And I add it - Then I should be notified that the command has been created - And I should see 1 command in the list - And the first command on the list should have name "Test command" - - @ui - Scenario: Adding a new command with full data - When I go to the create command page - And I fill "Name" with "Test command" - And I fill "Command" with "debug:config" - And I fill "Arguments" with "-v" - And I fill "Cron expression" with "0 0 * * *" - And I fill "Log file prefix" with "debug_config.log" - And I fill "Priority" with "1" - And I fill "Execute immediately" with "1" - And I fill "Enabled" with "1" - And I add it - Then I should be notified that the command has been created - And I should see 1 command in the list diff --git a/features/ui/admin/bulk_clean_log.feature b/features/ui/admin/bulk_clean_log.feature deleted file mode 100644 index 0578b3ae..00000000 --- a/features/ui/admin/bulk_clean_log.feature +++ /dev/null @@ -1,23 +0,0 @@ -@managing_scheduled_command -Feature: Bulk cleaning logs file - In order to clean log files of a command - As an Administrator - I want to add scheduled commands with log file and clean it - - Background: - Given I have a working command-line interface - And I have an empty list of command - And I have command "about" named "Displays project information without logs" - And I have command "about" named "Displays project information with log" - And this scheduled command has "logfile" in "logFilePrefix" - Given I am logged in as an administrator - - @ui @javascript - Scenario: Bulk cleaning logs file - Given there is a command in the store - When I run scheduled commands - And I go to the scheduler command page - And I check the "Displays project information without logs" command - And I check also the "Displays project information with log" command - And I empty logs of them - Then I should be notified that log files has been emptied diff --git a/features/ui/admin/bulk_delete.feature b/features/ui/admin/bulk_delete.feature deleted file mode 100644 index dd9cf6dc..00000000 --- a/features/ui/admin/bulk_delete.feature +++ /dev/null @@ -1,23 +0,0 @@ -@managing_scheduled_command -Feature: Bulk cleaning logs file - In order to delete a command - As an Administrator - I want to add a command and delete it - - Background: - Given I have a working command-line interface - And I have an empty list of command - And I have command "about" named "Displays project information without logs" - And I have command "about" named "Displays project information with log" - And this scheduled command has "logfile" in "logFilePrefix" - Given I am logged in as an administrator - - @ui @javascript - Scenario: Bulk deleting command - Given there is a command in the store - When I run scheduled commands - And I go to the scheduler command page - And I check the "Displays project information without logs" command - And I check also the "Displays project information with log" command - And I delete them - Then I should be notified that they have been successfully deleted diff --git a/features/ui/admin/check_every_fields.feature b/features/ui/admin/check_every_fields.feature deleted file mode 100644 index 8caf4e86..00000000 --- a/features/ui/admin/check_every_fields.feature +++ /dev/null @@ -1,24 +0,0 @@ -@managing_command -Feature: Check schedule command fields - In order to have every fields - As an Administrator - I want to check every fields - - Background: - Given I have a working command-line interface - And I have an empty list of command - And I have command "about" named "Displays project information logs" - And this command has "logfile" in "logFilePrefix" - And this command has "*****" in "cronExpression" - And this command has "1" in "priority" - Given I am logged in as an administrator - - @ui - Scenario: Check execution time field - When I run scheduled commands - And I go to the scheduler command page - Then the command field "name" should have value "Displays project information logs" on the line "0" - And the command field "command" should have value "about" on the line "0" - And the command field "cronExpression" should have value "* * * * *" on the line "0" - And the command field "priority" should have value "1" on the line "0" - And the command field "enabled" should not be empty on the line "0" diff --git a/features/ui/admin/delete_scheduled_command.feature b/features/ui/admin/delete_scheduled_command.feature deleted file mode 100644 index f0318942..00000000 --- a/features/ui/admin/delete_scheduled_command.feature +++ /dev/null @@ -1,17 +0,0 @@ -@managing_command -Feature: Delete a command - In order to remove command - As an Administrator - I want to delete a command to the store - - Background: - Given I am logged in as an administrator - And I have an empty list of command - - @ui - Scenario: Delete a command - Given there is a command in the store - When I go to the scheduler command page - And I delete this command - Then I should be notified that the command has been deleted - And I should see 0 command in the list diff --git a/features/ui/admin/download_log_file.feature b/features/ui/admin/download_log_file.feature deleted file mode 100644 index e641efca..00000000 --- a/features/ui/admin/download_log_file.feature +++ /dev/null @@ -1,20 +0,0 @@ -@managing_scheduled_command -Feature: Downloading log file - In order to see logs of a scheduled command - As an Administrator - I want to download a log file - - Background: - Given I have a working command-line interface - And I have an empty list of scheduled command - And I have scheduled command "about" named "0. Displays project information without logs" - And I have scheduled command "about" named "1. Displays project information" - And this scheduled command has "logfile" in "logFile" - Given I am logged in as an administrator - - @ui - Scenario: Downloading log file - When I run scheduled commands - And I go to the scheduler command page - Then the scheduled command field "logFile" should not be empty on the line "0" - And the scheduled command field "logFile" should be empty on the line "1" diff --git a/features/ui/admin/update_scheduled_command.feature b/features/ui/admin/update_scheduled_command.feature deleted file mode 100644 index 3fe63f5c..00000000 --- a/features/ui/admin/update_scheduled_command.feature +++ /dev/null @@ -1,18 +0,0 @@ -@managing_command -Feature: Update a command - In order to update command - As an Administrator - I want to edit a command to the store - - Background: - Given I am logged in as an administrator - And I have an empty list of command - - @ui - Scenario: Update a command - Given there is a command in the store - When I update this command - And I fill "Name" with "Update command" - And I update it - Then I should be notified that the command has been successfully updated - And I should see 1 command in the list diff --git a/tests/Behat/Context/Cli/CliContext.php b/tests/Behat/Context/Cli/CliContext.php deleted file mode 100644 index 82954a7b..00000000 --- a/tests/Behat/Context/Cli/CliContext.php +++ /dev/null @@ -1,183 +0,0 @@ -kernel = $kernel; - $this->sharedStorage = $sharedStorage; - $this->scheduledCommandManager = $scheduledCommandManager; - $this->scheduleCommandRunner = $scheduleCommandRunner; - $this->commandRepository = $commandRepository; - $this->scheduledCommandRepository = $scheduledCommandRepository; - $this->scheduledCommandPlanner = $scheduledCommandPlanner; - $this->isDueVoter = $isDueVoter; - $this->logger = $logger; - } - - /** - * @Given I have a working command-line interface - */ - public function iHaveAWorkingCommandLineInterface(): void - { - $this->application = new Application($this->kernel); - } - - /** - * @Then I should see :messagePart in the output - */ - public function iShouldSeeInTheMessage(string $messagePart): void - { - Assert::assertStringContainsString($messagePart, $this->tester->getDisplay()); - } - - /** - * @When I run scheduled commands - */ - public function iRunScheduledCommands(): void - { - $this->application->add( - new SynoliaSchedulerRunCommand( - $this->scheduledCommandManager, - $this->scheduleCommandRunner, - $this->commandRepository, - $this->scheduledCommandRepository, - $this->scheduledCommandPlanner, - $this->isDueVoter, - $this->logger, - ), - ); - $this->command = $this->application->find('synolia:scheduler-run'); - $this->tester = new CommandTester($this->command); - $this->tester->execute(['command' => 'synolia:scheduler-run']); - } - - /** - * @Given it is executed immediately - */ - public function itIsExecutedImmediately(): void - { - /** @var CommandInterface $command */ - $command = $this->sharedStorage->get('command'); - $command->setExecuteImmediately(true); - $this->scheduledCommandManager->flush(); - } - - /** - * @Given this command has :value in :attribute - */ - public function thisCommandHasIn(string $value, string $attribute): void - { - /** @var CommandInterface $command */ - $command = $this->sharedStorage->get('command'); - $getter = 'get' . \ucfirst($attribute); - $attributeType = gettype($command->$getter()); - $setter = 'set' . \ucfirst($attribute); - - if ($attributeType === 'double') { - $command->$setter((float) $value); - } - if ($attributeType === 'integer') { - $command->$setter((int) $value); - } - if ($command->$getter() === null || $command->$getter() === '') { - $command->$setter($value); - } - - $this->commandRepository->add($command); - } - - /** - * @Then the file of this command must contain :messagePart - */ - public function theFileOfThisCommandMustContain(string $messagePart): void - { - /** @var ScheduledCommandInterface $schedule */ - $schedule = $this->sharedStorage->get('command'); - $logFile = $this->kernel->getLogDir() . \DIRECTORY_SEPARATOR . $schedule->getLogFile(); - - Assert::assertContains($messagePart, \file_get_contents($logFile)); - } - - /** - * @Given this file not exit yet - */ - public function thisFileNotExitYet(): void - { - /** @var CommandInterface $schedule */ - $schedule = $this->sharedStorage->get('command'); - $logFile = $this->kernel->getLogDir() . \DIRECTORY_SEPARATOR . $schedule->getLogFilePrefix(); - - @\unlink($logFile); - } -} diff --git a/tests/Behat/Context/Setup/CommandContext.php b/tests/Behat/Context/Setup/CommandContext.php deleted file mode 100644 index b983ce3e..00000000 --- a/tests/Behat/Context/Setup/CommandContext.php +++ /dev/null @@ -1,49 +0,0 @@ -sharedStorage = $sharedStorage; - $this->commandFactory = $commandFactory; - $this->commandRepository = $commandRepository; - } - - /** - * @Given I have command :code named :name - */ - public function iHaveCommandNamed(string $code, string $name): void - { - /** @var ScheduledCommandInterface $command */ - $command = $this->commandFactory->createNew(); - $command->setCommand($code) - ->setName($name) - ; - - $this->sharedStorage->set('command', $command); - $this->commandRepository->add($command); - } -} diff --git a/tests/Behat/Context/Setup/ScheduledCommandContext.php b/tests/Behat/Context/Setup/ScheduledCommandContext.php deleted file mode 100644 index cc7e1590..00000000 --- a/tests/Behat/Context/Setup/ScheduledCommandContext.php +++ /dev/null @@ -1,72 +0,0 @@ -sharedStorage = $sharedStorage; - $this->scheduledCommandFactory = $scheduledCommandFactory; - $this->scheduledCommandRepository = $scheduledCommandRepository; - } - - /** - * @Given I have scheduled command :code named :name - */ - public function iHaveCommandNamed(string $code, string $name): void - { - /** @var ScheduledCommandInterface $command */ - $command = $this->scheduledCommandFactory->createNew(); - $command->setCommand($code) - ->setName($name) - ; - - $this->sharedStorage->set('scheduled_command', $command); - $this->scheduledCommandRepository->add($command); - } - - /** - * @Given this scheduled command has :value in :attribute - */ - public function thisScheduledCommandHasIn(string $value, string $attribute): void - { - /** @var ScheduledCommandInterface $scheduledCommand */ - $scheduledCommand = $this->sharedStorage->get('scheduled_command'); - $getter = 'get' . \ucfirst($attribute); - $attributeType = gettype($scheduledCommand->$getter()); - $setter = 'set' . \ucfirst($attribute); - - if ($attributeType === 'double') { - $scheduledCommand->$setter((float) $value); - } - if ($attributeType === 'integer') { - $scheduledCommand->$setter((int) $value); - } - if ($scheduledCommand->$getter() === null || $scheduledCommand->$getter() === '') { - $scheduledCommand->$setter($value); - } - - $this->scheduledCommandRepository->add($scheduledCommand); - } -} diff --git a/tests/Behat/Context/Ui/Admin/CommandContext.php b/tests/Behat/Context/Ui/Admin/CommandContext.php deleted file mode 100644 index 60bab729..00000000 --- a/tests/Behat/Context/Ui/Admin/CommandContext.php +++ /dev/null @@ -1,306 +0,0 @@ -indexPage->open(); - } - - /** - * @When I go to the create command page - */ - public function iGoToTheCreateCommandPage(): void - { - $this->createPage->open(); - } - - /** - * @When I fill :field with :value - */ - public function iFillFields(string $field, string $value): void - { - /** @var CreatePageInterface|UpdatePageInterface $currentPage */ - $currentPage = $this->resolveCurrentPage(); - $currentPage->fillField($field, $value); - } - - /** - * @When I add it - * @When I try to add it - */ - public function iAddIt(): void - { - $this->createPage->create(); - } - - /** - * @When I update it - */ - public function iUpdateIt(): void - { - $this->updatePage->saveChanges(); - } - - /** - * @When I update this command - */ - public function iUpdateThisCommand(): void - { - /** @var CommandInterface $schedule */ - $schedule = $this->sharedStorage->get('command'); - - $this->updatePage->open(['id' => $schedule->getId()]); - } - - /** - * @Given I have an empty list of command - */ - public function iHaveAnEmptyListOfCommand(): void - { - foreach ($this->commandRepository->findAll() as $command) { - $this->commandRepository->remove($command); - } - } - - /** - * @Then I should see :numberOfProducts command in the list - */ - public function iShouldSeeCommandInTheList(int $numberOfCommands): void - { - Assert::same($this->indexPage->countItems(), $numberOfCommands); - } - - /** - * @Then the first command on the list should have :field :value - */ - public function theFirstCommandOnTheListShouldHaveName(string $field, string $value): void - { - /** @var IndexPageInterface $currentPage */ - $currentPage = $this->resolveCurrentPage(); - - Assert::same($currentPage->getColumnFields($field)[0], $value); - } - - /** - * @Then I should be notified that the command has been created - */ - public function iShouldBeNotifiedThatNewCommandHasBeenCreated(): void - { - $this->notificationChecker->checkNotification( - 'Command has been successfully created.', - NotificationType::success(), - ); - } - - /** - * @Then I should be notified that the command has been successfully updated - */ - public function iShouldBeNotifiedThatTheCommandHasBeenSuccessfullyUpdated(): void - { - $this->notificationChecker->checkNotification( - 'Command has been successfully updated.', - NotificationType::success(), - ); - } - - /** - * @Then I should be notified that the command has been deleted - */ - public function iShouldBeNotifiedThatTheCommandHasBeenDeleted(): void - { - $this->notificationChecker->checkNotification( - 'Command has been successfully deleted.', - NotificationType::success(), - ); - } - - /** - * @Then I should be notified that the command log file has been cleaned - */ - public function iShouldBeNotifiedThatNewCommandLogFileHasBeenCleaned(): void - { - $this->notificationChecker->checkNotification( - 'Log file successfully emptied.', - NotificationType::success(), - ); - } - - /** - * @Given there is a command in the store - */ - public function thereIsACommandInTheStore(): void - { - $schedule = $this->createCommand(); - - $this->sharedStorage->set('command', $schedule); - $this->commandRepository->add($schedule); - } - - /** - * @When I delete this command - */ - public function iDeleteThisCommand(): void - { - /** @var CommandInterface $schedule */ - $schedule = $this->sharedStorage->get('command'); - - $this->indexPage->deleteResourceOnPage(['name' => $schedule->getName()]); - } - - /** - * @When I check (also) the :commandName command - */ - public function iCheckTheCommand(string $commandName): void - { - $this->indexPage->checkResourceOnPage(['name' => $commandName]); - } - - /** - * @When I empty logs of them - */ - public function iEmptyLogsOfThem(): void - { - $this->indexPage->bulkEmptyLogs(); - } - - /** - * @When I delete them - */ - public function iDeleteThem(): void - { - $this->indexPage->bulkDelete(); - } - - /** - * @Then the command field :field should not be empty on the line :index - */ - public function theCommandFieldShouldNotBeEmptyOnTheLine(string $field, int $index): void - { - Assert::notEmpty($this->indexPage->getColumnFields($field)[$index]); - } - - /** - * @Then the command field :field should have value :value on the line :index - */ - public function theCommandFieldShouldHaveValueOnTheLine(string $field, string $value, int $index): void - { - Assert::same($this->indexPage->getColumnFields($field)[$index], $value); - } - - /** - * @Then the command field :field should be empty on the line :index - */ - public function theCommandFieldShouldBeEmptyOnTheLine(string $field, int $index): void - { - Assert::isEmpty($this->indexPage->getColumnFields($field)[$index]); - } - - /** - * @Then the first command shouldn't have log file - */ - public function theFirstCommandShouldNotHaveLogFile(): void - { - Assert::isEmpty($this->indexPage->getColumnFields('logFile')[0]); - } - - /** - * @Then the second command should have a log file :filename - */ - public function theSecondCommandShouldHaveALogFile(string $filename): void - { - Assert::startsWith( - $this->indexPage->getColumnFields('logFile')[1], - \sprintf('%s %s', $this->translator->trans('sylius.ui.live_view'), $filename), - ); - } - - /** - * @When /^I clean log file for this command for command named "([^"]*)"$/ - */ - public function iCleanLogFileForThisCommandForCommandNamed(string $CommandName): void - { - $actions = $this->indexPage->getActionsForResource(['name' => $CommandName]); - $actions->pressButton('Empty log'); - } - - /** - * @Then /^I should be notified that the command log file has not been defined$/ - */ - public function iShouldBeNotifiedThatTheCommandLogFileHasNotBeenDefined(): void - { - $this->notificationChecker->checkNotification( - 'command has no defined log file.', - NotificationType::failure(), - ); - } - - /** - * @Then I should be notified that log files has been emptied - */ - public function iShouldBeNotifiedThatLogFilesHasBeenEmptied(): void - { - $this->notificationChecker->checkNotification( - 'The log files have been emptied.', - NotificationType::success(), - ); - } - - /** - * @return IndexPageInterface|CreatePageInterface|UpdatePageInterface|SymfonyPageInterface - */ - private function resolveCurrentPage(): SymfonyPageInterface - { - return $this->currentPageResolver->getCurrentPageWithForm([ - $this->indexPage, - $this->createPage, - $this->updatePage, - ]); - } - - private function createCommand(): CommandInterface - { - $command = new Command(); - $command->setName('About project') - ->setCommand('about') - ; - - return $command; - } -} diff --git a/tests/Behat/Context/Ui/Admin/ScheduledCommandContext.php b/tests/Behat/Context/Ui/Admin/ScheduledCommandContext.php deleted file mode 100644 index db9d05ad..00000000 --- a/tests/Behat/Context/Ui/Admin/ScheduledCommandContext.php +++ /dev/null @@ -1,247 +0,0 @@ -indexPage->open(); - $this->indexPage->sortBy('name'); - } - - /** - * @Given I have an empty list of scheduled command - */ - public function iHaveAnEmptyListOfScheduledCommand(): void - { - foreach ($this->scheduledCommandRepository->findAll() as $command) { - $this->scheduledCommandRepository->remove($command); - } - } - - /** - * @Then I should see :numberOfProducts scheduled command in the list - */ - public function iShouldSeeScheduledCommandInTheList(int $numberOfCommands): void - { - Assert::same($this->indexPage->countItems(), $numberOfCommands); - } - - /** - * @Then the first scheduled command on the list should have :field :value - */ - public function theFirstScheduledCommandOnTheListShouldHaveName(string $field, string $value): void - { - /** @var IndexPageInterface $currentPage */ - $currentPage = $this->resolveCurrentPage(); - - Assert::same($currentPage->getColumnFields($field)[0], $value); - } - - /** - * @Then I should be notified that the scheduled command has been created - */ - public function iShouldBeNotifiedThatNewScheduledCommandHasBeenCreated(): void - { - $this->notificationChecker->checkNotification( - 'Command has been successfully created.', - NotificationType::success(), - ); - } - - /** - * @Then I should be notified that the scheduled command has been successfully updated - */ - public function iShouldBeNotifiedThatTheScheduledCommandHasBeenSuccessfullyUpdated(): void - { - $this->notificationChecker->checkNotification( - 'Command has been successfully updated.', - NotificationType::success(), - ); - } - - /** - * @Then I should be notified that the scheduled command has been deleted - */ - public function iShouldBeNotifiedThatTheScheduledCommandHasBeenDeleted(): void - { - $this->notificationChecker->checkNotification( - 'Command has been successfully deleted.', - NotificationType::success(), - ); - } - - /** - * @Then I should be notified that the scheduled command log file has been cleaned - */ - public function iShouldBeNotifiedThatNewScheduledCommandLogFileHasBeenCleaned(): void - { - $this->notificationChecker->checkNotification( - 'Log file successfully emptied.', - NotificationType::success(), - ); - } - - /** - * @Given there is a scheduled command in the store - */ - public function thereIsAScheduledCommandInTheStore(): void - { - $schedule = $this->createCommand(); - - $this->sharedStorage->set('command', $schedule); - $this->scheduledCommandRepository->add($schedule); - } - - /** - * @When I delete this scheduled command - */ - public function iDeleteThisScheduledCommand(): void - { - /** @var ScheduledCommandInterface $schedule */ - $schedule = $this->sharedStorage->get('command'); - - $this->indexPage->deleteResourceOnPage(['name' => $schedule->getName()]); - } - - /** - * @When I check (also) the :commandName command - */ - public function iCheckTheCommand(string $commandName): void - { - $this->indexPage->checkResourceOnPage(['name' => $commandName]); - } - - /** - * @When I empty logs of them - */ - public function iEmptyLogsOfThem(): void - { - $this->indexPage->bulkEmptyLogs(); - } - - /** - * @When I delete them - */ - public function iDeleteThem(): void - { - $this->indexPage->bulkDelete(); - } - - /** - * @Then the scheduled command field :field should not be empty on the line :index - */ - public function theScheduledCommandFieldShouldNotBeEmptyOnTheLine(string $field, int $index): void - { - Assert::notEmpty($this->indexPage->getColumnFields($field)[$index]); - } - - /** - * @Then the scheduled command field :field should have value :value on the line :index - */ - public function theScheduledCommandFieldShouldHaveValueOnTheLine(string $field, string $value, int $index): void - { - Assert::same($this->indexPage->getColumnFields($field)[$index], $value); - } - - /** - * @Then the scheduled command field :field should be empty on the line :index - */ - public function theScheduledCommandFieldShouldBeEmptyOnTheLine(string $field, int $index): void - { - Assert::isEmpty($this->indexPage->getColumnFields($field)[$index]); - } - - /** - * @Then the first scheduled command shouldn't have log file - */ - public function theFirstScheduledCommandShouldNotHaveLogFile(): void - { - Assert::isEmpty($this->indexPage->getColumnFields('logFile')[0]); - } - - /** - * @Then the second scheduled command should have a log file :filename - */ - public function theSecondScheduledCommandShouldHaveALogFile(string $filename): void - { - Assert::startsWith( - $this->indexPage->getColumnFields('logFile')[1], - \sprintf('%s %s', $this->translator->trans('sylius.ui.live_view'), $filename), - ); - } - - /** - * @Then /^I should be notified that the scheduled command log file has not been defined$/ - */ - public function iShouldBeNotifiedThatTheScheduledCommandLogFileHasNotBeenDefined(): void - { - $this->notificationChecker->checkNotification( - 'Scheduled command has no defined log file.', - NotificationType::failure(), - ); - } - - /** - * @Then I should be notified that log files has been emptied - */ - public function iShouldBeNotifiedThatLogFilesHasBeenEmptied(): void - { - $this->notificationChecker->checkNotification( - 'The log files have been emptied.', - NotificationType::success(), - ); - } - - /** - * @return IndexPageInterface|SymfonyPageInterface - */ - private function resolveCurrentPage(): SymfonyPageInterface - { - return $this->currentPageResolver->getCurrentPageWithForm([ - $this->indexPage, - ]); - } - - private function createCommand(): CommandInterface - { - $command = new Command(); - $command->setName('About project') - ->setCommand('about') - ; - - return $command; - } -} diff --git a/tests/Behat/Page/Admin/Command/CreatePage.php b/tests/Behat/Page/Admin/Command/CreatePage.php deleted file mode 100644 index cc561718..00000000 --- a/tests/Behat/Page/Admin/Command/CreatePage.php +++ /dev/null @@ -1,15 +0,0 @@ -getDocument()->fillField($field, $value); - } -} diff --git a/tests/Behat/Page/Admin/Command/CreatePageInterface.php b/tests/Behat/Page/Admin/Command/CreatePageInterface.php deleted file mode 100644 index e93bce56..00000000 --- a/tests/Behat/Page/Admin/Command/CreatePageInterface.php +++ /dev/null @@ -1,12 +0,0 @@ -getElement('bulk_actions')->pressButton('Empty logs'); - $this->getElement('confirmation_button')->click(); - } -} diff --git a/tests/Behat/Page/Admin/Command/IndexPageInterface.php b/tests/Behat/Page/Admin/Command/IndexPageInterface.php deleted file mode 100644 index 31e8efa5..00000000 --- a/tests/Behat/Page/Admin/Command/IndexPageInterface.php +++ /dev/null @@ -1,11 +0,0 @@ -getDocument()->fillField($field, $value); - } -} diff --git a/tests/Behat/Page/Admin/Command/UpdatePageInterface.php b/tests/Behat/Page/Admin/Command/UpdatePageInterface.php deleted file mode 100644 index 37dd71f3..00000000 --- a/tests/Behat/Page/Admin/Command/UpdatePageInterface.php +++ /dev/null @@ -1,12 +0,0 @@ -getElement('bulk_actions')->pressButton('Empty logs'); - $this->getElement('confirmation_button')->click(); - } -} diff --git a/tests/Behat/Page/Admin/SchedulerCommand/IndexPageInterface.php b/tests/Behat/Page/Admin/SchedulerCommand/IndexPageInterface.php deleted file mode 100755 index 4a16e255..00000000 --- a/tests/Behat/Page/Admin/SchedulerCommand/IndexPageInterface.php +++ /dev/null @@ -1,11 +0,0 @@ - Date: Fri, 21 Nov 2025 15:01:01 +0100 Subject: [PATCH 4/8] Improve CI sylius --- .github/workflows/sylius.yaml | 41 +++++------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/.github/workflows/sylius.yaml b/.github/workflows/sylius.yaml index 40dd1e4a..539e3b8f 100644 --- a/.github/workflows/sylius.yaml +++ b/.github/workflows/sylius.yaml @@ -17,12 +17,13 @@ jobs: matrix: php: - 8.2 - - 8.3 + - 8.4 sylius: - 2.0.0 + - 2.1.0 symfony: - 6.4 - - 7.2 + - 7.3 node: - 20.x env: @@ -78,47 +79,15 @@ jobs: - name: 'Install Sylius-Standard and Plugin' run: 'make install -e SYLIUS_VERSION=${{ matrix.sylius }} SYMFONY_VERSION=${{ matrix.symfony }} PHP_VERSION=${{ matrix.php }}' - - - name: 'Output PHP version for Symfony CLI' - working-directory: ./tests/Application - run: 'php -v | head -n 1 | awk ''{ print $2 }'' > .php-version' - - - name: 'Install certificates' - working-directory: ./tests/Application - run: 'symfony server:ca:install' - - - name: 'Run Chrome headless' - working-directory: ./tests/Application - run: 'google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server=''direct://'' --proxy-bypass-list=''*'' https://127.0.0.1 > /dev/null 2>&1 &' - - - name: 'Run webserver' - working-directory: ./tests/Application - run: 'symfony server:start --port=8080 --dir=public --daemon' - id: end-of-setup-sylius - name: 'Doctrine Schema Validate - Run' - working-directory: ./tests/Application - run: 'php bin/console doctrine:schema:validate --skip-sync' + run: 'vendor/bin/console doctrine:schema:validate --skip-sync' if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' - name: 'Run PHPUnit' run: 'make phpunit' if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' - - - name: 'Configure Behat' - run: 'make behat-configure' - if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' - - - name: 'Run behat' - working-directory: ./tests/Application - run: 'vendor/bin/behat --strict --no-interaction -f progress || vendor/bin/behat --strict -vvv --no-interaction --rerun' - if: 'always() && steps.end-of-setup-sylius.outcome == ''success''' - - - uses: actions/upload-artifact@v4 - if: failure() - with: - name: logs - path: ./tests/Application/etc/build + services: mariadb: image: 'mariadb:10.4.11' From b62b85e52894d4a1d58e68fbacea0d2e25605d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Fri, 21 Nov 2025 15:07:56 +0100 Subject: [PATCH 5/8] Remove tests/Behat from ecs file --- ruleset/ecs.php | 1 - 1 file changed, 1 deletion(-) diff --git a/ruleset/ecs.php b/ruleset/ecs.php index 957b817c..aa42c42d 100644 --- a/ruleset/ecs.php +++ b/ruleset/ecs.php @@ -7,7 +7,6 @@ return static function (ECSConfig $ecsConfig): void { $ecsConfig->paths([ dirname(__DIR__, 1) . '/src', - dirname(__DIR__, 1) . '/tests/Behat', dirname(__DIR__, 1) . '/tests/PHPUnit', dirname(__DIR__, 1) . '/spec', ]); From 5a5512f3c90b46508139113d71decef208f300bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Fri, 21 Nov 2025 15:20:21 +0100 Subject: [PATCH 6/8] Fix analysis ci - Fix phpstan versions - Update phpspec --- .github/workflows/analysis.yaml | 6 +++--- composer.json | 12 ++++++------ src/Command/SynoliaSchedulerRunCommand.php | 4 +++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/analysis.yaml b/.github/workflows/analysis.yaml index fd38fa30..1a98ec6e 100644 --- a/.github/workflows/analysis.yaml +++ b/.github/workflows/analysis.yaml @@ -20,7 +20,7 @@ jobs: - 8.3 symfony: - '6.4.*' - - '7.2.*' + - '7.3.*' env: APP_ENV: test steps: @@ -59,11 +59,11 @@ jobs: id: end-of-setup - name: 'ECS - Run' - run: 'if [ -f ruleset/ecs.php ]; then vendor/bin/ecs check src/ tests/Behat/ --no-progress-bar -c ruleset/ecs.php ; else echo Ecs ruleset file does not exist, skipping step ; fi' + run: 'if [ -f ruleset/ecs.php ]; then vendor/bin/ecs check --no-progress-bar -c ruleset/ecs.php ; else echo Ecs ruleset file does not exist, skipping step ; fi' if: 'always() && steps.end-of-setup.outcome == ''success''' - name: 'PHPStan - Run' - run: 'if [ -f ruleset/phpstan.neon ]; then vendor/bin/phpstan analyse -c ruleset/phpstan.neon src/ ; else echo PHPStan ruleset file does not exist, skipping step ; fi' + run: 'if [ -f ruleset/phpstan.neon ]; then vendor/bin/phpstan analyse -c ruleset/phpstan.neon ; else echo PHPStan ruleset file does not exist, skipping step ; fi' if: 'always() && steps.end-of-setup.outcome == ''success''' - name: 'PHPSpec - Run' diff --git a/composer.json b/composer.json index 3aa045ac..54fe1a1d 100644 --- a/composer.json +++ b/composer.json @@ -23,16 +23,16 @@ "webmozart/assert": "^1.11" }, "require-dev": { - "friendsoftwig/twigcs": "6.4.0", + "friendsoftwig/twigcs": "6.5.0", "php-parallel-lint/php-parallel-lint": "^1.4", "phpmd/phpmd": "^2.15.0", "phpro/grumphp": "^2.9", - "phpspec/phpspec": "^7.3", + "phpspec/phpspec": "^8.0", "phpstan/extension-installer": "^1.3", - "phpstan/phpstan": "^2.0", - "phpstan/phpstan-doctrine": "^2.0", - "phpstan/phpstan-strict-rules": "^2.0", - "phpstan/phpstan-webmozart-assert": "^2.0", + "phpstan/phpstan": "2.1.32", + "phpstan/phpstan-doctrine": "2.0.11", + "phpstan/phpstan-strict-rules": "2.0.7", + "phpstan/phpstan-webmozart-assert": "2.0.0", "phpunit/phpunit": "^9.5", "rector/rector": "^2.0", "seld/jsonlint": "^1.11", diff --git a/src/Command/SynoliaSchedulerRunCommand.php b/src/Command/SynoliaSchedulerRunCommand.php index d96af7e8..d684d6a7 100644 --- a/src/Command/SynoliaSchedulerRunCommand.php +++ b/src/Command/SynoliaSchedulerRunCommand.php @@ -118,7 +118,9 @@ private function runScheduledCommand(SymfonyStyle $io, ScheduledCommandInterface { /** Fetch the object in case Connexion has been closed between two scheduled Command */ $scheduledCommand = $this->scheduledCommandRepository->find($scheduledCommand->getId()); - + if (null === $scheduledCommand) { + return; + } $this->executeCommand($scheduledCommand, $io); } From f94b5ef266ece30eec8ef968768cf30b0371874e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Fri, 21 Nov 2025 15:54:29 +0100 Subject: [PATCH 7/8] Fix phpstan issues - There is one remaining about TreeNodeBuilder --- ruleset/phpstan-baseline.neon | 18 ------------------ .../ScheduledCommandPostRemoveEvent.php | 7 +++---- src/Twig/BytesFormatterExtension.php | 2 +- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/ruleset/phpstan-baseline.neon b/ruleset/phpstan-baseline.neon index 2cb5500e..e9ff087e 100644 --- a/ruleset/phpstan-baseline.neon +++ b/ruleset/phpstan-baseline.neon @@ -1,25 +1,7 @@ parameters: ignoreErrors: - - - message: '#^Call to method getEntity\(\) on an unknown class Doctrine\\ORM\\Event\\LifecycleEventArgs\.$#' - identifier: class.notFound - count: 1 - path: ../src/DoctrineEvent/ScheduledCommandPostRemoveEvent.php - - - - message: '#^Parameter \$eventArgs of method Synolia\\SyliusSchedulerCommandPlugin\\DoctrineEvent\\ScheduledCommandPostRemoveEvent\:\:postRemove\(\) has invalid type Doctrine\\ORM\\Event\\LifecycleEventArgs\.$#' - identifier: class.notFound - count: 1 - path: ../src/DoctrineEvent/ScheduledCommandPostRemoveEvent.php - - message: '#^Cannot call method scalarNode\(\) on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface\|null\.$#' identifier: method.nonObject count: 1 path: ../src/Fixture/SchedulerCommandFixture.php - - - - message: '#^Invalid array key type float\.$#' - identifier: offsetAccess.invalidOffset - count: 2 - path: ../src/Twig/BytesFormatterExtension.php diff --git a/src/DoctrineEvent/ScheduledCommandPostRemoveEvent.php b/src/DoctrineEvent/ScheduledCommandPostRemoveEvent.php index b1e826a8..7052f89d 100644 --- a/src/DoctrineEvent/ScheduledCommandPostRemoveEvent.php +++ b/src/DoctrineEvent/ScheduledCommandPostRemoveEvent.php @@ -5,7 +5,7 @@ namespace Synolia\SyliusSchedulerCommandPlugin\DoctrineEvent; use Doctrine\Common\EventSubscriber; -use Doctrine\ORM\Event\LifecycleEventArgs; +use Doctrine\ORM\Event\PostRemoveEventArgs; use Doctrine\ORM\Events; use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag; use Symfony\Component\DependencyInjection\Attribute\Autowire; @@ -27,10 +27,9 @@ public function getSubscribedEvents(): array ]; } - public function postRemove(LifecycleEventArgs $eventArgs): void + public function postRemove(PostRemoveEventArgs $eventArgs): void { - $scheduledCommand = $eventArgs->getEntity(); - + $scheduledCommand = $eventArgs->getObject(); if (!$scheduledCommand instanceof ScheduledCommandInterface) { return; } diff --git a/src/Twig/BytesFormatterExtension.php b/src/Twig/BytesFormatterExtension.php index 022d822e..df4f9069 100644 --- a/src/Twig/BytesFormatterExtension.php +++ b/src/Twig/BytesFormatterExtension.php @@ -25,7 +25,7 @@ public function formatBytes(int $bytes): string } try { - $number = floor(log($bytes, 1024)); + $number = (int) floor(log($bytes, 1024)); return round($bytes / (1024 ** $number), [0, 2, 2, 2, 3][$number]) . ['B', 'kB', 'MB', 'GB', 'TB'][$number]; } catch (\Throwable) { From c519f5d5017f979701d782d9ef14f68941d5a0c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Fri, 21 Nov 2025 15:57:41 +0100 Subject: [PATCH 8/8] Add missing translation when add/edit command --- translations/messages.en.yml | 1 + translations/messages.fr.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/translations/messages.en.yml b/translations/messages.en.yml index 1b1e8b1a..beb7d235 100755 --- a/translations/messages.en.yml +++ b/translations/messages.en.yml @@ -1,5 +1,6 @@ synolia: ui: + command: Scheduled command commands: Scheduled commands scheduled_commands: Scheduled commands history scheduled_command: diff --git a/translations/messages.fr.yml b/translations/messages.fr.yml index ac99de26..f9f71e18 100755 --- a/translations/messages.fr.yml +++ b/translations/messages.fr.yml @@ -1,5 +1,6 @@ synolia: ui: + command: Commande planifiée commands: Commandes planifiées scheduled_commands: Historique des commandes planifiées scheduled_command: