diff --git a/.editorconfig b/.editorconfig index b0a2a8d..178a650 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,13 +3,23 @@ root = true [*] indent_style = space indent_size = 4 + end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true +[*.feature] +indent_size = 2 + [*.md] trim_trailing_whitespace = false +[*.sh] +indent_style = tab + [*.{yaml,yml}] trim_trailing_whitespace = false + +[{webpack.config.js,.eslintrc.js}] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes index b64312e..53f8a7c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,12 +1,18 @@ -/etc export-ignore -/features export-ignore -/spec export-ignore -/tests export-ignore -/.editorconfig export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore -/behat.yml.dist export-ignore -/ecs.php export-ignore -/phpspec.yml.dist export-ignore -/psalm.xml export-ignore -/README.md export-ignore +/.github export-ignore +/etc export-ignore +/docs export-ignore +/.editorconfig export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/README.md export-ignore +/behat.yml.dist export-ignore +/composer-require-checker.json export-ignore +/docs export-ignore +/ecs.php export-ignore +/node_modules export-ignore +/phpunit.xml.dist export-ignore +/psalm-baseline.xml export-ignore +/psalm.xml export-ignore +/tests export-ignore +/CHANGELOG.md export-ignore +/UPGRADE.md export-ignore diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..f2188b9 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: Setono diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml new file mode 100644 index 0000000..3dc2acd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -0,0 +1,36 @@ +name: Bug Report +description: File a bug report +title: "[Bug]: " +labels: [ "bug" ] +body: + - type: markdown + attributes: + value: Thanks for taking the time to fill out this bug report! + - type: input + id: plugin-version + attributes: + label: Plugin version + description: What version of the plugin are you using? + validations: + required: true + - type: input + id: sylius-version + attributes: + label: Sylius version + description: What version of Sylius are you using? + validations: + required: true + - type: textarea + id: what-happened + attributes: + label: What happened? + description: Also tell us, what did you expect to happen? + placeholder: Tell us what you see! + validations: + required: true + - type: textarea + id: logs + attributes: + label: Relevant log output + description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + render: shell diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..ecdc4ca --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: Support question? + url: https://sylius-devs.slack.com/archives/C3EGDG9LY + about: Please ask questions on the Sylius support channel. It's okay to tag a developer, but please understand that we also have other obligations ;) + - name: Security issue + url: https://setono.com + about: Please send security vulnerabilities directly to security@setono.com diff --git a/.github/ISSUE_TEMPLATE/feature.yaml b/.github/ISSUE_TEMPLATE/feature.yaml new file mode 100644 index 0000000..cf106ab --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.yaml @@ -0,0 +1,29 @@ +name: Feature request +description: Write a feature request +title: "[Feature request]: " +labels: [ "enhancement" ] +body: + - type: markdown + attributes: + value: "We really value feature requests. Thank you :tada:" + - type: textarea + id: what-happened + attributes: + label: Describe the proposed solution + description: A clear and concise description of what you want to happen + validations: + required: true + - type: textarea + id: alternatives + attributes: + label: Describe alternatives you've considered + description: A clear and concise description of any alternative solutions or features you've considered + validations: + required: false + - type: textarea + id: context + attributes: + label: Additional context + description: Add any other context or screenshots about the feature request here + validations: + required: false diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 540cd5c..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,17 +0,0 @@ -# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates - -version: 2 - -updates: - - commit-message: - include: "scope" - prefix: "composer" - directory: "/" - ignore: - - dependency-name: "symfony/*" - - dependency-name: "sylius/sylius" - open-pull-requests-limit: 10 - package-ecosystem: "composer" - schedule: - interval: "weekly" - versioning-strategy: "increase-if-necessary" diff --git a/.github/workflows/backwards-compatibility-check.yaml b/.github/workflows/backwards-compatibility-check.yaml new file mode 100644 index 0000000..806dd6a --- /dev/null +++ b/.github/workflows/backwards-compatibility-check.yaml @@ -0,0 +1,30 @@ +# See https://github.com/Roave/BackwardCompatibilityCheck + +name: "Backwards Compatibility Check" + +on: + pull_request: ~ + +jobs: + backwards-compatibility-check: + name: "Backwards Compatibility Check" + + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout" + uses: "actions/checkout@v4" + with: + fetch-depth: 0 + + - name: "Setup PHP, with composer and extensions" + uses: "shivammathur/setup-php@v2" + with: + php-version: "8.1" + coverage: "none" + + - name: "Install tool" + run: "composer global require roave/backward-compatibility-check" + + - name: "Check for BC breaks" + run: "~/.composer/vendor/bin/roave-backward-compatibility-check --from=origin/${{ github.event.pull_request.base.ref }} --format=github-actions" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1d4ab25..873083a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -2,7 +2,7 @@ name: "build" on: push: branches: - - "*.x" + - "1.x" paths-ignore: - "**/*.md" pull_request: @@ -24,14 +24,14 @@ jobs: strategy: matrix: php-version: - - "7.4" + - "8.1" # Always use the lowest version of PHP since a higher version could create actual syntax errors in lower versions dependencies: - "highest" steps: - name: "Checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "Setup PHP, with composer and extensions" uses: "shivammathur/setup-php@v2" @@ -41,7 +41,7 @@ jobs: coverage: "none" - name: "Install composer dependencies" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" with: dependency-versions: "${{ matrix.dependencies }}" @@ -54,6 +54,10 @@ jobs: - name: "Check style" run: "composer check-style" + - name: "Rector" + run: "vendor/bin/rector process --dry-run" + continue-on-error: true + - name: "Lint yaml files" run: "(cd tests/Application && bin/console lint:yaml ../../src/Resources)" @@ -68,19 +72,20 @@ jobs: strategy: matrix: php-version: - - "7.4" - - "8.0" - "8.1" + - "8.2" dependencies: + - "lowest" - "highest" - + symfony: - - "^5.4" + - "~5.4.0" + - "~6.4.0" steps: - name: "Checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "Setup PHP, with composer and extensions" uses: "shivammathur/setup-php@v2" @@ -90,19 +95,22 @@ jobs: php-version: "${{ matrix.php-version }}" tools: "composer-require-checker, composer-unused, flex" + - name: "Remove require-dev section in composer.json" + run: "composer config --unset require-dev" + - name: "Install composer dependencies" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" env: SYMFONY_REQUIRE: "${{ matrix.symfony }}" with: dependency-versions: "${{ matrix.dependencies }}" - name: "Run maglnet/composer-require-checker" - run: "composer-require-checker check --config-file=$(pwd)/composer-require-checker.json" + run: "composer-require-checker check" - name: "Run composer-unused/composer-unused" - run: "composer-unused || true" # todo remove when https://github.com/shivammathur/setup-php/issues/703 is fixed - + run: "composer-unused" + static-code-analysis: name: "Static Code Analysis (PHP${{ matrix.php-version }} | Deps: ${{ matrix.dependencies }} | SF${{ matrix.symfony }})" @@ -111,19 +119,20 @@ jobs: strategy: matrix: php-version: - - "7.4" - - "8.0" - "8.1" + - "8.2" dependencies: + - "lowest" - "highest" symfony: - - "^5.4" + - "~5.4.0" + - "~6.4.0" steps: - name: "Checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "Setup PHP, with composer and extensions" uses: "shivammathur/setup-php@v2" @@ -133,16 +142,16 @@ jobs: php-version: "${{ matrix.php-version }}" tools: "flex" + - name: "Remove sylius/sylius from composer.json" + run: "composer remove --dev --no-update --no-plugins --no-scripts sylius/sylius" + - name: "Install composer dependencies" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" env: SYMFONY_REQUIRE: "${{ matrix.symfony }}" with: dependency-versions: "${{ matrix.dependencies }}" - - name: "Cache warmup" - run: "(cd tests/Application && bin/console cache:warmup)" - - name: "Static analysis" run: "vendor/bin/psalm --php-version=${{ matrix.php-version }}" @@ -154,19 +163,20 @@ jobs: strategy: matrix: php-version: - - "7.4" - - "8.0" - "8.1" - + - "8.2" + dependencies: + - "lowest" - "highest" symfony: - - "^5.4" + - "~5.4.0" + - "~6.4.0" steps: - name: "Checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "Setup PHP, with composer and extensions" uses: "shivammathur/setup-php@v2" @@ -177,7 +187,7 @@ jobs: tools: "flex" - name: "Install composer dependencies" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" env: SYMFONY_REQUIRE: "${{ matrix.symfony }}" with: @@ -185,9 +195,6 @@ jobs: - name: "Run phpunit" run: "composer phpunit" - - - name: "Run phpspec" - run: "composer phpspec" integration-tests: name: "Integration tests (PHP${{ matrix.php-version }} | Deps: ${{ matrix.dependencies }} | SF${{ matrix.symfony }})" @@ -197,53 +204,51 @@ jobs: strategy: matrix: php-version: - - "7.4" - - "8.0" - "8.1" + - "8.2" dependencies: + - "lowest" - "highest" - + symfony: - - "^5.4" + - "~5.4.0" + - "~6.4.0" steps: - name: "Start MySQL" run: "sudo /etc/init.d/mysql start" - name: "Checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "Setup PHP, with composer and extensions" uses: "shivammathur/setup-php@v2" with: - php-version: "${{ matrix.php-version }}" - extensions: "${{ env.PHP_EXTENSIONS }}" coverage: "none" - tools: "symfony" - - - name: "Setup node" - uses: "actions/setup-node@v2" - with: - node-version: "12.x" + extensions: "${{ env.PHP_EXTENSIONS }}" + php-version: "${{ matrix.php-version }}" + tools: "flex" - name: "Install composer dependencies" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" + env: + SYMFONY_REQUIRE: "${{ matrix.symfony }}" with: dependency-versions: "${{ matrix.dependencies }}" - name: "Lint container" - run: "(cd tests/Application && bin/console lint:container) || true" + run: "(cd tests/Application && bin/console lint:container)" - name: "Create database" - run: "(cd tests/Application && bin/console doctrine:database:create -vvv)" + run: "(cd tests/Application && bin/console doctrine:database:create)" - name: "Create database schema" - run: "(cd tests/Application && bin/console doctrine:schema:create -vvv)" + run: "(cd tests/Application && bin/console doctrine:schema:create)" - name: "Validate Doctrine mapping" - run: "(cd tests/Application && bin/console doctrine:schema:validate -vvv)" - + run: "(cd tests/Application && bin/console doctrine:schema:validate -vvv)" # The verbose flag will show 'missing' SQL statements, if any + - name: "Get Yarn cache directory" id: "yarn-cache" run: "echo \"::set-output name=dir::$(yarn cache dir)\"" @@ -254,25 +259,25 @@ jobs: path: "${{ steps.yarn-cache.outputs.dir }}" key: "yarn-${{ hashFiles('**/package.json **/yarn.lock') }}" restore-keys: "yarn-" - + - name: "Install JS dependencies" run: "(cd tests/Application && yarn install)" - + - name: "Install assets" run: "(cd tests/Application && bin/console assets:install public -vvv)" - + - name: "Build assets" run: "(cd tests/Application && yarn build)" - name: "Output PHP version for Symfony CLI" run: "php -v | head -n 1 | awk '{ print $2 }' > .php-version" - + - name: "Install certificates" run: "symfony server:ca:install" - + - name: "Run Chrome Headless" 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='*' http://127.0.0.1 > /dev/null 2>&1 &" - + - name: "Wait for Chrome to start" run: | until curl -s http://127.0.0.1:9222/json/version | grep "Browser" > /dev/null 2>&1 @@ -282,7 +287,7 @@ jobs: - name: "Run webserver" run: "(cd tests/Application && symfony server:start --port=8080 --dir=public --daemon)" - + - name: "Wait for webserver to start" run: | until symfony server:list | grep /public > /dev/null 2>&1 @@ -294,29 +299,63 @@ jobs: run: "vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun" - name: "Upload Behat logs" - uses: "actions/upload-artifact@v2" + uses: "actions/upload-artifact@v4" if: "failure()" with: name: "Behat logs" path: "etc/build/" if-no-files-found: "ignore" + + mutation-tests: + name: "Mutation tests" + + runs-on: "ubuntu-latest" + + strategy: + matrix: + php-version: + - "8.2" + + dependencies: + - "highest" + + steps: + - name: "Checkout" + uses: "actions/checkout@v4" + - name: "Setup PHP, with composer and extensions" + uses: "shivammathur/setup-php@v2" + with: + coverage: "pcov" + extensions: "${{ env.PHP_EXTENSIONS }}" + php-version: "${{ matrix.php-version }}" + + - name: "Install composer dependencies" + uses: "ramsey/composer-install@v3" + with: + dependency-versions: "${{ matrix.dependencies }}" + + - name: "Run infection" + run: "vendor/bin/infection" + env: + STRYKER_DASHBOARD_API_KEY: "${{ secrets.STRYKER_DASHBOARD_API_KEY }}" + code-coverage: - name: "Code Coverage" + name: "Code Coverage (PHP${{ matrix.php-version }} | Deps: ${{ matrix.dependencies }})" runs-on: "ubuntu-latest" strategy: matrix: php-version: - - "8.1" + - "8.2" dependencies: - "highest" steps: - name: "Checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "Setup PHP, with composer and extensions" uses: "shivammathur/setup-php@v2" @@ -329,7 +368,7 @@ jobs: run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\"" - name: "Install composer dependencies" - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@v3" with: dependency-versions: "${{ matrix.dependencies }}" @@ -337,6 +376,6 @@ jobs: run: "vendor/bin/phpunit --coverage-clover=.build/logs/clover.xml" - name: "Send code coverage report to Codecov.io" - env: - CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}" - run: "bash <(curl -s https://codecov.io/bash)" + uses: "codecov/codecov-action@v3" + with: + token: "${{ secrets.CODECOV_TOKEN }}" diff --git a/.gitignore b/.gitignore index d96511f..2efe830 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.build/ /vendor/ /node_modules/ /composer.lock @@ -10,3 +11,7 @@ /behat.yml /phpspec.yml /.phpunit.result.cache + +# Symfony CLI https://symfony.com/doc/current/setup/symfony_server.html#different-php-settings-per-project +/.php-version +/php.ini diff --git a/LICENSE b/LICENSE index dc9924d..ddee45d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Setono +Copyright (c) 2024 Setono Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/behat.yml.dist b/behat.yml.dist index 1226fa0..cc4a4e6 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -46,7 +46,7 @@ default: FriendsOfBehat\SymfonyExtension: bootstrap: tests/Application/config/bootstrap.php kernel: - class: Tests\Setono\SyliusPickupPointPlugin\Application\Kernel + class: Setono\SyliusPickupPointPlugin\Tests\Application\Kernel FriendsOfBehat\VariadicExtension: ~ diff --git a/composer.json b/composer.json index 4cae2f8..cfa5aa0 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "sylius-plugin" ], "require": { - "php": ">=7.4", + "php": ">=8.1", "ext-mbstring": "*", "behat/transliterator": "^1.5", "doctrine/event-manager": "^1.2", @@ -33,35 +33,39 @@ "webmozart/assert": "^1.11" }, "require-dev": { - "api-platform/core": "^2.7", + "api-platform/core": "^2.7.16", + "babdev/pagerfanta-bundle": "^3.8", + "behat/behat": "^3.14", + "doctrine/doctrine-bundle": "^2.11", "fakerphp/faker": "^1.21", - "friendsofsymfony/oauth-server-bundle": ">2.0.0-alpha.0 ^2.0@dev", + "jms/serializer-bundle": "^4.2", "kriswallsmith/buzz": "^1.2", - "lexik/jwt-authentication-bundle": "^2.16", - "matthiasnoback/symfony-dependency-injection-test": "^4.3", + "lexik/jwt-authentication-bundle": "^2.17", + "matthiasnoback/symfony-config-test": "^4.3 || ^5.1", + "matthiasnoback/symfony-dependency-injection-test": "^4.3 || ^5.1", "nyholm/psr7": "^1.5", "phpspec/phpspec": "^7.3", "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5", - "psalm/plugin-phpunit": "^0.18", + "phpunit/phpunit": "^9.6.17", + "polishsymfonycommunity/symfony-mocker-container": "^1.0.7", + "psalm/plugin-phpunit": "^0.18.4", "psalm/plugin-symfony": "^5.0", - "roave/security-advisories": "dev-latest", "setono/budbee-bundle": "^1.0", - "setono/code-quality-pack": "^2.4", + "setono/code-quality-pack": "^2.7", "setono/coolrunner-bundle": "^1.0", "setono/dao-bundle": "^1.1", "setono/gls-webservice-bundle": "^1.3", - "setono/post-nord-bundle": "^1.2", + "setono/post-nord-bundle": "^1.0", "setono/sylius-behat-pack": "^0.2", - "sylius/admin-api-bundle": "^1.11", - "sylius/sylius": "~1.10.14", - "symfony/debug-bundle": "^5.4 || ^6.0", - "symfony/dotenv": "^5.4 || ^6.0", - "symfony/property-info": "^5.4 || ^6.0", - "symfony/serializer": "^5.4 || ^6.0", - "symfony/web-profiler-bundle": "^5.4 || ^6.0", - "symfony/webpack-encore-bundle": "^1.15", - "weirdan/doctrine-psalm-plugin": "^2.8" + "sylius/sylius": "~1.12.13", + "symfony/debug-bundle": "^5.4 || ^6.4", + "symfony/dotenv": "^5.4 || ^6.4", + "symfony/property-info": "^5.4 || ^6.4", + "symfony/serializer": "^5.4 || ^6.4", + "symfony/web-profiler-bundle": "^5.4 || ^6.4", + "symfony/webpack-encore-bundle": "^1.17.2", + "weirdan/doctrine-psalm-plugin": "^2.8", + "willdurand/negotiation": "^3.1" }, "suggest": { "setono/coolrunner-bundle": "Install this bundle to use the CoolRunner provider", @@ -77,7 +81,7 @@ }, "autoload-dev": { "psr-4": { - "Tests\\Setono\\SyliusPickupPointPlugin\\": "tests/" + "Setono\\SyliusPickupPointPlugin\\Tests\\": "tests/" }, "classmap": [ "tests/Application/Kernel.php" @@ -93,10 +97,7 @@ "sort-packages": true }, "scripts": { - "analyse": [ - "@ensure-test-container-exists", - "psalm" - ], + "analyse": "psalm", "behat": "php -d memory_limit=-1 vendor/bin/behat --no-interaction --format=progress", "check-style": "ecs check", "checks": [ @@ -105,7 +106,6 @@ "@check-style", "@analyse" ], - "ensure-test-container-exists": "[[ -f tests/Application/var/cache/test/ApplicationTests_Setono_SyliusPickupPointPlugin_Application_KernelTestDebugContainer.xml ]] || tests/Application/bin/console cache:warmup --env=test", "fix-style": "ecs check --fix", "fixtures": "(cd tests/Application && bin/console sylius:fixtures:load --no-interaction -e ${SYMFONY_ENV:-'dev'})", "phpspec": "phpspec run", diff --git a/ecs.php b/ecs.php index 4e03a58..6e01c25 100644 --- a/ecs.php +++ b/ecs.php @@ -2,16 +2,16 @@ 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 $config): void { +return static function (ECSConfig $config): void { $config->import('vendor/sylius-labs/coding-standard/ecs.php'); - $config->parameters()->set(Option::PATHS, [ + $config->paths([ 'src', - 'tests' + 'tests', ]); - $config->parameters()->set(Option::SKIP, [ - 'tests/Application/**', + $config->skip([ + 'tests/Application/node_modules/**', + 'tests/Application/var/**', ]); }; diff --git a/infection.json.dist b/infection.json.dist new file mode 100644 index 0000000..f5c9da9 --- /dev/null +++ b/infection.json.dist @@ -0,0 +1,16 @@ +{ + "source": { + "directories": [ + "src" + ] + }, + "logs": { + "text": "php://stderr", + "github": true, + "stryker": { + "badge": "1.12.x" + } + }, + "minMsi": 100.00, + "minCoveredMsi": 100.00 +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 6dabf75..e3d4405 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ + bootstrap="tests/Application/config/bootstrap.php"> src/ diff --git a/psalm-baseline.xml b/psalm-baseline.xml deleted file mode 100644 index 683bdd7..0000000 --- a/psalm-baseline.xml +++ /dev/null @@ -1,236 +0,0 @@ - - - - - $provider - - - $io - - - - - get - - - - - get - get - - - $request->get('_csrf_token') - - - $pickupPoints instanceof Generator - - - - - $attributes['code'] - $attributes['code'] - $attributes['label'] - - - $typeToLabelMap[$attributes['code']] - - - $attributes - $typeToLabelMap[$attributes['code']] - - - - - $cacheEnabled - $config['cache']['pool'] - $config['driver'] - $config['local'] - $config['resources'] - - - $config['cache']['enabled'] - $config['cache']['pool'] - $config['cache']['pool'] - $config['providers']['budbee'] - $config['providers']['coolrunner'] - $config['providers']['dao'] - $config['providers']['faker'] - $config['providers']['gls'] - $config['providers']['post_nord'] - - - $cacheEnabled - - - - - ?PickupPointInterface - - - $this->createQueryBuilder('o') - ->andWhere('o.code.id = :codeId') - ->andWhere('o.code.provider = :codeProvider') - ->andWhere('o.code.country = :codeCountry') - ->setParameters([ - 'codeId' => $code->getIdPart(), - 'codeProvider' => $code->getProviderPart(), - 'codeCountry' => $code->getCountryPart(), - ]) - ->getQuery() - ->getOneOrNullResult() - - - - - $options['pickup_point_provider'] - - - - - end - - - - - $value - - - - - $key - $value - - - $key - $value - - - - - $pickupPoint->getAddress() - $pickupPoint->getCity() - $pickupPoint->getCountry() - $pickupPoint->getName() - $pickupPoint->getZipCode() - - - - - $id - - - $this->getAddress() - $this->getCity() - $this->getZipCode() - - - - - $order->getNumber() - $pickupPoint->getCode() - - - $pickupPoints instanceof Generator - - - - - $item - - - $item - - - - - $pickupPoint - $servicePoint['adresse'] - $servicePoint['bynavn'] - $servicePoint['navn'] - $servicePoint['postnr'] - - - $pickupPoint - - - - - $pickupPoint - - - PickupPoint - - - - - $countryCode - - - $countryCode - - - - - $servicePoint - $servicePoint - $servicePoint['name'] - $servicePoint['visitingAddress']['city'] - $servicePoint['visitingAddress']['countryCode'] - $servicePoints[0] - - - $servicePoint['coordinates'][0]['easting'] - $servicePoint['coordinates'][0]['northing'] - $servicePoint['visitingAddress']['city'] - $servicePoint['visitingAddress']['countryCode'] - $servicePoint['visitingAddress']['countryCode'] - $servicePoint['visitingAddress']['postalCode'] - $servicePoint['visitingAddress']['streetName'] - $servicePoint['visitingAddress']['streetNumber'] - - - $servicePoint - $servicePoint - - - $servicePoint['visitingAddress']['streetName'] - $servicePoint['visitingAddress']['streetNumber'] - - - - - [ - $this->findPickupPoint(new PickupPointCode('', '', '')), - ] - [ - $this->findPickupPoint(new PickupPointCode('', '', '')), - ] - - - iterable - iterable - - - - - [ - $this->findPickupPoint(new PickupPointCode('', '', '')), - ] - [ - $this->findPickupPoint(new PickupPointCode('', '', '')), - ] - - - iterable - iterable - - - - - getFirstElementOfIterable - - - $elm - - - diff --git a/psalm.xml b/psalm.xml index c49c0e7..3529aca 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,10 +1,14 @@ @@ -15,25 +19,21 @@ - - - tests/Application/var/cache/test/ApplicationTests_Setono_SyliusPickupPointPlugin_Application_KernelTestDebugContainer.xml - - - tests/Application/var/cache/test/Tests_Setono_SyliusPickupPointPlugin_Application_KernelTestDebugContainer.xml - + + + - + diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..af10a30 --- /dev/null +++ b/rector.php @@ -0,0 +1,25 @@ +cacheClass(FileCacheStorage::class); + $rectorConfig->cacheDirectory('./.build/rector'); + + $rectorConfig->paths([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]); + + $rectorConfig->skip([ + __DIR__ . '/tests/Application', + ]); + + $rectorConfig->sets([ + LevelSetList::UP_TO_PHP_81 + ]); +}; diff --git a/src/Controller/Action/PickupPointByIdAction.php b/src/Controller/Action/PickupPointByIdAction.php index b9e1356..b22d36d 100644 --- a/src/Controller/Action/PickupPointByIdAction.php +++ b/src/Controller/Action/PickupPointByIdAction.php @@ -20,7 +20,7 @@ final class PickupPointByIdAction public function __construct( ViewHandlerInterface $viewHandler, - DataTransformerInterface $pickupPointToIdentifierTransformer + DataTransformerInterface $pickupPointToIdentifierTransformer, ) { $this->viewHandler = $viewHandler; $this->pickupPointToIdentifierTransformer = $pickupPointToIdentifierTransformer; diff --git a/src/Controller/Action/PickupPointsSearchByCartAddressAction.php b/src/Controller/Action/PickupPointsSearchByCartAddressAction.php index 2ffdf03..9d58fb7 100644 --- a/src/Controller/Action/PickupPointsSearchByCartAddressAction.php +++ b/src/Controller/Action/PickupPointsSearchByCartAddressAction.php @@ -33,7 +33,7 @@ public function __construct( ViewHandlerInterface $viewHandler, CartContextInterface $cartContext, CsrfTokenManagerInterface $csrfTokenManager, - ServiceRegistryInterface $providerRegistry + ServiceRegistryInterface $providerRegistry, ) { $this->viewHandler = $viewHandler; $this->cartContext = $cartContext; @@ -59,7 +59,7 @@ public function __invoke(Request $request): Response throw new NotFoundHttpException(sprintf( 'Provider \'%s\' not recognized. Expecting one of: %s', $providerCode, - implode(', ', array_keys($this->providerRegistry->all())) + implode(', ', array_keys($this->providerRegistry->all())), )); } diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 5752160..3e46a4d 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -24,6 +24,8 @@ final class Configuration implements ConfigurationInterface public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('setono_sylius_pickup_point'); + + /** @var ArrayNodeDefinition $rootNode */ $rootNode = $treeBuilder->getRootNode(); /** @psalm-suppress MixedMethodCall,PossiblyUndefinedMethod,PossiblyNullReference */ @@ -72,7 +74,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->booleanNode('post_nord') ->info('Whether to enable the PostNord provider') ->defaultValue(class_exists(SetonoPostNordBundle::class)) - ; + ; $this->addResourcesSection($rootNode); diff --git a/src/Form/DataTransformer/PickupPointToIdentifierTransformer.php b/src/Form/DataTransformer/PickupPointToIdentifierTransformer.php index b6cef33..6b551d1 100644 --- a/src/Form/DataTransformer/PickupPointToIdentifierTransformer.php +++ b/src/Form/DataTransformer/PickupPointToIdentifierTransformer.php @@ -62,6 +62,7 @@ public function reverseTransform($value): ?PickupPointInterface * * @param mixed $value * @param class-string $expectedType + * * @psalm-assert ExpectedType $value */ private function assertTransformationValueType($value, string $expectedType): void @@ -71,8 +72,8 @@ private function assertTransformationValueType($value, string $expectedType): vo sprintf( 'Expected "%s", but got "%s"', $expectedType, - is_object($value) ? get_class($value) : gettype($value) - ) + is_object($value) ? get_class($value) : gettype($value), + ), ); } } diff --git a/src/Form/Extension/ShippingMethodChoiceTypeExtension.php b/src/Form/Extension/ShippingMethodChoiceTypeExtension.php index e72d921..876ccae 100644 --- a/src/Form/Extension/ShippingMethodChoiceTypeExtension.php +++ b/src/Form/Extension/ShippingMethodChoiceTypeExtension.php @@ -28,7 +28,7 @@ public function __construct( ServiceRegistryInterface $providerRegistry, RouterInterface $router, CartContextInterface $cartContext, - CsrfTokenManagerInterface $csrfTokenManager + CsrfTokenManagerInterface $csrfTokenManager, ) { $this->providerRegistry = $providerRegistry; $this->router = $router; diff --git a/src/Message/Handler/LoadPickupPointsHandler.php b/src/Message/Handler/LoadPickupPointsHandler.php index e260293..55ce51d 100644 --- a/src/Message/Handler/LoadPickupPointsHandler.php +++ b/src/Message/Handler/LoadPickupPointsHandler.php @@ -23,7 +23,7 @@ final class LoadPickupPointsHandler implements MessageHandlerInterface public function __construct( ServiceRegistryInterface $providerRegistry, PickupPointRepositoryInterface $pickupPointRepository, - EntityManagerInterface $pickupPointManager + EntityManagerInterface $pickupPointManager, ) { $this->providerRegistry = $providerRegistry; $this->pickupPointRepository = $pickupPointRepository; diff --git a/src/Model/PickupPoint.php b/src/Model/PickupPoint.php index 0153e4f..1a6ea6b 100644 --- a/src/Model/PickupPoint.php +++ b/src/Model/PickupPoint.php @@ -122,7 +122,7 @@ public function getFullAddress(): string '%s, %s %s', $this->getAddress(), $this->getZipCode(), - $this->getCity() + $this->getCity(), ); } } diff --git a/src/Provider/BudbeeProvider.php b/src/Provider/BudbeeProvider.php index 0dca5ee..3c3d536 100644 --- a/src/Provider/BudbeeProvider.php +++ b/src/Provider/BudbeeProvider.php @@ -44,7 +44,7 @@ public function findPickupPoints(OrderInterface $order): iterable try { $boxes = $this->client->boxes()->getAvailableLockers( $countryCode, - $postCode + $postCode, ); } catch (\Throwable $e) { throw new TimeoutException($e); @@ -97,7 +97,7 @@ private function transform(Box $box): PickupPointInterface $pickupPoint->setCode(new PickupPointCode( $box->id, $this->getCode(), - $box->address->country + $box->address->country, )); $pickupPoint->setName($box->name); $pickupPoint->setAddress($box->address->street); diff --git a/src/Provider/CachedProvider.php b/src/Provider/CachedProvider.php index 4bb681f..340266c 100644 --- a/src/Provider/CachedProvider.php +++ b/src/Provider/CachedProvider.php @@ -99,7 +99,7 @@ private function buildOrderCacheKey(OrderInterface $order): string if (!$shippingAddress instanceof AddressInterface) { throw new RuntimeException(sprintf( 'Shipping address was not found for order #%s', - $order->getNumber() + $order->getNumber(), )); } @@ -119,7 +119,7 @@ private function buildOrderCacheKey(OrderInterface $order): string $this->getCode(), Transliterator::transliterate($countryCode), Transliterator::transliterate($postCode), - Transliterator::transliterate($street) + Transliterator::transliterate($street), ); } diff --git a/src/Provider/CoolRunnerProvider.php b/src/Provider/CoolRunnerProvider.php index 1fa3ed5..65a5e85 100644 --- a/src/Provider/CoolRunnerProvider.php +++ b/src/Provider/CoolRunnerProvider.php @@ -50,7 +50,7 @@ public function findPickupPoints(OrderInterface $order): iterable $countryCode, $street, $postCode, - $city + $city, ); } catch (\Throwable $e) { throw new TimeoutException($e); @@ -103,7 +103,7 @@ private function transform(Servicepoint $servicepoint): PickupPointInterface $pickupPoint->setCode(new PickupPointCode( $servicepoint->id, $this->getCode(), - $servicepoint->address->countryCode + $servicepoint->address->countryCode, )); $pickupPoint->setName($servicepoint->name); $pickupPoint->setAddress($servicepoint->address->street); diff --git a/src/Provider/GlsProvider.php b/src/Provider/GlsProvider.php index 9f4f4df..1c14d37 100644 --- a/src/Provider/GlsProvider.php +++ b/src/Provider/GlsProvider.php @@ -28,7 +28,7 @@ final class GlsProvider extends Provider public function __construct( ClientInterface $client, FactoryInterface $pickupPointFactory, - array $countryCodes = ['DK', 'SE'] + array $countryCodes = ['DK', 'SE'], ) { $this->client = $client; $this->pickupPointFactory = $pickupPointFactory; @@ -54,7 +54,7 @@ public function findPickupPoints(OrderInterface $order): iterable $street, preg_replace('/\s+/', '', $postCode), $countryCode, - 10 + 10, ); } catch (ConnectionException $e) { throw new TimeoutException($e); diff --git a/src/Provider/PostNordProvider.php b/src/Provider/PostNordProvider.php index e7a0979..bd8cda2 100644 --- a/src/Provider/PostNordProvider.php +++ b/src/Provider/PostNordProvider.php @@ -123,7 +123,7 @@ private function transform(array $servicePoint): PickupPointInterface $id = new PickupPointCode( $servicePoint['servicePointId'], $this->getCode(), - $servicePoint['visitingAddress']['countryCode'] + $servicePoint['visitingAddress']['countryCode'], ); $address = ''; diff --git a/src/Provider/ProviderInterface.php b/src/Provider/ProviderInterface.php index 5e2e13e..2858123 100644 --- a/src/Provider/ProviderInterface.php +++ b/src/Provider/ProviderInterface.php @@ -34,7 +34,7 @@ public function findPickupPoint(PickupPointCode $code): ?PickupPointInterface; /** * Returns all pickup points for this provider * - * @return iterable|PickupPointInterface[] + * @return iterable */ public function findAllPickupPoints(): iterable; } diff --git a/tests/Application/.env b/tests/Application/.env index 6fc56c3..15b087f 100644 --- a/tests/Application/.env +++ b/tests/Application/.env @@ -1,5 +1,16 @@ -# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file -# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production. +# In all environments, the following files are loaded if they exist, +# the later taking precedence over the former: +# +# * .env contains default values for the environment variables needed by the app +# * .env.local uncommitted file with local overrides +# * .env.$APP_ENV committed environment-specific defaults +# * .env.$APP_ENV.local uncommitted environment-specific overrides +# +# Real environment variables win over .env files. +# +# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES. +# +# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2). # https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration ###> symfony/framework-bundle ### @@ -9,7 +20,7 @@ APP_SECRET=EDITME ###< symfony/framework-bundle ### ###> doctrine/doctrine-bundle ### -# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url +# Format described at https://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url # For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db" # Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls DATABASE_URL=mysql://root@127.0.0.1/setono_sylius_pickup_point_%kernel.environment%?serverVersion=5.7 @@ -21,11 +32,18 @@ JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem JWT_PASSPHRASE=acme_plugin_development ###< lexik/jwt-authentication-bundle ### +###> symfony/messenger ### +# Choose one of the transports below +# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages +MESSENGER_TRANSPORT_DSN=doctrine://default +# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages +###< symfony/messenger ### + ###> symfony/swiftmailer-bundle ### # For Gmail as a transport, use: "gmail://username:password@localhost" # For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" # Delivery is disabled by default via "null://localhost" -MAILER_URL=smtp://localhost +MAILER_DSN=null://localhost ###< symfony/swiftmailer-bundle ### ###> setono/dao-bundle ### diff --git a/tests/Application/.env.test b/tests/Application/.env.test index 97a9d54..8732cab 100644 --- a/tests/Application/.env.test +++ b/tests/Application/.env.test @@ -1,2 +1,3 @@ APP_SECRET='ch4mb3r0f5ecr3ts' -KERNEL_CLASS='Tests\Setono\SyliusPickupPointPlugin\Application\Kernel' + +KERNEL_CLASS='Setono\SyliusPickupPointPlugin\Tests\Application\Kernel' diff --git a/tests/Application/.eslintrc.js b/tests/Application/.eslintrc.js index 92c4cee..dfddb25 100644 --- a/tests/Application/.eslintrc.js +++ b/tests/Application/.eslintrc.js @@ -1,20 +1,20 @@ module.exports = { - extends: 'airbnb-base', - env: { - node: true, - }, - rules: { - 'object-shorthand': ['error', 'always', { - avoidQuotes: true, - avoidExplicitReturnArrows: true, - }], - 'function-paren-newline': ['error', 'consistent'], - 'max-len': ['warn', 120, 2, { - ignoreUrls: true, - ignoreComments: false, - ignoreRegExpLiterals: true, - ignoreStrings: true, - ignoreTemplateLiterals: true, - }], - }, + extends: 'airbnb-base', + env: { + node: true, + }, + rules: { + 'object-shorthand': ['error', 'always', { + avoidQuotes: true, + avoidExplicitReturnArrows: true, + }], + 'function-paren-newline': ['error', 'consistent'], + 'max-len': ['warn', 120, 2, { + ignoreUrls: true, + ignoreComments: false, + ignoreRegExpLiterals: true, + ignoreStrings: true, + ignoreTemplateLiterals: true, + }], + }, }; diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index 35279bf..da0de16 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -2,16 +2,13 @@ declare(strict_types=1); -namespace Tests\Setono\SyliusPickupPointPlugin\Application; +namespace Setono\SyliusPickupPointPlugin\Tests\Application; -use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; -use Symfony\Component\Routing\RouteCollectionBuilder; +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; +use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; final class Kernel extends BaseKernel { @@ -32,59 +29,37 @@ public function getLogDir(): string public function registerBundles(): iterable { foreach ($this->getConfigurationDirectories() as $confDir) { - yield from $this->registerBundlesFromFile($confDir . '/bundles.php'); - } - } - - protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void - { - foreach ($this->getConfigurationDirectories() as $confDir) { - $container->addResource(new FileResource($confDir . '/bundles.php')); - } - - $container->setParameter('container.dumper.inline_class_loader', true); - - foreach ($this->getConfigurationDirectories() as $confDir) { - $this->loadContainerConfiguration($loader, $confDir); + $bundlesFile = $confDir . '/bundles.php'; + if (false === is_file($bundlesFile)) { + continue; + } + yield from $this->registerBundlesFromFile($bundlesFile); } } - protected function configureRoutes(RouteCollectionBuilder $routes): void + protected function configureRoutes(RoutingConfigurator $routes): void { foreach ($this->getConfigurationDirectories() as $confDir) { $this->loadRoutesConfiguration($routes, $confDir); } } - private function isTestEnvironment(): bool - { - return 0 === strpos($this->getEnvironment(), 'test'); - } - - private function loadContainerConfiguration(LoaderInterface $loader, string $confDir): void - { - $loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); - } - - private function loadRoutesConfiguration(RouteCollectionBuilder $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'); - } - protected function getContainerBaseClass(): string { - if ($this->isTestEnvironment()) { + if (str_contains($this->environment, 'test')) { return MockerContainer::class; } return parent::getContainerBaseClass(); } + private function loadRoutesConfiguration(RoutingConfigurator $routes, string $confDir): void + { + $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS); + $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS); + $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS); + } + /** * @return BundleInterface[] */ diff --git a/tests/Application/Model/Shipment.php b/tests/Application/Model/Shipment.php index 820577a..e5c29d5 100644 --- a/tests/Application/Model/Shipment.php +++ b/tests/Application/Model/Shipment.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Setono\SyliusPickupPointPlugin\Application\Model; +namespace Setono\SyliusPickupPointPlugin\Tests\Application\Model; use Doctrine\ORM\Mapping as ORM; use Setono\SyliusPickupPointPlugin\Model\PickupPointAwareTrait; @@ -11,6 +11,7 @@ /** * @ORM\Entity() + * * @ORM\Table(name="sylius_shipment") */ class Shipment extends BaseShipment implements ShipmentInterface diff --git a/tests/Application/Model/ShippingMethod.php b/tests/Application/Model/ShippingMethod.php index 30d6bf9..f379eca 100644 --- a/tests/Application/Model/ShippingMethod.php +++ b/tests/Application/Model/ShippingMethod.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Setono\SyliusPickupPointPlugin\Application\Model; +namespace Setono\SyliusPickupPointPlugin\Tests\Application\Model; use Doctrine\ORM\Mapping as ORM; use Setono\SyliusPickupPointPlugin\Model\PickupPointProviderAwareTrait; @@ -11,6 +11,7 @@ /** * @ORM\Entity() + * * @ORM\Table(name="sylius_shipping_method") */ class ShippingMethod extends BaseShippingMethod implements ShippingMethodInterface diff --git a/tests/Application/bin/console b/tests/Application/bin/console index 4b84e03..e6207c5 100755 --- a/tests/Application/bin/console +++ b/tests/Application/bin/console @@ -1,7 +1,7 @@ #!/usr/bin/env php ['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], @@ -38,6 +37,7 @@ FOS\RestBundle\FOSRestBundle::class => ['all' => true], Knp\Bundle\GaufretteBundle\KnpGaufretteBundle::class => ['all' => true], Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true], + League\FlysystemBundle\FlysystemBundle::class => ['all' => true], Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true], Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true], Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], @@ -47,25 +47,21 @@ Sylius\Bundle\ThemeBundle\SyliusThemeBundle::class => ['all' => true], Sylius\Bundle\AdminBundle\SyliusAdminBundle::class => ['all' => true], Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true], - FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true], - Sylius\Bundle\AdminApiBundle\SyliusAdminApiBundle::class => ['all' => true], Setono\SyliusPickupPointPlugin\SetonoSyliusPickupPointPlugin::class => ['all' => true], - Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], - Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], + Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true], + Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true], SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], - FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => [ - 'test' => true, - 'test_cached' => true - ], + FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true], Setono\GlsWebserviceBundle\SetonoGlsWebserviceBundle::class => ['all' => true], Setono\PostNordBundle\SetonoPostNordBundle::class => ['all' => true], Setono\DAOBundle\SetonoDAOBundle::class => ['all' => true], Setono\CoolRunnerBundle\SetonoCoolRunnerBundle::class => ['all' => true], Setono\BudbeeBundle\SetonoBudbeeBundle::class => ['all' => true], Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], + Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], ]; diff --git a/tests/Application/config/packages/_sylius.yaml b/tests/Application/config/packages/_sylius.yaml index d4d11f0..2f6645c 100644 --- a/tests/Application/config/packages/_sylius.yaml +++ b/tests/Application/config/packages/_sylius.yaml @@ -1,7 +1,6 @@ imports: - { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" } - { resource: "@SyliusAdminBundle/Resources/config/app/config.yml" } - - { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" } - { resource: "@SyliusShopBundle/Resources/config/app/config.yml" } - { resource: "@SyliusApiBundle/Resources/config/app/config.yaml" } @@ -19,7 +18,7 @@ sylius_shipping: resources: shipment: classes: - model: Tests\Setono\SyliusPickupPointPlugin\Application\Model\Shipment + model: Setono\SyliusPickupPointPlugin\Tests\Application\Model\Shipment shipping_method: classes: - model: Tests\Setono\SyliusPickupPointPlugin\Application\Model\ShippingMethod + model: Setono\SyliusPickupPointPlugin\Tests\Application\Model\ShippingMethod diff --git a/tests/Application/config/packages/dev/swiftmailer.yaml b/tests/Application/config/packages/dev/swiftmailer.yaml deleted file mode 100644 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/doctrine.yaml b/tests/Application/config/packages/doctrine.yaml index c1f3dcf..66aa54d 100644 --- a/tests/Application/config/packages/doctrine.yaml +++ b/tests/Application/config/packages/doctrine.yaml @@ -21,5 +21,5 @@ doctrine: is_bundle: false type: annotation dir: '%kernel.project_dir%/Model' - prefix: 'Tests\Setono\SyliusPickupPointPlugin\Application\Model' + prefix: 'Setono\SyliusPickupPointPlugin\Tests\Application\Model' alias: App diff --git a/tests/Application/config/packages/framework.yaml b/tests/Application/config/packages/framework.yaml index bd82dd9..3df2c0a 100644 --- a/tests/Application/config/packages/framework.yaml +++ b/tests/Application/config/packages/framework.yaml @@ -1,10 +1,9 @@ framework: - csrf_protection: true - form: true - ide: phpstorm secret: '%env(APP_SECRET)%' + ide: phpstorm + form: + enabled: true + legacy_error_messages: false + csrf_protection: true session: handler_id: ~ - serializer: - mapping: - paths: [ '%kernel.project_dir%/config/serialization' ] diff --git a/tests/Application/config/packages/mailer.yaml b/tests/Application/config/packages/mailer.yaml new file mode 100644 index 0000000..56a650d --- /dev/null +++ b/tests/Application/config/packages/mailer.yaml @@ -0,0 +1,3 @@ +framework: + mailer: + dsn: '%env(MAILER_DSN)%' diff --git a/tests/Application/config/packages/security.yaml b/tests/Application/config/packages/security.yaml index 51a6ec9..2f5c687 100644 --- a/tests/Application/config/packages/security.yaml +++ b/tests/Application/config/packages/security.yaml @@ -1,17 +1,5 @@ -parameters: - sylius.security.admin_regex: "^/%sylius_admin.path_name%" - sylius.security.shop_regex: "^/(?!%sylius_admin.path_name%|api/.*|api$|media/.*)[^/]++" - sylius.security.new_api_route: "/api/v2" - 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%" - sylius.security.new_api_user_account_route: "%sylius.security.new_api_shop_route%/account" - sylius.security.new_api_user_account_regex: "^%sylius.security.new_api_user_account_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 @@ -22,7 +10,7 @@ security: sylius_api_shop_user_provider: id: sylius.shop_user_provider.email_or_name_based - encoders: + password_hashers: Sylius\Component\User\Model\UserInterface: argon2i firewalls: admin: @@ -38,7 +26,7 @@ security: default_target_path: sylius_admin_dashboard use_forward: false use_referer: true - csrf_token_generator: security.csrf.token_manager + enable_csrf: true csrf_parameter: _csrf_admin_security_token csrf_token_id: admin_authenticate remember_me: @@ -50,37 +38,32 @@ security: logout: path: sylius_admin_logout target: sylius_admin_login - anonymous: true new_api_admin_user: 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_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_shop_regex%/.*" provider: sylius_api_shop_user_provider stateless: true - anonymous: 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 - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator + jwt: true shop: switch_user: { role: ROLE_ALLOWED_TO_SWITCH } @@ -97,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: @@ -107,36 +90,33 @@ 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)/ - security: false - - image_resolver: - pattern: ^/media/cache/resolve + 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: 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.admin_regex%/forgotten-password", role: PUBLIC_ACCESS } + + - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } - - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { 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: IS_AUTHENTICATED_ANONYMOUSLY } + - { 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: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { 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/packages/staging/monolog.yaml b/tests/Application/config/packages/staging/monolog.yaml deleted file mode 100644 index 6461211..0000000 --- a/tests/Application/config/packages/staging/monolog.yaml +++ /dev/null @@ -1,10 +0,0 @@ -monolog: - handlers: - main: - type: fingers_crossed - action_level: error - handler: nested - nested: - type: stream - path: "%kernel.logs_dir%/%kernel.environment%.log" - level: debug diff --git a/tests/Application/config/packages/staging/swiftmailer.yaml b/tests/Application/config/packages/staging/swiftmailer.yaml deleted file mode 100644 index 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 100644 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/framework.yaml b/tests/Application/config/packages/test/framework.yaml index 76d7e5e..fc1d3c1 100644 --- a/tests/Application/config/packages/test/framework.yaml +++ b/tests/Application/config/packages/test/framework.yaml @@ -1,4 +1,4 @@ framework: test: ~ session: - storage_id: session.storage.mock_file + storage_factory_id: session.storage.factory.mock_file diff --git a/tests/Application/config/packages/test/security.yaml b/tests/Application/config/packages/test/security.yaml index 21cc377..4071d31 100644 --- a/tests/Application/config/packages/test/security.yaml +++ b/tests/Application/config/packages/test/security.yaml @@ -1,3 +1,6 @@ security: - encoders: - sha512: sha512 + password_hashers: + Sylius\Component\User\Model\UserInterface: + algorithm: argon2i + time_cost: 3 + memory_cost: 10 diff --git a/tests/Application/config/packages/test/swiftmailer.yaml b/tests/Application/config/packages/test/swiftmailer.yaml deleted file mode 100644 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/doctrine.yaml b/tests/Application/config/packages/test_cached/doctrine.yaml deleted file mode 100644 index 4952860..0000000 --- a/tests/Application/config/packages/test_cached/doctrine.yaml +++ /dev/null @@ -1,16 +0,0 @@ -doctrine: - orm: - entity_managers: - default: - result_cache_driver: - type: memcached - host: localhost - port: 11211 - query_cache_driver: - type: memcached - host: localhost - port: 11211 - metadata_cache_driver: - type: memcached - host: localhost - port: 11211 diff --git a/tests/Application/config/packages/test_cached/fos_rest.yaml b/tests/Application/config/packages/test_cached/fos_rest.yaml deleted file mode 100644 index 2b4189d..0000000 --- a/tests/Application/config/packages/test_cached/fos_rest.yaml +++ /dev/null @@ -1,3 +0,0 @@ -fos_rest: - exception: - debug: true diff --git a/tests/Application/config/packages/test_cached/framework.yaml b/tests/Application/config/packages/test_cached/framework.yaml deleted file mode 100644 index 76d7e5e..0000000 --- a/tests/Application/config/packages/test_cached/framework.yaml +++ /dev/null @@ -1,4 +0,0 @@ -framework: - test: ~ - session: - storage_id: session.storage.mock_file diff --git a/tests/Application/config/packages/test_cached/monolog.yaml b/tests/Application/config/packages/test_cached/monolog.yaml deleted file mode 100644 index 7e2b9e3..0000000 --- a/tests/Application/config/packages/test_cached/monolog.yaml +++ /dev/null @@ -1,6 +0,0 @@ -monolog: - handlers: - main: - type: stream - path: "%kernel.logs_dir%/%kernel.environment%.log" - level: error 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 diff --git a/tests/Application/config/packages/test_cached/swiftmailer.yaml b/tests/Application/config/packages/test_cached/swiftmailer.yaml deleted file mode 100644 index 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/packages/test_cached/sylius_channel.yaml b/tests/Application/config/packages/test_cached/sylius_channel.yaml deleted file mode 100644 index bab83ef..0000000 --- a/tests/Application/config/packages/test_cached/sylius_channel.yaml +++ /dev/null @@ -1,2 +0,0 @@ -sylius_channel: - debug: true diff --git a/tests/Application/config/packages/test_cached/sylius_theme.yaml b/tests/Application/config/packages/test_cached/sylius_theme.yaml deleted file mode 100644 index 4d34199..0000000 --- a/tests/Application/config/packages/test_cached/sylius_theme.yaml +++ /dev/null @@ -1,3 +0,0 @@ -sylius_theme: - sources: - test: ~ diff --git a/tests/Application/config/packages/test_cached/twig.yaml b/tests/Application/config/packages/test_cached/twig.yaml deleted file mode 100644 index 8c6e0b4..0000000 --- a/tests/Application/config/packages/test_cached/twig.yaml +++ /dev/null @@ -1,2 +0,0 @@ -twig: - strict_variables: true diff --git a/tests/Application/config/routes/sylius_admin.yaml b/tests/Application/config/routes/sylius_admin.yaml index 1ba48d6..b9c12c2 100644 --- a/tests/Application/config/routes/sylius_admin.yaml +++ b/tests/Application/config/routes/sylius_admin.yaml @@ -1,3 +1,3 @@ sylius_admin: resource: "@SyliusAdminBundle/Resources/config/routing.yml" - prefix: /admin + prefix: '/%sylius_admin.path_name%' diff --git a/tests/Application/config/routes/sylius_shop.yaml b/tests/Application/config/routes/sylius_shop.yaml index 92eeae0..22e7a4a 100644 --- a/tests/Application/config/routes/sylius_shop.yaml +++ b/tests/Application/config/routes/sylius_shop.yaml @@ -11,4 +11,13 @@ sylius_shop_default_locale: path: / methods: [GET] defaults: - _controller: sylius.controller.shop.locale_switch:switchAction + _controller: sylius.controller.shop.locale_switch::switchAction + +# see https://web.dev/change-password-url/ +sylius_shop_request_password_reset_token_redirect: + path: /.well-known/change-password + methods: [GET] + controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction + defaults: + route: sylius_shop_request_password_reset_token + permanent: false diff --git a/tests/Application/package.json b/tests/Application/package.json index e990ba4..8f62c4c 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "chart.js": "^2.9", + "chart.js": "^3.9", "jquery": "^3.6", "jquery.dirtyforms": "^2.0", "lightbox2": "^2.9", diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php index 8843dff..67e8d1b 100644 --- a/tests/Application/public/index.php +++ b/tests/Application/public/index.php @@ -2,9 +2,9 @@ declare(strict_types=1); +use Setono\SyliusPickupPointPlugin\Tests\Application\Kernel; use Symfony\Component\ErrorHandler\Debug; use Symfony\Component\HttpFoundation\Request; -use Tests\Setono\SyliusPickupPointPlugin\Application\Kernel; require dirname(__DIR__) . '/config/bootstrap.php'; diff --git a/tests/Application/webpack.config.js b/tests/Application/webpack.config.js index 93c7461..fae1429 100644 --- a/tests/Application/webpack.config.js +++ b/tests/Application/webpack.config.js @@ -7,14 +7,14 @@ const uiBundleResources = path.resolve(syliusBundles, 'UiBundle/Resources/privat // 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(); + .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(); @@ -27,21 +27,21 @@ 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(); + .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.externals = Object.assign({}, adminConfig.externals, { window: 'window', document: 'document' }); adminConfig.name = 'admin'; module.exports = [shopConfig, adminConfig]; diff --git a/tests/Behat/Context/Setup/ShippingContext.php b/tests/Behat/Context/Setup/ShippingContext.php index 580cfb8..54d2dd1 100644 --- a/tests/Behat/Context/Setup/ShippingContext.php +++ b/tests/Behat/Context/Setup/ShippingContext.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Setono\SyliusPickupPointPlugin\Behat\Context\Setup; +namespace Setono\SyliusPickupPointPlugin\Tests\Behat\Context\Setup; use Behat\Behat\Context\Context; use Doctrine\ORM\EntityManagerInterface; @@ -20,7 +20,7 @@ final class ShippingContext implements Context public function __construct( ServiceRegistryInterface $providerRegistry, - EntityManagerInterface $shippingMethodEntityManager + EntityManagerInterface $shippingMethodEntityManager, ) { $this->providerRegistry = $providerRegistry; $this->shippingMethodEntityManager = $shippingMethodEntityManager; @@ -31,12 +31,12 @@ public function __construct( */ public function theShippingMethodHasTheSelectedGlsPickupPointProvider( ShippingMethodInterface $shippingMethod, - string $pickupPointProviderCode + string $pickupPointProviderCode, ): void { if (!$this->providerRegistry->has($pickupPointProviderCode)) { throw new RuntimeException(sprintf( 'PickupPoint provider with code %s was not found in registry.', - $pickupPointProviderCode + $pickupPointProviderCode, )); } $shippingMethod->setPickupPointProvider($pickupPointProviderCode); diff --git a/tests/Behat/Context/Ui/Admin/ShippingContext.php b/tests/Behat/Context/Ui/Admin/ShippingContext.php index 58e84dc..02726df 100644 --- a/tests/Behat/Context/Ui/Admin/ShippingContext.php +++ b/tests/Behat/Context/Ui/Admin/ShippingContext.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Tests\Setono\SyliusPickupPointPlugin\Behat\Context\Ui\Admin; +namespace Setono\SyliusPickupPointPlugin\Tests\Behat\Context\Ui\Admin; use Behat\Behat\Context\Context; -use Tests\Setono\SyliusPickupPointPlugin\Behat\Page\Admin\ShippingMethod\CreatePageInterface; +use Setono\SyliusPickupPointPlugin\Tests\Behat\Page\Admin\ShippingMethod\CreatePageInterface; final class ShippingContext implements Context { diff --git a/tests/Behat/Context/Ui/Shop/ShippingContext.php b/tests/Behat/Context/Ui/Shop/ShippingContext.php index d5f1d30..6c19826 100644 --- a/tests/Behat/Context/Ui/Shop/ShippingContext.php +++ b/tests/Behat/Context/Ui/Shop/ShippingContext.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace Tests\Setono\SyliusPickupPointPlugin\Behat\Context\Ui\Shop; +namespace Setono\SyliusPickupPointPlugin\Tests\Behat\Context\Ui\Shop; use Behat\Behat\Context\Context; use Setono\SyliusPickupPointPlugin\Model\PickupPointAwareInterface; +use Setono\SyliusPickupPointPlugin\Tests\Behat\Page\Shop\ShippingPickup\SelectShippingPageInterface; use Sylius\Behat\Page\Shop\Checkout\CompletePageInterface; use Sylius\Behat\Service\SharedStorageInterface; use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Resource\Repository\RepositoryInterface; -use Tests\Setono\SyliusPickupPointPlugin\Behat\Page\Shop\ShippingPickup\SelectShippingPageInterface; use Webmozart\Assert\Assert; final class ShippingContext implements Context @@ -31,7 +31,7 @@ public function __construct( SelectShippingPageInterface $selectShippingPage, CompletePageInterface $completePage, SharedStorageInterface $sharedStorage, - RepositoryInterface $orderRepository + RepositoryInterface $orderRepository, ) { $this->selectShippingPage = $selectShippingPage; $this->completePage = $completePage; diff --git a/tests/Behat/Mocker/GlsProviderMocker.php b/tests/Behat/Mocker/GlsProviderMocker.php index 6ff6cf1..036357b 100644 --- a/tests/Behat/Mocker/GlsProviderMocker.php +++ b/tests/Behat/Mocker/GlsProviderMocker.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Setono\SyliusPickupPointPlugin\Behat\Mocker; +namespace Setono\SyliusPickupPointPlugin\Tests\Behat\Mocker; use Setono\SyliusPickupPointPlugin\Model\PickupPoint; use Setono\SyliusPickupPointPlugin\Model\PickupPointCode; @@ -31,7 +31,7 @@ public function findPickupPoints(OrderInterface $order): iterable ]; } - public function findPickupPoint(PickupPointCode $code): ?PickupPointInterface + public function findPickupPoint(PickupPointCode $code): PickupPointInterface { $pickupPoint = new PickupPoint(); $pickupPoint->setCode(new PickupPointCode(self::PICKUP_POINT_ID, $this->getCode(), 'DK')); diff --git a/tests/Behat/Mocker/PostNordProviderMocker.php b/tests/Behat/Mocker/PostNordProviderMocker.php index b5ad803..2b511ce 100644 --- a/tests/Behat/Mocker/PostNordProviderMocker.php +++ b/tests/Behat/Mocker/PostNordProviderMocker.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Setono\SyliusPickupPointPlugin\Behat\Mocker; +namespace Setono\SyliusPickupPointPlugin\Tests\Behat\Mocker; use Setono\SyliusPickupPointPlugin\Model\PickupPoint; use Setono\SyliusPickupPointPlugin\Model\PickupPointCode; @@ -31,7 +31,7 @@ public function findPickupPoints(OrderInterface $order): iterable ]; } - public function findPickupPoint(PickupPointCode $code): ?PickupPointInterface + public function findPickupPoint(PickupPointCode $code): PickupPointInterface { $pickupPoint = new PickupPoint(); $pickupPoint->setCode(new PickupPointCode(self::PICKUP_POINT_ID, $this->getCode(), 'DK')); diff --git a/tests/Behat/Page/Admin/ShippingMethod/CreatePage.php b/tests/Behat/Page/Admin/ShippingMethod/CreatePage.php index 824a5dd..24dfd97 100644 --- a/tests/Behat/Page/Admin/ShippingMethod/CreatePage.php +++ b/tests/Behat/Page/Admin/ShippingMethod/CreatePage.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Setono\SyliusPickupPointPlugin\Behat\Page\Admin\ShippingMethod; +namespace Setono\SyliusPickupPointPlugin\Tests\Behat\Page\Admin\ShippingMethod; use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage; diff --git a/tests/Behat/Page/Admin/ShippingMethod/CreatePageInterface.php b/tests/Behat/Page/Admin/ShippingMethod/CreatePageInterface.php index 679e89e..80153c0 100644 --- a/tests/Behat/Page/Admin/ShippingMethod/CreatePageInterface.php +++ b/tests/Behat/Page/Admin/ShippingMethod/CreatePageInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Setono\SyliusPickupPointPlugin\Behat\Page\Admin\ShippingMethod; +namespace Setono\SyliusPickupPointPlugin\Tests\Behat\Page\Admin\ShippingMethod; use Sylius\Behat\Page\Admin\Crud\CreatePageInterface as BaseCreatePageInterface; diff --git a/tests/Behat/Page/Shop/ShippingPickup/SelectShippingPage.php b/tests/Behat/Page/Shop/ShippingPickup/SelectShippingPage.php index c87aba8..b9847f5 100644 --- a/tests/Behat/Page/Shop/ShippingPickup/SelectShippingPage.php +++ b/tests/Behat/Page/Shop/ShippingPickup/SelectShippingPage.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Setono\SyliusPickupPointPlugin\Behat\Page\Shop\ShippingPickup; +namespace Setono\SyliusPickupPointPlugin\Tests\Behat\Page\Shop\ShippingPickup; use Sylius\Behat\Page\Shop\Checkout\SelectShippingPage as BaseSelectShippingPage; use Webmozart\Assert\Assert; diff --git a/tests/Behat/Page/Shop/ShippingPickup/SelectShippingPageInterface.php b/tests/Behat/Page/Shop/ShippingPickup/SelectShippingPageInterface.php index e227167..6c5967c 100644 --- a/tests/Behat/Page/Shop/ShippingPickup/SelectShippingPageInterface.php +++ b/tests/Behat/Page/Shop/ShippingPickup/SelectShippingPageInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Setono\SyliusPickupPointPlugin\Behat\Page\Shop\ShippingPickup; +namespace Setono\SyliusPickupPointPlugin\Tests\Behat\Page\Shop\ShippingPickup; use Sylius\Behat\Page\Shop\Checkout\SelectShippingPageInterface as BaseSelectShippingPageInterface; diff --git a/tests/Behat/Resources/services.xml b/tests/Behat/Resources/services.xml index 4789807..19cb644 100644 --- a/tests/Behat/Resources/services.xml +++ b/tests/Behat/Resources/services.xml @@ -8,23 +8,23 @@ + class="Setono\SyliusPickupPointPlugin\Tests\Behat\Context\Setup\ShippingContext"> + class="Setono\SyliusPickupPointPlugin\Tests\Behat\Context\Ui\Shop\ShippingContext"> @@ -32,13 +32,13 @@ + class="Setono\SyliusPickupPointPlugin\Tests\Behat\Context\Ui\Admin\ShippingContext"> + class="Setono\SyliusPickupPointPlugin\Tests\Behat\Mocker\GlsProviderMocker"> + class="Setono\SyliusPickupPointPlugin\Tests\Behat\Mocker\PostNordProviderMocker">