diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..81d9a543 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,32 @@ +**/*.log +**/*.md +**/*.php~ +**/._* +**/.dockerignore +**/.DS_Store +**/.git/ +**/.gitattributes +**/.github +**/.gitignore +**/.gitkeep +**/.gitmodules +**/.idea +**/Dockerfile +**/Thumbs.db +**/docker-compose*.yaml +**/docker-compose*.yml +.editorconfig +.php_cs.cache +.travis.yml +composer.phar +docker/mysql/data/ +etc/build/* +node_modules/ +var/* +vendor/ +public/assets/ +public/build/ +public/bundles/ +public/css/ +public/js/ +public/media/ diff --git a/.editorconfig b/.editorconfig index 178a6505..b5f72a57 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,25 +1,82 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + root = true [*] +# Change these settings to your own preference indent_style = space indent_size = 4 +# We recommend you to keep these unchanged end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.feature] +indent_style = space +indent_size = 4 + +[*.js] +indent_style = space +indent_size = 2 + +[*.json] +indent_style = space indent_size = 2 [*.md] +indent_style = space +indent_size = 4 trim_trailing_whitespace = false +[*.neon] +indent_style = space +indent_size = 4 + +[*.php] +indent_style = space +indent_size = 4 + [*.sh] -indent_style = tab +indent_style = space +indent_size = 4 [*.{yaml,yml}] +indent_style = space +indent_size = 4 trim_trailing_whitespace = false -[{webpack.config.js,.eslintrc.js}] +[.babelrc] +indent_style = space indent_size = 2 + +[.gitmodules] +indent_style = tab +indent_size = 4 + +[.php_cs{,.dist}] +indent_style = space +indent_size = 4 + +[composer.json] +indent_style = space +indent_size = 4 + +[package.json] +indent_style = space +indent_size = 2 + +[phpspec.yml{,.dist}] +indent_style = space +indent_size = 4 + +[phpstan.neon] +indent_style = space +indent_size = 4 + +[phpunit.xml{,.dist}] +indent_style = space +indent_size = 4 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4f085c8f..39b4735b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -2,7 +2,7 @@ name: "build" on: push: branches: - - "0.*.x" + - "sylius-2" paths-ignore: - "**/*.md" pull_request: @@ -10,274 +10,145 @@ on: - "**/*.md" workflow_dispatch: ~ -env: - APP_ENV: "test" - DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=8.0" - PHP_EXTENSIONS: "intl, mbstring" - jobs: - coding-standards: - name: "Coding Standards (PHP ${{ matrix.php-version }} | Dependency versions: ${{ matrix.dependencies }})" + tests: + name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" runs-on: "ubuntu-latest" strategy: + fail-fast: false matrix: - php-version: - - "8.1" # Always use the lowest version of PHP since a higher version would create actual syntax errors in lower versions - - dependencies: - - "highest" + php: ["8.4"] + symfony: ["^7.4"] + sylius: ["~2.2.0"] + node: ["22.x"] + mysql: ["8.4"] + + env: + APP_ENV: "test" + BEHAT_BASE_URL: "https://127.0.0.1:8080/" + BEHAT_CHROME_URL: "http://127.0.0.1:9222" + DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" + PHP_EXTENSIONS: "intl, mbstring" steps: - name: "Checkout" uses: "actions/checkout@v4" + - name: "Install wkhtmltopdf" + run: "sudo apt-get update && sudo apt-get install -y wkhtmltopdf" + - name: "Setup PHP, with composer and extensions" uses: "shivammathur/setup-php@v2" with: - php-version: "${{ matrix.php-version }}" + php-version: "${{ matrix.php }}" extensions: "${{ env.PHP_EXTENSIONS }}" + tools: "flex,symfony" coverage: "none" - - name: "Install composer dependencies" - uses: "ramsey/composer-install@v3" + - name: "Setup Node" + uses: "actions/setup-node@v4" with: - dependency-versions: "${{ matrix.dependencies }}" - - - name: "Validate composer" - run: "composer validate --strict" - - - name: "Check composer normalized" - run: "composer normalize --dry-run" + node-version: "${{ matrix.node }}" - - name: "Check style" - run: "composer check-style" - - - name: "Lint yaml files" - run: "(cd tests/Application && bin/console lint:yaml ../../src/Resources)" - - - name: "Lint twig files" - run: "(cd tests/Application && bin/console lint:twig ../../src/Resources)" - - dependency-analysis: - name: "Dependency Analysis (PHP ${{ matrix.php-version }} | Dependency versions: ${{ matrix.dependencies }} | Symfony: ${{ matrix.symfony }})" - - runs-on: "ubuntu-latest" + - name: "Shutdown default MySQL" + run: "sudo service mysql stop" - strategy: - matrix: - php-version: - - "8.1" - - "8.2" - - dependencies: - - "lowest" - - "highest" - - symfony: - - "~5.4.0" - - "~6.4.0" - - steps: - - name: "Checkout" - uses: "actions/checkout@v4" - - - name: "Setup PHP, with composer and extensions" - uses: "shivammathur/setup-php@v2" + - name: "Setup MySQL" + uses: "mirromutth/mysql-action@v1.1" with: - coverage: "none" - extensions: "${{ env.PHP_EXTENSIONS }}" - 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@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" - - - name: "Run composer-unused/composer-unused" - run: "composer-unused" - - static-code-analysis: - name: "Static Code Analysis (PHP ${{ matrix.php-version }} | Dependency versions: ${{ matrix.dependencies }} | Symfony: ${{ matrix.symfony }})" + mysql version: "${{ matrix.mysql }}" + mysql root password: "root" - runs-on: "ubuntu-latest" - - strategy: - matrix: - php-version: - - "8.1" - - "8.2" - - dependencies: - - "lowest" - - "highest" - - symfony: - - "~5.4.0" - - "~6.4.0" + - name: "Output PHP version for Symfony CLI" + run: "php -v | head -n 1 | awk '{ print $2 }' > .php-version" - steps: - - name: "Checkout" - uses: "actions/checkout@v4" + - name: "Validate composer" + run: "composer validate --ansi --strict" - - name: "Setup PHP, with composer and extensions" - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - extensions: "${{ env.PHP_EXTENSIONS }}" - php-version: "${{ matrix.php-version }}" - tools: "flex" + - name: "Get Composer cache directory" + id: "composer-cache" + run: "echo \"dir=$(composer config cache-files-dir)\" >> $GITHUB_OUTPUT" - - 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@v3" - env: - SYMFONY_REQUIRE: "${{ matrix.symfony }}" + - name: "Cache Composer" + uses: "actions/cache@v4" with: - dependency-versions: "${{ matrix.dependencies }}" + path: "${{ steps.composer-cache.outputs.dir }}" + key: "${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}" + restore-keys: | + ${{ runner.os }}-php-${{ matrix.php }}-composer- - - name: "Static analysis" - run: "vendor/bin/psalm --php-version=${{ matrix.php-version }}" + - name: "Restrict Symfony version" + if: "matrix.symfony != ''" + run: | + composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^2.4" + composer global config --no-plugins allow-plugins.symfony/flex true + composer config extra.symfony.require "${{ matrix.symfony }}" - unit-tests: - name: "Unit tests (PHP ${{ matrix.php-version }} | Dependency versions: ${{ matrix.dependencies }} | Symfony: ${{ matrix.symfony }})" + - name: "Restrict Sylius version" + if: "matrix.sylius != ''" + run: "composer require \"sylius/sylius:${{ matrix.sylius }}\" --no-update --no-scripts --no-interaction" - runs-on: "ubuntu-latest" + - name: "Install composer dependencies" + run: "composer install --no-interaction" - strategy: - matrix: - php-version: - - "8.1" - - "8.2" + - name: "Lint container" + run: "vendor/bin/console lint:container" - dependencies: - - "highest" + - name: "Lint yaml files" + run: "vendor/bin/console lint:yaml config" - symfony: - - "~5.4.0" - - "~6.4.0" + - name: "Lint twig files" + run: "vendor/bin/console lint:twig templates" - steps: - - name: "Checkout" - uses: "actions/checkout@v4" + - name: "Check style" + run: "composer check-style" - - name: "Setup PHP, with composer and extensions" - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - extensions: "${{ env.PHP_EXTENSIONS }}" - php-version: "${{ matrix.php-version }}" - tools: "flex" + - name: "Static analysis" + run: "vendor/bin/psalm --no-cache" - - 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@v3" - env: - SYMFONY_REQUIRE: "${{ matrix.symfony }}" - with: - dependency-versions: "${{ matrix.dependencies }}" + - name: "Run phpspec" + run: "vendor/bin/phpspec run --ansi -f progress --no-interaction" - name: "Run phpunit" run: "composer phpunit" - integration-tests: - name: "Integration tests (PHP ${{ matrix.php-version }} | Dependency versions: ${{ matrix.dependencies }} | Symfony: ${{ matrix.symfony }})" - - runs-on: "ubuntu-latest" - - strategy: - matrix: - php-version: - - "8.1" - - "8.2" - - dependencies: - - "highest" - - symfony: - - "~6.4" - - steps: - - name: "Start MySQL" - run: "sudo /etc/init.d/mysql start" - - - name: "Checkout" - uses: "actions/checkout@v4" - - - name: "Setup PHP, with composer and extensions" - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - extensions: "${{ env.PHP_EXTENSIONS }}" - php-version: "${{ matrix.php-version }}" - tools: "flex,symfony" - - - name: "Setup node" - uses: "actions/setup-node@v4" - with: - node-version: "18" + - name: "Get Yarn cache directory" + id: "yarn-cache" + run: "echo \"dir=$(yarn cache dir)\" >> $GITHUB_OUTPUT" - - name: "Install composer dependencies" - uses: "ramsey/composer-install@v3" - env: - SYMFONY_REQUIRE: "${{ matrix.symfony }}" + - name: "Cache Yarn" + uses: "actions/cache@v4" with: - dependency-versions: "${{ matrix.dependencies }}" - - - name: "Install wkhtmltopdf" - run: "sudo apt-get install wkhtmltopdf" + path: "${{ steps.yarn-cache.outputs.dir }}" + key: "${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }}" + restore-keys: | + ${{ runner.os }}-node-${{ matrix.node }}-yarn- - - name: "Lint container" - run: '(cd tests/Application && bin/console lint:container)' + - name: "Install JS dependencies" + run: "(cd vendor/sylius/test-application && yarn install)" - name: "Create database" - run: "(cd tests/Application && bin/console doctrine:database:create)" + run: "vendor/bin/console doctrine:database:create -vvv" - name: "Create database schema" - run: "(cd tests/Application && bin/console doctrine:schema:create)" + run: "vendor/bin/console doctrine:schema:create -vvv" - name: "Validate Doctrine mapping" - run: "(cd tests/Application && bin/console doctrine:schema:validate)" - - - name: "Get Yarn cache directory" - id: "yarn-cache" - run: "echo \"::set-output name=dir::$(yarn cache dir)\"" - - - name: "Cache Yarn" - uses: "actions/cache@v2" - with: - 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)" + run: "vendor/bin/console doctrine:schema:validate" - name: "Install assets" - run: "(cd tests/Application && bin/console assets:install public -vvv)" + run: "vendor/bin/console assets:install vendor/sylius/test-application/public -vvv" - name: "Build assets" - run: "(cd tests/Application && yarn build)" + run: "(cd vendor/sylius/test-application && yarn build)" - - name: "Output PHP version for Symfony CLI" - run: "php -v | head -n 1 | awk '{ print $2 }' > .php-version" + - name: "Warm up cache" + run: "vendor/bin/console cache:warmup -vvv" - name: "Install certificates" - run: "symfony server:ca:install" + run: "symfony server:ca:install || true" - 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 &" @@ -290,14 +161,7 @@ jobs: done - 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 - do - sleep 1 - done + run: "symfony server:start --port=8080 --daemon" - name: "Run behat" run: "vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun" @@ -306,43 +170,8 @@ jobs: uses: "actions/upload-artifact@v4" if: "failure()" with: - name: "Behat logs" + name: "Behat logs - ${{ matrix.sylius }}-${{ github.run_id }}-${{ github.run_number }}" path: "etc/build/" if-no-files-found: "ignore" - - code-coverage: - name: "Code Coverage (PHP ${{ matrix.php-version }} | Dependency versions: ${{ matrix.dependencies }})" - - 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: "Collect code coverage with pcov and phpunit/phpunit" - 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)" + compression-level: 6 + overwrite: true diff --git a/.gitignore b/.gitignore index 82b272e5..a24d6718 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,24 @@ /vendor/ +/var/ /node_modules/ +/drivers/ /composer.lock +/docker/ /etc/build/* !/etc/build/.gitignore -/tests/Application/yarn.lock - +/.phpunit.result.cache /behat.yml +/behat.sh /phpspec.yml -/.phpunit.result.cache -.php-version +/phpunit.xml +/compose.override.yml +/compose.test.yml + +# Symfony CLI https://symfony.com/doc/current/setup/symfony_server.html#different-php-settings-per-project +/.php-version +/php.ini + +/tests/TestApplication/.env.local +/tests/TestApplication/.env.*.local diff --git a/CLAUDE.md b/CLAUDE.md index 17d78a86..8e1c6788 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,7 +4,9 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co ## Project -`setono/sylius-gift-card-plugin` — a Sylius plugin adding gift card functionality (buy gift cards, spend them on orders, check balances, admin management, API Platform support). PHP >= 8.1, Symfony 5.4 || 6.4, Sylius ~1.12. Development branches follow the `0.*.x` naming scheme (current: `0.12.x`). +`setono/sylius-gift-card-plugin` — a Sylius plugin adding gift card functionality (buy gift cards, spend them on orders, check balances, admin management). PHP ^8.2, Symfony ^6.4 || ^7.4, Sylius ^2.0. Development branch: `sylius-2`. + +Note: this plugin does not expose an ApiPlatform API — that layer was dropped during the Sylius 2 migration and is intentionally out of scope. ## Commands @@ -19,38 +21,45 @@ vendor/bin/phpspec run # phpspec specs (spec/ directory) vendor/bin/behat # Behat acceptance tests (requires running test app, see below) ``` -Note: the README mentions `composer tests`, `composer try` and `composer all` — those scripts do not exist in composer.json; use the commands above. - ### Test application -`tests/Application/` contains a full Sylius app used as the kernel for PHPUnit (bootstrap `tests/Application/config/bootstrap.php`) and Behat. Run its console with `(cd tests/Application && bin/console ...)`. Behat (behat.yml.dist) expects the app served at `http://localhost:8080`, a MySQL database, built assets (`yarn install && yarn build` inside tests/Application), and headless Chrome for `@javascript` scenarios — see the `integration-tests` job in `.github/workflows/build.yaml` for the full setup sequence. +`tests/TestApplication/` holds only this plugin's overrides (entity models, repositories, config, template overrides) on top of the `sylius/test-application` package (the actual Sylius 2 test kernel lives in `vendor/sylius/test-application`). Its `.env` sets `SYLIUS_TEST_APP_BUNDLES_REPLACE_PATH`/`SYLIUS_TEST_APP_CONFIGS_TO_IMPORT`/`SYLIUS_TEST_APP_ROUTES_TO_IMPORT`, read by `Sylius\TestApplication\Kernel`. `tests/TestApplication/config/bundles.php` is a full bundle list (not just plugin additions) because the plugin bundle must be registered before `SyliusGridBundle` for its resource parameters to exist when grid config loads — the additive `SYLIUS_TEST_APP_BUNDLES_PATH` env var would append it after core bundles instead. + +Local dev can run entirely in Docker: `compose.yml` + `compose.override.dist.yml` (copy to `compose.override.yml`, gitignored) bring up php/mysql/nginx/chrome/chrome-proxy/mailhog; `behat.sh` runs Behat with `APP_ENV=test` inside the container. `docker/` and `behat.sh`/`compose.test.yml` are gitignored local-dev conveniences, not committed. -CI additionally runs `composer validate --strict`, `composer normalize --dry-run`, `composer-require-checker`, `composer-unused`, yaml/twig/container lints, and Doctrine schema validation. +CI (`.github/workflows/build.yaml`) runs a single job/matrix-cell (PHP 8.4, Symfony ^7.4, Sylius ~2.2.0): composer validate, container/yaml/twig lint, ecs, psalm, phpspec, phpunit, then boots the real app (MySQL, node assets, headless Chrome) and runs Behat. ## Architecture -Namespace `Setono\SyliusGiftCardPlugin\` maps to `src/`; tests are `Setono\SyliusGiftCardPlugin\Tests\` in `tests/`. Bundle class is `src/SetonoSyliusGiftCardPlugin.php`; services are XML files under `src/Resources/config/services/` (one per area: applicator, factory, order_processor, ...) imported by `services.xml`. Resource/grid/route/serializer/API configs also live under `src/Resources/config/`. The bundle must be registered before SyliusGridBundle in host apps (parameter resolution order). +Namespace `Setono\SyliusGiftCardPlugin\` maps to `src/`; tests are `Setono\SyliusGiftCardPlugin\Tests\` in `tests/`. Bundle class is `src/SetonoSyliusGiftCardPlugin.php` — it overrides `getPath()` to return the repo root (not `src/`) and `getConfigFilesPath()` to `config/doctrine/model`, so plugin resources live as root-level siblings of `src/` (Sylius 2 convention, matching `sylius/sylius`'s own plugins), not nested under a Sylius-1.x-style `src/Resources/` tree: + +- `config/` — DI service XML (`services.xml` importing `config/services/*.xml`), `app/config.yaml` (+ `app/fixtures.yaml`), `grids.yaml` (+ `grids/*.yaml`), `routes.yaml`/`routes_no_locale.yaml` (+ `routes/*.yaml`), `sylius_ui.yaml` (now `sylius_twig_hooks` config, despite the filename), `doctrine/model/*.orm.xml`, `serialization/*.xml`, `validation/*.xml` +- `templates/` — Twig views (`Admin/`, `Shop/`, `Email/`, plus `templates/bundles/...` reference overrides for host apps to copy) +- `translations/`, `public/` (assets copied via `assets:install`), `fixtures/` (fixture data files) +- `src/DependencyInjection/SetonoSyliusGiftCardExtension.php` loads `config/services.xml` via a `FileLocator` pointed at `../../config` relative to itself + +The bundle must still be registered before `SyliusGridBundle` in host apps (parameter resolution order) — this is unrelated to the resource-path convention above. ### Domain model `GiftCard` holds a code, `amount`/`initialAmount` (integers, minor units per Sylius money convention), currency, channel, optional customer/expiry, and an enabled toggle. When bought in the shop it is linked 1:1 to an `OrderItemUnit`. `GiftCardConfiguration` (+ `GiftCardChannelConfiguration` join entity) defines per-channel/locale settings: PDF template, default validity period, images. -Host applications integrate by applying the plugin's traits/interfaces to their entities — `ProductTrait` (adds `isGiftCard` and `giftCardAmountConfigurable` flags), `OrderTrait` (applied gift cards collection), `OrderItemTrait`, `OrderItemUnitTrait` (gift card relation), and repository traits in `src/Doctrine/ORM/`. The README documents the exact setup; `tests/Application/` shows a working example. +Host applications integrate by applying the plugin's traits/interfaces to their entities — `ProductTrait` (adds `isGiftCard` and `giftCardAmountConfigurable` flags, PHP attributes not annotations), `OrderTrait` (applied gift cards collection), `OrderItemTrait`, `OrderItemUnitTrait` (gift card relation), and repository traits in `src/Doctrine/ORM/`. The README documents the exact setup; `tests/TestApplication/` shows a working example. ### Two distinct gift card flows -**Buying a gift card** (product flagged as gift card): the gift card entity is created at add-to-cart time via `GiftCardFactory::createFromOrderItemUnitAndCart()` — called from `Form/Extension/AddToCartTypeExtension` (shop form flow, POST_SUBMIT listener) and `Api/CommandHandler/AddItemToCartHandler` (API flow). The card starts disabled; winzou state machine callbacks (`src/Resources/config/state_machine/`) drive its lifecycle through `Operator/OrderGiftCardOperator`: checkout complete → `associateToCustomer`, payment paid → `enable` + `send` (email with PDF), order cancel → `disable`. "Configurable" gift card products let the customer choose the amount. +**Buying a gift card** (product flagged as gift card): the gift card entity is created at add-to-cart time via `GiftCardFactory::createFromOrderItemUnitAndCart()`, called from `Form/Extension/AddToCartTypeExtension` (shop form flow, POST_SUBMIT listener). The card starts disabled; Symfony Workflow event listeners (`src/EventListener/Workflow/*`, tagged on `workflow..completed.`) drive its lifecycle through `Operator/OrderGiftCardOperator`: checkout complete → `associateToCustomer`, payment paid → `enable` + `send` (email with PDF), order cancel → `disable`. Sylius 2 defaults to the `symfony_workflow` state machine adapter (not winzou), which is why these are plain kernel event listeners rather than winzou callback config. "Configurable" gift card products let the customer choose the amount. -**Spending a gift card**: `Applicator/GiftCardApplicator` validates (enabled, not expired, channel matches) and attaches the card to the order, then reprocesses it. `OrderProcessor/OrderGiftCardProcessor` (a Sylius order processor) converts each applied card into a negative order adjustment (`AdjustmentInterface::ORDER_GIFT_CARD_ADJUSTMENT`, origin code = gift card code) capped at the eligible order total. Actual balance mutation happens via state machine callbacks on `Modifier/OrderGiftCardAmountModifier`: decrement on order create, increment back on cancel. Both flows can coexist on one order. - -### API - -API Platform resources are declared in `src/Resources/config/api_resources/` with messenger commands/handlers in `src/Api/Command` and `src/Api/CommandHandler`. The plugin replaces the input of Sylius' shop `add item to cart` operation with its own `AddItemToCart` command (carrying gift card info); host apps must copy/adjust `Order.xml` as described in the README. +**Spending a gift card**: `Applicator/GiftCardApplicator` validates (enabled, not expired, channel matches) and attaches the card to the order, then reprocesses it. `OrderProcessor/OrderGiftCardProcessor` (a Sylius order processor) converts each applied card into a negative order adjustment (`AdjustmentInterface::ORDER_GIFT_CARD_ADJUSTMENT`, origin code = gift card code) capped at the eligible order total. Actual balance mutation happens via the same workflow listeners, calling `Modifier/OrderGiftCardAmountModifier`: decrement on order create, increment back on cancel. Both flows can coexist on one order. ### PDF rendering Gift cards render to PDF via knp-snappy/wkhtmltopdf (`Renderer/PdfRenderer`), with template content and rendering options coming from the gift card's configuration (`Provider/`). Admin supports live preview of example PDFs. +### UI hooks + +Sylius 2 replaced the old `sylius_ui: events:` (SonataBlock-style) system with `sylius/twig-hooks`. `config/sylius_ui.yaml` (filename kept for continuity) now declares `sylius_twig_hooks` entries for the shop add-to-cart gift-card fields and the cart-summary applied-gift-cards block. The admin CRUD javascripts (image preview, live PDF rendering, send-customer-email checkbox) and the shop account gift card index hooks still use the removed block system and need porting to twig-hooks — see the `TODO` comment in `config/app/config.yaml`. + ### Test layout - `tests/Unit/` — PHPUnit (includes DI/config tests using matthiasnoback's symfony-config-test / dependency-injection-test) diff --git a/README.md b/README.md index 89ed61ab..ef9e128c 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,6 @@ can be used for auditing. ![Screenshot showing gift card admin create page](docs/images/admin-gift-card-create.png) -## Api platform support - -Everything related to Gift Card can be done via API. Whether it is admin or shop actions - ## Installation ### Require plugin with composer: @@ -39,7 +35,7 @@ $ composer require setono/sylius-gift-card-plugin # config/packages/setono_sylius_gift_card.yaml imports: # ... - - { resource: "@SetonoSyliusGiftCardPlugin/Resources/config/app/config.yaml" } + - { resource: "@SetonoSyliusGiftCardPlugin/config/app/config.yaml" } ``` ### (Optional) Import fixtures @@ -50,7 +46,7 @@ If you wish to have some gift cards to play with in your application during deve # config/packages/setono_sylius_gift_card.yaml imports: # ... - - { resource: "@SetonoSyliusGiftCardPlugin/Resources/config/app/fixtures.yaml" } + - { resource: "@SetonoSyliusGiftCardPlugin/config/app/fixtures.yaml" } ``` ### Import routing: @@ -58,7 +54,7 @@ imports: ```yaml # config/routes.yaml setono_sylius_gift_card: - resource: "@SetonoSyliusGiftCardPlugin/Resources/config/routes.yaml" + resource: "@SetonoSyliusGiftCardPlugin/config/routes.yaml" ``` or if your app doesn't use locales: @@ -66,7 +62,7 @@ or if your app doesn't use locales: ```yaml # config/routes.yaml setono_sylius_gift_card: - resource: "@SetonoSyliusGiftCardPlugin/Resources/config/routes_no_locale.yaml" + resource: "@SetonoSyliusGiftCardPlugin/config/routes_no_locale.yaml" ``` ### Add plugin class to your `bundles.php`: @@ -86,7 +82,7 @@ $bundles = [ ### Copy templates -You will find the templates you need to override in the [test application](https://github.com/Setono/SyliusGiftCardPlugin/tree/master/tests/Application/templates). +You will find the templates you need to override in the [test application](https://github.com/Setono/SyliusGiftCardPlugin/tree/master/tests/TestApplication/templates). ### Extend entities @@ -273,32 +269,6 @@ sylius_product: model: App\Entity\Product\Product ``` -### Copy Api Resources - -Resources declaration that need to be copied are: -* [Order.xml](src/Resources/config/api_resources/Order.xml) - -If you already have them overriden, just change the following routes: - -**[Order.xml](src/Resources/config/api_resources/Order.xml)** -```xml - - PATCH - /shop/orders/{tokenValue}/items - input - Setono\SyliusGiftCardPlugin\Api\Command\AddItemToCart - - shop:cart:read - - - shop:cart:add_item - - - Adds Item to cart - - -``` - ### Update your database: ```bash diff --git a/assets/admin/controllers.json b/assets/admin/controllers.json new file mode 100644 index 00000000..e2ce9b5c --- /dev/null +++ b/assets/admin/controllers.json @@ -0,0 +1,4 @@ +{ + "controllers": [], + "entrypoints": [] +} diff --git a/tests/Application/config/api_platform/.gitignore b/assets/admin/entrypoint.js similarity index 100% rename from tests/Application/config/api_platform/.gitignore rename to assets/admin/entrypoint.js diff --git a/assets/shop/controllers.json b/assets/shop/controllers.json new file mode 100644 index 00000000..e2ce9b5c --- /dev/null +++ b/assets/shop/controllers.json @@ -0,0 +1,4 @@ +{ + "controllers": [], + "entrypoints": [] +} diff --git a/tests/Application/config/secrets/dev/.gitignore b/assets/shop/entrypoint.js similarity index 100% rename from tests/Application/config/secrets/dev/.gitignore rename to assets/shop/entrypoint.js diff --git a/behat.yml.dist b/behat.yml.dist index 3bfa4adf..75635d8b 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -4,6 +4,8 @@ imports: default: extensions: + DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~ + FriendsOfBehat\MinkDebugExtension: directory: etc/build clean_start: false @@ -11,39 +13,27 @@ default: Behat\MinkExtension: files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/" - base_url: "http://localhost:8080/" + base_url: "%env(BEHAT_BASE_URL)%" default_session: symfony - javascript_session: chrome + javascript_session: chromedriver sessions: symfony: symfony: ~ - 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: - unexpectedAlertBehaviour: accept - firefox: - selenium2: - browser: firefox - show_auto: false + chromedriver: + chrome: + api_url: "%env(BEHAT_CHROME_URL)%" + validate_certificate: false FriendsOfBehat\SymfonyExtension: - bootstrap: tests/Application/config/bootstrap.php + bootstrap: vendor/sylius/test-application/config/bootstrap.php kernel: - class: Setono\SyliusGiftCardPlugin\Tests\Application\Kernel + class: Sylius\TestApplication\Kernel + environment: test FriendsOfBehat\VariadicExtension: ~ FriendsOfBehat\SuiteSettingsExtension: paths: - "features" + + SyliusLabs\SuiteTagsExtension: ~ diff --git a/bin/console b/bin/console new file mode 120000 index 00000000..46e506e4 --- /dev/null +++ b/bin/console @@ -0,0 +1 @@ +../vendor/bin/console \ No newline at end of file diff --git a/bin/create_console_symlink.php b/bin/create_console_symlink.php new file mode 100755 index 00000000..9dbf03cb --- /dev/null +++ b/bin/create_console_symlink.php @@ -0,0 +1,53 @@ + {$targetRelativeFromBin}"); +} + +@chmod($linkPath, 0755); +info("Created symlink: bin/console -> {$targetRelativeFromBin}"); diff --git a/compose.override.dist.yml b/compose.override.dist.yml new file mode 100644 index 00000000..b5e94aff --- /dev/null +++ b/compose.override.dist.yml @@ -0,0 +1,33 @@ +services: + php: + image: ghcr.io/sylius/sylius-php:8.4-xdebug-alpine + working_dir: /app + volumes: + - .:/app + - ./docker/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini:ro + environment: + APP_ENV: dev + DATABASE_URL: mysql://root@mysql/setono_sylius_gift_card_plugin_%kernel.environment% + BEHAT_BASE_URL: http://nginx/ + BEHAT_CHROME_URL: http://chrome-proxy:9222 + XDEBUG_CONFIG: >- + client_host=host.docker.internal + client_port=9003 + PHP_IDE_CONFIG: serverName=SetonoSyliusGiftCardPlugin + extra_hosts: + - "host.docker.internal:host-gateway" + mysql: + ports: + - ${MYSQL_PORT:-33062}:3306 + nginx: + ports: + - ${NGINX_PORT:-8081}:80 + environment: + WORKING_DIR: /app/vendor/sylius/test-application + volumes: + - .:/app + node: + image: node:22-alpine + working_dir: /app/vendor/sylius/test-application + volumes: + - .:/app diff --git a/compose.yml b/compose.yml new file mode 100644 index 00000000..cf6a7479 --- /dev/null +++ b/compose.yml @@ -0,0 +1,40 @@ +services: + php: + image: ghcr.io/sylius/sylius-php:8.4-alpine + mysql: + image: mysql:8.4 + platform: linux/amd64 + healthcheck: + test: '/usr/bin/mysql --execute "SHOW databases;"' + timeout: 3s + interval: 1s + retries: 10 + environment: + MYSQL_ALLOW_EMPTY_PASSWORD: 1 + cap_add: + - SYS_NICE # prevent "mbind: Operation not permitted" errors + ports: + - ${MYSQL_PORT:-33062}:3306 + volumes: + - setono-sylius-gift-card-plugin-mysql-data:/var/lib/mysql:rw + nginx: + image: ghcr.io/sylius/sylius-nginx:latest + depends_on: + - php + chrome: + image: chromedp/headless-shell:stable + command: --remote-allow-origins=* + + chrome-proxy: + image: nginx:alpine + volumes: + - ./docker/nginx/chrome-proxy.conf:/etc/nginx/conf.d/default.conf:ro + depends_on: + - chrome + + mailhog: + # do not use in production! + image: axllent/mailpit:latest + +volumes: + setono-sylius-gift-card-plugin-mysql-data: diff --git a/composer-require-checker.json b/composer-require-checker.json deleted file mode 100644 index 3cc0b605..00000000 --- a/composer-require-checker.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "symbol-whitelist": [ - "array", - "bool", - "callable", - "false", - "float", - "int", - "iterable", - "null", - "object", - "parent", - "self", - "static", - "string", - "true", - "void", - "ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Util\\QueryNameGeneratorInterface" - ] -} diff --git a/composer-unused.php b/composer-unused.php deleted file mode 100644 index c6ffb76c..00000000 --- a/composer-unused.php +++ /dev/null @@ -1,12 +0,0 @@ -addNamedFilter(NamedFilter::fromString('knplabs/knp-snappy-bundle')) - ; -}; diff --git a/composer.json b/composer.json index af86ad3c..8c9dd88b 100644 --- a/composer.json +++ b/composer.json @@ -4,85 +4,85 @@ "license": "MIT", "type": "sylius-plugin", "require": { - "php": ">=8.1", + "php": "^8.2", "ext-filter": "*", "ext-mbstring": "*", - "api-platform/core": "^2.6", - "doctrine/collections": "^1.8", - "doctrine/dbal": "^2.13 || ^3.0", - "doctrine/orm": "^2.7", - "doctrine/persistence": "^1.3 || ^2.5 || ^3.0", - "fakerphp/faker": "^1.21", - "knplabs/knp-menu": "^3.3", + "doctrine/collections": "^2.2", + "doctrine/dbal": "^3.0", + "doctrine/orm": "^2.18 || ^3.3", + "doctrine/persistence": "^3.3", + "fakerphp/faker": "^1.23", + "knplabs/knp-menu": "^3.5", "knplabs/knp-snappy": "^1.4", "knplabs/knp-snappy-bundle": "^1.9", "setono/doctrine-object-manager-trait": "^1.1", - "sylius/api-bundle": "^1.11", - "sylius/channel": "^1.0", - "sylius/channel-bundle": "^1.0", - "sylius/core": "^1.0", - "sylius/core-bundle": "^1.0", - "sylius/currency": "^1.0", - "sylius/customer": "^1.0", - "sylius/grid-bundle": "^1.0", - "sylius/locale": "^1.0", - "sylius/locale-bundle": "^1.0", - "sylius/mailer-bundle": "^1.6 || ^2.0", - "sylius/money-bundle": "^1.0", - "sylius/order": "^1.10", - "sylius/order-bundle": "^1.0", - "sylius/product": "^1.0", - "sylius/product-bundle": "^1.0", - "sylius/promotion": "^1.0", - "sylius/resource-bundle": "^1.8", - "sylius/shipping-bundle": "^1.0", - "sylius/ui-bundle": "^1.0", - "sylius/user": "^1.0", - "symfony/config": "^5.4 || ^6.4", - "symfony/dependency-injection": "^5.4 || ^6.4", - "symfony/event-dispatcher": "^5.4 || ^6.4", - "symfony/form": "^5.4 || ^6.4", - "symfony/http-foundation": "^5.4 || ^6.4", - "symfony/http-kernel": "^5.4 || ^6.4", - "symfony/messenger": "^5.4 || ^6.4", - "symfony/options-resolver": "^5.4 || ^6.4", - "symfony/property-access": "^5.4 || ^6.4", - "symfony/routing": "^5.4 || ^6.4", - "symfony/security-core": "^5.4 || ^6.4", - "symfony/serializer": "^5.4 || ^6.4", - "symfony/translation-contracts": "^2.4", - "symfony/validator": "^5.4 || ^6.4", - "twig/twig": "^2.15 || ^3.5", + "sylius-labs/doctrine-migrations-extra-bundle": "^0.2.2", + "sylius/grid-bundle": "^1.16", + "sylius/mailer-bundle": "^2.0", + "sylius/resource-bundle": "^1.14", + "sylius/sylius": "^2.0", + "symfony/config": "^7.4", + "symfony/dependency-injection": "^7.4", + "symfony/event-dispatcher": "^7.4", + "symfony/form": "^7.4", + "symfony/framework-bundle": "^7.4", + "symfony/http-foundation": "^7.4", + "symfony/http-kernel": "^7.4", + "symfony/messenger": "^7.4", + "symfony/options-resolver": "^7.4", + "symfony/property-access": "^7.4", + "symfony/routing": "^7.4", + "symfony/security-core": "^7.4", + "symfony/serializer": "^7.4", + "symfony/property-info": "^7.3", + "symfony/translation": "^7.4", + "symfony/translation-contracts": "^3.5", + "symfony/twig-bundle": "^7.4", + "symfony/type-info": ">=7.2 <7.4", + "symfony/validator": "^7.4", + "twig/twig": "^3.5", "webimpress/safe-writer": "^2.2", "webmozart/assert": "^1.11" }, "require-dev": { - "babdev/pagerfanta-bundle": "^3.8", - "behat/behat": "^3.14", - "doctrine/doctrine-bundle": "^2.7", - "infection/infection": "^0.27.10", - "jms/serializer-bundle": "^4.2", - "lexik/jwt-authentication-bundle": "^2.17", - "matthiasnoback/symfony-config-test": "^4.3 || ^5.1", - "matthiasnoback/symfony-dependency-injection-test": "^4.3 || ^5.1", + "babdev/pagerfanta-bundle": "^4.4", + "behat/behat": "^3.16", + "behat/mink": "^1.13", + "behat/mink-selenium2-driver": "^1.7", + "dbrekelmans/bdi": "^1.4", + "dmore/behat-chrome-extension": "^1.4", + "dmore/chrome-mink-driver": "^2.9", + "doctrine/doctrine-bundle": "^2.13", + "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.6", + "friends-of-behat/variadic-extension": "^1.6", + "lexik/jwt-authentication-bundle": "^3.1", + "matthiasnoback/symfony-config-test": "^5.1", + "matthiasnoback/symfony-dependency-injection-test": "^5.1", "php-http/message-factory": "^1.1", - "phpspec/phpspec": "^7.4", + "phpspec/phpspec": "^8.0", "phpspec/prophecy-phpunit": "^2.0.2", "phpunit/phpunit": "^9.6.17", - "polishsymfonycommunity/symfony-mocker-container": "^1.0.7", - "psalm/plugin-phpunit": "^0.18.4", - "psalm/plugin-symfony": "^5.0", + "polishsymfonycommunity/symfony-mocker-container": "^1.0", + "psalm/plugin-symfony": "^5.2", + "rector/rector": "^1.0", "setono/code-quality-pack": "^2.7", - "setono/sylius-behat-pack": "^0.2.2", - "sylius/sylius": "~1.12.13", - "symfony/debug-bundle": "^5.4 || ^6.4", - "symfony/dotenv": "^5.4 || ^6.4", - "symfony/intl": "^5.4 || ^6.4", - "symfony/property-info": "^5.4 || ^6.4", - "symfony/web-profiler-bundle": "^5.4 || ^6.4", - "symfony/webpack-encore-bundle": "^1.17.2", - "weirdan/doctrine-psalm-plugin": "^2.9", - "willdurand/negotiation": "^3.1" + "sylius-labs/coding-standard": "^4.4", + "sylius-labs/suite-tags-extension": "~0.2", + "sylius/sylius-rector": "^2.0", + "sylius/test-application": "^2.0.0@alpha", + "symfony/browser-kit": "^7.4", + "symfony/debug-bundle": "^7.4", + "symfony/dotenv": "^7.4", + "symfony/intl": "^7.4", + "symfony/web-profiler-bundle": "^7.4", + "symfony/webpack-encore-bundle": "^2.2", + "vimeo/psalm": "^6.13", + "weirdan/doctrine-psalm-plugin": "^2.10" }, "prefer-stable": true, "autoload": { @@ -93,24 +93,56 @@ "autoload-dev": { "psr-4": { "Setono\\SyliusGiftCardPlugin\\Tests\\": "tests/" - }, - "classmap": [ - "tests/Application/Kernel.php" - ] + } }, "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": false, - "ergebnis/composer-normalize": true, - "infection/extension-installer": true, - "symfony/thanks": false + "ergebnis/composer-normalize": false, + "php-http/discovery": false, + "symfony/thanks": false, + "symfony/runtime": true, + "symfony/flex": true }, "sort-packages": true }, + "extra": { + "branch-alias": { + "dev-sylius-2": "2.0-dev" + }, + "public-dir": "vendor/sylius/test-application/public" + }, "scripts": { + "database-reset": [ + "vendor/bin/console doctrine:database:drop --force --if-exists", + "vendor/bin/console doctrine:database:create", + "vendor/bin/console doctrine:migration:migrate -n", + "vendor/bin/console sylius:fixtures:load -n" + ], + "frontend-clear": [ + "cd vendor/sylius/test-application && yarn install && yarn build", + "vendor/bin/console assets:install" + ], + "test-app-init": [ + "@database-reset", + "@frontend-clear" + ], "analyse": "psalm", "check-style": "ecs check", "fix-style": "ecs check --fix", - "phpunit": "phpunit" + "phpunit": "phpunit", + "behat": "behat --strict -vvv --no-interaction || behat --strict -vvv --no-interaction --rerun", + "auto-scripts": { + "security-checker security:check": "script" + }, + "post-install-cmd": [ + "@create-console-symlink" + ], + "post-update-cmd": [ + "@create-console-symlink" + ], + "create-console-symlink": [ + "@php bin/create_console_symlink.php" + ] } } diff --git a/config/app/config.yaml b/config/app/config.yaml new file mode 100644 index 00000000..413ec0bc --- /dev/null +++ b/config/app/config.yaml @@ -0,0 +1,22 @@ +imports: + - { resource: "@SetonoSyliusGiftCardPlugin/config/grids.yaml" } + - { resource: "@SetonoSyliusGiftCardPlugin/config/sylius_ui.yaml" } + +sylius_mailer: + emails: + gift_card_customer: + subject: setono_sylius_gift_card.email.new_gift_card + template: "@SetonoSyliusGiftCardPlugin/Email/giftCardToCustomer.html.twig" + gift_card_order: + subject: setono_sylius_gift_card.email.your_gift_cards_you_bought_in_the_order + template: "@SetonoSyliusGiftCardPlugin/Email/giftCardsFromOrder.html.twig" + +liip_imagine: + filter_sets: + setono_sylius_gift_card_background: + filters: + thumbnail: { size: [1200], mode: inset } + +# TODO the admin CRUD javascripts (image preview, live PDF rendering, send-customer-email +# checkbox) and the shop account gift card index hooks used the removed sylius_ui "events" +# block system (SonataBlock-style). They still need to be ported to sylius/twig-hooks. diff --git a/src/Resources/config/app/fixtures.yaml b/config/app/fixtures.yaml similarity index 96% rename from src/Resources/config/app/fixtures.yaml rename to config/app/fixtures.yaml index db52d513..72a7993b 100644 --- a/src/Resources/config/app/fixtures.yaml +++ b/config/app/fixtures.yaml @@ -35,6 +35,6 @@ sylius_fixtures: custom: default_configuration: code: 'default_configuration' - background_image: '@SetonoSyliusGiftCardPlugin/Resources/fixtures/default_background.png' + background_image: '@SetonoSyliusGiftCardPlugin/fixtures/default_background.png' enabled: true default: true diff --git a/src/Resources/config/doctrine/model/GiftCard.orm.xml b/config/doctrine/model/GiftCard.orm.xml similarity index 100% rename from src/Resources/config/doctrine/model/GiftCard.orm.xml rename to config/doctrine/model/GiftCard.orm.xml diff --git a/src/Resources/config/doctrine/model/GiftCardChannelConfiguration.orm.xml b/config/doctrine/model/GiftCardChannelConfiguration.orm.xml similarity index 100% rename from src/Resources/config/doctrine/model/GiftCardChannelConfiguration.orm.xml rename to config/doctrine/model/GiftCardChannelConfiguration.orm.xml diff --git a/src/Resources/config/doctrine/model/GiftCardConfiguration.orm.xml b/config/doctrine/model/GiftCardConfiguration.orm.xml similarity index 100% rename from src/Resources/config/doctrine/model/GiftCardConfiguration.orm.xml rename to config/doctrine/model/GiftCardConfiguration.orm.xml diff --git a/src/Resources/config/doctrine/model/GiftCardConfigurationImage.orm.xml b/config/doctrine/model/GiftCardConfigurationImage.orm.xml similarity index 100% rename from src/Resources/config/doctrine/model/GiftCardConfigurationImage.orm.xml rename to config/doctrine/model/GiftCardConfigurationImage.orm.xml diff --git a/src/Resources/config/grids.yaml b/config/grids.yaml similarity index 56% rename from src/Resources/config/grids.yaml rename to config/grids.yaml index ed91fe09..628fc6f5 100644 --- a/src/Resources/config/grids.yaml +++ b/config/grids.yaml @@ -1,8 +1,8 @@ imports: - - { resource: "@SetonoSyliusGiftCardPlugin/Resources/config/grids/setono_sylius_gift_card_admin_gift_card.yaml" } - - { resource: "@SetonoSyliusGiftCardPlugin/Resources/config/grids/setono_sylius_gift_card_admin_gift_card_configuration.yaml" } - - { resource: "@SetonoSyliusGiftCardPlugin/Resources/config/grids/setono_sylius_gift_card_admin_gift_card_order.yaml" } - - { resource: "@SetonoSyliusGiftCardPlugin/Resources/config/grids/setono_sylius_gift_card_shop_gift_card.yaml" } + - { resource: "@SetonoSyliusGiftCardPlugin/config/grids/setono_sylius_gift_card_admin_gift_card.yaml" } + - { resource: "@SetonoSyliusGiftCardPlugin/config/grids/setono_sylius_gift_card_admin_gift_card_configuration.yaml" } + - { resource: "@SetonoSyliusGiftCardPlugin/config/grids/setono_sylius_gift_card_admin_gift_card_order.yaml" } + - { resource: "@SetonoSyliusGiftCardPlugin/config/grids/setono_sylius_gift_card_shop_gift_card.yaml" } sylius_grid: templates: diff --git a/src/Resources/config/grids/setono_sylius_gift_card_admin_gift_card.yaml b/config/grids/setono_sylius_gift_card_admin_gift_card.yaml similarity index 97% rename from src/Resources/config/grids/setono_sylius_gift_card_admin_gift_card.yaml rename to config/grids/setono_sylius_gift_card_admin_gift_card.yaml index ee0bc509..1e7d4277 100644 --- a/src/Resources/config/grids/setono_sylius_gift_card_admin_gift_card.yaml +++ b/config/grids/setono_sylius_gift_card_admin_gift_card.yaml @@ -32,13 +32,13 @@ sylius_grid: label: sylius.ui.channel sortable: channel.code options: - template: "@SyliusAdmin/Order/Grid/Field/channel.html.twig" + template: "@SyliusAdmin/shared/grid/field/channel.html.twig" enabled: type: twig label: sylius.ui.enabled sortable: ~ options: - template: "@SyliusUi/Grid/Field/enabled.html.twig" + template: "@SyliusUi/grid/field/enabled.html.twig" createdAt: type: datetime label: sylius.ui.created diff --git a/src/Resources/config/grids/setono_sylius_gift_card_admin_gift_card_configuration.yaml b/config/grids/setono_sylius_gift_card_admin_gift_card_configuration.yaml similarity index 91% rename from src/Resources/config/grids/setono_sylius_gift_card_admin_gift_card_configuration.yaml rename to config/grids/setono_sylius_gift_card_admin_gift_card_configuration.yaml index 043dd3da..a411ec38 100644 --- a/src/Resources/config/grids/setono_sylius_gift_card_admin_gift_card_configuration.yaml +++ b/config/grids/setono_sylius_gift_card_admin_gift_card_configuration.yaml @@ -16,13 +16,13 @@ sylius_grid: label: sylius.ui.status sortable: ~ options: - template: '@SyliusUi/Grid/Field/enabled.html.twig' + template: '@SyliusUi/grid/field/enabled.html.twig' default: type: twig label: sylius.ui.default sortable: ~ options: - template: '@SyliusUi/Grid/Field/yesNo.html.twig' + template: '@SyliusUi/grid/field/yes_no.html.twig' channel_configurations: type: twig label: setono_sylius_gift_card.ui.channel_configurations diff --git a/src/Resources/config/grids/setono_sylius_gift_card_admin_gift_card_order.yaml b/config/grids/setono_sylius_gift_card_admin_gift_card_order.yaml similarity index 93% rename from src/Resources/config/grids/setono_sylius_gift_card_admin_gift_card_order.yaml rename to config/grids/setono_sylius_gift_card_admin_gift_card_order.yaml index e6b18fec..a35581b5 100644 --- a/src/Resources/config/grids/setono_sylius_gift_card_admin_gift_card_order.yaml +++ b/config/grids/setono_sylius_gift_card_admin_gift_card_order.yaml @@ -7,7 +7,7 @@ sylius_grid: repository: method: createCompletedQueryBuilderByGiftCard arguments: - giftCard: $id + criteria: $id fields: coveredByGiftCards: type: twig diff --git a/src/Resources/config/grids/setono_sylius_gift_card_shop_gift_card.yaml b/config/grids/setono_sylius_gift_card_shop_gift_card.yaml similarity index 97% rename from src/Resources/config/grids/setono_sylius_gift_card_shop_gift_card.yaml rename to config/grids/setono_sylius_gift_card_shop_gift_card.yaml index 15092629..eef7ed9a 100644 --- a/src/Resources/config/grids/setono_sylius_gift_card_shop_gift_card.yaml +++ b/config/grids/setono_sylius_gift_card_shop_gift_card.yaml @@ -36,7 +36,7 @@ sylius_grid: label: sylius.ui.enabled sortable: ~ options: - template: "@SyliusUi/Grid/Field/enabled.html.twig" + template: "@SyliusUi/grid/field/enabled.html.twig" createdAt: type: datetime label: sylius.ui.created diff --git a/config/routes.yaml b/config/routes.yaml new file mode 100644 index 00000000..7c5ede59 --- /dev/null +++ b/config/routes.yaml @@ -0,0 +1,13 @@ +setono_sylius_gift_card_shop: + resource: "@SetonoSyliusGiftCardPlugin/config/routes/shop.yaml" + prefix: /{_locale} + requirements: + _locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$ + +setono_sylius_gift_card_admin: + resource: "@SetonoSyliusGiftCardPlugin/config/routes/admin.yaml" + prefix: /admin + +setono_sylius_gift_card_admin_ajax: + resource: "@SetonoSyliusGiftCardPlugin/config/routes/admin_ajax.yaml" + prefix: /admin/ajax diff --git a/src/Resources/config/routes/admin.yaml b/config/routes/admin.yaml similarity index 75% rename from src/Resources/config/routes/admin.yaml rename to config/routes/admin.yaml index 31a37f97..c41cf4e4 100644 --- a/src/Resources/config/routes/admin.yaml +++ b/config/routes/admin.yaml @@ -4,14 +4,12 @@ setono_sylius_gift_card_admin_gift_card: section: admin permission: true only: [index, update, delete, bulkDelete] - templates: '@SyliusAdmin\\Crud' + templates: "@SyliusAdmin\\shared\\crud" redirect: index grid: setono_sylius_gift_card_admin_gift_card vars: all: subheader: setono_sylius_gift_card.ui.manage_gift_cards - templates: - form: "@SetonoSyliusGiftCardPlugin/Admin/GiftCard/_form.html.twig" index: icon: 'gift' type: sylius.resource @@ -44,7 +42,7 @@ setono_sylius_gift_card_admin_gift_card_configuration: section: admin permission: true only: [index, create, update, delete, bulkDelete] - templates: '@SyliusAdmin\\Crud' + templates: "@SyliusAdmin\\shared\\crud" redirect: index grid: setono_sylius_gift_card_admin_gift_card_configuration vars: @@ -52,16 +50,6 @@ setono_sylius_gift_card_admin_gift_card_configuration: subheader: setono_sylius_gift_card.ui.manage_gift_card_configurations index: icon: 'gift' - templates: - breadcrumb: '@SetonoSyliusGiftCardPlugin/Admin/GiftCardConfiguration/Index/_breadcrumb.html.twig' - create: - templates: - breadcrumb: '@SetonoSyliusGiftCardPlugin/Admin/GiftCardConfiguration/Create/_breadcrumb.html.twig' - form: "@SetonoSyliusGiftCardPlugin/Admin/GiftCardConfiguration/_form.html.twig" - update: - templates: - breadcrumb: '@SetonoSyliusGiftCardPlugin/Admin/GiftCardConfiguration/Update/_breadcrumb.html.twig' - form: "@SetonoSyliusGiftCardPlugin/Admin/GiftCardConfiguration/_form.html.twig" type: sylius.resource # todo what is this route doing? @@ -86,7 +74,7 @@ setono_sylius_gift_card_admin_gift_card_create: method: createForChannelFromAdmin arguments: channel: "expr:service('sylius.repository.channel').findOneByCode($channelCode)" - template: '@SyliusAdmin/Crud/create.html.twig' + template: '@SyliusAdmin/shared/crud/create.html.twig' grid: setono_sylius_gift_card_admin_gift_card section: admin redirect: @@ -96,8 +84,7 @@ setono_sylius_gift_card_admin_gift_card_create: route: parameters: channelCode: $channelCode - templates: - form: "@SetonoSyliusGiftCardPlugin/Admin/GiftCard/_form.html.twig" + hook_prefix: setono_sylius_gift_card_admin_gift_card_create setono_sylius_gift_card_admin_gift_card_orders_index: path: /gift-cards/{id}/orders @@ -109,7 +96,7 @@ setono_sylius_gift_card_admin_gift_card_orders_index: route: parameters: id: $id - template: '@SyliusAdmin/Crud/index.html.twig' + template: '@SyliusAdmin/shared/crud/index.html.twig' grid: setono_sylius_gift_card_admin_gift_card_order section: admin permission: true diff --git a/config/routes/admin_ajax.yaml b/config/routes/admin_ajax.yaml new file mode 100644 index 00000000..4e6791df --- /dev/null +++ b/config/routes/admin_ajax.yaml @@ -0,0 +1,6 @@ +setono_sylius_gift_card_admin_ajax_generate_pdf: + path: /gift-card-configurations/{id}/generate-encoded-example-pdf + methods: [ PUT ] + controller: setono_sylius_gift_card.controller.action.generate_encoded_example_pdf + requirements: + id: \d+ diff --git a/src/Resources/config/routes/shop.yaml b/config/routes/shop.yaml similarity index 85% rename from src/Resources/config/routes/shop.yaml rename to config/routes/shop.yaml index 511a95c9..9a57e85b 100644 --- a/src/Resources/config/routes/shop.yaml +++ b/config/routes/shop.yaml @@ -16,12 +16,6 @@ setono_sylius_gift_card_shop_partial_add_gift_card_to_order: defaults: _controller: setono_sylius_gift_card.controller.action.add_gift_card_to_order -setono_sylius_gift_card_shop_ajax_add_gift_card_to_order: - path: /ajax/gift-card/add-to-order - methods: [ GET, POST ] - defaults: - _controller: setono_sylius_gift_card.controller.action.add_gift_card_to_order - setono_sylius_gift_card_shop_gift_card_index: path: /account/gift-cards methods: [ GET ] diff --git a/config/routes_no_locale.yaml b/config/routes_no_locale.yaml new file mode 100644 index 00000000..3b5dcd77 --- /dev/null +++ b/config/routes_no_locale.yaml @@ -0,0 +1,10 @@ +setono_sylius_gift_card_shop: + resource: "@SetonoSyliusGiftCardPlugin/config/routes/shop.yaml" + +setono_sylius_gift_card_admin: + resource: "@SetonoSyliusGiftCardPlugin/config/routes/admin.yaml" + prefix: /admin + +setono_sylius_gift_card_admin_ajax: + resource: "@SetonoSyliusGiftCardPlugin/config/routes/admin_ajax.yaml" + prefix: /admin/ajax diff --git a/src/Resources/config/serialization/Channel.xml b/config/serialization/Channel.xml similarity index 100% rename from src/Resources/config/serialization/Channel.xml rename to config/serialization/Channel.xml diff --git a/src/Resources/config/serialization/Customer.xml b/config/serialization/Customer.xml similarity index 100% rename from src/Resources/config/serialization/Customer.xml rename to config/serialization/Customer.xml diff --git a/src/Resources/config/serialization/GiftCard.xml b/config/serialization/GiftCard.xml similarity index 100% rename from src/Resources/config/serialization/GiftCard.xml rename to config/serialization/GiftCard.xml diff --git a/src/Resources/config/serialization/GiftCardBalance.xml b/config/serialization/GiftCardBalance.xml similarity index 100% rename from src/Resources/config/serialization/GiftCardBalance.xml rename to config/serialization/GiftCardBalance.xml diff --git a/src/Resources/config/serialization/GiftCardChannelConfiguration.xml b/config/serialization/GiftCardChannelConfiguration.xml similarity index 100% rename from src/Resources/config/serialization/GiftCardChannelConfiguration.xml rename to config/serialization/GiftCardChannelConfiguration.xml diff --git a/src/Resources/config/serialization/GiftCardConfiguration.xml b/config/serialization/GiftCardConfiguration.xml similarity index 100% rename from src/Resources/config/serialization/GiftCardConfiguration.xml rename to config/serialization/GiftCardConfiguration.xml diff --git a/src/Resources/config/serialization/GiftCardConfigurationImage.xml b/config/serialization/GiftCardConfigurationImage.xml similarity index 100% rename from src/Resources/config/serialization/GiftCardConfigurationImage.xml rename to config/serialization/GiftCardConfigurationImage.xml diff --git a/src/Resources/config/serialization/Product.xml b/config/serialization/Product.xml similarity index 100% rename from src/Resources/config/serialization/Product.xml rename to config/serialization/Product.xml diff --git a/src/Resources/config/services.xml b/config/services.xml similarity index 96% rename from src/Resources/config/services.xml rename to config/services.xml index dda2fd7e..3e32b51e 100644 --- a/src/Resources/config/services.xml +++ b/config/services.xml @@ -3,7 +3,6 @@ xmlns="http://symfony.com/schema/dic/services" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - diff --git a/src/Resources/config/services/applicator.xml b/config/services/applicator.xml similarity index 100% rename from src/Resources/config/services/applicator.xml rename to config/services/applicator.xml diff --git a/src/Resources/config/services/controller.xml b/config/services/controller.xml similarity index 100% rename from src/Resources/config/services/controller.xml rename to config/services/controller.xml diff --git a/src/Resources/config/services/event_listener.xml b/config/services/event_listener.xml similarity index 51% rename from src/Resources/config/services/event_listener.xml rename to config/services/event_listener.xml index 1eb03eed..7a20a579 100644 --- a/src/Resources/config/services/event_listener.xml +++ b/config/services/event_listener.xml @@ -25,12 +25,41 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/config/services/factory.xml b/config/services/factory.xml similarity index 95% rename from src/Resources/config/services/factory.xml rename to config/services/factory.xml index 7b1dfadc..094b31a3 100644 --- a/src/Resources/config/services/factory.xml +++ b/config/services/factory.xml @@ -10,7 +10,7 @@ - + diff --git a/src/Resources/config/services/field_types.xml b/config/services/field_types.xml similarity index 100% rename from src/Resources/config/services/field_types.xml rename to config/services/field_types.xml diff --git a/src/Resources/config/services/fixture.xml b/config/services/fixture.xml similarity index 97% rename from src/Resources/config/services/fixture.xml rename to config/services/fixture.xml index 71763f39..fc2e3031 100644 --- a/src/Resources/config/services/fixture.xml +++ b/config/services/fixture.xml @@ -19,7 +19,7 @@ - + diff --git a/src/Resources/config/services/form.xml b/config/services/form.xml similarity index 97% rename from src/Resources/config/services/form.xml rename to config/services/form.xml index 2b17d91b..e2dbc2cd 100644 --- a/src/Resources/config/services/form.xml +++ b/config/services/form.xml @@ -63,7 +63,7 @@ %setono_sylius_gift_card.order.model.gift_card_information.class% %setono_sylius_gift_card.form.type.add_to_cart_gift_card_information.validation_groups% - + @@ -110,8 +110,9 @@ - + %sylius.model.customer.class% + diff --git a/src/Resources/config/services/generator.xml b/config/services/generator.xml similarity index 100% rename from src/Resources/config/services/generator.xml rename to config/services/generator.xml diff --git a/src/Resources/config/services/menu.xml b/config/services/menu.xml similarity index 100% rename from src/Resources/config/services/menu.xml rename to config/services/menu.xml diff --git a/src/Resources/config/services/misc.xml b/config/services/misc.xml similarity index 100% rename from src/Resources/config/services/misc.xml rename to config/services/misc.xml diff --git a/src/Resources/config/services/modifier.xml b/config/services/modifier.xml similarity index 100% rename from src/Resources/config/services/modifier.xml rename to config/services/modifier.xml diff --git a/src/Resources/config/services/order.xml b/config/services/order.xml similarity index 100% rename from src/Resources/config/services/order.xml rename to config/services/order.xml diff --git a/src/Resources/config/services/order_processor.xml b/config/services/order_processor.xml similarity index 100% rename from src/Resources/config/services/order_processor.xml rename to config/services/order_processor.xml diff --git a/src/Resources/config/services/promotion_rule.xml b/config/services/promotion_rule.xml similarity index 100% rename from src/Resources/config/services/promotion_rule.xml rename to config/services/promotion_rule.xml diff --git a/src/Resources/config/services/provider.xml b/config/services/provider.xml similarity index 100% rename from src/Resources/config/services/provider.xml rename to config/services/provider.xml diff --git a/src/Resources/config/services/renderer.xml b/config/services/renderer.xml similarity index 100% rename from src/Resources/config/services/renderer.xml rename to config/services/renderer.xml diff --git a/src/Resources/config/services/resolver.xml b/config/services/resolver.xml similarity index 100% rename from src/Resources/config/services/resolver.xml rename to config/services/resolver.xml diff --git a/src/Resources/config/services/serializer.xml b/config/services/serializer.xml similarity index 94% rename from src/Resources/config/services/serializer.xml rename to config/services/serializer.xml index b746ac67..abc728fb 100644 --- a/src/Resources/config/services/serializer.xml +++ b/config/services/serializer.xml @@ -7,7 +7,7 @@ - + diff --git a/src/Resources/config/services/twig.xml b/config/services/twig.xml similarity index 62% rename from src/Resources/config/services/twig.xml rename to config/services/twig.xml index eebf960c..334c6162 100644 --- a/src/Resources/config/services/twig.xml +++ b/config/services/twig.xml @@ -16,5 +16,17 @@ + + + + + + + + + + diff --git a/src/Resources/config/services/validator.xml b/config/services/validator.xml similarity index 100% rename from src/Resources/config/services/validator.xml rename to config/services/validator.xml diff --git a/src/Resources/config/services/voter.xml b/config/services/voter.xml similarity index 100% rename from src/Resources/config/services/voter.xml rename to config/services/voter.xml diff --git a/config/sylius_ui.yaml b/config/sylius_ui.yaml new file mode 100644 index 00000000..17b3de03 --- /dev/null +++ b/config/sylius_ui.yaml @@ -0,0 +1,77 @@ +sylius_twig_hooks: + hooks: + 'sylius_shop.product.show.content.info.summary.add_to_cart': + setono_sylius_gift_card_information: + template: '@SetonoSyliusGiftCardPlugin/Shop/Product/Show/_addToCartGiftCardInformation.html.twig' + priority: 50 + + 'sylius_shop.cart.index.content.form.sections.general.summary': + setono_sylius_gift_card_applied_gift_cards: + template: '@SetonoSyliusGiftCardPlugin/Shop/Cart/Summary/_appliedGiftCards.html.twig' + priority: 150 + + 'sylius_shop.cart.index.content': + setono_sylius_gift_card_add_gift_card_to_order: + template: '@SetonoSyliusGiftCardPlugin/Shop/Cart/Summary/_addGiftCardToOrder.html.twig' + priority: 50 + + 'sylius_admin.order.show.content.sections.summary': + setono_sylius_gift_card_total: + template: '@SetonoSyliusGiftCardPlugin/Admin/Order/Show/Summary/_giftCardTotal.html.twig' + priority: 50 + + 'sylius_shop.shared.order.show.summary.table_summary': + setono_sylius_gift_card_total: + template: '@SetonoSyliusGiftCardPlugin/Shop/Order/Show/Summary/_giftCardTotal.html.twig' + priority: 250 + + 'setono_sylius_gift_card.shop.account.gift_card.index.content': + breadcrumbs: + template: '@SetonoSyliusGiftCardPlugin/Shop/Account/GiftCard/Index/_breadcrumbs.html.twig' + priority: 200 + menu: + template: '@SyliusShop/account/common/content/menu.html.twig' + priority: 100 + main: + template: '@SyliusShop/account/common/content/main.html.twig' + priority: 0 + + 'setono_sylius_gift_card.shop.account.gift_card.index.content.main': + grid: + template: '@SyliusShop/shared/grid.html.twig' + priority: 0 + + 'setono_sylius_gift_card.shop.account.gift_card.index.content.main.header': + title: + template: '@SetonoSyliusGiftCardPlugin/Shop/Account/GiftCard/Index/_title.html.twig' + priority: 100 + + 'sylius_admin.gift_card.update.content.form.sections.general': + default: + template: '@SetonoSyliusGiftCardPlugin/Admin/GiftCard/_form.html.twig' + priority: 0 + + 'sylius_admin.gift_card_configuration.create.content.form.sections.general': + default: + template: '@SetonoSyliusGiftCardPlugin/Admin/GiftCardConfiguration/_form.html.twig' + priority: 0 + + 'sylius_admin.gift_card_configuration.update.content.form.sections.general': + default: + template: '@SetonoSyliusGiftCardPlugin/Admin/GiftCardConfiguration/_form.html.twig' + priority: 0 + + 'setono_sylius_gift_card_admin_gift_card_create.create.content.form.sections.general': + default: + template: '@SetonoSyliusGiftCardPlugin/Admin/GiftCard/_form.html.twig' + priority: 0 + + 'sylius_admin.product.create.content.form.sections.general': + setono_sylius_gift_card: + template: '@SetonoSyliusGiftCardPlugin/Admin/Product/Form/Sections/General/_giftCard.html.twig' + priority: 350 + + 'sylius_admin.product.update.content.form.sections.general': + setono_sylius_gift_card: + template: '@SetonoSyliusGiftCardPlugin/Admin/Product/Form/Sections/General/_giftCard.html.twig' + priority: 350 diff --git a/src/Resources/config/validation/AddGiftCardToOrderCommand.xml b/config/validation/AddGiftCardToOrderCommand.xml similarity index 100% rename from src/Resources/config/validation/AddGiftCardToOrderCommand.xml rename to config/validation/AddGiftCardToOrderCommand.xml diff --git a/src/Resources/config/validation/AddToCardCommand.xml b/config/validation/AddToCardCommand.xml similarity index 100% rename from src/Resources/config/validation/AddToCardCommand.xml rename to config/validation/AddToCardCommand.xml diff --git a/src/Resources/config/validation/AddToCardGiftCardInformation.xml b/config/validation/AddToCardGiftCardInformation.xml similarity index 100% rename from src/Resources/config/validation/AddToCardGiftCardInformation.xml rename to config/validation/AddToCardGiftCardInformation.xml diff --git a/src/Resources/config/validation/GiftCard.xml b/config/validation/GiftCard.xml similarity index 100% rename from src/Resources/config/validation/GiftCard.xml rename to config/validation/GiftCard.xml diff --git a/src/Resources/config/validation/GiftCardChannelConfiguration.xml b/config/validation/GiftCardChannelConfiguration.xml similarity index 100% rename from src/Resources/config/validation/GiftCardChannelConfiguration.xml rename to config/validation/GiftCardChannelConfiguration.xml diff --git a/src/Resources/config/validation/GiftCardConfiguration.xml b/config/validation/GiftCardConfiguration.xml similarity index 100% rename from src/Resources/config/validation/GiftCardConfiguration.xml rename to config/validation/GiftCardConfiguration.xml diff --git a/src/Resources/config/validation/GiftCardConfigurationImage.xml b/config/validation/GiftCardConfigurationImage.xml similarity index 100% rename from src/Resources/config/validation/GiftCardConfigurationImage.xml rename to config/validation/GiftCardConfigurationImage.xml diff --git a/src/Resources/config/validation/GiftCardSearchCommand.xml b/config/validation/GiftCardSearchCommand.xml similarity index 100% rename from src/Resources/config/validation/GiftCardSearchCommand.xml rename to config/validation/GiftCardSearchCommand.xml diff --git a/ecs.php b/ecs.php index 6e01c257..6397e610 100644 --- a/ecs.php +++ b/ecs.php @@ -10,8 +10,4 @@ 'src', 'tests', ]); - $config->skip([ - 'tests/Application/node_modules/**', - 'tests/Application/var/**', - ]); }; diff --git a/features/admin/adding_gift_card.feature b/features/admin/adding_gift_card.feature deleted file mode 100644 index a6bf4eb6..00000000 --- a/features/admin/adding_gift_card.feature +++ /dev/null @@ -1,36 +0,0 @@ -@managing_gift_cards -Feature: Creating a gift card - In order to have gift cards in the shop - As an Administrator - I want to create a new gift card - - Background: - Given the store operates on a single channel in "United States" - And I am logged in as an administrator - And there is a customer account "john-doe@setono.com" - - @api - Scenario: Creating a gift card - When I want to create a new gift card - And I specify its code as "GIFT-CARD-100" - And I do not specify its customer - And I specify its amount as "$100" - And I specify its currency code as "USD" - And I specify its channel as "United States" - And I add it - Then I should be notified that it has been successfully created - And I should see a gift card with code "GIFT-CARD-100" valued at "$100" - And this gift card should have api origin - - @api - Scenario: Creating a gift card for a customer - When I want to create a new gift card - And I specify its code as "GIFT-CARD-100" - And I specify its customer as "john-doe@setono.com" - And I specify its amount as "$100" - And I specify its currency code as "USD" - And I specify its channel as "United States" - And I add it - Then I should be notified that it has been successfully created - And I should see a gift card with code "GIFT-CARD-100" valued at "$100" associated to the customer "john-doe@setono.com" - And this gift card should have api origin diff --git a/features/admin/adding_gift_card_configurations.feature b/features/admin/adding_gift_card_configurations.feature deleted file mode 100644 index 0389c179..00000000 --- a/features/admin/adding_gift_card_configurations.feature +++ /dev/null @@ -1,31 +0,0 @@ -@managing_gift_card_configurations -Feature: Adding a new gift card configuration - In order to create a gift card configuration - As an Administrator - I want to add a new gift card configuration - - Background: - Given the store operates on a single channel in "United States" - And I am logged in as an administrator - - @api - Scenario: Adding gift card configuration - When I want to create a new gift card configuration - And I specify its code as "new_configuration" - And I specify it as default configuration - And I add it - Then I should be notified that it has been successfully created - And I should see a gift card configuration with code "new_configuration" - And It should be enabled - And It should be default configuration - - @api - Scenario: Adding disabled gift card configuration - When I want to create a new gift card configuration - And I specify its code as "new_configuration" - And I disable it - And I add it - Then I should be notified that it has been successfully created - And I should see a gift card configuration with code "new_configuration" - And It should not be enabled - And It should not be default configuration diff --git a/features/admin/adding_product_that_is_gift_card.feature b/features/admin/adding_product_that_is_gift_card.feature index aa29710c..471b26f1 100644 --- a/features/admin/adding_product_that_is_gift_card.feature +++ b/features/admin/adding_product_that_is_gift_card.feature @@ -13,8 +13,8 @@ Feature: Adding a new product that is a gift card Scenario: Adding a new gift card product Given I want to create a new simple product When I specify its code as "gift_card_100" - And I name it "Gift Card $100" in "English (United States)" - And I set its slug to "gift-card-100" in "English (United States)" + And I name it "Gift Card $100" in "English (United States)" locale + And I set its slug to "gift-card-100" in "English (United States)" locale And I set its price to "$100.00" for "United States" channel And I set its gift card value to true And I add it diff --git a/features/admin/associating_gift_card_configurations.feature b/features/admin/associating_gift_card_configurations.feature deleted file mode 100644 index f5974312..00000000 --- a/features/admin/associating_gift_card_configurations.feature +++ /dev/null @@ -1,20 +0,0 @@ -@managing_gift_card_configurations -Feature: Associating an existing gift card configuration to a channel - In order to define a different gift card configuration per channel - As an Administrator - I want to associate an existing gift card configuration to a channel with a locale - - Background: - Given the store operates on a channel named "United States" in "USD" currency - And that channel allows to shop using "English" and "French" locales - And the store operates on a channel named "Europe" in "EUR" currency - And that channel allows to shop using "English" and "French" locales - And I am logged in as an administrator - And the store has a gift card configuration with code "default_configuration" - - @api - Scenario: Association an existing gift card configuration to a channel - When I associate gift card configuration default_configuration to channel "Europe" and locale fr - Then I should be notified that it has been successfully updated - And I should see a gift card configuration with code "default_configuration" - And It should have channel configuration for channel "Europe" and locale fr diff --git a/features/admin/browse_gift_cards.feature b/features/admin/browse_gift_cards.feature deleted file mode 100644 index cfa02498..00000000 --- a/features/admin/browse_gift_cards.feature +++ /dev/null @@ -1,17 +0,0 @@ -@managing_gift_cards -Feature: Browsing existing gift cards - In order to manage the existing gift cards - As an Administrator - I want to browse existing gift cards - - Background: - Given the store operates on a single channel in "United States" - And I am logged in as an administrator - And the store has a gift card with code "GIFT-CARD-100" valued at "$100" - And the store has a gift card with code "GIFT-CARD-200" valued at "$200" - - @api - Scenario: Browsing gift cards - When I browse gift cards - Then I should see a gift card with code "GIFT-CARD-100" valued at "$100" - And I should see a gift card with code "GIFT-CARD-200" valued at "$200" diff --git a/features/admin/browsing_gift_card_configurations.feature b/features/admin/browsing_gift_card_configurations.feature deleted file mode 100644 index 024e110d..00000000 --- a/features/admin/browsing_gift_card_configurations.feature +++ /dev/null @@ -1,17 +0,0 @@ -@managing_gift_card_configurations -Feature: Browsing existing gift card configurations - In order to manage the existing gift card configurations - As an Administrator - I want to browse existing gift card configurations - - Background: - Given the store operates on a single channel in "United States" - And I am logged in as an administrator - And the store has a gift card configuration with code "default_configuration" - And the store has a gift card configuration with code "second_configuration" - - @api - Scenario: Browsing gift cards - When I browse gift card configurations - Then I should see a gift card configuration with code "default_configuration" - And I should see a gift card configuration with code "second_configuration" diff --git a/features/admin/deleting_gift_card_configurations.feature b/features/admin/deleting_gift_card_configurations.feature deleted file mode 100644 index 89ab0cad..00000000 --- a/features/admin/deleting_gift_card_configurations.feature +++ /dev/null @@ -1,16 +0,0 @@ -@managing_gift_card_configurations -Feature: Deleting an existing gift card configuration - In order to remove a gift card configuration - As an Administrator - I want to delete an existing gift card configuration - - Background: - Given the store operates on a single channel in "United States" - And I am logged in as an administrator - And the store has a gift card configuration with code "default_configuration" - - @api - Scenario: Deleting an existing gift card configuration - When I delete gift card configuration "default_configuration" - Then I should be notified that it has been successfully deleted - And I should not see a gift card configuration with code "default_configuration" diff --git a/features/admin/deleting_gift_cards.feature b/features/admin/deleting_gift_cards.feature deleted file mode 100644 index d1dc5c0b..00000000 --- a/features/admin/deleting_gift_cards.feature +++ /dev/null @@ -1,16 +0,0 @@ -@managing_gift_cards -Feature: Deleting an existing gift card - In order to manage the existing gift cards - As an Administrator - I want to delete an existing gift card - - Background: - Given the store operates on a channel named "United States" in "USD" currency - And I am logged in as an administrator - And the store has a gift card with code "GIFT-CARD-100" valued at "$100" - - @api - Scenario: Deleting gift card - When I delete the gift card "GIFT-CARD-100" - Then I should be notified that it has been successfully deleted - And I should no longer see a gift card with code "GIFT-CARD-100" diff --git a/features/admin/reading_gift_cards.feature b/features/admin/reading_gift_cards.feature deleted file mode 100644 index 8cf2255b..00000000 --- a/features/admin/reading_gift_cards.feature +++ /dev/null @@ -1,18 +0,0 @@ -@managing_gift_cards -Feature: Reading an existing gift card - In order to manage the existing gift cards - As an Administrator - I want to read an existing gift card - - Background: - Given the store operates on a channel named "United States" in "USD" currency - And I am logged in as an administrator - And the store has a gift card with code "GIFT-CARD-100" valued at "$100" - - @api - Scenario: Browsing gift cards - When I open the gift card "GIFT-CARD-100" page - Then It should be valued at "$100" - And It should be initially valued at "$100" - And It should be on channel "United States" - And It should have "USD" currency diff --git a/features/admin/updating_gift_card_configurations.feature b/features/admin/updating_gift_card_configurations.feature deleted file mode 100644 index 51377706..00000000 --- a/features/admin/updating_gift_card_configurations.feature +++ /dev/null @@ -1,28 +0,0 @@ -@managing_gift_card_configurations -Feature: Updating an existing gift card configuration - In order to modify a gift card configuration - As an Administrator - I want to edit an existing gift card configuration - - Background: - Given the store operates on a single channel in "United States" - And I am logged in as an administrator - And the store has a gift card configuration with code "default_configuration" - - @api - Scenario: Updating an existing gift card configuration - When I want to update gift card configuration "default_configuration" - And I disable it - And I save my changes - Then I should be notified that it has been successfully updated - And I should see a gift card configuration with code "default_configuration" - And It should be disabled - - @api - Scenario: Updating an existing gift card configuration - When I want to update gift card configuration "default_configuration" - And I enable it - And I save my changes - Then I should be notified that it has been successfully updated - And I should see a gift card configuration with code "default_configuration" - And It should be enabled diff --git a/features/admin/updating_gift_cards.feature b/features/admin/updating_gift_cards.feature deleted file mode 100644 index f99d8b99..00000000 --- a/features/admin/updating_gift_cards.feature +++ /dev/null @@ -1,23 +0,0 @@ -@managing_gift_cards -Feature: Updating an existing gift card - In order to manage the existing gift cards - As an Administrator - I want to update an existing gift card - - Background: - Given the store operates on a channel named "United States" in "USD" currency - And I am logged in as an administrator - And the store has a gift card with code "GIFT-CARD-100" valued at "$100" - - @api - Scenario: Updating gift card - When I want to edit the gift card "GIFT-CARD-100" - And I do not specify its customer - And I specify its amount as "$150" - And I specify its currency code as "USD" - And I specify its channel as "United States" - And I disable it - And I save my changes - Then I should be notified that it has been successfully updated - And It should be valued at "$150" - And It should be disabled diff --git a/features/admin/viewing_gift_cards_balance.feature b/features/admin/viewing_gift_cards_balance.feature deleted file mode 100644 index 2d058e1d..00000000 --- a/features/admin/viewing_gift_cards_balance.feature +++ /dev/null @@ -1,23 +0,0 @@ -@managing_gift_cards_balance -Feature: Viewing gift cards balance - In order to get a view of edited gift cards amount - As an Administrator - I want to see gift cards balance - - Background: - Given the store has currency "USD" - And the store has currency "EUR" - And the store operates on a channel named "United States" in "USD" currency - And that channel allows to shop using "EUR" and "USD" currencies - And the store operates on a channel named "Europe" in "EUR" currency - And that channel allows to shop using "EUR" and "USD" currencies - And I am logged in as an administrator - And the store has a gift card with code "GIFT-CARD-100" valued at "$100" on channel "United States" - And the store has a gift card with code "GIFT-CARD-200" valued at "$200" on channel "United States" - And the store has a gift card with code "GIFT-CARD-50" valued at "€50" on channel "Europe" - - @api - Scenario: Browsing gift cards - When I browse gift cards balance - Then I should see a gift card balance of "$300" in "USD" currency - And I should see a gift card balance of "€50" in "EUR" currency diff --git a/features/shop/adding_configurable_gift_card_to_cart.feature b/features/shop/adding_configurable_gift_card_to_cart.feature index 86fab005..5c1a5e5e 100644 --- a/features/shop/adding_configurable_gift_card_to_cart.feature +++ b/features/shop/adding_configurable_gift_card_to_cart.feature @@ -9,7 +9,7 @@ Feature: Adding a configurable gift card to the cart And the store has a product "Gift card" And this product is a configurable gift card - @ui + @ui @mink:chromedriver Scenario: Adding a configurable gift card to the cart Given I am a logged in customer When I add this product to the cart with amount "$125.00" and custom message "Hey buddy" @@ -18,9 +18,3 @@ Feature: Adding a configurable gift card to the cart And there should be one item in my cart And this item should have name "Gift card" And total price of "Gift card" item should be "$125.00" - - @api - Scenario: Adding a configurable gift card to the cart - Given I am a logged in customer - When I add this product to the cart with amount "$125.00" and custom message "Hey buddy" - Then I should see "Gift card" with unit price "$125.00" in my cart diff --git a/features/shop/applying_gift_card.feature b/features/shop/applying_gift_card.feature index 19dc0722..3efa1cc3 100644 --- a/features/shop/applying_gift_card.feature +++ b/features/shop/applying_gift_card.feature @@ -7,29 +7,18 @@ Feature: Applying gift card Background: Given the store operates on a single channel in "United States" And the store has a product "PHP T-Shirt" priced at "$100.00" - And the store has a product "Javascript T-Shirt" priced at "$1" - And the store has a gift card with code "GIFT-CARD-100" valued at "$100" + And the store has a product "Javascript T-Shirt" priced at "$1.00" + And the store has a gift card with code "GIFT-CARD-100" valued at "$100.00" And the store ships everywhere for free And the store allows paying offline - @ui + @ui @mink:chromedriver Scenario: Buying a gift card Given I am a logged in customer - And I have product "PHP T-Shirt" in the cart - And I have product "Javascript T-Shirt" in the cart + And I have product "PHP T-Shirt" added to the cart + And I have product "Javascript T-Shirt" added to the cart And I apply gift card with code "GIFT-CARD-100" - When I proceed selecting "Offline" payment method - And I confirm my order - Then I should see the thank you page - And the gift card "GIFT-CARD-100" should be disabled - - @api - Scenario: Buying a gift card - Given I am a logged in customer - And I have product "PHP T-Shirt" in the cart - And I have product "Javascript T-Shirt" in the cart - And I apply gift card with code "GIFT-CARD-100" - When I proceed through checkout process + When I proceed with selecting "Offline" payment method And I confirm my order Then I should see the thank you page And the gift card "GIFT-CARD-100" should be disabled diff --git a/features/shop/browse_gift_cards.feature b/features/shop/browse_gift_cards.feature deleted file mode 100644 index c51388ff..00000000 --- a/features/shop/browse_gift_cards.feature +++ /dev/null @@ -1,22 +0,0 @@ -@managing_shop_gift_cards -Feature: Browsing existing gift cards - In order to see my gift cards - As a Shop user - I want to browse existing gift cards that are associated to my account - - Background: - Given the store operates on a single channel in "United States" - And there is a user "alice@setono.com" identified by "sylius" - And I am logged in as "alice@setono.com" - And the store has a gift card with code "GIFT-CARD-100" valued at "$100" associated to customer "alice@setono.com" - And the store has a gift card with code "GIFT-CARD-200" valued at "$200" associated to customer "alice@setono.com" - And the store has a gift card with code "GIFT-CARD-200-2" valued at "$200" - And the store has a gift card with code "GIFT-CARD-200-3" valued at "$200" associated to customer "alices-husband@setono.com" - - @api - Scenario: Browsing gift cards - When I browse gift cards - Then Gift cards list should contain a gift card with code "GIFT-CARD-100" - And Gift cards list should contain a gift card with code "GIFT-CARD-200" - And Gift cards list should not contain a gift card with code "GIFT-CARD-200-2" - And Gift cards list should not contain a gift card with code "GIFT-CARD-200-3" diff --git a/features/shop/buying_gift_card.feature b/features/shop/buying_gift_card.feature index 4381e784..267f0811 100644 --- a/features/shop/buying_gift_card.feature +++ b/features/shop/buying_gift_card.feature @@ -11,11 +11,11 @@ Feature: Buying a gift card And the store ships everywhere for free And the store allows paying offline - @ui + @ui @mink:chromedriver Scenario: Buying a gift card Given I am a logged in customer - And I have product "Gift card 100" in the cart - When I proceed selecting "Offline" payment method + And I have product "Gift card 100" added to the cart + When I proceed with selecting "Offline" payment method And I confirm my order and pay successfully Then I should see the thank you page And I should receive an email with gift card code diff --git a/features/shop/reading_gift_cards.feature b/features/shop/reading_gift_cards.feature deleted file mode 100644 index 67accff8..00000000 --- a/features/shop/reading_gift_cards.feature +++ /dev/null @@ -1,15 +0,0 @@ -@managing_shop_gift_cards -Feature: Reading an existing gift card - In order to see the existing gift cards - I want to read an existing gift card by its code - - Background: - Given the store operates on a channel named "United States" in "USD" currency - And the store has a gift card with code "GIFT-CARD-100" valued at "$100" - - @api - Scenario: Browsing gift cards - When I open the gift card "GIFT-CARD-100" page - Then It should be valued at "$100" - And It should be initially valued at "$100" - And It should have "USD" currency diff --git a/features/shop/removing_gift_card.feature b/features/shop/removing_gift_card.feature deleted file mode 100644 index ebb62691..00000000 --- a/features/shop/removing_gift_card.feature +++ /dev/null @@ -1,25 +0,0 @@ -@applying_gift_card -Feature: Removing gift card - In order to cancel gift card application - As a Customer - I want to have gift card removed from my cart - - Background: - Given the store operates on a single channel in "United States" - And the store has a product "PHP T-Shirt" priced at "$100.00" - And the store has a product "Javascript T-Shirt" priced at "$1" - And the store has a gift card with code "GIFT-CARD-100" valued at "$100" - And the store ships everywhere for free - And the store allows paying offline - And I have product "PHP T-Shirt" in the cart - And I have product "Javascript T-Shirt" in the cart - And My cart has gift card with code "GIFT-CARD-100" - - @api - Scenario: Buying a gift card - Given I am a logged in customer - And I remove gift card with code "GIFT-CARD-100" - When I proceed through checkout process - And I confirm my order - Then I should see the thank you page - And the gift card "GIFT-CARD-100" should still be enabled diff --git a/src/Resources/fixtures/default_background.png b/fixtures/default_background.png similarity index 100% rename from src/Resources/fixtures/default_background.png rename to fixtures/default_background.png diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 33c5b231..ecbf8bb5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,7 +3,7 @@ + bootstrap="vendor/sylius/test-application/config/bootstrap.php"> src/ @@ -15,7 +15,7 @@ - + diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 14bad85e..f4acb63c 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,9 +1,3 @@ - - - LegacyIriConverterInterface|IriConverterInterface - LegacyIriConverterInterface|IriConverterInterface - - diff --git a/psalm.xml b/psalm.xml index 6962ce05..5e928033 100644 --- a/psalm.xml +++ b/psalm.xml @@ -15,12 +15,11 @@ - + - @@ -31,12 +30,24 @@ - + - + - + + + + + + + + + + + + + @@ -46,10 +57,5 @@ - - - - - diff --git a/src/Resources/public/setono-logo.png b/public/setono-logo.png similarity index 100% rename from src/Resources/public/setono-logo.png rename to public/setono-logo.png diff --git a/spec/Applicator/GiftCardApplicatorSpec.php b/spec/Applicator/GiftCardApplicatorSpec.php index c74e666e..5c473e9c 100644 --- a/spec/Applicator/GiftCardApplicatorSpec.php +++ b/spec/Applicator/GiftCardApplicatorSpec.php @@ -4,7 +4,6 @@ namespace spec\Setono\SyliusGiftCardPlugin\Applicator; -use Doctrine\Persistence\ObjectManager; use PhpSpec\ObjectBehavior; use Setono\SyliusGiftCardPlugin\Applicator\GiftCardApplicator; use Setono\SyliusGiftCardPlugin\Applicator\GiftCardApplicatorInterface; @@ -18,10 +17,9 @@ final class GiftCardApplicatorSpec extends ObjectBehavior { public function let( GiftCardRepositoryInterface $giftCardRepository, - OrderProcessorInterface $orderProcessor, - ObjectManager $orderManager + OrderProcessorInterface $orderProcessor ): void { - $this->beConstructedWith($giftCardRepository, $orderProcessor, $orderManager); + $this->beConstructedWith($giftCardRepository, $orderProcessor); } public function it_implements_gift_card_applicator_interface(): void @@ -37,13 +35,14 @@ public function it_is_initializable(): void public function it_applies( GiftCardRepositoryInterface $giftCardRepository, OrderProcessorInterface $orderProcessor, - ObjectManager $orderManager, OrderInterface $order, GiftCardInterface $giftCard, ChannelInterface $channel ): void { $giftCardCode = '123'; + $giftCard->isEnabled()->willReturn(true); + $giftCard->isExpired()->willReturn(false); $giftCard->getChannel()->willReturn($channel); $order->getChannel()->willReturn($channel); @@ -52,7 +51,6 @@ public function it_applies( $giftCardRepository->findOneByCode($giftCardCode)->willReturn($giftCard); $orderProcessor->process($order)->shouldBeCalled(); - $orderManager->flush()->shouldBeCalled(); $this->apply($order, $giftCardCode); } diff --git a/spec/EmailManager/GiftCardEmailManagerSpec.php b/spec/EmailManager/GiftCardEmailManagerSpec.php index cf2d0ef9..9fd28a33 100644 --- a/spec/EmailManager/GiftCardEmailManagerSpec.php +++ b/spec/EmailManager/GiftCardEmailManagerSpec.php @@ -9,6 +9,8 @@ use Setono\SyliusGiftCardPlugin\EmailManager\GiftCardEmailManagerInterface; use Setono\SyliusGiftCardPlugin\Mailer\Emails; use Setono\SyliusGiftCardPlugin\Model\GiftCardInterface; +use Setono\SyliusGiftCardPlugin\Renderer\PdfRendererInterface; +use Setono\SyliusGiftCardPlugin\Renderer\PdfResponse; use Setono\SyliusGiftCardPlugin\Resolver\CustomerChannelResolverInterface; use Setono\SyliusGiftCardPlugin\Resolver\LocaleResolverInterface; use Sylius\Component\Core\Model\ChannelInterface; @@ -24,11 +26,12 @@ public function let( SenderInterface $sender, LocaleAwareInterface $translator, CustomerChannelResolverInterface $customerChannelResolver, - LocaleResolverInterface $localeResolver + LocaleResolverInterface $localeResolver, + PdfRendererInterface $pdfRenderer ): void { $translator->getLocale()->willReturn('en_US'); - $this->beConstructedWith($sender, $translator, $customerChannelResolver, $localeResolver); + $this->beConstructedWith($sender, $translator, $customerChannelResolver, $localeResolver, $pdfRenderer, sys_get_temp_dir()); } public function it_is_initializable(): void @@ -49,7 +52,8 @@ public function it_sends_email_with_gift_card_codes( ChannelInterface $channel, LocaleInterface $locale, LocaleAwareInterface $translator, - LocaleResolverInterface $localeResolver + LocaleResolverInterface $localeResolver, + PdfRendererInterface $pdfRenderer ): void { $customer->getEmail()->willReturn('example@shop.com'); $order->getCustomer()->willReturn($customer); @@ -58,13 +62,18 @@ public function it_sends_email_with_gift_card_codes( $channel->getDefaultLocale()->willReturn($locale); $locale->getCode()->willReturn('en_US'); $localeResolver->resolveFromOrder($order)->willReturn('en_US'); + $giftCard->getCode()->willReturn('GIFT-CARD-CODE'); + $pdfRenderer->render($giftCard)->willReturn(new PdfResponse('%PDF-fake%')); $translator->setLocale('en_US')->shouldBeCalled(); + $expectedAttachment = sprintf('%s/gift-card-GIFT-CARD-CODE.pdf', sys_get_temp_dir()); + $sender->send( Emails::GIFT_CARD_ORDER, ['example@shop.com'], - ['giftCards' => [$giftCard], 'order' => $order, 'channel' => $channel, 'localeCode' => 'en_US'] + ['giftCards' => [$giftCard], 'order' => $order, 'channel' => $channel, 'localeCode' => 'en_US'], + [$expectedAttachment], )->shouldBeCalled(); $this->sendEmailWithGiftCardsFromOrder($order, [$giftCard]); diff --git a/spec/Modifier/OrderGiftCardAmountModifierSpec.php b/spec/Modifier/OrderGiftCardAmountModifierSpec.php index 0fe3a23d..4b6f321c 100644 --- a/spec/Modifier/OrderGiftCardAmountModifierSpec.php +++ b/spec/Modifier/OrderGiftCardAmountModifierSpec.php @@ -5,7 +5,6 @@ namespace spec\Setono\SyliusGiftCardPlugin\Modifier; use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\Persistence\ObjectManager; use PhpSpec\ObjectBehavior; use Setono\SyliusGiftCardPlugin\Model\AdjustmentInterface; use Setono\SyliusGiftCardPlugin\Model\GiftCardInterface; @@ -15,12 +14,6 @@ final class OrderGiftCardAmountModifierSpec extends ObjectBehavior { - public function let( - ObjectManager $giftCardManager - ): void { - $this->beConstructedWith($giftCardManager); - } - public function it_is_initializable(): void { $this->shouldHaveType(OrderGiftCardAmountModifier::class); diff --git a/src/Api/Command/AddGiftCardToOrder.php b/src/Api/Command/AddGiftCardToOrder.php deleted file mode 100644 index 43dd5a29..00000000 --- a/src/Api/Command/AddGiftCardToOrder.php +++ /dev/null @@ -1,27 +0,0 @@ -orderTokenValue = $orderTokenValue; - } - - public function getGiftCardCode(): ?string - { - return $this->giftCardCode; - } - - public function setGiftCardCode(?string $giftCardCode): void - { - $this->giftCardCode = $giftCardCode; - } -} diff --git a/src/Api/Command/AddItemToCart.php b/src/Api/Command/AddItemToCart.php deleted file mode 100644 index fdf8735e..00000000 --- a/src/Api/Command/AddItemToCart.php +++ /dev/null @@ -1,32 +0,0 @@ -amount = $amount; - $this->customMessage = $customMessage; - } - - public function getAmount(): ?int - { - return $this->amount; - } - - public function getCustomMessage(): ?string - { - return $this->customMessage; - } -} diff --git a/src/Api/Command/AssociateConfigurationToChannel.php b/src/Api/Command/AssociateConfigurationToChannel.php deleted file mode 100644 index 92032cde..00000000 --- a/src/Api/Command/AssociateConfigurationToChannel.php +++ /dev/null @@ -1,30 +0,0 @@ -localeCode = $localeCode; - $this->channelCode = $channelCode; - } - - public function getConfigurationCode(): ?string - { - return $this->configurationCode; - } - - public function setConfigurationCode(?string $configurationCode): void - { - $this->configurationCode = $configurationCode; - } -} diff --git a/src/Api/Command/ConfigurationCodeAwareInterface.php b/src/Api/Command/ConfigurationCodeAwareInterface.php deleted file mode 100644 index 945d1757..00000000 --- a/src/Api/Command/ConfigurationCodeAwareInterface.php +++ /dev/null @@ -1,14 +0,0 @@ -code = $code; - $this->default = $default; - $this->enabled = $enabled; - $this->defaultValidityPeriod = $defaultValidityPeriod; - $this->pageSize = $pageSize; - $this->orientation = $orientation; - $this->template = $template; - } -} diff --git a/src/Api/Command/GiftCardCodeAwareInterface.php b/src/Api/Command/GiftCardCodeAwareInterface.php deleted file mode 100644 index 82189996..00000000 --- a/src/Api/Command/GiftCardCodeAwareInterface.php +++ /dev/null @@ -1,14 +0,0 @@ -orderTokenValue = $orderTokenValue; - } - - public function getGiftCardCode(): ?string - { - return $this->giftCardCode; - } - - public function setGiftCardCode(?string $giftCardCode): void - { - $this->giftCardCode = $giftCardCode; - } -} diff --git a/src/Api/CommandHandler/AddGiftCardToOrderHandler.php b/src/Api/CommandHandler/AddGiftCardToOrderHandler.php deleted file mode 100644 index 6fca53ef..00000000 --- a/src/Api/CommandHandler/AddGiftCardToOrderHandler.php +++ /dev/null @@ -1,49 +0,0 @@ -giftCardRepository = $giftCardRepository; - $this->orderRepository = $orderRepository; - $this->giftCardApplicator = $giftCardApplicator; - } - - public function __invoke(AddGiftCardToOrder $command): GiftCardInterface - { - $giftCardCode = $command->getGiftCardCode(); - Assert::notNull($giftCardCode); - - $giftCard = $this->giftCardRepository->findOneByCode($giftCardCode); - Assert::notNull($giftCard); - - /** @var OrderInterface|null $order */ - $order = $this->orderRepository->findOneBy(['tokenValue' => $command->orderTokenValue]); - Assert::notNull($order); - - $this->giftCardApplicator->apply($order, $giftCard); - - return $giftCard; - } -} diff --git a/src/Api/CommandHandler/AddItemToCartHandler.php b/src/Api/CommandHandler/AddItemToCartHandler.php deleted file mode 100644 index 54535be5..00000000 --- a/src/Api/CommandHandler/AddItemToCartHandler.php +++ /dev/null @@ -1,101 +0,0 @@ -orderRepository = $orderRepository; - $this->productVariantRepository = $productVariantRepository; - $this->orderModifier = $orderModifier; - $this->cartItemFactory = $cartItemFactory; - $this->orderItemQuantityModifier = $orderItemQuantityModifier; - $this->giftCardFactory = $giftCardFactory; - $this->giftCardManager = $giftCardManager; - } - - public function __invoke(SyliusAddItemToCart $addItemToCart): OrderInterface - { - /** @var ProductVariantInterface|null $productVariant */ - $productVariant = $this->productVariantRepository->findOneBy(['code' => $addItemToCart->productVariantCode]); - - Assert::notNull($productVariant); - Assert::notNull($addItemToCart->orderTokenValue); - - /** @var OrderInterface|null $cart */ - $cart = $this->orderRepository->findCartByTokenValue($addItemToCart->orderTokenValue); - - Assert::notNull($cart); - - /** @var OrderItemInterface $cartItem */ - $cartItem = $this->cartItemFactory->createNew(); - $cartItem->setVariant($productVariant); - - if ($addItemToCart instanceof SetonoSyliusGiftCardAddItemToCart) { - /** @var ProductInterface $product */ - $product = $productVariant->getProduct(); - if ($product->isGiftCardAmountConfigurable()) { - $giftCardAmount = $addItemToCart->getAmount(); - Assert::notNull($giftCardAmount); - $cartItem->setUnitPrice($giftCardAmount); - $cartItem->setImmutable(true); - } - } - - $this->orderItemQuantityModifier->modify($cartItem, $addItemToCart->quantity); - $this->orderModifier->addToOrder($cart, $cartItem); - - if ($addItemToCart instanceof SetonoSyliusGiftCardAddItemToCart) { - /** @var OrderItemUnitInterface $unit */ - foreach ($cartItem->getUnits() as $unit) { - $giftCard = $this->giftCardFactory->createFromOrderItemUnitAndCart($unit, $cart); - $giftCard->setCustomMessage($addItemToCart->getCustomMessage()); - - // As the common flow for any add to cart action will flush later. Do not flush here. - $this->giftCardManager->persist($giftCard); - } - } - - return $cart; - } -} diff --git a/src/Api/CommandHandler/AssociateConfigurationToChannelHandler.php b/src/Api/CommandHandler/AssociateConfigurationToChannelHandler.php deleted file mode 100644 index f8418c22..00000000 --- a/src/Api/CommandHandler/AssociateConfigurationToChannelHandler.php +++ /dev/null @@ -1,77 +0,0 @@ -giftCardConfigurationRepository = $giftCardConfigurationRepository; - $this->channelRepository = $channelRepository; - $this->localeRepository = $localeRepository; - $this->giftCardChannelConfigurationRepository = $giftCardChannelConfigurationRepository; - $this->giftCardChannelConfigurationFactory = $giftCardChannelConfigurationFactory; - } - - public function __invoke(AssociateConfigurationToChannel $command): GiftCardConfigurationInterface - { - Assert::notNull($command->getConfigurationCode(), 'GiftCardConfiguration code can not be null'); - - /** @var GiftCardConfigurationInterface|null $configuration */ - $configuration = $this->giftCardConfigurationRepository->findOneBy(['code' => $command->getConfigurationCode()]); - Assert::notNull($configuration, 'GiftCardConfiguration can not be null'); - - $channel = $this->channelRepository->findOneByCode($command->channelCode); - Assert::notNull($channel, 'Channel can not be null'); - - /** @var LocaleInterface|null $locale */ - $locale = $this->localeRepository->findOneBy(['code' => $command->localeCode]); - Assert::notNull($locale, 'Locale can not be null'); - - /** @var GiftCardChannelConfigurationInterface|null $existingChannelConfiguration */ - $existingChannelConfiguration = $this->giftCardChannelConfigurationRepository->findOneBy([ - 'configuration' => $configuration, - 'channel' => $channel, - 'locale' => $locale, - ]); - if (null !== $existingChannelConfiguration) { - return $configuration; - } - - /** @var GiftCardChannelConfigurationInterface $channelConfiguration */ - $channelConfiguration = $this->giftCardChannelConfigurationFactory->createNew(); - $channelConfiguration->setConfiguration($configuration); - $channelConfiguration->setChannel($channel); - $channelConfiguration->setLocale($locale); - - $configuration->addChannelConfiguration($channelConfiguration); - - return $configuration; - } -} diff --git a/src/Api/CommandHandler/CreateGiftCardConfigurationHandler.php b/src/Api/CommandHandler/CreateGiftCardConfigurationHandler.php deleted file mode 100644 index 47fb3e63..00000000 --- a/src/Api/CommandHandler/CreateGiftCardConfigurationHandler.php +++ /dev/null @@ -1,50 +0,0 @@ -giftCardConfigurationFactory = $giftCardConfigurationFactory; - $this->giftCardConfigurationManager = $giftCardConfigurationManager; - } - - public function __invoke(CreateGiftCardConfiguration $command): GiftCardConfigurationInterface - { - $giftCardConfiguration = $this->giftCardConfigurationFactory->createNew(); - - $giftCardConfiguration->setCode($command->code); - $giftCardConfiguration->setEnabled($command->enabled); - $giftCardConfiguration->setDefault($command->default); - if (null !== $command->defaultValidityPeriod) { - $giftCardConfiguration->setDefaultValidityPeriod($command->defaultValidityPeriod); - } - if (null !== $command->pageSize) { - $giftCardConfiguration->setPageSize($command->pageSize); - } - if (null !== $command->orientation) { - $giftCardConfiguration->setOrientation($command->orientation); - } - if (null !== $command->template) { - $giftCardConfiguration->setTemplate($command->template); - } - - $this->giftCardConfigurationManager->persist($giftCardConfiguration); - - return $giftCardConfiguration; - } -} diff --git a/src/Api/CommandHandler/RemoveGiftCardFromOrderHandler.php b/src/Api/CommandHandler/RemoveGiftCardFromOrderHandler.php deleted file mode 100644 index 8487fa23..00000000 --- a/src/Api/CommandHandler/RemoveGiftCardFromOrderHandler.php +++ /dev/null @@ -1,49 +0,0 @@ -giftCardRepository = $giftCardRepository; - $this->orderRepository = $orderRepository; - $this->giftCardApplicator = $giftCardApplicator; - } - - public function __invoke(RemoveGiftCardFromOrder $command): GiftCardInterface - { - $giftCardCode = $command->getGiftCardCode(); - Assert::notNull($giftCardCode); - - $giftCard = $this->giftCardRepository->findOneByCode($giftCardCode); - Assert::notNull($giftCard); - - /** @var OrderInterface|null $order */ - $order = $this->orderRepository->findOneBy(['tokenValue' => $command->orderTokenValue]); - Assert::notNull($order); - - $this->giftCardApplicator->remove($order, $giftCard); - - return $giftCard; - } -} diff --git a/src/Api/Controller/Action/DownloadGiftCardPdfAction.php b/src/Api/Controller/Action/DownloadGiftCardPdfAction.php deleted file mode 100644 index 8f7ced89..00000000 --- a/src/Api/Controller/Action/DownloadGiftCardPdfAction.php +++ /dev/null @@ -1,37 +0,0 @@ -configurationProvider = $configurationProvider; - $this->pdfRenderer = $giftCardPDFRenderer; - } - - public function __invoke(GiftCardInterface $data): Response - { - $configuration = $this->configurationProvider->getConfigurationForGiftCard($data); - if (!$configuration instanceof GiftCardConfigurationInterface) { - throw new NotFoundHttpException('No configuration found for this GiftCard'); - } - - return $this->pdfRenderer->render($data, $configuration); - } -} diff --git a/src/Api/Controller/Action/GiftCardBalanceAction.php b/src/Api/Controller/Action/GiftCardBalanceAction.php deleted file mode 100644 index 7b89460c..00000000 --- a/src/Api/Controller/Action/GiftCardBalanceAction.php +++ /dev/null @@ -1,25 +0,0 @@ -giftCardRepository = $giftCardRepository; - } - - public function __invoke(): GiftCardBalanceCollection - { - return GiftCardBalanceCollection::createFromGiftCards( - $this->giftCardRepository->findEnabled(), - ); - } -} diff --git a/src/Api/Controller/Action/ResendGiftCardEmailAction.php b/src/Api/Controller/Action/ResendGiftCardEmailAction.php deleted file mode 100644 index fbbc7643..00000000 --- a/src/Api/Controller/Action/ResendGiftCardEmailAction.php +++ /dev/null @@ -1,33 +0,0 @@ -giftCardEmailManager = $giftCardEmailManager; - } - - public function __invoke(GiftCardInterface $data): Response - { - if (($order = $data->getOrder()) !== null) { - $this->giftCardEmailManager->sendEmailWithGiftCardsFromOrder($order, [$data]); - } elseif (($customer = $data->getCustomer()) !== null) { - $this->giftCardEmailManager->sendEmailToCustomerWithGiftCard($customer, $data); - } else { - throw new BadRequestHttpException(); - } - - return new Response(null, Response::HTTP_NO_CONTENT); - } -} diff --git a/src/Api/Controller/Action/UploadGiftCardConfigurationImageAction.php b/src/Api/Controller/Action/UploadGiftCardConfigurationImageAction.php deleted file mode 100644 index 79c47634..00000000 --- a/src/Api/Controller/Action/UploadGiftCardConfigurationImageAction.php +++ /dev/null @@ -1,93 +0,0 @@ -giftCardConfigurationImageFactory = $giftCardConfigurationImageFactory; - $this->giftCardConfigurationImageRepository = $giftCardConfigurationImageRepository; - $this->imageUploader = $imageUploader; - $this->iriConverter = $iriConverter; - } - - public function __invoke(Request $request): GiftCardConfigurationImageInterface - { - /** @var UploadedFile $file */ - $file = $request->files->get('file'); - - /** @var GiftCardConfigurationImageInterface $image */ - $image = $this->giftCardConfigurationImageFactory->createNew(); - $image->setFile($file); - - /** @var string $imageType */ - $imageType = $request->request->get('type') ?? $request->query->get('type'); - Assert::notEmpty($imageType); - - $image->setType($imageType); - - $ownerIri = $request->request->get('owner') ?? $request->query->get('type'); - Assert::stringNotEmpty($ownerIri); - - $owner = $this->getOwner($ownerIri); - - $oldImages = $owner->getImagesByType($imageType); - foreach ($oldImages as $oldImage) { - $owner->removeImage($oldImage); - $this->giftCardConfigurationImageRepository->remove($oldImage); - } - $owner->addImage($image); - - $this->imageUploader->upload($image); - - return $image; - } - - private function getOwner(string $ownerIri): GiftCardConfigurationInterface - { - if ($this->iriConverter instanceof LegacyIriConverterInterface) { - $owner = $this->iriConverter->getItemFromIri($ownerIri); - } else { - /** - * @psalm-suppress UndefinedDocblockClass - * - * @var mixed $owner - */ - $owner = $this->iriConverter->getResourceFromIri($ownerIri); - } - - Assert::isInstanceOf($owner, GiftCardConfigurationInterface::class); - - return $owner; - } -} diff --git a/src/Api/DataPersister/GiftCardDataPersister.php b/src/Api/DataPersister/GiftCardDataPersister.php deleted file mode 100644 index 1512447e..00000000 --- a/src/Api/DataPersister/GiftCardDataPersister.php +++ /dev/null @@ -1,51 +0,0 @@ -decoratedDataPersister = $decoratedDataPersister; - } - - /** - * @param mixed $data - */ - public function supports($data, array $context = []): bool - { - return $data instanceof GiftCardInterface; - } - - /** - * @param GiftCardInterface|mixed $data - * - * @return object|void - */ - public function persist($data, array $context = []) - { - Assert::isInstanceOf($data, GiftCardInterface::class); - - $data->setOrigin(GiftCardInterface::ORIGIN_API); - - return $this->decoratedDataPersister->persist($data, $context); - } - - /** - * @param GiftCardInterface|mixed $data - * - * @return mixed - */ - public function remove($data, array $context = []) - { - return $this->decoratedDataPersister->remove($data, $context); - } -} diff --git a/src/Api/DataTransformer/GiftCardCodeAwareInputCommandDataTransformer.php b/src/Api/DataTransformer/GiftCardCodeAwareInputCommandDataTransformer.php deleted file mode 100644 index 2ebe8a46..00000000 --- a/src/Api/DataTransformer/GiftCardCodeAwareInputCommandDataTransformer.php +++ /dev/null @@ -1,33 +0,0 @@ -setGiftCardCode($giftCard->getCode()); - - return $object; - } - - /** - * @param object $object - */ - public function supportsTransformation($object): bool - { - return $object instanceof GiftCardCodeAwareInterface; - } -} diff --git a/src/Api/DataTransformer/GiftCardConfigurationCodeAwareInputCommandDataTransformer.php b/src/Api/DataTransformer/GiftCardConfigurationCodeAwareInputCommandDataTransformer.php deleted file mode 100644 index d2d49c0b..00000000 --- a/src/Api/DataTransformer/GiftCardConfigurationCodeAwareInputCommandDataTransformer.php +++ /dev/null @@ -1,33 +0,0 @@ -setConfigurationCode($giftCardConfiguration->getCode()); - - return $object; - } - - /** - * @param object $object - */ - public function supportsTransformation($object): bool - { - return $object instanceof ConfigurationCodeAwareInterface; - } -} diff --git a/src/Api/Doctrine/QueryCollectionExtension/GiftCardsByLoggedInUserExtension.php b/src/Api/Doctrine/QueryCollectionExtension/GiftCardsByLoggedInUserExtension.php deleted file mode 100644 index 41b62e32..00000000 --- a/src/Api/Doctrine/QueryCollectionExtension/GiftCardsByLoggedInUserExtension.php +++ /dev/null @@ -1,59 +0,0 @@ -userContext = $userContext; - } - - public function applyToCollection( - QueryBuilder $queryBuilder, - QueryNameGeneratorInterface $queryNameGenerator, - string $resourceClass, - string $operationName = null, - array $context = [], - ): void { - if (!is_a($resourceClass, GiftCardInterface::class, true)) { - return; - } - - $user = $this->userContext->getUser(); - - if ($user instanceof AdminUserInterface) { - return; - } - - if (!$user instanceof ShopUserInterface) { - throw new AccessDeniedException(); - } - - /** @var CustomerInterface $customer */ - $customer = $user->getCustomer(); - - /** @var list $rootAliases */ - $rootAliases = $queryBuilder->getRootAliases(); - - $queryBuilder - ->andWhere(sprintf('%s.customer = :customer', $rootAliases[0])) - ->setParameter('customer', $customer->getId(), Types::INTEGER) - ; - } -} diff --git a/src/Applicator/GiftCardApplicator.php b/src/Applicator/GiftCardApplicator.php index b6770512..3dd755fe 100644 --- a/src/Applicator/GiftCardApplicator.php +++ b/src/Applicator/GiftCardApplicator.php @@ -29,6 +29,7 @@ public function __construct( /** * @param string|GiftCardInterface $giftCard */ + #[\Override] public function apply(OrderInterface $order, $giftCard): void { if (is_string($giftCard)) { @@ -65,6 +66,7 @@ public function apply(OrderInterface $order, $giftCard): void /** * @param string|GiftCardInterface $giftCard */ + #[\Override] public function remove(OrderInterface $order, $giftCard): void { if (is_string($giftCard)) { diff --git a/src/Controller/Action/AddGiftCardToOrderAction.php b/src/Controller/Action/AddGiftCardToOrderAction.php index c6d8f6fd..0f6144bb 100644 --- a/src/Controller/Action/AddGiftCardToOrderAction.php +++ b/src/Controller/Action/AddGiftCardToOrderAction.php @@ -63,16 +63,23 @@ public function __invoke(Request $request): Response $form = $this->formFactory->create(AddGiftCardToOrderType::class, $addGiftCardToOrderCommand); $form->handleRequest($request); - if ($form->isSubmitted() && $form->isValid()) { - $giftCard = $addGiftCardToOrderCommand->getGiftCard(); - Assert::notNull($giftCard); - $this->giftCardApplicator->apply($order, $giftCard); + if ($form->isSubmitted()) { + $session = $request->getSession(); - $this->getManager($order)->flush(); + if ($form->isValid()) { + $giftCard = $addGiftCardToOrderCommand->getGiftCard(); + Assert::notNull($giftCard); + $this->giftCardApplicator->apply($order, $giftCard); - $session = $request->getSession(); - if ($session instanceof Session) { - $session->getFlashBag()->add('success', 'setono_sylius_gift_card.gift_card_added'); + $this->getManager($order)->flush(); + + if ($session instanceof Session) { + $session->getFlashBag()->add('success', 'setono_sylius_gift_card.gift_card_added'); + } + } elseif ($session instanceof Session) { + foreach ($form->getErrors(true) as $error) { + $session->getFlashBag()->add('error', $error->getMessage()); + } } return new RedirectResponse($this->redirectRouteResolver->getUrlToRedirectTo($request, 'sylius_shop_cart_summary')); diff --git a/src/DependencyInjection/Compiler/AddAdjustmentsToOrderAdjustmentClearerPass.php b/src/DependencyInjection/Compiler/AddAdjustmentsToOrderAdjustmentClearerPass.php index ceb73b3b..d296463f 100644 --- a/src/DependencyInjection/Compiler/AddAdjustmentsToOrderAdjustmentClearerPass.php +++ b/src/DependencyInjection/Compiler/AddAdjustmentsToOrderAdjustmentClearerPass.php @@ -7,23 +7,21 @@ use Setono\SyliusGiftCardPlugin\Model\AdjustmentInterface; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Webmozart\Assert\Assert; final class AddAdjustmentsToOrderAdjustmentClearerPass implements CompilerPassInterface { + #[\Override] public function process(ContainerBuilder $container): void { - if (!$container->has('sylius.order_processing.order_adjustments_clearer')) { + if (!$container->hasParameter('sylius.order_processing.adjustment_clearing_types')) { return; } - $clearerDefinition = $container->getDefinition('sylius.order_processing.order_adjustments_clearer'); - - $adjustmentsToRemove = $clearerDefinition->getArgument(0); - Assert::isArray($adjustmentsToRemove); + $adjustmentsToRemove = $container->getParameter('sylius.order_processing.adjustment_clearing_types'); + \assert(\is_array($adjustmentsToRemove)); $adjustmentsToRemove[] = AdjustmentInterface::ORDER_GIFT_CARD_ADJUSTMENT; - $clearerDefinition->setArgument(0, $adjustmentsToRemove); + $container->setParameter('sylius.order_processing.adjustment_clearing_types', $adjustmentsToRemove); } } diff --git a/src/DependencyInjection/Compiler/CreateServiceAliasesPass.php b/src/DependencyInjection/Compiler/CreateServiceAliasesPass.php index 14c2f37d..104dd0b5 100644 --- a/src/DependencyInjection/Compiler/CreateServiceAliasesPass.php +++ b/src/DependencyInjection/Compiler/CreateServiceAliasesPass.php @@ -10,6 +10,7 @@ final class CreateServiceAliasesPass implements CompilerPassInterface { + #[\Override] public function process(ContainerBuilder $container): void { // if this service is already defined, we don't need to do anything. It means the Sylius version is < 1.11 diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 132e08c4..639058b7 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -26,6 +26,7 @@ final class Configuration implements ConfigurationInterface { + #[\Override] public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('setono_sylius_gift_card'); diff --git a/src/DependencyInjection/SetonoSyliusGiftCardExtension.php b/src/DependencyInjection/SetonoSyliusGiftCardExtension.php index 5d603e8d..c33f1ffb 100644 --- a/src/DependencyInjection/SetonoSyliusGiftCardExtension.php +++ b/src/DependencyInjection/SetonoSyliusGiftCardExtension.php @@ -4,13 +4,18 @@ namespace Setono\SyliusGiftCardPlugin\DependencyInjection; +use Sylius\Bundle\CoreBundle\DependencyInjection\PrependDoctrineMigrationsTrait; use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -final class SetonoSyliusGiftCardExtension extends AbstractResourceExtension +final class SetonoSyliusGiftCardExtension extends AbstractResourceExtension implements PrependExtensionInterface { + use PrependDoctrineMigrationsTrait; + + #[\Override] public function load(array $configs, ContainerBuilder $container): void { /** @@ -30,7 +35,7 @@ public function load(array $configs, ContainerBuilder $container): void * @psalm-suppress PossiblyNullArgument */ $config = $this->processConfiguration($this->getConfiguration([], $container), $configs); - $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); + $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../config')); $container->setParameter('setono_sylius_gift_card.code_length', $config['code_length']); $container->setParameter( @@ -54,14 +59,34 @@ public function load(array $configs, ContainerBuilder $container): void $config['pdf_rendering']['preferred_page_sizes'], ); - // Load default CSS file - $container->setParameter( - 'setono_sylius_gift_card.default_css_file', - '@SetonoSyliusGiftCardPlugin/Shop/GiftCard/defaultGiftCardConfiguration.css.twig', - ); - $this->registerResources('setono_sylius_gift_card', $config['driver'], $config['resources'], $container); $loader->load('services.xml'); } + + #[\Override] + public function prepend(ContainerBuilder $container): void + { + $this->prependDoctrineMigrations($container); + } + + #[\Override] + protected function getMigrationsNamespace(): string + { + return 'DoctrineMigrations'; + } + + #[\Override] + protected function getMigrationsDirectory(): string + { + return '@SetonoSyliusGiftCardPlugin/src/Migrations'; + } + + #[\Override] + protected function getNamespacesOfMigrationsExecutedBefore(): array + { + return [ + 'Sylius\Bundle\CoreBundle\Migrations', + ]; + } } diff --git a/src/Doctrine/ORM/GiftCardConfigurationRepository.php b/src/Doctrine/ORM/GiftCardConfigurationRepository.php index 951e2030..0af5e3db 100644 --- a/src/Doctrine/ORM/GiftCardConfigurationRepository.php +++ b/src/Doctrine/ORM/GiftCardConfigurationRepository.php @@ -13,16 +13,15 @@ class GiftCardConfigurationRepository extends EntityRepository implements GiftCardConfigurationRepositoryInterface { + #[\Override] public function findOneByChannelAndLocale(ChannelInterface $channel, LocaleInterface $locale): ?GiftCardConfigurationInterface { $obj = $this->createQueryBuilder('o') ->join('o.channelConfigurations', 'c') ->andWhere('c.channel = :channel') ->andWhere('c.locale = :locale') - ->setParameters([ - 'channel' => $channel, - 'locale' => $locale, - ]) + ->setParameter('channel', $channel) + ->setParameter('locale', $locale) ->getQuery() ->getOneOrNullResult() ; @@ -32,6 +31,7 @@ public function findOneByChannelAndLocale(ChannelInterface $channel, LocaleInter return $obj; } + #[\Override] public function findDefault(): ?GiftCardConfigurationInterface { $obj = $this->findOneBy([ diff --git a/src/Doctrine/ORM/GiftCardRepository.php b/src/Doctrine/ORM/GiftCardRepository.php index baf41728..43b37f40 100644 --- a/src/Doctrine/ORM/GiftCardRepository.php +++ b/src/Doctrine/ORM/GiftCardRepository.php @@ -15,6 +15,7 @@ class GiftCardRepository extends EntityRepository implements GiftCardRepositoryInterface { + #[\Override] public function createListQueryBuilder(): QueryBuilder { return $this->createQueryBuilder('o') @@ -23,6 +24,7 @@ public function createListQueryBuilder(): QueryBuilder ; } + #[\Override] public function findOneEnabledByCodeAndChannel(string $code, ChannelInterface $channel): ?GiftCardInterface { $giftCard = $this->findOneBy([ @@ -35,6 +37,7 @@ public function findOneEnabledByCodeAndChannel(string $code, ChannelInterface $c return $giftCard; } + #[\Override] public function findOneByCode(string $code): ?GiftCardInterface { $giftCard = $this->findOneBy([ @@ -45,6 +48,7 @@ public function findOneByCode(string $code): ?GiftCardInterface return $giftCard; } + #[\Override] public function findOneByOrderItemUnit(OrderItemUnitInterface $orderItemUnit): ?GiftCardInterface { $giftCard = $this->findOneBy([ @@ -55,6 +59,7 @@ public function findOneByOrderItemUnit(OrderItemUnitInterface $orderItemUnit): ? return $giftCard; } + #[\Override] public function findEnabled(): array { $giftCards = $this->findBy([ @@ -66,6 +71,7 @@ public function findEnabled(): array return $giftCards; } + #[\Override] public function createAccountListQueryBuilder(CustomerInterface $customer): QueryBuilder { $qb = $this->createListQueryBuilder(); diff --git a/src/EmailManager/GiftCardEmailManager.php b/src/EmailManager/GiftCardEmailManager.php index 2bafce64..4965e68e 100644 --- a/src/EmailManager/GiftCardEmailManager.php +++ b/src/EmailManager/GiftCardEmailManager.php @@ -45,6 +45,7 @@ public function __construct( $this->cacheDir = $cacheDir; } + #[\Override] public function sendEmailToCustomerWithGiftCard(CustomerInterface $customer, GiftCardInterface $giftCard): void { $email = $customer->getEmail(); @@ -72,6 +73,7 @@ public function sendEmailToCustomerWithGiftCard(CustomerInterface $customer, Gif }); } + #[\Override] public function sendEmailWithGiftCardsFromOrder(OrderInterface $order, array $giftCards): void { $customer = $order->getCustomer(); diff --git a/src/EventListener/Workflow/AssociateGiftCardToCustomerListener.php b/src/EventListener/Workflow/AssociateGiftCardToCustomerListener.php new file mode 100644 index 00000000..ef7c51fb --- /dev/null +++ b/src/EventListener/Workflow/AssociateGiftCardToCustomerListener.php @@ -0,0 +1,25 @@ +getSubject(); + Assert::isInstanceOf($order, OrderInterface::class); + + $this->orderGiftCardOperator->associateToCustomer($order); + } +} diff --git a/src/EventListener/Workflow/CancelOrderGiftCardListener.php b/src/EventListener/Workflow/CancelOrderGiftCardListener.php new file mode 100644 index 00000000..66f7661e --- /dev/null +++ b/src/EventListener/Workflow/CancelOrderGiftCardListener.php @@ -0,0 +1,29 @@ +getSubject(); + Assert::isInstanceOf($order, OrderInterface::class); + + $this->orderGiftCardAmountModifier->increment($order); + $this->orderGiftCardOperator->disable($order); + } +} diff --git a/src/EventListener/Workflow/DecrementGiftCardAmountListener.php b/src/EventListener/Workflow/DecrementGiftCardAmountListener.php new file mode 100644 index 00000000..79d4c966 --- /dev/null +++ b/src/EventListener/Workflow/DecrementGiftCardAmountListener.php @@ -0,0 +1,25 @@ +getSubject(); + Assert::isInstanceOf($order, OrderInterface::class); + + $this->orderGiftCardAmountModifier->decrement($order); + } +} diff --git a/src/EventListener/Workflow/EnableAndSendGiftCardListener.php b/src/EventListener/Workflow/EnableAndSendGiftCardListener.php new file mode 100644 index 00000000..277c55a5 --- /dev/null +++ b/src/EventListener/Workflow/EnableAndSendGiftCardListener.php @@ -0,0 +1,26 @@ +getSubject(); + Assert::isInstanceOf($order, OrderInterface::class); + + $this->orderGiftCardOperator->enable($order); + $this->orderGiftCardOperator->send($order); + } +} diff --git a/src/EventSubscriber/DefaultGiftCardConfigurationSubscriber.php b/src/EventSubscriber/DefaultGiftCardConfigurationSubscriber.php index f6a8ac3f..4a5ba744 100644 --- a/src/EventSubscriber/DefaultGiftCardConfigurationSubscriber.php +++ b/src/EventSubscriber/DefaultGiftCardConfigurationSubscriber.php @@ -22,6 +22,7 @@ public function __construct(GiftCardConfigurationRepositoryInterface $giftCardCo $this->giftCardConfigurationRepository = $giftCardConfigurationRepository; } + #[\Override] public static function getSubscribedEvents(): array { return [ diff --git a/src/EventSubscriber/GiftCardDeletionSubscriber.php b/src/EventSubscriber/GiftCardDeletionSubscriber.php index 5978e751..bf1c1c4b 100644 --- a/src/EventSubscriber/GiftCardDeletionSubscriber.php +++ b/src/EventSubscriber/GiftCardDeletionSubscriber.php @@ -11,6 +11,7 @@ final class GiftCardDeletionSubscriber implements EventSubscriberInterface { + #[\Override] public static function getSubscribedEvents(): array { return [ diff --git a/src/EventSubscriber/SendEmailWithGiftCardToCustomerSubscriber.php b/src/EventSubscriber/SendEmailWithGiftCardToCustomerSubscriber.php index 7a6c37d4..e913a182 100644 --- a/src/EventSubscriber/SendEmailWithGiftCardToCustomerSubscriber.php +++ b/src/EventSubscriber/SendEmailWithGiftCardToCustomerSubscriber.php @@ -23,6 +23,7 @@ public function __construct(GiftCardEmailManagerInterface $giftCardEmailManager) $this->giftCardEmailManager = $giftCardEmailManager; } + #[\Override] public static function getSubscribedEvents(): array { return [ diff --git a/src/Factory/GiftCardConfigurationFactory.php b/src/Factory/GiftCardConfigurationFactory.php index f51fc279..036e5104 100644 --- a/src/Factory/GiftCardConfigurationFactory.php +++ b/src/Factory/GiftCardConfigurationFactory.php @@ -30,6 +30,7 @@ public function __construct( $this->defaultPageSize = $defaultPageSize; } + #[\Override] public function createNew(): GiftCardConfigurationInterface { /** @var GiftCardConfigurationInterface $configuration */ diff --git a/src/Factory/GiftCardConfigurationFactoryInterface.php b/src/Factory/GiftCardConfigurationFactoryInterface.php index 209831a1..0422233e 100644 --- a/src/Factory/GiftCardConfigurationFactoryInterface.php +++ b/src/Factory/GiftCardConfigurationFactoryInterface.php @@ -9,5 +9,6 @@ interface GiftCardConfigurationFactoryInterface extends FactoryInterface { + #[\Override] public function createNew(): GiftCardConfigurationInterface; } diff --git a/src/Factory/GiftCardFactory.php b/src/Factory/GiftCardFactory.php index c044cf17..7e41ce75 100644 --- a/src/Factory/GiftCardFactory.php +++ b/src/Factory/GiftCardFactory.php @@ -5,17 +5,16 @@ namespace Setono\SyliusGiftCardPlugin\Factory; use DateTimeImmutable; -use DateTimeInterface; use Setono\SyliusGiftCardPlugin\Generator\GiftCardCodeGeneratorInterface; use Setono\SyliusGiftCardPlugin\Model\GiftCardInterface; use Setono\SyliusGiftCardPlugin\Model\OrderItemUnitInterface; use Setono\SyliusGiftCardPlugin\Provider\GiftCardConfigurationProviderInterface; -use Sylius\Bundle\ShippingBundle\Provider\DateTimeProvider; use Sylius\Component\Core\Model\ChannelInterface; use Sylius\Component\Core\Model\CustomerInterface; use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Currency\Context\CurrencyContextInterface; use Sylius\Component\Resource\Factory\FactoryInterface; +use Symfony\Component\Clock\ClockInterface; use Webmozart\Assert\Assert; final class GiftCardFactory implements GiftCardFactoryInterface @@ -24,12 +23,12 @@ public function __construct( private readonly FactoryInterface $decoratedFactory, private readonly GiftCardCodeGeneratorInterface $giftCardCodeGenerator, private readonly GiftCardConfigurationProviderInterface $giftCardConfigurationProvider, - /** @psalm-suppress DeprecatedInterface */ - private readonly DateTimeProvider $dateTimeProvider, + private readonly ClockInterface $clock, private readonly CurrencyContextInterface $currencyContext, ) { } + #[\Override] public function createNew(): GiftCardInterface { /** @var GiftCardInterface $giftCard */ @@ -39,6 +38,7 @@ public function createNew(): GiftCardInterface return $giftCard; } + #[\Override] public function createForChannel(ChannelInterface $channel): GiftCardInterface { $giftCard = $this->createNew(); @@ -47,18 +47,15 @@ public function createForChannel(ChannelInterface $channel): GiftCardInterface $channelConfiguration = $this->giftCardConfigurationProvider->getConfigurationForGiftCard($giftCard); $validityPeriod = $channelConfiguration->getDefaultValidityPeriod(); if (null !== $validityPeriod) { - $today = $this->dateTimeProvider->today(); - // Since the interface is types to DateTimeInterface, the modify method does not exist - // whereas it does in DateTime and DateTimeImmutable - Assert::isInstanceOf($today, DateTimeImmutable::class); - /** @var DateTimeInterface $today */ - $today = $today->modify('+' . $validityPeriod); + $today = $this->clock->now()->modify('+' . $validityPeriod); + Assert::notFalse($today); $giftCard->setExpiresAt($today); } return $giftCard; } + #[\Override] public function createForChannelFromAdmin(ChannelInterface $channel): GiftCardInterface { $giftCard = $this->createForChannel($channel); @@ -67,6 +64,7 @@ public function createForChannelFromAdmin(ChannelInterface $channel): GiftCardIn return $giftCard; } + #[\Override] public function createFromOrderItemUnit(OrderItemUnitInterface $orderItemUnit): GiftCardInterface { /** @var OrderInterface|null $order */ @@ -84,6 +82,7 @@ public function createFromOrderItemUnit(OrderItemUnitInterface $orderItemUnit): return $giftCard; } + #[\Override] public function createFromOrderItemUnitAndCart( OrderItemUnitInterface $orderItemUnit, OrderInterface $cart, @@ -104,6 +103,7 @@ public function createFromOrderItemUnitAndCart( return $giftCard; } + #[\Override] public function createExample(): GiftCardInterface { $giftCard = $this->createNew(); diff --git a/src/Factory/GiftCardFactoryInterface.php b/src/Factory/GiftCardFactoryInterface.php index 7ac4bb3b..8abd7826 100644 --- a/src/Factory/GiftCardFactoryInterface.php +++ b/src/Factory/GiftCardFactoryInterface.php @@ -12,6 +12,7 @@ interface GiftCardFactoryInterface extends FactoryInterface { + #[\Override] public function createNew(): GiftCardInterface; public function createForChannel(ChannelInterface $channel): GiftCardInterface; diff --git a/src/Form/DataTransformer/GiftCardToCodeDataTransformer.php b/src/Form/DataTransformer/GiftCardToCodeDataTransformer.php index 932312b8..becf36b6 100644 --- a/src/Form/DataTransformer/GiftCardToCodeDataTransformer.php +++ b/src/Form/DataTransformer/GiftCardToCodeDataTransformer.php @@ -28,6 +28,7 @@ public function __construct( /** * @param GiftCardInterface|mixed $value */ + #[\Override] public function transform($value): ?string { if (null === $value || '' === $value) { @@ -39,6 +40,7 @@ public function transform($value): ?string return $value->getCode(); } + #[\Override] public function reverseTransform($value): ?GiftCardInterface { if (null === $value || '' === $value) { diff --git a/src/Form/Extension/AddToCartTypeExtension.php b/src/Form/Extension/AddToCartTypeExtension.php index 16413fae..ec8f5f37 100644 --- a/src/Form/Extension/AddToCartTypeExtension.php +++ b/src/Form/Extension/AddToCartTypeExtension.php @@ -25,6 +25,7 @@ public function __construct( ) { } + #[\Override] public static function getExtendedTypes(): iterable { return [ @@ -32,6 +33,7 @@ public static function getExtendedTypes(): iterable ]; } + #[\Override] public function buildForm(FormBuilderInterface $builder, array $options): void { $builder->addEventListener(FormEvents::PRE_SET_DATA, [$this, 'reworkFormForGiftCard']); diff --git a/src/Form/Extension/ProductTypeExtension.php b/src/Form/Extension/ProductTypeExtension.php index 88f624da..fc47c0c2 100644 --- a/src/Form/Extension/ProductTypeExtension.php +++ b/src/Form/Extension/ProductTypeExtension.php @@ -11,6 +11,7 @@ final class ProductTypeExtension extends AbstractTypeExtension { + #[\Override] public function buildForm(FormBuilderInterface $builder, array $options): void { $builder->add('giftCard', CheckboxType::class, [ @@ -23,6 +24,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]); } + #[\Override] public static function getExtendedTypes(): iterable { return [ diff --git a/src/Form/Type/AddGiftCardToOrderType.php b/src/Form/Type/AddGiftCardToOrderType.php index 3e514d6f..0277b83b 100644 --- a/src/Form/Type/AddGiftCardToOrderType.php +++ b/src/Form/Type/AddGiftCardToOrderType.php @@ -26,6 +26,7 @@ public function __construct(DataTransformerInterface $giftCardToCodeDataTransfor $this->validationGroups = $validationGroups; } + #[\Override] public function buildForm(FormBuilderInterface $builder, array $options): void { $builder @@ -41,6 +42,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $builder->get('giftCard')->addModelTransformer($this->giftCardToCodeDataTransformer); } + #[\Override] public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ @@ -49,6 +51,7 @@ public function configureOptions(OptionsResolver $resolver): void ]); } + #[\Override] public function getBlockPrefix(): string { return 'setono_sylius_gift_card_add_gift_card_to_order'; diff --git a/src/Form/Type/AddToCartGiftCardInformationType.php b/src/Form/Type/AddToCartGiftCardInformationType.php index 79291439..2e29d830 100644 --- a/src/Form/Type/AddToCartGiftCardInformationType.php +++ b/src/Form/Type/AddToCartGiftCardInformationType.php @@ -45,6 +45,7 @@ public function __construct( $this->channelContext = $channelContext; } + #[\Override] public function buildForm(FormBuilderInterface $builder, array $options): void { $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options): void { @@ -84,6 +85,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]); } + #[\Override] public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefault('data_class', $this->dataClass); diff --git a/src/Form/Type/CustomerAutocompleteChoiceType.php b/src/Form/Type/CustomerAutocompleteChoiceType.php index 25dd5d51..66afa679 100644 --- a/src/Form/Type/CustomerAutocompleteChoiceType.php +++ b/src/Form/Type/CustomerAutocompleteChoiceType.php @@ -4,46 +4,40 @@ namespace Setono\SyliusGiftCardPlugin\Form\Type; -use Sylius\Bundle\ResourceBundle\Form\Type\ResourceAutocompleteChoiceType; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\UX\Autocomplete\Form\AsEntityAutocompleteField; +use Symfony\UX\Autocomplete\Form\BaseEntityAutocompleteType; +#[AsEntityAutocompleteField( + alias: 'setono_sylius_gift_card_customer', + route: 'sylius_admin_entity_autocomplete', +)] final class CustomerAutocompleteChoiceType extends AbstractType { - private UrlGeneratorInterface $urlGenerator; - - public function __construct(UrlGeneratorInterface $urlGenerator) + public function __construct(private readonly string $customerClass) { - $this->urlGenerator = $urlGenerator; } + #[\Override] public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ - 'resource' => 'sylius.customer', - 'choice_name' => 'email', - 'choice_value' => 'email', + 'class' => $this->customerClass, + 'choice_label' => 'email', + 'searchable_fields' => ['email', 'firstName', 'lastName'], ]); } - public function buildView(FormView $view, FormInterface $form, array $options): void - { - $view->vars['remote_criteria_type'] = 'contains'; - $view->vars['remote_criteria_name'] = 'phrase'; - $view->vars['remote_url'] = $this->urlGenerator->generate('setono_sylius_gift_card_admin_ajax_customer_by_email_phrase'); - $view->vars['load_edit_url'] = $this->urlGenerator->generate('setono_sylius_gift_card_admin_ajax_customer_by_email'); - } - + #[\Override] public function getBlockPrefix(): string { return 'setono_sylius_gift_card_customer_autocomplete_choice'; } + #[\Override] public function getParent(): string { - return ResourceAutocompleteChoiceType::class; + return BaseEntityAutocompleteType::class; } } diff --git a/src/Form/Type/DatePeriodType.php b/src/Form/Type/DatePeriodType.php index cf9dc367..3c7afaf3 100644 --- a/src/Form/Type/DatePeriodType.php +++ b/src/Form/Type/DatePeriodType.php @@ -19,6 +19,7 @@ public function __construct(DatePeriodUnitProviderInterface $datePeriodUnitProvi $this->datePeriodUnitProvider = $datePeriodUnitProvider; } + #[\Override] public function buildForm(FormBuilderInterface $builder, array $options): void { $builder->add('value', IntegerType::class, [ diff --git a/src/Form/Type/GiftCardChannelConfigurationType.php b/src/Form/Type/GiftCardChannelConfigurationType.php index 189f2695..a6371c77 100644 --- a/src/Form/Type/GiftCardChannelConfigurationType.php +++ b/src/Form/Type/GiftCardChannelConfigurationType.php @@ -11,6 +11,7 @@ final class GiftCardChannelConfigurationType extends AbstractResourceType { + #[\Override] public function buildForm(FormBuilderInterface $builder, array $options): void { $builder->add('channel', ChannelChoiceType::class, [ @@ -23,6 +24,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]); } + #[\Override] public function getBlockPrefix(): string { return 'setono_sylius_gift_card_gift_card_channel_configuration'; diff --git a/src/Form/Type/GiftCardConfigurationImageType.php b/src/Form/Type/GiftCardConfigurationImageType.php index 29f1c05f..20365828 100644 --- a/src/Form/Type/GiftCardConfigurationImageType.php +++ b/src/Form/Type/GiftCardConfigurationImageType.php @@ -10,6 +10,7 @@ final class GiftCardConfigurationImageType extends ImageType { + #[\Override] public function buildForm(FormBuilderInterface $builder, array $options): void { parent::buildForm($builder, $options); @@ -19,6 +20,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void } } + #[\Override] public function configureOptions(OptionsResolver $resolver): void { parent::configureOptions($resolver); @@ -27,6 +29,7 @@ public function configureOptions(OptionsResolver $resolver): void $resolver->setAllowedTypes('remove_type', ['bool']); } + #[\Override] public function getBlockPrefix(): string { return 'setono_sylius_gift_card_gift_card_configuration_image'; diff --git a/src/Form/Type/GiftCardConfigurationType.php b/src/Form/Type/GiftCardConfigurationType.php index bc58f366..3b448ed2 100644 --- a/src/Form/Type/GiftCardConfigurationType.php +++ b/src/Form/Type/GiftCardConfigurationType.php @@ -44,6 +44,7 @@ public function __construct( $this->preferredPageSizes = $preferredPageSizes; } + #[\Override] public function buildForm(FormBuilderInterface $builder, array $options): void { $builder->add('code', TextType::class, [ @@ -119,6 +120,7 @@ function (array $data): ?string { ); } + #[\Override] public function getBlockPrefix(): string { return 'setono_sylius_gift_card_gift_card_configuration'; diff --git a/src/Form/Type/GiftCardSearchType.php b/src/Form/Type/GiftCardSearchType.php index a4c84ee4..dbddbc16 100644 --- a/src/Form/Type/GiftCardSearchType.php +++ b/src/Form/Type/GiftCardSearchType.php @@ -23,6 +23,7 @@ public function __construct(DataTransformerInterface $giftCardToCodeDataTransfor $this->validationGroups = $validationGroups; } + #[\Override] public function buildForm(FormBuilderInterface $builder, array $options): void { $builder @@ -38,6 +39,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $builder->get('giftCard')->addModelTransformer($this->giftCardToCodeDataTransformer); } + #[\Override] public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ @@ -46,6 +48,7 @@ public function configureOptions(OptionsResolver $resolver): void ]); } + #[\Override] public function getBlockPrefix(): string { return 'setono_sylius_gift_card_gift_card_search'; diff --git a/src/Form/Type/GiftCardType.php b/src/Form/Type/GiftCardType.php index 9557acfa..7f8dd0f2 100644 --- a/src/Form/Type/GiftCardType.php +++ b/src/Form/Type/GiftCardType.php @@ -42,6 +42,7 @@ public function __construct( $this->giftCardCodeGenerator = $giftCardCodeGenerator; } + #[\Override] public function buildForm(FormBuilderInterface $builder, array $options): void { $builder->addEventSubscriber(new AddCodeFormSubscriber()); @@ -118,10 +119,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void return null; } - return (int) round($amount * 100); + return (int) round($amount * 100.0); })); } + #[\Override] public function getBlockPrefix(): string { return 'setono_sylius_gift_card_gift_card'; diff --git a/src/Generator/GiftCardCodeGenerator.php b/src/Generator/GiftCardCodeGenerator.php index 8ec1baaf..4bbb4fd6 100644 --- a/src/Generator/GiftCardCodeGenerator.php +++ b/src/Generator/GiftCardCodeGenerator.php @@ -26,6 +26,7 @@ public function __construct(GiftCardRepositoryInterface $giftCardRepository, int $this->codeLength = $codeLength; } + #[\Override] public function generate(): string { do { @@ -34,6 +35,7 @@ public function generate(): string /** @psalm-suppress ArgumentTypeCoercion */ $code = bin2hex(random_bytes($this->codeLength)); $code = preg_replace('/[01]/', '', $code); // remove hard to read characters + Assert::notNull($code); $code = mb_strtoupper(mb_substr($code, 0, $this->codeLength)); } while (mb_strlen($code) !== $this->codeLength || $this->exists($code)); diff --git a/src/Grid/FieldTypes/StringFieldType.php b/src/Grid/FieldTypes/StringFieldType.php index 56876464..4f0eb040 100644 --- a/src/Grid/FieldTypes/StringFieldType.php +++ b/src/Grid/FieldTypes/StringFieldType.php @@ -21,7 +21,8 @@ public function __construct(PropertyAccessorInterface $propertyAccessor) $this->propertyAccessor = $propertyAccessor; } - public function render(Field $field, $data, array $options): string + #[\Override] + public function render(Field $field, mixed $data, array $options): string { try { if (!is_object($data) && !is_array($data)) { @@ -38,6 +39,7 @@ public function render(Field $field, $data, array $options): string return htmlspecialchars((string) $value); } + #[\Override] public function configureOptions(OptionsResolver $resolver): void { } diff --git a/src/Migrations/Version20260729000001.php b/src/Migrations/Version20260729000001.php new file mode 100644 index 00000000..4f71d39a --- /dev/null +++ b/src/Migrations/Version20260729000001.php @@ -0,0 +1,51 @@ +addSql('CREATE TABLE setono_sylius_gift_card__configuration (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, is_default TINYINT(1) DEFAULT 0 NOT NULL, defaultValidityPeriod VARCHAR(255) DEFAULT NULL, pageSize VARCHAR(255) DEFAULT NULL, orientation VARCHAR(255) DEFAULT NULL, template LONGTEXT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_ADC64AD077153098 (code), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE setono_sylius_gift_card__gift_card (id INT AUTO_INCREMENT NOT NULL, order_item_unit_id INT DEFAULT NULL, customer_id INT DEFAULT NULL, channel_id INT NOT NULL, code VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, amount INT NOT NULL, initialAmount INT NOT NULL, currencyCode VARCHAR(3) NOT NULL, customMessage LONGTEXT DEFAULT NULL, origin VARCHAR(255) DEFAULT NULL, expiresAt DATETIME DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_A5B7155477153098 (code), UNIQUE INDEX UNIQ_A5B71554F720C233 (order_item_unit_id), INDEX IDX_A5B715549395C3F3 (customer_id), INDEX IDX_A5B7155472F5A1AA (channel_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE setono_sylius_gift_card__configuration_image (id INT AUTO_INCREMENT NOT NULL, owner_id INT NOT NULL, type VARCHAR(255) DEFAULT NULL, path VARCHAR(255) NOT NULL, INDEX IDX_CDFECBED7E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE setono_sylius_gift_card__channel_configuration (id INT AUTO_INCREMENT NOT NULL, channel_id INT NOT NULL, configuration_id INT NOT NULL, locale_id INT NOT NULL, INDEX IDX_571F956572F5A1AA (channel_id), INDEX IDX_571F956573F32DD8 (configuration_id), INDEX IDX_571F9565E559DFD1 (locale_id), UNIQUE INDEX unique_channel_locale (channel_id, locale_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE setono_sylius_gift_card__order_gift_cards (order_id INT NOT NULL, gift_card_id INT NOT NULL, INDEX IDX_429AE86C8D9F6D38 (order_id), INDEX IDX_429AE86C2696A98F (gift_card_id), PRIMARY KEY(order_id, gift_card_id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB'); + + $this->addSql('ALTER TABLE setono_sylius_gift_card__gift_card ADD CONSTRAINT FK_A5B71554F720C233 FOREIGN KEY (order_item_unit_id) REFERENCES sylius_order_item_unit (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE setono_sylius_gift_card__gift_card ADD CONSTRAINT FK_A5B715549395C3F3 FOREIGN KEY (customer_id) REFERENCES sylius_customer (id) ON DELETE SET NULL'); + $this->addSql('ALTER TABLE setono_sylius_gift_card__gift_card ADD CONSTRAINT FK_A5B7155472F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id)'); + $this->addSql('ALTER TABLE setono_sylius_gift_card__configuration_image ADD CONSTRAINT FK_CDFECBED7E3C61F9 FOREIGN KEY (owner_id) REFERENCES setono_sylius_gift_card__configuration (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE setono_sylius_gift_card__channel_configuration ADD CONSTRAINT FK_571F956572F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE setono_sylius_gift_card__channel_configuration ADD CONSTRAINT FK_571F956573F32DD8 FOREIGN KEY (configuration_id) REFERENCES setono_sylius_gift_card__configuration (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE setono_sylius_gift_card__channel_configuration ADD CONSTRAINT FK_571F9565E559DFD1 FOREIGN KEY (locale_id) REFERENCES sylius_locale (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE setono_sylius_gift_card__order_gift_cards ADD CONSTRAINT FK_429AE86C8D9F6D38 FOREIGN KEY (order_id) REFERENCES sylius_order (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE setono_sylius_gift_card__order_gift_cards ADD CONSTRAINT FK_429AE86C2696A98F FOREIGN KEY (gift_card_id) REFERENCES setono_sylius_gift_card__gift_card (id) ON DELETE CASCADE'); + + $this->addSql('ALTER TABLE sylius_product ADD giftCard TINYINT(1) DEFAULT 0 NOT NULL, ADD giftCardAmountConfigurable TINYINT(1) DEFAULT 0 NOT NULL'); + } + + #[\Override] + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE sylius_product DROP giftCard, DROP giftCardAmountConfigurable'); + + $this->addSql('DROP TABLE setono_sylius_gift_card__order_gift_cards'); + $this->addSql('DROP TABLE setono_sylius_gift_card__channel_configuration'); + $this->addSql('DROP TABLE setono_sylius_gift_card__configuration_image'); + $this->addSql('DROP TABLE setono_sylius_gift_card__gift_card'); + $this->addSql('DROP TABLE setono_sylius_gift_card__configuration'); + } +} diff --git a/src/Model/GiftCard.php b/src/Model/GiftCard.php index 9bbf37b2..57f8c5e6 100644 --- a/src/Model/GiftCard.php +++ b/src/Model/GiftCard.php @@ -60,31 +60,37 @@ public function __toString(): string return (string) $this->code; } + #[\Override] public function getCode(): ?string { return $this->code; } + #[\Override] public function setCode(?string $code): void { $this->code = $code; } + #[\Override] public function getId(): ?int { return $this->id; } + #[\Override] public function isDeletable(): bool { return null === $this->orderItemUnit; } + #[\Override] public function getOrderItemUnit(): ?OrderItemUnitInterface { return $this->orderItemUnit; } + #[\Override] public function setOrderItemUnit(OrderItemUnitInterface $orderItemUnit): void { if ($this->orderItemUnit === $orderItemUnit) { @@ -96,6 +102,7 @@ public function setOrderItemUnit(OrderItemUnitInterface $orderItemUnit): void $orderItemUnit->setGiftCard($this); } + #[\Override] public function getOrder(): ?OrderInterface { $orderItemUnit = $this->getOrderItemUnit(); @@ -112,21 +119,25 @@ public function getOrder(): ?OrderInterface return $order; } + #[\Override] public function getCustomer(): ?CustomerInterface { return $this->customer; } + #[\Override] public function setCustomer(?CustomerInterface $customer): void { $this->customer = $customer; } + #[\Override] public function getInitialAmount(): ?int { return $this->initialAmount; } + #[\Override] public function setInitialAmount(int $initialAmount): void { if (null !== $this->initialAmount) { @@ -136,11 +147,13 @@ public function setInitialAmount(int $initialAmount): void $this->initialAmount = $initialAmount; } + #[\Override] public function getAmount(): int { return $this->amount; } + #[\Override] public function setAmount(int $amount): void { if (null === $this->initialAmount) { @@ -150,16 +163,19 @@ public function setAmount(int $amount): void $this->amount = $amount; } + #[\Override] public function getAppliedOrders(): Collection { return $this->appliedOrders; } + #[\Override] public function hasAppliedOrders(): bool { return !$this->getAppliedOrders()->isEmpty(); } + #[\Override] public function hasAppliedCompletedOrders(): bool { foreach ($this->appliedOrders as $appliedOrder) { @@ -171,6 +187,7 @@ public function hasAppliedCompletedOrders(): bool return false; } + #[\Override] public function addAppliedOrder(OrderInterface $order): void { if (!$this->hasAppliedOrder($order)) { @@ -178,6 +195,7 @@ public function addAppliedOrder(OrderInterface $order): void } } + #[\Override] public function removeAppliedOrder(OrderInterface $order): void { if ($this->hasAppliedOrder($order)) { @@ -185,34 +203,37 @@ public function removeAppliedOrder(OrderInterface $order): void } } + #[\Override] public function hasAppliedOrder(OrderInterface $order): bool { return $this->appliedOrders->contains($order); } + #[\Override] public function getCurrencyCode(): ?string { return $this->currencyCode; } + #[\Override] public function setCurrencyCode(string $currencyCode): void { $this->currencyCode = $currencyCode; } + #[\Override] public function getChannel(): ?ChannelInterface { return $this->channel; } + #[\Override] public function setChannel(ChannelInterface $channel): void { $this->channel = $channel; } - /** - * API specific methods. See src/Resources/config/serializer/Model.GiftCard.yml - */ + #[\Override] public function getCustomerIdentification(): ?array { $customer = $this->getCustomer(); @@ -226,6 +247,7 @@ public function getCustomerIdentification(): ?array ]; } + #[\Override] public function getOrderIdentification(): ?array { $order = $this->getOrder(); @@ -247,6 +269,7 @@ public function getOrderIdentification(): ?array ]; } + #[\Override] public function getChannelCode(): ?string { $channel = $this->getChannel(); @@ -257,42 +280,50 @@ public function getChannelCode(): ?string return $channel->getCode(); } + #[\Override] public function hasOrderOrCustomer(): bool { return null !== $this->getCustomer() || null !== $this->getOrder(); } + #[\Override] public function getCustomMessage(): ?string { return $this->customMessage; } + #[\Override] public function setCustomMessage(?string $customMessage): void { $this->customMessage = $customMessage; } + #[\Override] public function setOrigin(?string $origin): void { $this->origin = $origin; } + #[\Override] public function getOrigin(): ?string { return $this->origin; } + #[\Override] public function getExpiresAt(): ?DateTimeInterface { return $this->expiresAt; } + #[\Override] public function setExpiresAt(?DateTimeInterface $expiresAt): void { $this->expiresAt = $expiresAt; } - public function isExpired(DateTimeInterface $date = null): bool + #[\Override] + public function isExpired(?DateTimeInterface $date = null): bool { if (null === $date) { $date = new DateTime(); @@ -306,11 +337,13 @@ public function isExpired(DateTimeInterface $date = null): bool return $date > $giftCardValidUntil; } + #[\Override] public function getSendNotificationEmail(): bool { return $this->sendNotificationEmail; } + #[\Override] public function setSendNotificationEmail(bool $sendNotificationEmail = true): void { $this->sendNotificationEmail = $sendNotificationEmail; diff --git a/src/Model/GiftCardBalanceCollection.php b/src/Model/GiftCardBalanceCollection.php index 15ca8895..25c6bf5d 100644 --- a/src/Model/GiftCardBalanceCollection.php +++ b/src/Model/GiftCardBalanceCollection.php @@ -42,11 +42,13 @@ public static function createFromGiftCards(iterable $giftCards): self return $collection; } + #[\Override] public function count(): int { return count($this->collection); } + #[\Override] public function current(): GiftCardBalance { $cur = current($this->collection); @@ -57,11 +59,13 @@ public function current(): GiftCardBalance return $cur; } + #[\Override] public function next(): void { next($this->collection); } + #[\Override] public function key(): ?string { $k = (string) key($this->collection); @@ -69,11 +73,13 @@ public function key(): ?string return '' === $k ? null : $k; } + #[\Override] public function valid(): bool { return key($this->collection) !== null; } + #[\Override] public function rewind(): void { reset($this->collection); diff --git a/src/Model/GiftCardChannelConfiguration.php b/src/Model/GiftCardChannelConfiguration.php index 46ade47e..83dcefb3 100644 --- a/src/Model/GiftCardChannelConfiguration.php +++ b/src/Model/GiftCardChannelConfiguration.php @@ -18,37 +18,44 @@ class GiftCardChannelConfiguration implements GiftCardChannelConfigurationInterf protected ?GiftCardConfigurationInterface $configuration = null; + #[\Override] public function getId(): ?int { return $this->id; } + #[\Override] public function getChannel(): ?ChannelInterface { return $this->channel; } + #[\Override] public function setChannel(?ChannelInterface $channel): void { Assert::notNull($channel); $this->channel = $channel; } + #[\Override] public function getLocale(): ?LocaleInterface { return $this->locale; } + #[\Override] public function setLocale(LocaleInterface $locale): void { $this->locale = $locale; } + #[\Override] public function getConfiguration(): ?GiftCardConfigurationInterface { return $this->configuration; } + #[\Override] public function setConfiguration(?GiftCardConfigurationInterface $configuration): void { $this->configuration = $configuration; diff --git a/src/Model/GiftCardConfiguration.php b/src/Model/GiftCardConfiguration.php index 48bb2322..55bcb560 100644 --- a/src/Model/GiftCardConfiguration.php +++ b/src/Model/GiftCardConfiguration.php @@ -47,26 +47,31 @@ public function __construct() $this->channelConfigurations = new ArrayCollection(); } + #[\Override] public function getId(): ?int { return $this->id; } + #[\Override] public function getCode(): ?string { return $this->code; } + #[\Override] public function setCode(?string $code): void { $this->code = $code; } + #[\Override] public function getImages(): Collection { return $this->images; } + #[\Override] public function getImagesByType(string $type): Collection { return $this->images->filter(function (ImageInterface $image) use ($type): bool { @@ -74,16 +79,19 @@ public function getImagesByType(string $type): Collection }); } + #[\Override] public function hasImages(): bool { return !$this->getImages()->isEmpty(); } + #[\Override] public function hasImage(ImageInterface $image): bool { return $this->getImages()->contains($image); } + #[\Override] public function addImage(ImageInterface $image): void { if (!$this->hasImage($image)) { @@ -92,6 +100,7 @@ public function addImage(ImageInterface $image): void } } + #[\Override] public function removeImage(ImageInterface $image): void { if ($this->hasImage($image)) { @@ -100,6 +109,7 @@ public function removeImage(ImageInterface $image): void } } + #[\Override] public function getBackgroundImage(): ?GiftCardConfigurationImageInterface { $images = $this->getImagesByType(GiftCardConfigurationImageInterface::TYPE_BACKGROUND); @@ -113,6 +123,7 @@ public function getBackgroundImage(): ?GiftCardConfigurationImageInterface return $image; } + #[\Override] public function setBackgroundImage(?GiftCardConfigurationImageInterface $image): void { $actualImage = $this->getBackgroundImage(); @@ -130,21 +141,25 @@ public function setBackgroundImage(?GiftCardConfigurationImageInterface $image): $this->addImage($image); } + #[\Override] public function getChannelConfigurations(): Collection { return $this->channelConfigurations; } + #[\Override] public function hasChannelConfigurations(): bool { return !$this->channelConfigurations->isEmpty(); } + #[\Override] public function hasChannelConfiguration(GiftCardChannelConfigurationInterface $channelConfiguration): bool { return $this->channelConfigurations->contains($channelConfiguration); } + #[\Override] public function addChannelConfiguration(GiftCardChannelConfigurationInterface $channelConfiguration): void { if (!$this->hasChannelConfiguration($channelConfiguration)) { @@ -153,6 +168,7 @@ public function addChannelConfiguration(GiftCardChannelConfigurationInterface $c } } + #[\Override] public function removeChannelConfiguration(GiftCardChannelConfigurationInterface $channelConfiguration): void { if ($this->hasChannelConfiguration($channelConfiguration)) { @@ -161,51 +177,61 @@ public function removeChannelConfiguration(GiftCardChannelConfigurationInterface } } + #[\Override] public function isDefault(): bool { return $this->default; } + #[\Override] public function setDefault(bool $default): void { $this->default = $default; } + #[\Override] public function getDefaultValidityPeriod(): ?string { return $this->defaultValidityPeriod; } + #[\Override] public function setDefaultValidityPeriod(?string $defaultValidityPeriod): void { $this->defaultValidityPeriod = $defaultValidityPeriod; } + #[\Override] public function getPageSize(): ?string { return $this->pageSize; } + #[\Override] public function setPageSize(?string $pageSize): void { $this->pageSize = $pageSize; } + #[\Override] public function getOrientation(): ?string { return $this->orientation; } + #[\Override] public function setOrientation(?string $orientation): void { $this->orientation = $orientation; } + #[\Override] public function getTemplate(): ?string { return $this->template; } + #[\Override] public function setTemplate(?string $template): void { $this->template = $template; diff --git a/src/Model/GiftCardInterface.php b/src/Model/GiftCardInterface.php index 770dde2e..ad5caec1 100644 --- a/src/Model/GiftCardInterface.php +++ b/src/Model/GiftCardInterface.php @@ -23,6 +23,7 @@ interface GiftCardInterface extends ResourceInterface, ToggleableInterface, Code public function __toString(): string; + #[\Override] public function getId(): ?int; /** @@ -70,6 +71,7 @@ public function getInitialAmount(): ?int; */ public function setInitialAmount(int $initialAmount): void; + #[\Override] public function isEnabled(): bool; public function getCurrencyCode(): ?string; @@ -127,7 +129,7 @@ public function getExpiresAt(): ?\DateTimeInterface; public function setExpiresAt(?\DateTimeInterface $expiresAt): void; - public function isExpired(\DateTimeInterface $date = null): bool; + public function isExpired(?\DateTimeInterface $date = null): bool; public function getSendNotificationEmail(): bool; diff --git a/src/Model/OrderItemUnitTrait.php b/src/Model/OrderItemUnitTrait.php index 80cf5cd6..cb4d41b9 100644 --- a/src/Model/OrderItemUnitTrait.php +++ b/src/Model/OrderItemUnitTrait.php @@ -8,7 +8,7 @@ trait OrderItemUnitTrait { - /** @ORM\OneToOne (targetEntity="Setono\SyliusGiftCardPlugin\Model\GiftCardInterface", mappedBy="orderItemUnit") */ + #[ORM\OneToOne(targetEntity: GiftCardInterface::class, mappedBy: 'orderItemUnit')] protected ?GiftCardInterface $giftCard = null; public function getGiftCard(): ?GiftCardInterface diff --git a/src/Model/OrderTrait.php b/src/Model/OrderTrait.php index e28519a2..5c91d127 100644 --- a/src/Model/OrderTrait.php +++ b/src/Model/OrderTrait.php @@ -15,16 +15,11 @@ */ trait OrderTrait { - /** - * @var Collection|GiftCardInterface[] - * - * @ORM\ManyToMany(targetEntity="Setono\SyliusGiftCardPlugin\Model\GiftCardInterface", inversedBy="appliedOrders") - * - * @ORM\JoinTable(name="setono_sylius_gift_card__order_gift_cards", - * joinColumns={@ORM\JoinColumn(name="order_id", referencedColumnName="id", onDelete="CASCADE")}, - * inverseJoinColumns={@ORM\JoinColumn(name="gift_card_id", referencedColumnName="id", onDelete="CASCADE")} - * ) - */ + /** @var Collection */ + #[ORM\ManyToMany(targetEntity: GiftCardInterface::class, inversedBy: 'appliedOrders')] + #[ORM\JoinTable(name: 'setono_sylius_gift_card__order_gift_cards')] + #[ORM\JoinColumn(name: 'order_id', referencedColumnName: 'id', onDelete: 'CASCADE')] + #[ORM\InverseJoinColumn(name: 'gift_card_id', referencedColumnName: 'id', onDelete: 'CASCADE')] protected Collection $giftCards; public function __construct() diff --git a/src/Model/ProductTrait.php b/src/Model/ProductTrait.php index e4bad295..34a04c3a 100644 --- a/src/Model/ProductTrait.php +++ b/src/Model/ProductTrait.php @@ -8,10 +8,10 @@ trait ProductTrait { - /** @ORM\Column(type="boolean", options={"default": false}) */ + #[ORM\Column(type: 'boolean', options: ['default' => false])] protected bool $giftCard = false; - /** @ORM\Column(type="boolean", options={"default": false}) */ + #[ORM\Column(type: 'boolean', options: ['default' => false])] protected bool $giftCardAmountConfigurable = false; public function isGiftCard(): bool diff --git a/src/Modifier/OrderGiftCardAmountModifier.php b/src/Modifier/OrderGiftCardAmountModifier.php index 75faca80..19f4722b 100644 --- a/src/Modifier/OrderGiftCardAmountModifier.php +++ b/src/Modifier/OrderGiftCardAmountModifier.php @@ -15,6 +15,7 @@ */ final class OrderGiftCardAmountModifier implements OrderGiftCardAmountModifierInterface { + #[\Override] public function decrement(OrderInterface $order): void { foreach ($order->getAdjustments(AdjustmentInterface::ORDER_GIFT_CARD_ADJUSTMENT) as $adjustment) { @@ -35,6 +36,7 @@ public function decrement(OrderInterface $order): void } } + #[\Override] public function increment(OrderInterface $order): void { foreach ($order->getAdjustments(AdjustmentInterface::ORDER_GIFT_CARD_ADJUSTMENT) as $adjustment) { diff --git a/src/Operator/OrderGiftCardOperator.php b/src/Operator/OrderGiftCardOperator.php index 5cdc3a2e..93909131 100644 --- a/src/Operator/OrderGiftCardOperator.php +++ b/src/Operator/OrderGiftCardOperator.php @@ -33,6 +33,7 @@ public function __construct( $this->giftCardOrderEmailManager = $giftCardOrderEmailManager; } + #[\Override] public function associateToCustomer(OrderInterface $order): void { $items = self::getOrderItemsThatAreGiftCards($order); @@ -58,6 +59,7 @@ public function associateToCustomer(OrderInterface $order): void $this->giftCardManager->flush(); } + #[\Override] public function enable(OrderInterface $order): void { $giftCards = $this->getGiftCards($order); @@ -77,6 +79,7 @@ public function enable(OrderInterface $order): void * Calls when Order this GiftCardCode was bought at * become cancelled */ + #[\Override] public function disable(OrderInterface $order): void { $giftCards = $this->getGiftCards($order); @@ -92,6 +95,7 @@ public function disable(OrderInterface $order): void $this->giftCardManager->flush(); } + #[\Override] public function send(OrderInterface $order): void { $giftCards = $this->getGiftCards($order); diff --git a/src/Operator/OrderGiftCardOperatorInterface.php b/src/Operator/OrderGiftCardOperatorInterface.php index 0107d64d..fb9aed9b 100644 --- a/src/Operator/OrderGiftCardOperatorInterface.php +++ b/src/Operator/OrderGiftCardOperatorInterface.php @@ -16,4 +16,6 @@ public function associateToCustomer(OrderInterface $order): void; public function enable(OrderInterface $order): void; public function disable(OrderInterface $order): void; + + public function send(OrderInterface $order): void; } diff --git a/src/Order/AddToCartCommand.php b/src/Order/AddToCartCommand.php index 6a815e46..8385295d 100644 --- a/src/Order/AddToCartCommand.php +++ b/src/Order/AddToCartCommand.php @@ -7,13 +7,13 @@ use Setono\SyliusGiftCardPlugin\Model\OrderInterface; use Sylius\Component\Core\Model\OrderItemInterface; -class AddToCartCommand implements AddToCartCommandInterface +final class AddToCartCommand implements AddToCartCommandInterface { - protected OrderInterface $cart; + private OrderInterface $cart; - protected OrderItemInterface $cartItem; + private OrderItemInterface $cartItem; - protected GiftCardInformationInterface $giftCardInformation; + private GiftCardInformationInterface $giftCardInformation; public function __construct( OrderInterface $cart, @@ -25,16 +25,19 @@ public function __construct( $this->giftCardInformation = $giftCardInformation; } + #[\Override] public function getCart(): OrderInterface { return $this->cart; } + #[\Override] public function getCartItem(): OrderItemInterface { return $this->cartItem; } + #[\Override] public function getGiftCardInformation(): GiftCardInformationInterface { return $this->giftCardInformation; diff --git a/src/Order/AddToCartCommandInterface.php b/src/Order/AddToCartCommandInterface.php index fb205306..e526f628 100644 --- a/src/Order/AddToCartCommandInterface.php +++ b/src/Order/AddToCartCommandInterface.php @@ -10,8 +10,10 @@ interface AddToCartCommandInterface extends BaseCommandInterface { + #[\Override] public function getCart(): OrderInterface; + #[\Override] public function getCartItem(): OrderItemInterface; public function getGiftCardInformation(): GiftCardInformationInterface; diff --git a/src/Order/Factory/AddToCartCommandFactory.php b/src/Order/Factory/AddToCartCommandFactory.php index b257073b..9deebde5 100644 --- a/src/Order/Factory/AddToCartCommandFactory.php +++ b/src/Order/Factory/AddToCartCommandFactory.php @@ -27,6 +27,7 @@ public function __construct( $this->giftCardInformationFactory = $giftCardInformationFactory; } + #[\Override] public function createWithCartAndCartItem(OrderInterface $cart, OrderItemInterface $cartItem): AddToCartCommandInterface { return new $this->className($cart, $cartItem, $this->giftCardInformationFactory->createNew($cartItem)); diff --git a/src/Order/Factory/GiftCardInformationFactory.php b/src/Order/Factory/GiftCardInformationFactory.php index 5275433b..c35e7a03 100644 --- a/src/Order/Factory/GiftCardInformationFactory.php +++ b/src/Order/Factory/GiftCardInformationFactory.php @@ -20,6 +20,7 @@ public function __construct(string $className) $this->className = $className; } + #[\Override] public function createNew(OrderItemInterface $orderItem): GiftCardInformationInterface { return new $this->className($orderItem->getUnitPrice()); diff --git a/src/Order/GiftCardInformation.php b/src/Order/GiftCardInformation.php index 5d260746..c89ecf90 100644 --- a/src/Order/GiftCardInformation.php +++ b/src/Order/GiftCardInformation.php @@ -4,33 +4,37 @@ namespace Setono\SyliusGiftCardPlugin\Order; -class GiftCardInformation implements GiftCardInformationInterface +final class GiftCardInformation implements GiftCardInformationInterface { - protected int $amount; + private int $amount; - protected ?string $customMessage; + private ?string $customMessage; - public function __construct(int $amount, string $customMessage = null) + public function __construct(int $amount, ?string $customMessage = null) { $this->amount = $amount; $this->customMessage = $customMessage; } + #[\Override] public function getAmount(): int { return $this->amount; } + #[\Override] public function setAmount(int $amount): void { $this->amount = $amount; } + #[\Override] public function getCustomMessage(): ?string { return $this->customMessage; } + #[\Override] public function setCustomMessage(?string $customMessage): void { $this->customMessage = $customMessage; diff --git a/src/OrderProcessor/OrderGiftCardProcessor.php b/src/OrderProcessor/OrderGiftCardProcessor.php index f31ff588..ca566b31 100644 --- a/src/OrderProcessor/OrderGiftCardProcessor.php +++ b/src/OrderProcessor/OrderGiftCardProcessor.php @@ -34,6 +34,7 @@ public function __construct( /** * @param BaseOrderInterface|OrderInterface $order */ + #[\Override] public function process(BaseOrderInterface $order): void { Assert::isInstanceOf($order, OrderInterface::class); diff --git a/src/Promotion/Checker/Rule/HasNoGiftCardRuleChecker.php b/src/Promotion/Checker/Rule/HasNoGiftCardRuleChecker.php index 710ede3c..1c7628de 100644 --- a/src/Promotion/Checker/Rule/HasNoGiftCardRuleChecker.php +++ b/src/Promotion/Checker/Rule/HasNoGiftCardRuleChecker.php @@ -14,6 +14,7 @@ final class HasNoGiftCardRuleChecker implements RuleCheckerInterface { public const TYPE = 'has_no_gift_card'; + #[\Override] public function isEligible(PromotionSubjectInterface $subject, array $configuration): bool { Assert::isInstanceOf($subject, OrderInterface::class); diff --git a/src/Provider/DatePeriodUnitProvider.php b/src/Provider/DatePeriodUnitProvider.php index 8445c49a..b9072a5b 100644 --- a/src/Provider/DatePeriodUnitProvider.php +++ b/src/Provider/DatePeriodUnitProvider.php @@ -4,8 +4,9 @@ namespace Setono\SyliusGiftCardPlugin\Provider; -class DatePeriodUnitProvider implements DatePeriodUnitProviderInterface +final class DatePeriodUnitProvider implements DatePeriodUnitProviderInterface { + #[\Override] public function getPeriodUnits(): array { return [ diff --git a/src/Provider/DefaultGiftCardTemplateContentProvider.php b/src/Provider/DefaultGiftCardTemplateContentProvider.php index 0886ecff..71580bd9 100644 --- a/src/Provider/DefaultGiftCardTemplateContentProvider.php +++ b/src/Provider/DefaultGiftCardTemplateContentProvider.php @@ -6,6 +6,7 @@ final class DefaultGiftCardTemplateContentProvider implements DefaultGiftCardTemplateContentProviderInterface { + #[\Override] public function getContent(): string { return <<managerRegistry = $managerRegistry; } + #[\Override] public function getConfiguration(BaseChannelInterface $channel, LocaleInterface $locale): GiftCardConfigurationInterface { $configuration = $this->giftCardConfigurationRepository->findOneByChannelAndLocale($channel, $locale); @@ -70,6 +71,7 @@ public function getConfiguration(BaseChannelInterface $channel, LocaleInterface return $configuration; } + #[\Override] public function getConfigurationForGiftCard(GiftCardInterface $giftCard): GiftCardConfigurationInterface { $channel = $giftCard->getChannel(); diff --git a/src/Provider/OrderEligibleTotalProvider.php b/src/Provider/OrderEligibleTotalProvider.php index f637e273..2b15c4af 100644 --- a/src/Provider/OrderEligibleTotalProvider.php +++ b/src/Provider/OrderEligibleTotalProvider.php @@ -9,6 +9,7 @@ final class OrderEligibleTotalProvider implements OrderEligibleTotalProviderInterface { + #[\Override] public function getEligibleTotal(OrderInterface $order, GiftCardInterface $giftCard): int { return $order->getTotal(); diff --git a/src/Provider/PdfRenderingOptionsProvider.php b/src/Provider/PdfRenderingOptionsProvider.php index 329bd148..2d1019c6 100644 --- a/src/Provider/PdfRenderingOptionsProvider.php +++ b/src/Provider/PdfRenderingOptionsProvider.php @@ -8,6 +8,7 @@ final class PdfRenderingOptionsProvider implements PdfRenderingOptionsProviderInterface { + #[\Override] public function getRenderingOptions(GiftCardConfigurationInterface $giftCardConfiguration): array { $options = []; diff --git a/src/Renderer/PdfRenderer.php b/src/Renderer/PdfRenderer.php index 06e6b7cf..d87635d5 100644 --- a/src/Renderer/PdfRenderer.php +++ b/src/Renderer/PdfRenderer.php @@ -50,11 +50,12 @@ public function __construct( $this->normalizer = $normalizer; } + #[\Override] public function render( GiftCardInterface $giftCard, - GiftCardConfigurationInterface $giftCardConfiguration = null, - ChannelInterface $channel = null, - string $localeCode = null, + ?GiftCardConfigurationInterface $giftCardConfiguration = null, + ?ChannelInterface $channel = null, + ?string $localeCode = null, ): PdfResponse { if (null === $channel) { $order = $giftCard->getOrder(); diff --git a/src/Renderer/PdfRendererInterface.php b/src/Renderer/PdfRendererInterface.php index e33aefaa..b5c7991f 100644 --- a/src/Renderer/PdfRendererInterface.php +++ b/src/Renderer/PdfRendererInterface.php @@ -17,8 +17,8 @@ interface PdfRendererInterface */ public function render( GiftCardInterface $giftCard, - GiftCardConfigurationInterface $giftCardConfiguration = null, - ChannelInterface $channel = null, - string $localeCode = null, + ?GiftCardConfigurationInterface $giftCardConfiguration = null, + ?ChannelInterface $channel = null, + ?string $localeCode = null, ): PdfResponse; } diff --git a/src/Resolver/CustomerChannelResolver.php b/src/Resolver/CustomerChannelResolver.php index 559135ce..abddabac 100644 --- a/src/Resolver/CustomerChannelResolver.php +++ b/src/Resolver/CustomerChannelResolver.php @@ -23,6 +23,7 @@ public function __construct( $this->channelRepository = $channelRepository; } + #[\Override] public function resolve(CustomerInterface $customer): ChannelInterface { $latestOrder = $this->orderRepository->findLatestByCustomer($customer); diff --git a/src/Resolver/LocaleResolver.php b/src/Resolver/LocaleResolver.php index 602c6949..ade5215e 100644 --- a/src/Resolver/LocaleResolver.php +++ b/src/Resolver/LocaleResolver.php @@ -24,6 +24,7 @@ public function __construct( $this->channelRepository = $channelRepository; } + #[\Override] public function resolveFromCustomer(CustomerInterface $customer): string { $latestOrder = $this->orderRepository->findLatestByCustomer($customer); @@ -34,6 +35,7 @@ public function resolveFromCustomer(CustomerInterface $customer): string return $this->resolve(); } + #[\Override] public function resolveFromOrder(OrderInterface $order): string { $localeCode = $order->getLocaleCode(); @@ -49,6 +51,7 @@ public function resolveFromOrder(OrderInterface $order): string return $this->resolve(); } + #[\Override] public function resolveFromChannel(ChannelInterface $channel): string { return $this->_resolveFromChannel($channel) ?? $this->resolve(); diff --git a/src/Resolver/RedirectUrlResolver.php b/src/Resolver/RedirectUrlResolver.php index a478b70c..35c8fc5a 100644 --- a/src/Resolver/RedirectUrlResolver.php +++ b/src/Resolver/RedirectUrlResolver.php @@ -18,6 +18,7 @@ public function __construct(UrlGeneratorInterface $router) $this->router = $router; } + #[\Override] public function getUrlToRedirectTo(Request $request, string $defaultRoute): string { /** @var mixed $redirect */ diff --git a/src/Resources/config/api_resources/GiftCard.xml b/src/Resources/config/api_resources/GiftCard.xml deleted file mode 100644 index 15b15dae..00000000 --- a/src/Resources/config/api_resources/GiftCard.xml +++ /dev/null @@ -1,160 +0,0 @@ - - - - - sylius - - - - GET - /admin/gift-cards - - admin:gift_card:read - - - - - POST - /admin/gift-cards - - admin:gift_card:read - - - admin:gift_card:create - - - - - GET - /admin/gift-cards/balance - setono_sylius_gift_card.controller.action.get_balance - false - - Get the gift cards balance. - - - admin:gift_card_balance:read - - Setono\SyliusGiftCardPlugin\Model\GiftCardBalanceCollection - - - - GET - /shop/gift-cards - - Retrieves the collection of GiftCard ressources associated to the logged in customer. - - - shop:gift_card:read - - - - - - - GET - /admin/gift-cards/{code} - - Use $code to retrieve a gift card resource. - - - admin:gift_card:read - - - - - GET - /admin/gift-cards/{code}/resend-email - setono_sylius_gift_card_plugin.api.resend_gift_card_email - - Resend the gift card email to the customer. - - - - - GET - /admin/gift-cards/{code}/pdf - setono_sylius_gift_card_plugin.api.download_gift_card_pdf - - Download the gift card as a PDF. - - Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse - - - - PUT - /admin/gift-cards/{code} - - admin:gift_card:read - - - admin:gift_card:update - - - - - DELETE - /admin/gift-cards/{code} - - - - GET - /shop/gift-cards/{code} - - Use $code to retrieve a gift card resource. You can use this to 'search' for gift cards. - - - shop:gift_card:read - - - - - GET - /shop/gift-cards/{code}/pdf - setono_sylius_gift_card_plugin.api.download_gift_card_pdf - - Download the gift card as a PDF. - - Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse - - - - PATCH - /shop/gift-cards/{code}/add-to-order - input - Setono\SyliusGiftCardPlugin\Api\Command\AddGiftCardToOrder - - Apply a gift card to your order. - - - shop:gift_card:read - - - shop:gift_card:add_to_order - - - - - PATCH - /shop/gift-cards/{code}/remove-from-order - input - Setono\SyliusGiftCardPlugin\Api\Command\RemoveGiftCardFromOrder - - Remove a gift card from your order. - - - shop:gift_card:read - - - shop:gift_card:remove_from_order - - - - - - - - diff --git a/src/Resources/config/api_resources/GiftCardConfiguration.xml b/src/Resources/config/api_resources/GiftCardConfiguration.xml deleted file mode 100644 index 091d40a5..00000000 --- a/src/Resources/config/api_resources/GiftCardConfiguration.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - admin/gift-card-configurations - sylius - - - - GET - - - admin:gift_card_configuration:read - - - - - POST - - input - Setono\SyliusGiftCardPlugin\Api\Command\CreateGiftCardConfiguration - - admin:gift_card_configuration:create - - setono_sylius_gift_card_configuration - - - - - - GET - /{code} - - admin:gift_card_configuration:read - - - - - PUT - /{code} - - admin:gift_card_configuration:read - - - admin:gift_card_configuration:update - - - - - DELETE - /{code} - - - - PATCH - /{code}/associate-channel - input - Setono\SyliusGiftCardPlugin\Api\Command\AssociateConfigurationToChannel - - admin:gift_card_configuration:read - - - admin:gift_card_configuration:associate_channel - - - Associate a channel to the configuration - - - - - - - - - diff --git a/src/Resources/config/api_resources/GiftCardConfigurationImage.xml b/src/Resources/config/api_resources/GiftCardConfigurationImage.xml deleted file mode 100644 index 4a693d48..00000000 --- a/src/Resources/config/api_resources/GiftCardConfigurationImage.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - admin - sylius - - - - POST - setono_sylius_gift_card_plugin.api.upload_gift_card_configuration_image - false - - - - - - object - - - string - - - string - binary - - - string - iri-reference - - - - - - - - - admin:gift_card_configuration_image:read - - - - - - - GET - - admin:gift_card_configuration_image:read - - - - - DELETE - - - - - - - - - diff --git a/src/Resources/config/api_resources/Order.xml b/src/Resources/config/api_resources/Order.xml deleted file mode 100644 index 8369296c..00000000 --- a/src/Resources/config/api_resources/Order.xml +++ /dev/null @@ -1,419 +0,0 @@ - - - - - - - sylius - - - - GET - admin/orders - - admin:order:read - - - - - POST - /shop/orders - input - Sylius\Bundle\ApiBundle\Command\Cart\PickupCart - - shop:order:read - - - shop:order:create - - - Pickups a new cart. Provided locale code has to be one of available for a particular channel. - - - - - GET - /shop/orders - - - shop:order:read - - - - - - - - GET - /admin/orders/{tokenValue} - - admin:order:read - - - - - GET - /shop/orders/{tokenValue} - - shop:cart:read - - - - - DELETE - /shop/orders/{tokenValue} - - Deletes cart - - - shop:order:read - - - - - PATCH - /admin/orders/{tokenValue}/cancel - false - Sylius\Bundle\ApiBundle\Applicator\OrderStateMachineTransitionApplicatorInterface:cancel - - - admin:order:read - - - - admin:order:update - - - Cancels Order - - - - - POST - /shop/orders/{tokenValue}/items - input - Setono\SyliusGiftCardPlugin\Api\Command\AddItemToCart - - shop:cart:read - - - shop:cart:add_item - - - Adds Item to cart - - - - - PATCH - - sylius - - /shop/orders/{tokenValue}/shipments/{shipmentId} - input - Sylius\Bundle\ApiBundle\Command\Checkout\ChooseShippingMethod - - shop:cart:select_shipping_method - - - shop:cart:read - - - Selects shipping methods for particular shipment - - - tokenValue - path - true - - string - - - - shipmentId - path - true - - string - - - - - - - - PATCH - /shop/orders/{tokenValue}/payments/{paymentId} - input - Sylius\Bundle\ApiBundle\Command\Checkout\ChoosePaymentMethod - - shop:cart:select_payment_method - - - shop:cart:read - - - Selects payment methods for particular payment - - - tokenValue - path - true - - string - - - - paymentId - path - true - - string - - - - - - - - PATCH - /shop/account/orders/{tokenValue}/payments/{paymentId} - input - Sylius\Bundle\ApiBundle\Command\Account\ChangePaymentMethod - - shop:order:account:change_payment_method - - - shop:order:account:read - - - Change the payment method as logged shop user - - - tokenValue - path - true - - string - - - - paymentId - path - true - - string - - - - - - - - GET - Sylius\Bundle\ApiBundle\Controller\Payment\GetPaymentConfiguration - /shop/orders/{tokenValue}/payments/{paymentId}/configuration - - Retrieve payment method configuration - - - tokenValue - path - true - - string - - - - paymentId - path - true - - string - - - - - - - - PATCH - /shop/orders/{tokenValue}/complete - - sylius - sylius_checkout_complete - - input - Sylius\Bundle\ApiBundle\Command\Checkout\CompleteOrder - - shop:cart:complete - - - shop:cart:read - - - Completes checkout - - - - - DELETE - /shop/orders/{tokenValue}/items/{itemId} - input - Sylius\Bundle\ApiBundle\Controller\DeleteOrderItemAction - false - - shop:cart:remove_item - - - - - tokenValue - path - true - - string - - - - itemId - path - true - - string - - - - - - - - PATCH - /shop/orders/{tokenValue}/items/{orderItemId} - input - Sylius\Bundle\ApiBundle\Command\Cart\ChangeItemQuantityInCart - - shop:cart:read - - - shop:cart:change_quantity - - - Changes quantity of order item - - - tokenValue - path - true - - string - - - - orderItemId - path - true - - string - - - - - - - - PUT - /shop/orders/{tokenValue} - input - Sylius\Bundle\ApiBundle\Command\Checkout\UpdateCart - - shop:cart:update - - - shop:cart:read - - - Addresses cart to given location, logged in Customer does not have to provide an email. Applies coupon to cart. - - - - - - - GET - /shop/orders/{tokenValue}/items - - - - GET - /admin/orders/{tokenValue}/shipments - - - - GET - /admin/orders/{tokenValue}/payments - - - - GET - /shop/orders/{tokenValue}/adjustments - - - - GET - /shop/orders/{tokenValue}/payments/{payments}/methods - - - - GET - /shop/orders/{tokenValue}/shipments/{shipments}/methods - - - - GET - /shop/orders/{tokenValue}/items/{items}/adjustments - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/app/config.yaml b/src/Resources/config/app/config.yaml deleted file mode 100644 index 91154c3e..00000000 --- a/src/Resources/config/app/config.yaml +++ /dev/null @@ -1,76 +0,0 @@ -imports: - - { resource: "@SetonoSyliusGiftCardPlugin/Resources/config/grids.yaml" } - - { resource: "@SetonoSyliusGiftCardPlugin/Resources/config/sylius_ui.yaml" } - - - { resource: "@SetonoSyliusGiftCardPlugin/Resources/config/state_machine/sylius_order.yaml" } - - { resource: "@SetonoSyliusGiftCardPlugin/Resources/config/state_machine/sylius_order_checkout.yaml" } - - { resource: "@SetonoSyliusGiftCardPlugin/Resources/config/state_machine/sylius_order_payment.yaml" } - -sylius_mailer: - emails: - gift_card_customer: - subject: setono_sylius_gift_card.email.new_gift_card - template: "@SetonoSyliusGiftCardPlugin/Email/giftCardToCustomer.html.twig" - gift_card_order: - subject: setono_sylius_gift_card.email.your_gift_cards_you_bought_in_the_order - template: "@SetonoSyliusGiftCardPlugin/Email/giftCardsFromOrder.html.twig" - -jms_serializer: - metadata: - directories: - setono-sylius-gift-card-sylius: - namespace_prefix: "Setono\\SyliusGiftCardPlugin\\Model" - path: "@SetonoSyliusGiftCardPlugin/Resources/config/serializer" - -liip_imagine: - filter_sets: - setono_sylius_gift_card_background: - filters: - thumbnail: { size: [1200], mode: inset } - -sylius_ui: - events: - setono_sylius_gift_card.admin.gift_card_configuration.create.javascripts: - blocks: - preview_uploaded_image: '@SetonoSyliusGiftCardPlugin/Admin/GiftCardConfiguration/_javascripts.html.twig' - - setono_sylius_gift_card.admin.gift_card_configuration.update.javascripts: - blocks: - preview_uploaded_image: '@SetonoSyliusGiftCardPlugin/Admin/GiftCardConfiguration/_javascripts.html.twig' - live_pdf_rendering_js: '@SetonoSyliusGiftCardPlugin/Admin/GiftCardConfiguration/Update/_javascripts.html.twig' - - setono_sylius_gift_card.admin.gift_card.create.javascripts: - blocks: - send_customer_email_js: '@SetonoSyliusGiftCardPlugin/Admin/GiftCard/Create/_javascripts.html.twig' - - setono_sylius_gift_card.shop.account.gift_card.index.after_content_header: - blocks: - after_content_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 50 - context: - event: setono_sylius_gift_card.shop.account.gift_card.index.after_content_header - - setono_sylius_gift_card.shop.account.gift_card.index.after_grid: - blocks: - after_content_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 50 - context: - event: setono_sylius_gift_card.shop.account.gift_card.index.after_grid - - setono_sylius_gift_card.shop.account.gift_card.index.header: - blocks: - after_content_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 50 - context: - event: setono_sylius_gift_card.shop.account.gift_card.index.header - - setono_sylius_gift_card.shop.cart.summary.applied_gift_cards: - blocks: - after_content_header_legacy: - template: "@SyliusUi/Block/_legacySonataEvent.html.twig" - priority: 50 - context: - event: setono_sylius_gift_card.shop.cart.summary.applied_gift_cards diff --git a/src/Resources/config/routes.yaml b/src/Resources/config/routes.yaml deleted file mode 100644 index b134a7ff..00000000 --- a/src/Resources/config/routes.yaml +++ /dev/null @@ -1,17 +0,0 @@ -setono_sylius_gift_card_shop: - resource: "@SetonoSyliusGiftCardPlugin/Resources/config/routes/shop.yaml" - prefix: /{_locale} - requirements: - _locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$ - -setono_sylius_gift_card_admin: - resource: "@SetonoSyliusGiftCardPlugin/Resources/config/routes/admin.yaml" - prefix: /admin - -setono_sylius_gift_card_admin_ajax: - resource: "@SetonoSyliusGiftCardPlugin/Resources/config/routes/admin_ajax.yaml" - prefix: /admin/ajax - -setono_sylius_gift_card_admin_api: - resource: "@SetonoSyliusGiftCardPlugin/Resources/config/routes/admin_api.yaml" - prefix: /api/v{version} diff --git a/src/Resources/config/routes/admin_ajax.yaml b/src/Resources/config/routes/admin_ajax.yaml deleted file mode 100644 index 0879a561..00000000 --- a/src/Resources/config/routes/admin_ajax.yaml +++ /dev/null @@ -1,33 +0,0 @@ -setono_sylius_gift_card_admin_ajax_customer_by_email_phrase: - path: /customer/search - methods: [GET] - defaults: - _controller: sylius.controller.customer::indexAction - _format: json - _sylius: - serialization_groups: [Default] - permission: true - repository: - method: findByEmailPartForGiftCard - arguments: - email: $phrase - -setono_sylius_gift_card_admin_ajax_customer_by_email: - path: /customer/email - methods: [GET] - defaults: - _controller: sylius.controller.customer::indexAction - _format: json - _sylius: - serialization_groups: [Default] - permission: true - repository: - method: findBy - arguments: [email: $email] - -setono_sylius_gift_card_admin_ajax_generate_pdf: - path: /gift-card-configurations/{id}/generate-encoded-example-pdf - methods: [ PUT ] - controller: setono_sylius_gift_card.controller.action.generate_encoded_example_pdf - requirements: - id: \d+ diff --git a/src/Resources/config/routes/admin_api.yaml b/src/Resources/config/routes/admin_api.yaml deleted file mode 100644 index 350b36ad..00000000 --- a/src/Resources/config/routes/admin_api.yaml +++ /dev/null @@ -1,7 +0,0 @@ -setono_sylius_gift_card_admin_api_gift_card: - resource: | - alias: setono_sylius_gift_card.gift_card - section: admin_api - form: Setono\SyliusGiftCardPlugin\Form\Type\GiftCardType - serialization_version: $version - type: sylius.resource_api diff --git a/src/Resources/config/routes_no_locale.yaml b/src/Resources/config/routes_no_locale.yaml deleted file mode 100644 index 988acf3d..00000000 --- a/src/Resources/config/routes_no_locale.yaml +++ /dev/null @@ -1,14 +0,0 @@ -setono_sylius_gift_card_shop: - resource: "@SetonoSyliusGiftCardPlugin/Resources/config/routes/shop.yaml" - -setono_sylius_gift_card_admin: - resource: "@SetonoSyliusGiftCardPlugin/Resources/config/routes/admin.yaml" - prefix: /admin - -setono_sylius_gift_card_admin_ajax: - resource: "@SetonoSyliusGiftCardPlugin/Resources/config/routes/admin_ajax.yaml" - prefix: /admin/ajax - -setono_sylius_gift_card_admin_api: - resource: "@SetonoSyliusGiftCardPlugin/Resources/config/routes/admin_api.yaml" - prefix: /api/v{version} diff --git a/src/Resources/config/serialization/Command/AddGiftCardToOrder.xml b/src/Resources/config/serialization/Command/AddGiftCardToOrder.xml deleted file mode 100644 index 5cdc4d30..00000000 --- a/src/Resources/config/serialization/Command/AddGiftCardToOrder.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - shop:gift_card:add_to_order - - - diff --git a/src/Resources/config/serialization/Command/AddItemToCartCommand.xml b/src/Resources/config/serialization/Command/AddItemToCartCommand.xml deleted file mode 100644 index bce69317..00000000 --- a/src/Resources/config/serialization/Command/AddItemToCartCommand.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - shop:cart:add_item - - - shop:cart:add_item - - - shop:cart:add_item - - - shop:cart:add_item - - - diff --git a/src/Resources/config/serialization/Command/AssociateConfigurationToChannel.xml b/src/Resources/config/serialization/Command/AssociateConfigurationToChannel.xml deleted file mode 100644 index 1505ed77..00000000 --- a/src/Resources/config/serialization/Command/AssociateConfigurationToChannel.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - admin:gift_card_configuration:associate_channel - - - - admin:gift_card_configuration:associate_channel - - - diff --git a/src/Resources/config/serialization/Command/CreateGiftCardConfiguration.xml b/src/Resources/config/serialization/Command/CreateGiftCardConfiguration.xml deleted file mode 100644 index 03883740..00000000 --- a/src/Resources/config/serialization/Command/CreateGiftCardConfiguration.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - admin:gift_card_configuration:create - - - admin:gift_card_configuration:create - - - admin:gift_card_configuration:create - - - admin:gift_card_configuration:create - - - admin:gift_card_configuration:create - - - admin:gift_card_configuration:create - - - admin:gift_card_configuration:create - - - diff --git a/src/Resources/config/serialization/Command/RemoveGiftCardFromOrder.xml b/src/Resources/config/serialization/Command/RemoveGiftCardFromOrder.xml deleted file mode 100644 index 0dffd2b2..00000000 --- a/src/Resources/config/serialization/Command/RemoveGiftCardFromOrder.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - shop:gift_card:remove_from_order - - - diff --git a/src/Resources/config/serializer/Model.GiftCard.yml b/src/Resources/config/serializer/Model.GiftCard.yml deleted file mode 100644 index fe281f95..00000000 --- a/src/Resources/config/serializer/Model.GiftCard.yml +++ /dev/null @@ -1,44 +0,0 @@ -Setono\SyliusGiftCardPlugin\Model\GiftCard: - exclusion_policy: ALL - xml_root_name: setono_sylius_gift_card - properties: - code: - expose: true - type: string - groups: [Default, Detailed] - currencyCode: - expose: true - type: string - groups: [Default, Detailed] - amount: - expose: true - type: integer - groups: [Default, Detailed] - initialAmount: - expose: true - type: integer - groups: [Default, Detailed] - enabled: - expose: true - type: boolean - groups: [Default, Detailed] - createdAt: - expose: true - type: DateTime - groups: [Default, Detailed] - virtual_properties: - getCustomerIdentification: - serialized_name: customer - expose: true - type: array - groups: [Default, Detailed] - getOrderIdentification: - serialized_name: order - expose: true - type: array - groups: [Default, Detailed] - getChannelCode: - serialized_name: channel - expose: true - type: string - groups: [Default, Detailed] diff --git a/src/Resources/config/services/api.xml b/src/Resources/config/services/api.xml deleted file mode 100644 index afba0b51..00000000 --- a/src/Resources/config/services/api.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - diff --git a/src/Resources/config/services/api/command_handler.xml b/src/Resources/config/services/api/command_handler.xml deleted file mode 100644 index cacbbfb8..00000000 --- a/src/Resources/config/services/api/command_handler.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/services/api/controller.xml b/src/Resources/config/services/api/controller.xml deleted file mode 100644 index 2324a2a3..00000000 --- a/src/Resources/config/services/api/controller.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/services/api/data_persister.xml b/src/Resources/config/services/api/data_persister.xml deleted file mode 100644 index 131c397c..00000000 --- a/src/Resources/config/services/api/data_persister.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - diff --git a/src/Resources/config/services/api/data_transformer.xml b/src/Resources/config/services/api/data_transformer.xml deleted file mode 100644 index c72cf769..00000000 --- a/src/Resources/config/services/api/data_transformer.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - diff --git a/src/Resources/config/services/api/doctrine.xml b/src/Resources/config/services/api/doctrine.xml deleted file mode 100644 index 822ffeed..00000000 --- a/src/Resources/config/services/api/doctrine.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - diff --git a/src/Resources/config/state_machine/sylius_order.yaml b/src/Resources/config/state_machine/sylius_order.yaml deleted file mode 100644 index 1cf79315..00000000 --- a/src/Resources/config/state_machine/sylius_order.yaml +++ /dev/null @@ -1,16 +0,0 @@ -winzou_state_machine: - sylius_order: - callbacks: - after: - setono_decrement_gift_card_amount: - on: ["create"] - do: ["@setono_sylius_gift_card.modifier.order_gift_card_amount", "decrement"] - args: ["object"] - setono_increment_gift_card_amount: - on: ["cancel"] - do: ["@setono_sylius_gift_card.modifier.order_gift_card_amount", "increment"] - args: ["object"] - setono_order_cancellation_gift_card: - on: ["cancel"] - do: ["@setono_sylius_gift_card.operator.order_gift_card", "disable"] - args: ["object"] diff --git a/src/Resources/config/state_machine/sylius_order_checkout.yaml b/src/Resources/config/state_machine/sylius_order_checkout.yaml deleted file mode 100644 index 12c9d934..00000000 --- a/src/Resources/config/state_machine/sylius_order_checkout.yaml +++ /dev/null @@ -1,8 +0,0 @@ -winzou_state_machine: - sylius_order_checkout: - callbacks: - after: - setono_gift_card_associate_to_customer: - on: ["complete"] - do: ["@setono_sylius_gift_card.operator.order_gift_card", "associateToCustomer"] - args: ["object"] diff --git a/src/Resources/config/state_machine/sylius_order_payment.yaml b/src/Resources/config/state_machine/sylius_order_payment.yaml deleted file mode 100644 index a30259eb..00000000 --- a/src/Resources/config/state_machine/sylius_order_payment.yaml +++ /dev/null @@ -1,12 +0,0 @@ -winzou_state_machine: - sylius_order_payment: - callbacks: - after: - setono_gift_card_enable: - on: ["pay"] - do: ["@setono_sylius_gift_card.operator.order_gift_card", "enable"] - args: ["object"] - setono_gift_card_send: - on: ["pay"] - do: ["@setono_sylius_gift_card.operator.order_gift_card", "send"] - args: ["object"] diff --git a/src/Resources/config/sylius_ui.yaml b/src/Resources/config/sylius_ui.yaml deleted file mode 100644 index 7a641d5e..00000000 --- a/src/Resources/config/sylius_ui.yaml +++ /dev/null @@ -1,7 +0,0 @@ -sylius_ui: - events: - sylius.shop.product.show.add_to_cart_form: - blocks: - setono_sylius_gift_card_information: - template: '@SetonoSyliusGiftCardPlugin/Shop/Product/Show/_addToCartGiftCardInformation.html.twig' - priority: 10 diff --git a/src/Resources/config/validation/CreateGiftCardConfiguration.xml b/src/Resources/config/validation/CreateGiftCardConfiguration.xml deleted file mode 100644 index 4527b4d5..00000000 --- a/src/Resources/config/validation/CreateGiftCardConfiguration.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/public/setono-sylius-gift-card-add-gift-card-to-order.js b/src/Resources/public/setono-sylius-gift-card-add-gift-card-to-order.js deleted file mode 100644 index 98fba8d7..00000000 --- a/src/Resources/public/setono-sylius-gift-card-add-gift-card-to-order.js +++ /dev/null @@ -1,29 +0,0 @@ -(function ($) { - 'use strict'; - - $.fn.extend({ - addGiftCardToOrder: function () { - const $element = $(this); - const url = $element.data('action'); - const redirectUrl = $element.data('redirect'); - - $element.on('submit', function (event) { - event.preventDefault(); - - $.ajax(url, { - method: 'POST', - data: $element.serialize(), - success: function () { - window.location.href = redirectUrl; - }, - error: function (xhr) { - $('.setono-sylius-gift-card-gift-card-block').replaceWith(xhr.responseText); - - $('#setono-sylius-gift-card-add-gift-card-to-order').addGiftCardToOrder(); - }, - }); - }); - - }, - }); -})(jQuery); diff --git a/src/Resources/public/setono-sylius-gift-card-live-pdf-rendering.js b/src/Resources/public/setono-sylius-gift-card-live-pdf-rendering.js deleted file mode 100644 index aa7420eb..00000000 --- a/src/Resources/public/setono-sylius-gift-card-live-pdf-rendering.js +++ /dev/null @@ -1,22 +0,0 @@ -(function ($) { - 'use strict'; - - $.fn.extend({ - applyPdfChanges: function () { - const $element = $(this); - const url = $element.data('url'); - - $element.on('click', function (event) { - event.preventDefault(); - - $.ajax(url, { - method: 'POST', - data: $('form[name="setono_sylius_gift_card_gift_card_configuration"]').serialize(), - success(response) { - $('.js-ssgc-live-render-container').html(``); - }, - }); - }); - }, - }); -})(jQuery); diff --git a/src/Resources/public/setono-sylius-gift-card-send-notification-email.js b/src/Resources/public/setono-sylius-gift-card-send-notification-email.js deleted file mode 100644 index 68d172c1..00000000 --- a/src/Resources/public/setono-sylius-gift-card-send-notification-email.js +++ /dev/null @@ -1,32 +0,0 @@ -(function ($) { - 'use strict'; - - $.fn.extend({ - sendNotificationEmailInput: function () { - const $customerInput = $(this); - const $sendCustomerNotificationEmail = $($customerInput.data('target')); - - if ($customerInput.val() !== '') { - $sendCustomerNotificationEmail.show(); - } else { - $sendCustomerNotificationEmail.hide(); - } - - $('label[for="setono_sylius_gift_card_gift_card_customer"]').prepend(''); - - $customerInput.on('change', () => { - if ($customerInput.val() !== '') { - $sendCustomerNotificationEmail.show(); - } else { - $sendCustomerNotificationEmail.hide(); - } - }); - - $('.js-ssgc-clear-input').on('click', () => { - $customerInput.parent().children('div.text').html(''); - $customerInput.val(''); - $customerInput.trigger('change'); - }); - } - }); -})(jQuery); diff --git a/src/Resources/views/Admin/GiftCard/Create/_javascripts.html.twig b/src/Resources/views/Admin/GiftCard/Create/_javascripts.html.twig deleted file mode 100644 index 4fbabf62..00000000 --- a/src/Resources/views/Admin/GiftCard/Create/_javascripts.html.twig +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/src/Resources/views/Admin/GiftCard/Grid/Action/create.html.twig b/src/Resources/views/Admin/GiftCard/Grid/Action/create.html.twig deleted file mode 100644 index a3907282..00000000 --- a/src/Resources/views/Admin/GiftCard/Grid/Action/create.html.twig +++ /dev/null @@ -1,8 +0,0 @@ -{# todo this should be a knp menu builder instead #} - diff --git a/src/Resources/views/Admin/GiftCard/Grid/Action/delete_conditional.html.twig b/src/Resources/views/Admin/GiftCard/Grid/Action/delete_conditional.html.twig deleted file mode 100644 index c6597d0f..00000000 --- a/src/Resources/views/Admin/GiftCard/Grid/Action/delete_conditional.html.twig +++ /dev/null @@ -1,6 +0,0 @@ -{% import '@SyliusUi/Macro/buttons.html.twig' as buttons %} - -{% set visible = options.visible is defined ? options.visible : true %} -{% if visible %} - {% include '@SyliusUi/Grid/Action/delete.html.twig' %} -{% endif %} diff --git a/src/Resources/views/Admin/GiftCard/Grid/Action/gift_card_balance.html.twig b/src/Resources/views/Admin/GiftCard/Grid/Action/gift_card_balance.html.twig deleted file mode 100644 index 082029ef..00000000 --- a/src/Resources/views/Admin/GiftCard/Grid/Action/gift_card_balance.html.twig +++ /dev/null @@ -1,9 +0,0 @@ -{% import '@SyliusUi/Macro/buttons.html.twig' as buttons %} - -{{ buttons.default( - path('setono_sylius_gift_card_admin_gift_card_balance'), - 'setono_sylius_gift_card.ui.balance'|trans, - null, - 'balance scale', - 'grey') -}} diff --git a/src/Resources/views/Admin/GiftCard/Grid/Action/list_conditional.html.twig b/src/Resources/views/Admin/GiftCard/Grid/Action/list_conditional.html.twig deleted file mode 100644 index ae264db7..00000000 --- a/src/Resources/views/Admin/GiftCard/Grid/Action/list_conditional.html.twig +++ /dev/null @@ -1,8 +0,0 @@ -{% import '@SyliusUi/Macro/buttons.html.twig' as buttons %} - -{% set path = options.link.url|default(path(options.link.route, options.link.parameters)) %} -{% set visible = options.visible is defined ? options.visible : true %} - -{% if visible %} - {{ buttons.default(path, action.label, null, 'list', 'primary') }} -{% endif %} diff --git a/src/Resources/views/Admin/GiftCard/Grid/Action/resend_email.html.twig b/src/Resources/views/Admin/GiftCard/Grid/Action/resend_email.html.twig deleted file mode 100644 index 1731f884..00000000 --- a/src/Resources/views/Admin/GiftCard/Grid/Action/resend_email.html.twig +++ /dev/null @@ -1,10 +0,0 @@ -{% import '@SyliusUi/Macro/buttons.html.twig' as buttons %} - - -{% set visible = options.visible is defined ? options.visible : true %} - -{% if visible %} - {% set path = options.link.url|default(path(options.link.route, options.link.parameters)) %} - - {{ buttons.default(path, action.label, null, 'mail', 'purple') }} -{% endif %} diff --git a/src/Resources/views/Admin/GiftCard/Grid/Field/amount.html.twig b/src/Resources/views/Admin/GiftCard/Grid/Field/amount.html.twig deleted file mode 100644 index 1cfdb2c8..00000000 --- a/src/Resources/views/Admin/GiftCard/Grid/Field/amount.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -{% import "@SyliusAdmin/Common/Macro/money.html.twig" as money %} - -{{ money.format(data.amount, data.currencyCode) }} diff --git a/src/Resources/views/Admin/GiftCard/_form.html.twig b/src/Resources/views/Admin/GiftCard/_form.html.twig deleted file mode 100644 index 73d9dfd2..00000000 --- a/src/Resources/views/Admin/GiftCard/_form.html.twig +++ /dev/null @@ -1,26 +0,0 @@ -{{ form_errors(form) }} -
-
-
- {{ form_errors(form) }} - {{ form_row(form.code) }} - {{ form_row(form.enabled) }} - {{ form_row(form.expiresAt) }} - {{ form_row(form.customer, {'attr': {'data-target': '.js-ssgc-send-customer-email'}}) }} - {% if form.sendNotificationEmail is defined %} - - {% endif %} -
-
- -
-
- {{ form_row(form.currencyCode) }} - {{ form_row(form.amount) }} - {{ form_row(form.customMessage) }} -
-
-
diff --git a/src/Resources/views/Admin/GiftCardConfiguration/Create/_breadcrumb.html.twig b/src/Resources/views/Admin/GiftCardConfiguration/Create/_breadcrumb.html.twig deleted file mode 100644 index 7b877fcd..00000000 --- a/src/Resources/views/Admin/GiftCardConfiguration/Create/_breadcrumb.html.twig +++ /dev/null @@ -1,17 +0,0 @@ -{% import '@SyliusAdmin/Macro/breadcrumb.html.twig' as breadcrumb %} - -{% set index_url = path( - configuration.vars.index.route.name|default(configuration.getRouteName('index')), - configuration.vars.index.route.parameters|default(configuration.vars.route.parameters|default({})) - ) -%} - -{% set breadcrumbs = [ - { label: 'sylius.ui.administration'|trans, url: path('sylius_admin_dashboard') }, - { label: 'setono_sylius_gift_card.ui.gift_cards'|trans, url: path('setono_sylius_gift_card_admin_gift_card_index') }, - { label: (metadata.applicationName~'.ui.'~metadata.pluralName)|trans, url: index_url }, - { label: 'sylius.ui.new'|trans } -] -%} - -{{ breadcrumb.crumble(breadcrumbs) }} diff --git a/src/Resources/views/Admin/GiftCardConfiguration/Index/_breadcrumb.html.twig b/src/Resources/views/Admin/GiftCardConfiguration/Index/_breadcrumb.html.twig deleted file mode 100644 index b5f3aa4d..00000000 --- a/src/Resources/views/Admin/GiftCardConfiguration/Index/_breadcrumb.html.twig +++ /dev/null @@ -1,10 +0,0 @@ -{% import '@SyliusAdmin/Macro/breadcrumb.html.twig' as breadcrumb %} - -{% set breadcrumbs = [ - { label: 'sylius.ui.administration'|trans, url: path('sylius_admin_dashboard') }, - { label: 'setono_sylius_gift_card.ui.gift_cards'|trans, url: path('setono_sylius_gift_card_admin_gift_card_index') }, - { label: (metadata.applicationName~'.ui.'~metadata.pluralName)|trans }, -] -%} - -{{ breadcrumb.crumble(breadcrumbs) }} diff --git a/src/Resources/views/Admin/GiftCardConfiguration/Update/_breadcrumb.html.twig b/src/Resources/views/Admin/GiftCardConfiguration/Update/_breadcrumb.html.twig deleted file mode 100644 index ae88645e..00000000 --- a/src/Resources/views/Admin/GiftCardConfiguration/Update/_breadcrumb.html.twig +++ /dev/null @@ -1,18 +0,0 @@ -{% import '@SyliusAdmin/Macro/breadcrumb.html.twig' as breadcrumb %} - -{% set index_url = path( - configuration.vars.index.route.name|default(configuration.getRouteName('index')), - configuration.vars.index.route.parameters|default(configuration.vars.route.parameters|default({})) - ) -%} - -{% set breadcrumbs = [ - { label: 'sylius.ui.administration'|trans, url: path('sylius_admin_dashboard') }, - { label: 'setono_sylius_gift_card.ui.gift_cards'|trans, url: path('setono_sylius_gift_card_admin_gift_card_index') }, - { label: (metadata.applicationName~'.ui.'~metadata.pluralName)|trans, url: index_url }, - { label: resource.name|default(resource.code|default(resource.id)) }, - { label: 'sylius.ui.edit'|trans } -] -%} - -{{ breadcrumb.crumble(breadcrumbs) }} diff --git a/src/Resources/views/Admin/GiftCardConfiguration/Update/_javascripts.html.twig b/src/Resources/views/Admin/GiftCardConfiguration/Update/_javascripts.html.twig deleted file mode 100644 index 6845f157..00000000 --- a/src/Resources/views/Admin/GiftCardConfiguration/Update/_javascripts.html.twig +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/src/Resources/views/Admin/GiftCardConfiguration/_form.html.twig b/src/Resources/views/Admin/GiftCardConfiguration/_form.html.twig deleted file mode 100644 index ebbef5b6..00000000 --- a/src/Resources/views/Admin/GiftCardConfiguration/_form.html.twig +++ /dev/null @@ -1,64 +0,0 @@ -{% form_theme form '@SyliusAdmin/Form/imagesTheme.html.twig' %} - - - -{{ form_errors(form) }} -
-
-
- {{ form_row(form.code) }} -
- {{ form_label(form.defaultValidityPeriod) }} -
- {{ form_widget(form.defaultValidityPeriod.value) }} - {{ form_widget(form.defaultValidityPeriod.unit, {'attr': {'class': 'ui compact selection dropdown'}}) }} -
-
-
- {{ form_label(form.backgroundImage) }} - {{ form_widget(form.backgroundImage) }} - {{ form_errors(form.backgroundImage) }} -
- {{ form_row(form.pageSize) }} - {{ form_row(form.orientation) }} -
-
-
-
- {{ form_row(form.enabled) }} - {{ form_row(form.default) }} - {{ form_row(form.channelConfigurations) }} -
-
-
- - - -

- {{ 'setono_sylius_gift_card.ui.gift_card_configuration.pdf_live_rendering.title'|trans }} -

-
-
-
- {{ form_row(form.template, {'attr': {'rows': 40}}) }} - {% if resource.id is not null %} - - {% endif %} -
-
- -
-
-
diff --git a/src/Resources/views/Admin/GiftCardConfiguration/_javascripts.html.twig b/src/Resources/views/Admin/GiftCardConfiguration/_javascripts.html.twig deleted file mode 100644 index 043283c8..00000000 --- a/src/Resources/views/Admin/GiftCardConfiguration/_javascripts.html.twig +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/src/Resources/views/Admin/giftCardBalance.html.twig b/src/Resources/views/Admin/giftCardBalance.html.twig deleted file mode 100644 index 9f2c1a11..00000000 --- a/src/Resources/views/Admin/giftCardBalance.html.twig +++ /dev/null @@ -1,61 +0,0 @@ -{# @var \Setono\SyliusGiftCardPlugin\Model\GiftCardBalanceCollection giftCardBalanceCollection #} - -{% extends '@SyliusAdmin/layout.html.twig' %} - -{% import '@SyliusAdmin/Macro/breadcrumb.html.twig' as breadcrumb %} -{% import "@SyliusAdmin/Common/Macro/money.html.twig" as money %} - -{% block title %}{{ 'setono_sylius_gift_card.ui.balance'|trans }} {{ parent() }}{% endblock %} - -{% block content %} -
-
-

- -
- {{ 'setono_sylius_gift_card.ui.balance'|trans }} -
-

-
-
- - {% set breadcrumbs = [ - { label: 'sylius.ui.administration'|trans, url: path('sylius_admin_dashboard') }, - { label: 'setono_sylius_gift_card.ui.gift_cards'|trans, url: path('setono_sylius_gift_card_admin_gift_card_index') }, - { label: 'setono_sylius_gift_card.ui.balance'|trans } - ] - %} - - {{ breadcrumb.crumble(breadcrumbs) }} - -
-
-
- - - - - - - - - - {% for giftCardBalance in giftCardBalanceCollection %} - - - - - - {% endfor %} - -
{{ 'setono_sylius_gift_card.ui.total'|trans }}{{ 'setono_sylius_gift_card.ui.count'|trans }}{{ 'setono_sylius_gift_card.ui.average_amount'|trans }}
- {{ money.format(giftCardBalance.total, giftCardBalance.currencyCode) }} - - {{ giftCardBalance.count }} - - {{ money.format(giftCardBalance.averageAmount, giftCardBalance.currencyCode) }} -
-
-
-
-{% endblock %} diff --git a/src/Resources/views/Cart/_giftCard.html.twig b/src/Resources/views/Cart/_giftCard.html.twig deleted file mode 100644 index f04b1346..00000000 --- a/src/Resources/views/Cart/_giftCard.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ render(url('setono_sylius_gift_card_shop_partial_add_gift_card_to_order')) }} diff --git a/src/Resources/views/Shop/Account/GiftCard/Grid/Field/amount.html.twig b/src/Resources/views/Shop/Account/GiftCard/Grid/Field/amount.html.twig deleted file mode 100644 index 3a91aeff..00000000 --- a/src/Resources/views/Shop/Account/GiftCard/Grid/Field/amount.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} - -{{ money.format(data.amount, data.currencyCode) }} diff --git a/src/Resources/views/Shop/Account/GiftCard/Grid/Field/initial_amount.html.twig b/src/Resources/views/Shop/Account/GiftCard/Grid/Field/initial_amount.html.twig deleted file mode 100644 index c4554fd1..00000000 --- a/src/Resources/views/Shop/Account/GiftCard/Grid/Field/initial_amount.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} - -{{ money.format(data.initialAmount, data.currencyCode) }} diff --git a/src/Resources/views/Shop/Account/GiftCard/Index/_breadcrumb.html.twig b/src/Resources/views/Shop/Account/GiftCard/Index/_breadcrumb.html.twig deleted file mode 100644 index eacd14f7..00000000 --- a/src/Resources/views/Shop/Account/GiftCard/Index/_breadcrumb.html.twig +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/src/Resources/views/Shop/Account/GiftCard/Index/_header.html.twig b/src/Resources/views/Shop/Account/GiftCard/Index/_header.html.twig deleted file mode 100644 index baadd430..00000000 --- a/src/Resources/views/Shop/Account/GiftCard/Index/_header.html.twig +++ /dev/null @@ -1,5 +0,0 @@ -

- {{ 'setono_sylius_gift_card.ui.gift_cards'|trans }} - - {{ sylius_template_event('setono_sylius_gift_card.shop.account.gift_card.index.header', {'giftCards': resources}) }} -

diff --git a/src/Resources/views/Shop/Account/GiftCard/index.html.twig b/src/Resources/views/Shop/Account/GiftCard/index.html.twig deleted file mode 100644 index 04f74852..00000000 --- a/src/Resources/views/Shop/Account/GiftCard/index.html.twig +++ /dev/null @@ -1,15 +0,0 @@ -{% extends '@SyliusShop/Account/layout.html.twig' %} - -{% block breadcrumb %} - {% include '@SetonoSyliusGiftCardPlugin/Shop/Account/GiftCard/Index/_breadcrumb.html.twig' %} -{% endblock %} - -{% block subcontent %} - {% include '@SetonoSyliusGiftCardPlugin/Shop/Account/GiftCard/Index/_header.html.twig' %} - - {{ sylius_template_event('setono_sylius_gift_card.shop.account.gift_card.index.after_content_header', {'giftCards': resources}) }} - - {{ sylius_grid_render(resources, '@SyliusShop/Grid/_default.html.twig') }} - - {{ sylius_template_event('setono_sylius_gift_card.shop.account.gift_card.index.after_grid', {'giftCards': resources}) }} -{% endblock %} diff --git a/src/Resources/views/Shop/GiftCard/search.html.twig b/src/Resources/views/Shop/GiftCard/search.html.twig deleted file mode 100644 index 556ae5df..00000000 --- a/src/Resources/views/Shop/GiftCard/search.html.twig +++ /dev/null @@ -1,45 +0,0 @@ -{# @var \Setono\SyliusGiftCardPlugin\Model\GiftCardInterface giftCard #} -{% extends '@SyliusShop/layout.html.twig' %} - -{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} - -{% form_theme form '@SyliusShop/Form/theme.html.twig' %} - -{% block content %} - -
-

- {{ 'setono_sylius_gift_card.ui.gift_card_search'|trans }} -

- - {{ form_start(form, {'attr': {'class': 'ui form', 'novalidate': 'novalidate'}}) }} - {{ form_errors(form) }} - {{ form_row(form.giftCard) }} - - {{ form_row(form._token) }} - {{ form_end(form, {'render_rest': false}) }} - - {% if giftCard is not null %} - - - - - - - - - - - - - - - -
{{ 'setono_sylius_gift_card.ui.gift_card'|trans }}{{ 'setono_sylius_gift_card.ui.amount'|trans }}{{ 'setono_sylius_gift_card.ui.initial_amount'|trans }}
{{ giftCard.code }}{{ money.format(giftCard.amount, giftCard.currencyCode) }}{{ money.format(giftCard.initialAmount, giftCard.currencyCode) }}
- {% endif %} -
-{% endblock %} diff --git a/src/Resources/views/Shop/addGiftCardToOrder.html.twig b/src/Resources/views/Shop/addGiftCardToOrder.html.twig deleted file mode 100644 index 8fd92a25..00000000 --- a/src/Resources/views/Shop/addGiftCardToOrder.html.twig +++ /dev/null @@ -1,29 +0,0 @@ -{% form_theme form '@SyliusShop/Form/theme.html.twig' %} - -
- - - {{ form_start(form, { - 'action': path('setono_sylius_gift_card_shop_partial_add_gift_card_to_order'), - 'attr': { - 'id': 'setono-sylius-gift-card-add-gift-card-to-order', - 'class': 'ui loadable form', - 'novalidate': 'novalidate', - 'data-action': path('setono_sylius_gift_card_shop_ajax_add_gift_card_to_order'), - 'data-redirect': path('sylius_shop_cart_summary') - } - }) }} - {{ form_row(form._token) }} - {{ form_end(form, {'render_rest': false}) }} - -
-
- {{ form_widget(form.giftCard, {'attr': {'form': 'setono-sylius-gift-card-add-gift-card-to-order'}}) }} - -
-
- {{ form_errors(form.giftCard) }} -
-
diff --git a/src/Resources/views/templates/bundles/SyliusAdminBundle/Form/imagesTheme.html.twig b/src/Resources/views/templates/bundles/SyliusAdminBundle/Form/imagesTheme.html.twig deleted file mode 100644 index 39599d88..00000000 --- a/src/Resources/views/templates/bundles/SyliusAdminBundle/Form/imagesTheme.html.twig +++ /dev/null @@ -1,17 +0,0 @@ -{% extends '@!SyliusAdmin/Form/imagesTheme.html.twig' %} - -{% block setono_sylius_gift_card_gift_card_configuration_image_widget %} - {%- if form.type is defined -%} - {{- form_row(form.type) -}} - {%- endif -%} - - {%- if form.vars.value.path|default(null) is not null -%} - {{ form.vars.value.type }} - {%- endif -%} - -
- {{- form_errors(form.file) -}} -
-{% endblock %} diff --git a/src/Resources/views/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_totals.html.twig b/src/Resources/views/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_totals.html.twig deleted file mode 100644 index c61d5b72..00000000 --- a/src/Resources/views/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_totals.html.twig +++ /dev/null @@ -1,35 +0,0 @@ -{% import "@SyliusAdmin/Common/Macro/money.html.twig" as money %} - -{% set giftCardAdjustment = constant('Setono\\SyliusGiftCardPlugin\\Model\\AdjustmentInterface::ORDER_GIFT_CARD_ADJUSTMENT') %} -{% set giftCardAdjustments = order.getAdjustments(giftCardAdjustment) %} -{% set giftCardAdjustmentsTotal = order.getAdjustmentsTotal(giftCardAdjustment) %} - - - - {% if giftCardAdjustments is not empty %} -
-
- {{ 'setono_sylius_gift_card.ui.gift_cards'|trans }}: -
- {% for adjustment in giftCardAdjustments %} -
-
{{ money.format(adjustment.amount, order.currencyCode) }}
- -
- {% endfor %} -
- {% else %} -

{{ 'setono_sylius_gift_card.ui.no_gift_card'|trans }}.

- {% endif %} - - - {{ 'setono_sylius_gift_card.ui.gift_cards_adjustment_total'|trans }}: - {{ money.format(giftCardAdjustmentsTotal, order.currencyCode) }} - - diff --git a/src/Resources/views/templates/bundles/SyliusShopBundle/Cart/Summary/_totals.html.twig b/src/Resources/views/templates/bundles/SyliusShopBundle/Cart/Summary/_totals.html.twig deleted file mode 100644 index a6b7170c..00000000 --- a/src/Resources/views/templates/bundles/SyliusShopBundle/Cart/Summary/_totals.html.twig +++ /dev/null @@ -1,11 +0,0 @@ -{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} - -{% set giftCardAdjustment = constant('Setono\\SyliusGiftCardPlugin\\Model\\AdjustmentInterface::ORDER_GIFT_CARD_ADJUSTMENT') %} -{% set giftCardAdjustmentsTotal = cart.getAdjustmentsTotal(giftCardAdjustment) %} - -{% if giftCardAdjustmentsTotal != 0 %} - - {{ 'setono_sylius_gift_card.ui.gift_cards_adjustment_total'|trans }}: - {{ money.convertAndFormat(giftCardAdjustmentsTotal) }} - -{% endif %} diff --git a/src/Resources/views/templates/bundles/SyliusShopBundle/Cart/summary.html.twig b/src/Resources/views/templates/bundles/SyliusShopBundle/Cart/summary.html.twig deleted file mode 100644 index 9acd8d33..00000000 --- a/src/Resources/views/templates/bundles/SyliusShopBundle/Cart/summary.html.twig +++ /dev/null @@ -1,35 +0,0 @@ -{# @var \Setono\SyliusGiftCardPlugin\Model\OrderInterface cart #} -{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} - -{% set giftCardAdjustment = constant('Setono\\SyliusGiftCardPlugin\\Model\\AdjustmentInterface::ORDER_GIFT_CARD_ADJUSTMENT') %} -{% set giftCardAdjustments = cart.getAdjustments(giftCardAdjustment) %} - -{% if giftCardAdjustments.count > 0 %} -
- - {{ 'setono_sylius_gift_card.ui.applied_gift_cards'|trans }} - - - {{ sylius_template_event('setono_sylius_gift_card.shop.cart.summary.applied_gift_cards', {'cart': cart}) }} - - - - {% for adjustment in giftCardAdjustments %} - {# @var \Setono\SyliusGiftCardPlugin\Model\AdjustmentInterface adjustment #} - - - - - {% endfor %} - -
- {{ adjustment.originCode }} - - - - - - {{ money.convertAndFormat(-adjustment.amount) }} -
-
-{% endif %} diff --git a/src/Resources/views/templates/bundles/SyliusShopBundle/Checkout/_summary.html.twig b/src/Resources/views/templates/bundles/SyliusShopBundle/Checkout/_summary.html.twig deleted file mode 100644 index f16b5cad..00000000 --- a/src/Resources/views/templates/bundles/SyliusShopBundle/Checkout/_summary.html.twig +++ /dev/null @@ -1,15 +0,0 @@ -{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} - -{% set giftCardAdjustment = constant('Setono\\SyliusGiftCardPlugin\\Model\\AdjustmentInterface::ORDER_GIFT_CARD_ADJUSTMENT') %} -{% set giftCardAdjustmentsTotal = order.getAdjustmentsTotal(giftCardAdjustment) %} - -{% if giftCardAdjustmentsTotal != 0 %} - - - {{ 'setono_sylius_gift_card.ui.gift_cards_adjustment_total'|trans }}: - - - {{ money.convertAndFormat(giftCardAdjustmentsTotal) }} - - -{% endif %} diff --git a/src/Resources/views/templates/bundles/SyliusShopBundle/Common/Order/Table/_totals.html.twig b/src/Resources/views/templates/bundles/SyliusShopBundle/Common/Order/Table/_totals.html.twig deleted file mode 100644 index 46b1518e..00000000 --- a/src/Resources/views/templates/bundles/SyliusShopBundle/Common/Order/Table/_totals.html.twig +++ /dev/null @@ -1,34 +0,0 @@ -{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} - -{% set giftCardAdjustment = constant('Setono\\SyliusGiftCardPlugin\\Model\\AdjustmentInterface::ORDER_GIFT_CARD_ADJUSTMENT') %} -{% set giftCardTotal = order.getAdjustmentsTotal(giftCardAdjustment) %} - -{% if giftCardTotal %} - {% set giftCardAdjustments = order.getAdjustments(giftCardAdjustment) %} - - {% if giftCardAdjustments is not empty %} - -
- {% for adjustment in giftCardAdjustments %} -
-
- - {{ adjustment.label }} - - {{ adjustment.originCode }} - - -
- {{ money.convertAndFormat(adjustment.amount) }} -
-
-
- {% endfor %} -
- - {% endif %} - - {{ 'setono_sylius_gift_card.ui.gift_cards_adjustment_total'|trans }}: {{ money.convertAndFormat(giftCardTotal) }} - - -{% endif %} diff --git a/src/Security/GiftCardVoter.php b/src/Security/GiftCardVoter.php index 2ae72cb4..a453696a 100644 --- a/src/Security/GiftCardVoter.php +++ b/src/Security/GiftCardVoter.php @@ -17,7 +17,8 @@ final class GiftCardVoter extends Voter { public const READ = 'read'; - protected function supports($attribute, $subject): bool + #[\Override] + protected function supports(mixed $attribute, mixed $subject): bool { if (self::READ !== $attribute) { return false; @@ -30,12 +31,11 @@ protected function supports($attribute, $subject): bool return true; } - /** - * @param string $attribute - * @param GiftCardInterface $subject - */ - protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool + #[\Override] + protected function voteOnAttribute(mixed $attribute, mixed $subject, TokenInterface $token): bool { + Assert::isInstanceOf($subject, GiftCardInterface::class); + /** @var UserInterface|ShopUserInterface|AdminUserInterface|null $user */ $user = $token->getUser(); if (!$user instanceof UserInterface) { diff --git a/src/Serializer/Normalizer/GiftCardConfigurationNormalizer.php b/src/Serializer/Normalizer/GiftCardConfigurationNormalizer.php index 042630ba..5367d562 100644 --- a/src/Serializer/Normalizer/GiftCardConfigurationNormalizer.php +++ b/src/Serializer/Normalizer/GiftCardConfigurationNormalizer.php @@ -8,11 +8,11 @@ use Setono\SyliusGiftCardPlugin\Exception\UnexpectedTypeException; use Setono\SyliusGiftCardPlugin\Model\GiftCardConfigurationInterface; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Webmozart\Assert\Assert; -final class GiftCardConfigurationNormalizer implements ContextAwareNormalizerInterface +final class GiftCardConfigurationNormalizer implements NormalizerInterface { private ObjectNormalizer $objectNormalizer; @@ -31,12 +31,14 @@ public function __construct( } /** - * @param GiftCardConfigurationInterface|mixed $object - * @param string $format + * @param GiftCardConfigurationInterface|mixed $data + * @param array $context */ - public function normalize($object, $format = null, array $context = []): array + #[\Override] + public function normalize($data, ?string $format = null, array $context = []): array { - Assert::isInstanceOf($object, GiftCardConfigurationInterface::class); + Assert::isInstanceOf($data, GiftCardConfigurationInterface::class); + $object = $data; $data = $this->objectNormalizer->normalize($object, $format, $context); if (!is_array($data) && !$data instanceof ArrayObject) { @@ -67,11 +69,8 @@ public function normalize($object, $format = null, array $context = []): array return $data; } - /** - * @param mixed $data - * @param string $format - */ - public function supportsNormalization($data, $format = null, array $context = []): bool + #[\Override] + public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool { $groups = (array) ($context['groups'] ?? []); @@ -81,4 +80,12 @@ public function supportsNormalization($data, $format = null, array $context = [] true, ); } + + #[\Override] + public function getSupportedTypes(?string $format): array + { + return [ + GiftCardConfigurationInterface::class => false, + ]; + } } diff --git a/src/Serializer/Normalizer/GiftCardNormalizer.php b/src/Serializer/Normalizer/GiftCardNormalizer.php index 403eb7d6..5231dede 100644 --- a/src/Serializer/Normalizer/GiftCardNormalizer.php +++ b/src/Serializer/Normalizer/GiftCardNormalizer.php @@ -8,11 +8,11 @@ use Setono\SyliusGiftCardPlugin\Exception\UnexpectedTypeException; use Setono\SyliusGiftCardPlugin\Model\GiftCardInterface; use Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatterInterface; -use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Webmozart\Assert\Assert; -final class GiftCardNormalizer implements ContextAwareNormalizerInterface +final class GiftCardNormalizer implements NormalizerInterface { private ObjectNormalizer $objectNormalizer; @@ -25,12 +25,14 @@ public function __construct(ObjectNormalizer $objectNormalizer, MoneyFormatterIn } /** - * @param GiftCardInterface|mixed $object - * @param string $format + * @param GiftCardInterface|mixed $data + * @param array $context */ - public function normalize($object, $format = null, array $context = []): array + #[\Override] + public function normalize($data, ?string $format = null, array $context = []): array { - Assert::isInstanceOf($object, GiftCardInterface::class); + Assert::isInstanceOf($data, GiftCardInterface::class); + $object = $data; $data = $this->objectNormalizer->normalize($object, $format, $context); if (!is_array($data) && !$data instanceof ArrayObject) { @@ -47,14 +49,19 @@ public function normalize($object, $format = null, array $context = []): array return $data; } - /** - * @param mixed $data - * @param string $format - */ - public function supportsNormalization($data, $format = null, array $context = []): bool + #[\Override] + public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool { $groups = (array) ($context['groups'] ?? []); return $data instanceof GiftCardInterface && in_array('setono:sylius-gift-card:render', $groups, true); } + + #[\Override] + public function getSupportedTypes(?string $format): array + { + return [ + GiftCardInterface::class => false, + ]; + } } diff --git a/src/SetonoSyliusGiftCardPlugin.php b/src/SetonoSyliusGiftCardPlugin.php index 6535c739..8d2a1df8 100644 --- a/src/SetonoSyliusGiftCardPlugin.php +++ b/src/SetonoSyliusGiftCardPlugin.php @@ -15,6 +15,7 @@ final class SetonoSyliusGiftCardPlugin extends AbstractResourceBundle { use SyliusPluginTrait; + #[\Override] public function build(ContainerBuilder $container): void { parent::build($container); @@ -23,10 +24,23 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass(new CreateServiceAliasesPass()); } + #[\Override] public function getSupportedDrivers(): array { return [ SyliusResourceBundle::DRIVER_DOCTRINE_ORM, ]; } + + #[\Override] + public function getPath(): string + { + return \dirname(__DIR__); + } + + #[\Override] + protected function getConfigFilesPath(): string + { + return sprintf('%s/config/doctrine/%s', $this->getPath(), strtolower($this->getDoctrineMappingDirectory())); + } } diff --git a/src/Twig/Extension/AddGiftCardToOrderExtension.php b/src/Twig/Extension/AddGiftCardToOrderExtension.php new file mode 100644 index 00000000..09c257b2 --- /dev/null +++ b/src/Twig/Extension/AddGiftCardToOrderExtension.php @@ -0,0 +1,19 @@ +formFactory->create(AddGiftCardToOrderType::class, new AddGiftCardToOrderCommand())->createView(); + } +} diff --git a/src/Twig/Extension/PdfExtension.php b/src/Twig/Extension/PdfExtension.php index 3b1728e0..6da63185 100644 --- a/src/Twig/Extension/PdfExtension.php +++ b/src/Twig/Extension/PdfExtension.php @@ -9,6 +9,7 @@ final class PdfExtension extends AbstractExtension { + #[\Override] public function getFunctions(): array { return [ diff --git a/src/Validator/Constraints/DatePeriodValidator.php b/src/Validator/Constraints/DatePeriodValidator.php index f8fa38df..35e8d211 100644 --- a/src/Validator/Constraints/DatePeriodValidator.php +++ b/src/Validator/Constraints/DatePeriodValidator.php @@ -22,6 +22,7 @@ public function __construct(DatePeriodUnitProviderInterface $datePeriodUnitProvi /** * @param mixed $value */ + #[\Override] public function validate($value, Constraint $constraint): void { if (!$constraint instanceof DatePeriod) { diff --git a/src/Validator/Constraints/DefaultGiftCardConfigurationMustExist.php b/src/Validator/Constraints/DefaultGiftCardConfigurationMustExist.php index 1b387664..e7b21f2b 100644 --- a/src/Validator/Constraints/DefaultGiftCardConfigurationMustExist.php +++ b/src/Validator/Constraints/DefaultGiftCardConfigurationMustExist.php @@ -10,6 +10,7 @@ final class DefaultGiftCardConfigurationMustExist extends Constraint { public string $message = 'setono_sylius_gift_card.gift_card_configuration.default_configuration_must_exist'; + #[\Override] public function getTargets(): array { return [self::CLASS_CONSTRAINT]; diff --git a/src/Validator/Constraints/DefaultGiftCardConfigurationMustExistValidator.php b/src/Validator/Constraints/DefaultGiftCardConfigurationMustExistValidator.php index d2344661..0efa5e19 100644 --- a/src/Validator/Constraints/DefaultGiftCardConfigurationMustExistValidator.php +++ b/src/Validator/Constraints/DefaultGiftCardConfigurationMustExistValidator.php @@ -22,6 +22,7 @@ public function __construct(GiftCardConfigurationRepositoryInterface $giftCardCo /** * @param mixed $value */ + #[\Override] public function validate($value, Constraint $constraint): void { if (!$constraint instanceof DefaultGiftCardConfigurationMustExist) { diff --git a/src/Validator/Constraints/GiftCardIsNotExpiredValidator.php b/src/Validator/Constraints/GiftCardIsNotExpiredValidator.php index 5ee77279..2be4dc37 100644 --- a/src/Validator/Constraints/GiftCardIsNotExpiredValidator.php +++ b/src/Validator/Constraints/GiftCardIsNotExpiredValidator.php @@ -15,6 +15,7 @@ final class GiftCardIsNotExpiredValidator extends ConstraintValidator /** * @param mixed $value */ + #[\Override] public function validate($value, Constraint $constraint): void { if (!$constraint instanceof GiftCardIsNotExpired) { diff --git a/src/Validator/Constraints/HasBackgroundImage.php b/src/Validator/Constraints/HasBackgroundImage.php index 06289d17..6f30e4ea 100644 --- a/src/Validator/Constraints/HasBackgroundImage.php +++ b/src/Validator/Constraints/HasBackgroundImage.php @@ -10,6 +10,7 @@ final class HasBackgroundImage extends Constraint { public string $message = 'setono_sylius_gift_card.gift_card_configuration.background_image_required'; + #[\Override] public function getTargets(): array { return [self::CLASS_CONSTRAINT]; diff --git a/src/Validator/Constraints/HasBackgroundImageValidator.php b/src/Validator/Constraints/HasBackgroundImageValidator.php index 1efd72a7..b1dedd98 100644 --- a/src/Validator/Constraints/HasBackgroundImageValidator.php +++ b/src/Validator/Constraints/HasBackgroundImageValidator.php @@ -14,6 +14,7 @@ final class HasBackgroundImageValidator extends ConstraintValidator /** * @param mixed $value */ + #[\Override] public function validate($value, Constraint $constraint): void { if (!$constraint instanceof HasBackgroundImage) { diff --git a/src/Validator/Constraints/Pdf/ValidOrientationValidator.php b/src/Validator/Constraints/Pdf/ValidOrientationValidator.php index 4c1d3a73..6b05e158 100644 --- a/src/Validator/Constraints/Pdf/ValidOrientationValidator.php +++ b/src/Validator/Constraints/Pdf/ValidOrientationValidator.php @@ -20,6 +20,7 @@ public function __construct(array $availableOrientations) /** * @param mixed $value */ + #[\Override] public function validate($value, Constraint $constraint): void { if (!$constraint instanceof ValidOrientation) { diff --git a/src/Validator/Constraints/Pdf/ValidPageSizeValidator.php b/src/Validator/Constraints/Pdf/ValidPageSizeValidator.php index 9258961b..c1628b5a 100644 --- a/src/Validator/Constraints/Pdf/ValidPageSizeValidator.php +++ b/src/Validator/Constraints/Pdf/ValidPageSizeValidator.php @@ -20,6 +20,7 @@ public function __construct(array $availableOrientations) /** * @param mixed $value */ + #[\Override] public function validate($value, Constraint $constraint): void { if (!$constraint instanceof ValidPageSize) { diff --git a/templates/Admin/GiftCard/Grid/Action/create.html.twig b/templates/Admin/GiftCard/Grid/Action/create.html.twig new file mode 100644 index 00000000..8f2832a0 --- /dev/null +++ b/templates/Admin/GiftCard/Grid/Action/create.html.twig @@ -0,0 +1,9 @@ + diff --git a/templates/Admin/GiftCard/Grid/Action/delete_conditional.html.twig b/templates/Admin/GiftCard/Grid/Action/delete_conditional.html.twig new file mode 100644 index 00000000..9d72f762 --- /dev/null +++ b/templates/Admin/GiftCard/Grid/Action/delete_conditional.html.twig @@ -0,0 +1,4 @@ +{% set visible = options.visible is defined ? options.visible : true %} +{% if visible %} + {% include '@SyliusAdmin/shared/grid/action/delete.html.twig' %} +{% endif %} diff --git a/templates/Admin/GiftCard/Grid/Action/gift_card_balance.html.twig b/templates/Admin/GiftCard/Grid/Action/gift_card_balance.html.twig new file mode 100644 index 00000000..b0f63cde --- /dev/null +++ b/templates/Admin/GiftCard/Grid/Action/gift_card_balance.html.twig @@ -0,0 +1,6 @@ +{% set path = path('setono_sylius_gift_card_admin_gift_card_balance') %} + + + {{ ux_icon('tabler:wallet') }} + {{ 'setono_sylius_gift_card.ui.balance'|trans }} + diff --git a/templates/Admin/GiftCard/Grid/Action/list_conditional.html.twig b/templates/Admin/GiftCard/Grid/Action/list_conditional.html.twig new file mode 100644 index 00000000..d796bb48 --- /dev/null +++ b/templates/Admin/GiftCard/Grid/Action/list_conditional.html.twig @@ -0,0 +1,10 @@ +{% set visible = options.visible is defined ? options.visible : true %} + +{% if visible %} + {% set path = options.link.url|default(path(options.link.route, options.link.parameters)) %} + {% set message = action.label %} + + + {{ ux_icon(action.icon|default('tabler:list')) }} + +{% endif %} diff --git a/templates/Admin/GiftCard/Grid/Action/resend_email.html.twig b/templates/Admin/GiftCard/Grid/Action/resend_email.html.twig new file mode 100644 index 00000000..737a75db --- /dev/null +++ b/templates/Admin/GiftCard/Grid/Action/resend_email.html.twig @@ -0,0 +1,10 @@ +{% set visible = options.visible is defined ? options.visible : true %} + +{% if visible %} + {% set path = options.link.url|default(path(options.link.route, options.link.parameters)) %} + {% set message = action.label %} + + + {{ ux_icon(action.icon|default('tabler:mail')) }} + +{% endif %} diff --git a/templates/Admin/GiftCard/Grid/Field/amount.html.twig b/templates/Admin/GiftCard/Grid/Field/amount.html.twig new file mode 100644 index 00000000..510c7989 --- /dev/null +++ b/templates/Admin/GiftCard/Grid/Field/amount.html.twig @@ -0,0 +1,3 @@ +{% import "@SyliusAdmin/shared/helper/money.html.twig" as money %} + +{{ money.format(data.amount, data.currencyCode) }} diff --git a/src/Resources/views/Admin/GiftCard/Grid/Field/channel_configurations.html.twig b/templates/Admin/GiftCard/Grid/Field/channel_configurations.html.twig similarity index 71% rename from src/Resources/views/Admin/GiftCard/Grid/Field/channel_configurations.html.twig rename to templates/Admin/GiftCard/Grid/Field/channel_configurations.html.twig index 16399b81..589b214a 100644 --- a/src/Resources/views/Admin/GiftCard/Grid/Field/channel_configurations.html.twig +++ b/templates/Admin/GiftCard/Grid/Field/channel_configurations.html.twig @@ -1,10 +1,10 @@ -{% import '@SyliusUi/Macro/labels.html.twig' as label %} +{% import '@SyliusUi/macro/labels.html.twig' as label %} {# @var \Setono\SyliusGiftCardPlugin\Model\GiftCardChannelConfigurationInterface[] data #} {% for channelConfiguration in data %}
{# @var \Setono\SyliusGiftCardPlugin\Model\GiftCardChannelConfigurationInterface channelConfiguration #} - {% include '@SyliusAdmin/Common/_channel.html.twig' with {'channel': channelConfiguration.channel} %} + {% include '@SyliusAdmin/shared/grid/field/channel.html.twig' with {'data': channelConfiguration.channel} %} {% if channelConfiguration.locale is not null %} {{ label.default(channelConfiguration.locale.code) }} diff --git a/src/Resources/views/Admin/GiftCard/Grid/Field/customer.html.twig b/templates/Admin/GiftCard/Grid/Field/customer.html.twig similarity index 79% rename from src/Resources/views/Admin/GiftCard/Grid/Field/customer.html.twig rename to templates/Admin/GiftCard/Grid/Field/customer.html.twig index eb20b16e..7e8d8c5a 100644 --- a/src/Resources/views/Admin/GiftCard/Grid/Field/customer.html.twig +++ b/templates/Admin/GiftCard/Grid/Field/customer.html.twig @@ -2,5 +2,5 @@ {% if data is null %} {{ 'setono_sylius_gift_card.ui.no_customer'|trans }} {% else %} - {{ data.emailCanonical }} + {{ data.emailCanonical }} {{ ux_icon('tabler:external-link') }} {% endif %} diff --git a/src/Resources/views/Admin/GiftCard/Grid/Field/item_units_order.html.twig b/templates/Admin/GiftCard/Grid/Field/item_units_order.html.twig similarity index 100% rename from src/Resources/views/Admin/GiftCard/Grid/Field/item_units_order.html.twig rename to templates/Admin/GiftCard/Grid/Field/item_units_order.html.twig diff --git a/templates/Admin/GiftCard/_form.html.twig b/templates/Admin/GiftCard/_form.html.twig new file mode 100644 index 00000000..9323a925 --- /dev/null +++ b/templates/Admin/GiftCard/_form.html.twig @@ -0,0 +1,30 @@ +{% if form is not defined %} + {% set form = hookable_metadata.context.form %} +{% endif %} + +{{ form_errors(form) }} +
+
+
+
+ {{ form_row(form.code) }} + {{ form_row(form.enabled) }} + {{ form_row(form.expiresAt) }} + {{ form_row(form.customer) }} + {% if form.sendNotificationEmail is defined %} + {{ form_row(form.sendNotificationEmail) }} + {% endif %} +
+
+
+ +
+
+
+ {{ form_row(form.currencyCode) }} + {{ form_row(form.amount) }} + {{ form_row(form.customMessage) }} +
+
+
+
diff --git a/src/Resources/views/Admin/GiftCard/create.html.twig b/templates/Admin/GiftCard/create.html.twig similarity index 91% rename from src/Resources/views/Admin/GiftCard/create.html.twig rename to templates/Admin/GiftCard/create.html.twig index acb862a3..cfa36164 100644 --- a/src/Resources/views/Admin/GiftCard/create.html.twig +++ b/templates/Admin/GiftCard/create.html.twig @@ -1,5 +1,5 @@ {% for channel in channels %} - + {{ 'setono_sylius_gift_card.ui.create_for_channel'|trans({ '%channel%': channel.name }) }} {% endfor %} diff --git a/templates/Admin/GiftCardConfiguration/_form.html.twig b/templates/Admin/GiftCardConfiguration/_form.html.twig new file mode 100644 index 00000000..afdcb492 --- /dev/null +++ b/templates/Admin/GiftCardConfiguration/_form.html.twig @@ -0,0 +1,78 @@ +{% if form is not defined %} + {% set form = hookable_metadata.context.form %} +{% endif %} +{% if resource is not defined %} + {% set resource = hookable_metadata.context.resource %} +{% endif %} + +{% form_theme form '@SetonoSyliusGiftCardPlugin/Admin/GiftCardConfiguration/_imageFormTheme.html.twig' %} + +{{ form_errors(form) }} +
+
+
+
+ {{ form_row(form.code) }} +
+ {{ form_label(form.defaultValidityPeriod) }} +
+ {{ form_widget(form.defaultValidityPeriod.value) }} + {{ form_widget(form.defaultValidityPeriod.unit) }} +
+ {{ form_errors(form.defaultValidityPeriod) }} +
+ {{ form_row(form.backgroundImage) }} + {{ form_row(form.pageSize) }} + {{ form_row(form.orientation) }} +
+
+
+
+
+
+ {{ form_row(form.enabled) }} + {{ form_row(form.default) }} + {{ form_row(form.channelConfigurations) }} +
+
+
+
+ +

{{ 'setono_sylius_gift_card.ui.gift_card_configuration.pdf_live_rendering.title'|trans }}

+
+
+
+ {{ form_row(form.template, {'attr': {'rows': 40}}) }} + {% if resource.id is not null %} + + {% endif %} +
+
+ +
+
+
+ + diff --git a/templates/Admin/GiftCardConfiguration/_imageFormTheme.html.twig b/templates/Admin/GiftCardConfiguration/_imageFormTheme.html.twig new file mode 100644 index 00000000..35b639fc --- /dev/null +++ b/templates/Admin/GiftCardConfiguration/_imageFormTheme.html.twig @@ -0,0 +1,12 @@ +{% block setono_sylius_gift_card_gift_card_configuration_image_widget %} + {% if form.type is defined %} + {{ form_row(form.type) }} + {% endif %} + + {% if form.vars.value.path|default(null) is not null %} + + {% endif %} + + {{ form_widget(form.file) }} + {{ form_errors(form.file) }} +{% endblock %} diff --git a/src/Resources/views/Admin/Order/Grid/Field/coveredByGiftCards.html.twig b/templates/Admin/Order/Grid/Field/coveredByGiftCards.html.twig similarity index 83% rename from src/Resources/views/Admin/Order/Grid/Field/coveredByGiftCards.html.twig rename to templates/Admin/Order/Grid/Field/coveredByGiftCards.html.twig index ad42b830..a1eb2167 100644 --- a/src/Resources/views/Admin/Order/Grid/Field/coveredByGiftCards.html.twig +++ b/templates/Admin/Order/Grid/Field/coveredByGiftCards.html.twig @@ -1,5 +1,5 @@ {# @var \Setono\SyliusGiftCardPlugin\Model\OrderInterface data #} -{% import "@SyliusAdmin/Common/Macro/money.html.twig" as money %} +{% import "@SyliusAdmin/shared/helper/money.html.twig" as money %} {% set giftCardAdjustment = constant('Setono\\SyliusGiftCardPlugin\\Model\\AdjustmentInterface::ORDER_GIFT_CARD_ADJUSTMENT') %} {% set giftCardAdjustmentsTotal = data.getAdjustmentsTotal(giftCardAdjustment) %} diff --git a/templates/Admin/Order/Show/Summary/_giftCardTotal.html.twig b/templates/Admin/Order/Show/Summary/_giftCardTotal.html.twig new file mode 100644 index 00000000..b46488ac --- /dev/null +++ b/templates/Admin/Order/Show/Summary/_giftCardTotal.html.twig @@ -0,0 +1,29 @@ +{% import '@SyliusAdmin/shared/helper/money.html.twig' as money %} + +{% set order = hookable_metadata.context.resource %} +{% set gift_card_adjustment = constant('Setono\\SyliusGiftCardPlugin\\Model\\AdjustmentInterface::ORDER_GIFT_CARD_ADJUSTMENT') %} +{% set gift_card_adjustments = order.getAdjustments(gift_card_adjustment) %} + +{% if gift_card_adjustments.count > 0 %} + + + {{ 'setono_sylius_gift_card.ui.gift_cards'|trans }}: + + + {{ money.format(-order.getAdjustmentsTotal(gift_card_adjustment), order.currencyCode) }} + + + + {% for adjustment in gift_card_adjustments %} + + +
+ • {{ adjustment.originCode }}: +
+ + + {{ money.format(adjustment.amount, order.currencyCode) }} + + + {% endfor %} +{% endif %} diff --git a/templates/Admin/Product/Form/Sections/General/_giftCard.html.twig b/templates/Admin/Product/Form/Sections/General/_giftCard.html.twig new file mode 100644 index 00000000..55fa959e --- /dev/null +++ b/templates/Admin/Product/Form/Sections/General/_giftCard.html.twig @@ -0,0 +1,6 @@ +{% set form = hookable_metadata.context.form %} + +
+ {{ form_row(form.giftCard) }} + {{ form_row(form.giftCardAmountConfigurable) }} +
diff --git a/templates/Admin/giftCardBalance.html.twig b/templates/Admin/giftCardBalance.html.twig new file mode 100644 index 00000000..f4eb37a7 --- /dev/null +++ b/templates/Admin/giftCardBalance.html.twig @@ -0,0 +1,59 @@ +{# @var \Setono\SyliusGiftCardPlugin\Model\GiftCardBalanceCollection giftCardBalanceCollection #} + +{% extends '@SyliusAdmin/shared/layout/base.html.twig' %} + +{% import '@SyliusAdmin/shared/helper/header.html.twig' as header %} +{% from '@SyliusAdmin/shared/helper/breadcrumbs.html.twig' import breadcrumbs %} +{% import '@SyliusAdmin/shared/helper/money.html.twig' as money %} + +{% block title %}{{ 'setono_sylius_gift_card.ui.balance'|trans }} {{ parent() }}{% endblock %} + +{% block body %} + {% include '@SyliusAdmin/shared/crud/common/sidebar.html.twig' %} + {% include '@SyliusAdmin/shared/crud/common/navbar.html.twig' %} + +
+ + +
+
+
+
+ + + + + + + + + + {% for giftCardBalance in giftCardBalanceCollection %} + + + + + + {% endfor %} + +
{{ 'setono_sylius_gift_card.ui.total'|trans }}{{ 'setono_sylius_gift_card.ui.count'|trans }}{{ 'setono_sylius_gift_card.ui.average_amount'|trans }}
{{ money.format(giftCardBalance.total, giftCardBalance.currencyCode) }}{{ giftCardBalance.count }}{{ money.format(giftCardBalance.averageAmount, giftCardBalance.currencyCode) }}
+
+
+
+
+
+{% endblock %} diff --git a/src/Resources/views/Email/giftCardToCustomer.html.twig b/templates/Email/giftCardToCustomer.html.twig similarity index 84% rename from src/Resources/views/Email/giftCardToCustomer.html.twig rename to templates/Email/giftCardToCustomer.html.twig index 5cb027f9..2933f479 100644 --- a/src/Resources/views/Email/giftCardToCustomer.html.twig +++ b/templates/Email/giftCardToCustomer.html.twig @@ -1,12 +1,12 @@ {# @var \Sylius\Component\Core\Model\CustomerInterface customer #} {# @var \Setono\SyliusGiftCardPlugin\Model\GiftCardInterface giftCard #} -{% extends '@SyliusAdmin/Email/layout.html.twig' %} +{% extends '@SyliusShop/email/layout.html.twig' %} {% block subject %}{{ 'setono_sylius_gift_card.email.new_gift_card'|trans }}{% endblock %} {% block content %} {# This needs to be imported here since the rendering of emails only take the block to render it. Not whole template #} - {% import "@SyliusShop/Common/Macro/money.html.twig" as money %} + {% import "@SyliusShop/shared/macro/money.html.twig" as money %}

{{ 'setono_sylius_gift_card.email.new_gift_card_intro'|trans }}

{{ giftCard.code }} ({{ 'setono_sylius_gift_card.email.balance'|trans }}: {{ money.convertAndFormat(giftCard.amount) }})
diff --git a/src/Resources/views/Email/giftCardsFromOrder.html.twig b/templates/Email/giftCardsFromOrder.html.twig similarity index 85% rename from src/Resources/views/Email/giftCardsFromOrder.html.twig rename to templates/Email/giftCardsFromOrder.html.twig index 28c3dd6b..b48f6a75 100644 --- a/src/Resources/views/Email/giftCardsFromOrder.html.twig +++ b/templates/Email/giftCardsFromOrder.html.twig @@ -1,11 +1,11 @@ {# @var \Setono\SyliusGiftCardPlugin\Model\GiftCardInterface[] giftCards #} -{% extends '@SyliusAdmin/Email/layout.html.twig' %} +{% extends '@SyliusShop/email/layout.html.twig' %} {% block subject %}{{ 'setono_sylius_gift_card.email.your_gift_card'|trans }}{% endblock %} {% block content %} {# This needs to be imported here since the rendering of emails only take the block to render it. Not whole template #} - {% import "@SyliusShop/Common/Macro/money.html.twig" as money %} + {% import "@SyliusShop/shared/macro/money.html.twig" as money %}

{{ 'setono_sylius_gift_card.email.your_gift_cards_you_bought_in_the_order'|trans ~ ' ' ~ order.number }}:

diff --git a/templates/Shop/Account/GiftCard/Grid/Field/amount.html.twig b/templates/Shop/Account/GiftCard/Grid/Field/amount.html.twig new file mode 100644 index 00000000..8324745c --- /dev/null +++ b/templates/Shop/Account/GiftCard/Grid/Field/amount.html.twig @@ -0,0 +1,3 @@ +{% import "@SyliusShop/shared/macro/money.html.twig" as money %} + +{{ money.format(data.amount, data.currencyCode) }} diff --git a/templates/Shop/Account/GiftCard/Grid/Field/initial_amount.html.twig b/templates/Shop/Account/GiftCard/Grid/Field/initial_amount.html.twig new file mode 100644 index 00000000..a6f73232 --- /dev/null +++ b/templates/Shop/Account/GiftCard/Grid/Field/initial_amount.html.twig @@ -0,0 +1,3 @@ +{% import "@SyliusShop/shared/macro/money.html.twig" as money %} + +{{ money.format(data.initialAmount, data.currencyCode) }} diff --git a/templates/Shop/Account/GiftCard/Index/_breadcrumbs.html.twig b/templates/Shop/Account/GiftCard/Index/_breadcrumbs.html.twig new file mode 100644 index 00000000..0ac09479 --- /dev/null +++ b/templates/Shop/Account/GiftCard/Index/_breadcrumbs.html.twig @@ -0,0 +1,9 @@ +{% from '@SyliusShop/shared/breadcrumbs.html.twig' import breadcrumbs %} + +
+ {{ breadcrumbs([ + { label: 'sylius.ui.home'|trans, path: path('sylius_shop_homepage') }, + { label: 'sylius.ui.my_account'|trans, path: path('sylius_shop_account_dashboard') }, + { label: 'setono_sylius_gift_card.ui.gift_cards'|trans, active: true }, + ]) }} +
diff --git a/templates/Shop/Account/GiftCard/Index/_title.html.twig b/templates/Shop/Account/GiftCard/Index/_title.html.twig new file mode 100644 index 00000000..0f9c55e8 --- /dev/null +++ b/templates/Shop/Account/GiftCard/Index/_title.html.twig @@ -0,0 +1 @@ +

{{ 'setono_sylius_gift_card.ui.gift_cards'|trans }}

diff --git a/templates/Shop/Account/GiftCard/index.html.twig b/templates/Shop/Account/GiftCard/index.html.twig new file mode 100644 index 00000000..070c0c16 --- /dev/null +++ b/templates/Shop/Account/GiftCard/index.html.twig @@ -0,0 +1,6 @@ +{% extends '@SyliusShop/account/common/index.html.twig' %} + +{% set prefixes = ['setono_sylius_gift_card.shop.account.gift_card'] %} +{% set attrs = { resources } %} + +{% block title %}{{ 'setono_sylius_gift_card.ui.gift_cards'|trans }} | {{ parent() }}{% endblock %} diff --git a/templates/Shop/Cart/Summary/_addGiftCardToOrder.html.twig b/templates/Shop/Cart/Summary/_addGiftCardToOrder.html.twig new file mode 100644 index 00000000..355f3612 --- /dev/null +++ b/templates/Shop/Cart/Summary/_addGiftCardToOrder.html.twig @@ -0,0 +1,5 @@ +
+ {{ include('@SetonoSyliusGiftCardPlugin/Shop/addGiftCardToOrder.html.twig', { + form: ssgc_add_gift_card_to_order_form_view(), + }) }} +
diff --git a/templates/Shop/Cart/Summary/_appliedGiftCards.html.twig b/templates/Shop/Cart/Summary/_appliedGiftCards.html.twig new file mode 100644 index 00000000..63ea9c2c --- /dev/null +++ b/templates/Shop/Cart/Summary/_appliedGiftCards.html.twig @@ -0,0 +1,25 @@ +{% import "@SyliusShop/shared/macro/money.html.twig" as money %} + +{% set cart = hookable_metadata.context.cart %} +{% set giftCardAdjustment = constant('Setono\\SyliusGiftCardPlugin\\Model\\AdjustmentInterface::ORDER_GIFT_CARD_ADJUSTMENT') %} +{% set giftCardAdjustments = cart.getAdjustments(giftCardAdjustment) %} + +{% if giftCardAdjustments.count > 0 %} +
+ {{ 'setono_sylius_gift_card.ui.applied_gift_cards'|trans }} + + {% for adjustment in giftCardAdjustments %} +
+
+ {{ adjustment.originCode }} + + {{ ux_icon('tabler:x') }} + +
+
+ {{ money.convertAndFormat(-adjustment.amount) }} +
+
+ {% endfor %} +
+{% endif %} diff --git a/templates/Shop/GiftCard/search.html.twig b/templates/Shop/GiftCard/search.html.twig new file mode 100644 index 00000000..c26b12c4 --- /dev/null +++ b/templates/Shop/GiftCard/search.html.twig @@ -0,0 +1,52 @@ +{# @var \Setono\SyliusGiftCardPlugin\Model\GiftCardInterface giftCard #} +{% extends '@SyliusShop/shared/layout/base.html.twig' %} + +{% import "@SyliusShop/shared/macro/money.html.twig" as money %} +{% from '@SyliusShop/shared/breadcrumbs.html.twig' import breadcrumbs %} + +{% form_theme form '@SyliusShop/form/theme.html.twig' %} + +{% block title %}{{ 'setono_sylius_gift_card.ui.gift_card_search'|trans }} | {{ parent() }}{% endblock %} + +{% block content %} +
+ {{ breadcrumbs([ + { label: 'sylius.ui.home'|trans, path: path('sylius_shop_homepage') }, + { label: 'setono_sylius_gift_card.ui.gift_card'|trans, active: true }, + ]) }} + +

{{ 'setono_sylius_gift_card.ui.gift_card_search'|trans }}

+ + {{ form_start(form) }} + {{ form_errors(form) }} +
+ {{ form_widget(form.giftCard) }} + +
+ {{ form_errors(form.giftCard) }} + {{ form_row(form._token) }} + {{ form_end(form, {'render_rest': false}) }} + + {% if giftCard is not null %} + + + + + + + + + + + + + + + +
{{ 'setono_sylius_gift_card.ui.gift_card'|trans }}{{ 'setono_sylius_gift_card.ui.amount'|trans }}{{ 'setono_sylius_gift_card.ui.initial_amount'|trans }}
{{ giftCard.code }}{{ money.format(giftCard.amount, giftCard.currencyCode) }}{{ money.format(giftCard.initialAmount, giftCard.currencyCode) }}
+ {% endif %} +
+{% endblock %} diff --git a/templates/Shop/Order/Show/Summary/_giftCardTotal.html.twig b/templates/Shop/Order/Show/Summary/_giftCardTotal.html.twig new file mode 100644 index 00000000..a64f181b --- /dev/null +++ b/templates/Shop/Order/Show/Summary/_giftCardTotal.html.twig @@ -0,0 +1,26 @@ +{% import "@SyliusShop/shared/macro/money.html.twig" as money %} + +{% set order = hookable_metadata.context.order %} +{% set gift_card_adjustment = constant('Setono\\SyliusGiftCardPlugin\\Model\\AdjustmentInterface::ORDER_GIFT_CARD_ADJUSTMENT') %} +{% set gift_card_adjustments = order.getAdjustments(gift_card_adjustment) %} + +{% if gift_card_adjustments.count > 0 %} + + + {{ 'setono_sylius_gift_card.ui.gift_cards'|trans }}: + + + {{ money.format(-order.getAdjustmentsTotal(gift_card_adjustment), order.currencyCode) }} + +
+ {% for adjustment in gift_card_adjustments %} +
+ + {{ adjustment.originCode }}: {{ money.format(adjustment.amount, order.currencyCode) }} + +
+ {% endfor %} +
+ + +{% endif %} diff --git a/src/Resources/views/Shop/Product/Show/_addToCartGiftCardInformation.html.twig b/templates/Shop/Product/Show/_addToCartGiftCardInformation.html.twig similarity index 89% rename from src/Resources/views/Shop/Product/Show/_addToCartGiftCardInformation.html.twig rename to templates/Shop/Product/Show/_addToCartGiftCardInformation.html.twig index cacb1589..65ddeff3 100644 --- a/src/Resources/views/Shop/Product/Show/_addToCartGiftCardInformation.html.twig +++ b/templates/Shop/Product/Show/_addToCartGiftCardInformation.html.twig @@ -1,3 +1,5 @@ +{% set form = hookable_metadata.context.form %} + {% if form.giftCardInformation is defined %} {% set giftCardInformationForm = form.giftCardInformation %} {% if giftCardInformationForm.amount is defined %} diff --git a/templates/Shop/addGiftCardToOrder.html.twig b/templates/Shop/addGiftCardToOrder.html.twig new file mode 100644 index 00000000..81b494c8 --- /dev/null +++ b/templates/Shop/addGiftCardToOrder.html.twig @@ -0,0 +1,20 @@ +{% form_theme form '@SyliusShop/form/theme.html.twig' %} + +
+
+ {{ form_start(form, { + 'action': path('setono_sylius_gift_card_shop_partial_add_gift_card_to_order'), + 'attr': {'id': 'setono-sylius-gift-card-add-gift-card-to-order'}, + }) }} + {{ form_row(form._token) }} + {{ form_end(form, {'render_rest': false}) }} + +
+ {{ form_widget(form.giftCard, {'attr': {'form': 'setono-sylius-gift-card-add-gift-card-to-order', 'class': 'form-control'}}) }} + +
+ {{ form_errors(form.giftCard) }} +
+
diff --git a/tests/Application/.env b/tests/Application/.env deleted file mode 100644 index b877f52b..00000000 --- a/tests/Application/.env +++ /dev/null @@ -1,47 +0,0 @@ -# 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 ### -APP_ENV=dev -APP_DEBUG=1 -APP_SECRET=EDITME -###< symfony/framework-bundle ### - -###> doctrine/doctrine-bundle ### -# 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_gift_card_%kernel.environment%?serverVersion=5.7 -###< doctrine/doctrine-bundle ### - -###> lexik/jwt-authentication-bundle ### -JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem -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_DSN=null://localhost -###< symfony/swiftmailer-bundle ### diff --git a/tests/Application/.env.test b/tests/Application/.env.test deleted file mode 100644 index 85259611..00000000 --- a/tests/Application/.env.test +++ /dev/null @@ -1,3 +0,0 @@ -APP_SECRET='ch4mb3r0f5ecr3ts' - -KERNEL_CLASS='Setono\SyliusGiftCardPlugin\Tests\Application\Kernel' diff --git a/tests/Application/.eslintrc.js b/tests/Application/.eslintrc.js deleted file mode 100644 index dfddb254..00000000 --- a/tests/Application/.eslintrc.js +++ /dev/null @@ -1,20 +0,0 @@ -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, - }], - }, -}; diff --git a/tests/Application/.gitignore b/tests/Application/.gitignore deleted file mode 100644 index bc600a8c..00000000 --- a/tests/Application/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -/public/assets -/public/build -/public/css -/public/js -/public/media/* -!/public/media/image/ -/public/media/image/* -!/public/media/image/.gitignore - -/node_modules - -###> symfony/framework-bundle ### -/.env.*.local -/.env.local -/.env.local.php -/public/bundles -/var/ -/vendor/ -###< symfony/framework-bundle ### - -###> symfony/web-server-bundle ### -/.web-server-pid -###< symfony/web-server-bundle ### diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php deleted file mode 100644 index 2ba30b4f..00000000 --- a/tests/Application/Kernel.php +++ /dev/null @@ -1,88 +0,0 @@ -getProjectDir() . '/var/cache/' . $this->environment; - } - - public function getLogDir(): string - { - return $this->getProjectDir() . '/var/log'; - } - - public function registerBundles(): iterable - { - foreach ($this->getConfigurationDirectories() as $confDir) { - $bundlesFile = $confDir . '/bundles.php'; - if (false === is_file($bundlesFile)) { - continue; - } - yield from $this->registerBundlesFromFile($bundlesFile); - } - } - - protected function configureRoutes(RoutingConfigurator $routes): void - { - foreach ($this->getConfigurationDirectories() as $confDir) { - $this->loadRoutesConfiguration($routes, $confDir); - } - } - - protected function getContainerBaseClass(): string - { - if ($this->isTestEnvironment()) { - 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[] - */ - private function registerBundlesFromFile(string $bundlesFile): iterable - { - $contents = require $bundlesFile; - foreach ($contents as $class => $envs) { - if (isset($envs['all']) || isset($envs[$this->environment])) { - yield new $class(); - } - } - } - - /** - * @return string[] - */ - private function getConfigurationDirectories(): iterable - { - yield $this->getProjectDir() . '/config'; - } - - private function isTestEnvironment(): bool - { - return str_starts_with($this->getEnvironment(), 'test'); - } -} diff --git a/tests/Application/assets/admin/entry.js b/tests/Application/assets/admin/entry.js deleted file mode 100644 index 635f5acc..00000000 --- a/tests/Application/assets/admin/entry.js +++ /dev/null @@ -1 +0,0 @@ -import 'sylius/bundle/AdminBundle/Resources/private/entry'; diff --git a/tests/Application/assets/shop/entry.js b/tests/Application/assets/shop/entry.js deleted file mode 100644 index aadc3174..00000000 --- a/tests/Application/assets/shop/entry.js +++ /dev/null @@ -1 +0,0 @@ -import 'sylius/bundle/ShopBundle/Resources/private/entry'; diff --git a/tests/Application/bin/console b/tests/Application/bin/console deleted file mode 100755 index b840f50e..00000000 --- a/tests/Application/bin/console +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env php -getParameterOption(['--env', '-e'], null, true)) { - putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); -} - -if ($input->hasParameterOption('--no-debug', true)) { - putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); -} - -require dirname(__DIR__).'/config/bootstrap.php'; - -if ($_SERVER['APP_DEBUG']) { - umask(0000); - - if (class_exists(Debug::class)) { - Debug::enable(); - } -} - -$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); -$application = new Application($kernel); -$application->run($input); diff --git a/tests/Application/composer.json b/tests/Application/composer.json deleted file mode 100644 index 326735f5..00000000 --- a/tests/Application/composer.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "sylius/plugin-skeleton-test-application", - "description": "Sylius application for plugin testing purposes (composer.json needed for project dir resolving)", - "license": "MIT" -} diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php deleted file mode 100644 index 2291ab42..00000000 --- a/tests/Application/config/bootstrap.php +++ /dev/null @@ -1,23 +0,0 @@ -=1.2) -if (is_array($env = @include dirname(__DIR__) . '/.env.local.php')) { - $_SERVER += $env; - $_ENV += $env; -} elseif (!class_exists(Dotenv::class)) { - throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); -} else { - // load all the .env files - (new Dotenv())->loadEnv(dirname(__DIR__) . '/.env'); -} - -$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; -$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; -$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], \FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; diff --git a/tests/Application/config/jwt/private.pem b/tests/Application/config/jwt/private.pem deleted file mode 100644 index 2bcf0230..00000000 --- a/tests/Application/config/jwt/private.pem +++ /dev/null @@ -1,54 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIIJrTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQIDbthk+aF5EACAggA -MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBA3DYfh2mXByUxFNke/Wf5SBIIJ -UBckIgXeXBWPLQAAq07pN8uNFMUcUirFuEvbmxVe1PupCCAqriNxi1DqeSu/M7c1 -h66y0BqKZu/0G9SVTg63iCKDEiRAM3hLyD2CsjYg8h2LAaqQ9dFYGV0cHRhCXagZ -Sdt9YTfn2rarRbxauMSt0z9zwCaiUrBU4JwSM3g+tD7W0lxAm9TeaqBZek5DIX+j -3Gom5tPYQe8jvfGMGdMPuanoEwH4WbWzGcqypWriy4JwaggwKCQ4ituWfa9kqMMC -8HRmBBDg0gtafmQP910RZh18JL2ewF5Pl7GDsLtOj5gNLNuAiQxDCcYRnD4/Cdsl -bH91btmGX1nUVIFViUTW93eBsjBgdgqOMRVxUKkSSX6CmIZWlE3AazgwSbvOvNrN -JGa8X21UwfuS/JHLmfRmgdti0YxRjJkBYLPpcd3ILsi+MMhSHy0uycAM/dB80Q1B -vkW1UXGbCw/PzA5yHrzULzAl69E3Tt5nTVMIIcBGxw2rf+ej+AVjsuOl7etwecdC -gnA90ViNlGOACLVnhsjd4WVF9Oircosf0UYoblwcT6gw1GSVF9pWuu7k5hy/7Pt/ -o1BvonUgz/4VHG+K58qvtnlto+JE0XWzPvukNUyggtekTLyoQCI3ZKge6ui3qLax -N6whHpzFnFVF3GJAisTk5naHFawHNvH7t85pmc+UnjNUUmyl9RStl9LMYDSBKNlR -LzPlJK27E5SLhhyJCni4+UYjH6PdlJuKXJ0365fufJ+5ajHRatwt039xLnK0W+oa -L35NxCuXrn8YxOgJIomt7IrkV3AuxoWxcx4lRFoM0WCdn9SWZVtfFFiyX/Xr1qDg -dUysw3/bePEkOKr5JWx09hT0OKDpkwLFo2Ljtvjln4EMXYEvvVqFciKw0kqF73Dw -NyoSubwR4qs6FQclKW1TAP6UW4B6ffq1iagKOCTZ5bBtsPBZk8UGCJb57q4fUj4P -nJy0hnSdlOH4Am+US4HF4ayOGuaV1Be1taurdJnt5cNnUYRah0wg4nG+wVdG5HJk -f4dJ4nih9d6WA/8LfxdpB7NCwdR+KK6lky+GgLSdhmIT9lzjj2GDsU4lBf29TkBn -lyt98/LWGrgCQgZAQ/obxLT8CZtY+tNejGoMppY+ub8DIaLBFID+fcz13kgA9x7a -TeVB8RPok+S3yHXP9a4WSFe9DGjjN+m7EnRtte7MEjyMoekXVnT04gNbTMoGAjNb -lrR4g3ICygZtsoGSB2VEu7o3azAspXNBMOuJfRCuC0LDXcjH3TbvjX0da5wHBoK9 -clRxu+CDo9A849HMkmSje8wED7ysZnkvSX0OdPjXahVd4t1tDRI6jSlzFo9fGcjp -S8Ikm9iMrHXaWcDdtcq4C63CjSynIBr4mNIxe/f2e9nynm3AIv+aOan891RWHqrd -DdpSSPShtzATI9PbB+b+S0Gw58Y8fpO7yoZ87VW1BMpadmFZ87YY78jdB7BwInNI -JqtnivinM6qCsvbdMoGinUyL6PUcfQGiEAibouKr3zNRDC4aesBZZmj7w0dnf+HK -YC905aR0cddlc6DBo/ed3o9krMcZ6oY/vruemPTc5G7Cg3t4H3mInRgURw22X1wo -FsioU1yOdkK+MYxvmGsQvQuSJhp7h1Uz37t/olkPRafZgy2nEtw6DQO0Dm4UfSsD -nysq6dn1WeZPkOipGBRgQmY1FTRzwPoCxi7+/EuHhD8hr962rHOglSuNqPG89J8r -wdbTDr8kgXj2A9p+jI3TVKEX+h6FEhrCHW9SHUqATOZ7RiNL6hKld9j0U4D9gQwZ -dflA0TxpVsHXm7pd1idkr46jIFgw7HA89Erm0Ty7RolfHkqlRca805AVmsKkviIz -sbF5uv4WzIE3ViO8P1KMUhCyElm72mpyNTXBhkxkup9hJ4fQieaN6pET6dQ2xyjs -SBIvQoXI0JQKpespcyAdoh88ULQjRUXEOaNFfN7q+itTcocwmPZfzW2nXORJT2p8 -SXLqSE73nYZdqzSYFq1hLcnlubJ7yPBYYG1fI0IydjSGKfnjtB0DReR32OToRZ7m -laduZ8O+IaBUY4Sp6QdYcVbGGpG/wsPmTQyScc/O2bfSI7AiPnL9EnwebI9sPSWQ -R0t0QMXZOSSqNY6jkYjsOCxeekRIdY6havo2Y52Ywti0QNrkT4BQ+175VVTmRMdy -LNaMFeEq6ehSEdaHaozvjHvP50HQT43tCK+RJiL+Gf9FqawoQRt693yO5LFbQsuw -QsUSMi41txpINMa+HEc2K5FvGoPr7FmajLK7X2fr+3c/yZ4fahoMKEAVFWl5kRYx -Fe1smlw1Vxl/qNQ32LFWsBIK+XnYBteYmlpVyYrTgXyjnp1rK2zz0118DPFuYiAP -O0r6nnBz0NbwnSKb7S4CjxBKDvDbWTzP35Q5L/vySnO2zRbM64Gw7sjeLiJittWS -gQfbFpEk9k8KVndKM4H50Jp0WznmYpm1Tman8hUOiCvmq0qdI3bJ5Bnj0K+q2zFV -+noGpMFdq1+8WaUFLQFGCPM+yJgCqDgT1RAgfsGcomckGcmenDtHaTbcSFabEdpM -Tsa2qLdg/Kju+7JyGrkmobXl/azuyjYTHfRvSZrvO5WUDFzhChrJpIL4nA3ZGRlS -gvy+OzyyBh4sRyHwLItwUwE81aya3W4llAkhQ7OycmqniJgjtJzLwnxv2RQsB8bF -pyoqQdKVxkqHdbUFeh9igI4ffRAK+8xDER5J+RUoZ4mO8qJebxar54XTb6I/Lepc -g8ITX8bJ/GH+M6JdP7tLCikDTSGS+i1ReMQXE5XuEajYOVbzQdyWU5jleZIx0f6X -mTa4WvMEGNyNxKZZXsy9FAaBkZqrNzEv8k0uFgFMNWQcMMtiqbei86yACdqe+jiW -HqHv8wfoBHR+eIARub2itOJ/cI+oKv96d4it4FqQ9Lml8RUFFZj7Hrd6EjDb6Nq4 -P9ti7eku/xZvS0saBNChvv44GhP6FZJS0i/gidVffLna7Wua98tPZEAXp57k+XUL -PzsRJ4a+hFuQjkyXFoz/v8YuUdyCFUSVVr9ArVu0v4+4euFWpQLav5sXv0Gh9X58 -Ek1KIf7Z/tZAJnSjTjFuSbDX/AoTMTxpRBKKnFW6zY0Nw2pjTVMtTVDkv9xkBpBK -wod7FPD5f0T7y9YOARVZnBxVRSkkcYpEJFy5pLNeadg9 ------END ENCRYPTED PRIVATE KEY----- diff --git a/tests/Application/config/jwt/public.pem b/tests/Application/config/jwt/public.pem deleted file mode 100644 index cb4e13da..00000000 --- a/tests/Application/config/jwt/public.pem +++ /dev/null @@ -1,14 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA6QkmF/Xi5nAYb8Kzr7qC -d63V2K+d/nCXbpDUKKDPJAqOtTlMoQSuJRLNnhhp7z1i/Cp4Bhifr20Pu2dq8JYg -6pRT4ctqvYb/MXxAaPZc3EcBC0S6AhgKO/fDvR3LcqYqGJmQQOXZvxTsgqongdvV -4XbqFBMMgngyayoBk0VKTaI/s+LQhIce+1QaxbAI0+/zbR0hZ1hWT73orJi3do+1 -TBzQol+V7WGa8LlJfmgM56qO3BmVkeTDMBc27pGp6g3+Oufk/l29jEGJlUT9yu7Q -BRhaQTWNVASa2aD+AKjVBzJh53O2zD8slAbjF1M9U7bbWN28Sv+xC/dUz0q9HnPu -RsY2tnwryqTyYn/Hf2xyP3/KvjJ6oslAwemu5JirdJkO7KVQAthWG42gLuhZg3ks -cSZhCLZH7nO2UDsf+2ZZgdbhpYZwR4gDRfNt7GKWXnWZOz9Uw1yVCPgylyZRZwg8 -l0y9aABdj3379I22icrwpMZbAgkyxNSV6UNJuxZksLUoP3i9OvXYgPYU9E4tU/Ul -Dm/T1rGSReGoPkU1YQnI50bq7p1byIoUu2scTflvpTVI5a7zULkS1tg60xk7vBRC -aBc7nr4UEtA235N6uLtcGxH11WBMwsKX69sSU0sQdC4Sk25zXM2gc8R1XV9K3qz2 -wQorQRlCwrkG44VRDgbFH+8CAwEAAQ== ------END PUBLIC KEY----- diff --git a/tests/Application/config/packages/_sylius.yaml b/tests/Application/config/packages/_sylius.yaml deleted file mode 100644 index 872717f0..00000000 --- a/tests/Application/config/packages/_sylius.yaml +++ /dev/null @@ -1,40 +0,0 @@ -imports: - - { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" } - - { resource: "@SyliusAdminBundle/Resources/config/app/config.yml" } - - { resource: "@SyliusShopBundle/Resources/config/app/config.yml" } - - { resource: "@SyliusApiBundle/Resources/config/app/config.yaml" } - -parameters: - sylius_core.public_dir: '%kernel.project_dir%/public' - -sylius_shop: - product_grid: - include_all_descendants: true - -sylius_api: - enabled: true - -sylius_customer: - resources: - customer: - classes: - repository: Setono\SyliusGiftCardPlugin\Tests\Application\Doctrine\ORM\CustomerRepository - -sylius_order: - resources: - order: - classes: - model: Setono\SyliusGiftCardPlugin\Tests\Application\Model\Order - repository: Setono\SyliusGiftCardPlugin\Tests\Application\Doctrine\ORM\OrderRepository - order_item: - classes: - model: Setono\SyliusGiftCardPlugin\Tests\Application\Model\OrderItem - order_item_unit: - classes: - model: Setono\SyliusGiftCardPlugin\Tests\Application\Model\OrderItemUnit - -sylius_product: - resources: - product: - classes: - model: Setono\SyliusGiftCardPlugin\Tests\Application\Model\Product diff --git a/tests/Application/config/packages/api_platform.yaml b/tests/Application/config/packages/api_platform.yaml deleted file mode 100644 index 26def491..00000000 --- a/tests/Application/config/packages/api_platform.yaml +++ /dev/null @@ -1,9 +0,0 @@ -api_platform: - mapping: - paths: - - '%kernel.project_dir%/../../vendor/sylius/sylius/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources' - - '%kernel.project_dir%/config/api_platform' - patch_formats: - json: ['application/merge-patch+json'] - swagger: - versions: [3] diff --git a/tests/Application/config/packages/assets.yaml b/tests/Application/config/packages/assets.yaml deleted file mode 100644 index 24689011..00000000 --- a/tests/Application/config/packages/assets.yaml +++ /dev/null @@ -1,7 +0,0 @@ -framework: - assets: - packages: - shop: - json_manifest_path: '%kernel.project_dir%/public/build/shop/manifest.json' - admin: - json_manifest_path: '%kernel.project_dir%/public/build/admin/manifest.json' diff --git a/tests/Application/config/packages/dev/debug.yaml b/tests/Application/config/packages/dev/debug.yaml deleted file mode 100644 index 26d4e53d..00000000 --- a/tests/Application/config/packages/dev/debug.yaml +++ /dev/null @@ -1,4 +0,0 @@ -debug: - # Forwards VarDumper Data clones to a centralized server allowing to inspect dumps on CLI or in your browser. - # See the "server:dump" command to start a new server. - dump_destination: "tcp://%env(VAR_DUMPER_SERVER)%" diff --git a/tests/Application/config/packages/dev/framework.yaml b/tests/Application/config/packages/dev/framework.yaml deleted file mode 100644 index 4b116def..00000000 --- a/tests/Application/config/packages/dev/framework.yaml +++ /dev/null @@ -1,2 +0,0 @@ -framework: - profiler: { only_exceptions: false } diff --git a/tests/Application/config/packages/dev/jms_serializer.yaml b/tests/Application/config/packages/dev/jms_serializer.yaml deleted file mode 100644 index 2f32a9b1..00000000 --- a/tests/Application/config/packages/dev/jms_serializer.yaml +++ /dev/null @@ -1,12 +0,0 @@ -jms_serializer: - visitors: - json_serialization: - options: - - JSON_PRETTY_PRINT - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION - json_deserialization: - options: - - JSON_PRETTY_PRINT - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/packages/dev/monolog.yaml b/tests/Application/config/packages/dev/monolog.yaml deleted file mode 100644 index da2b092d..00000000 --- a/tests/Application/config/packages/dev/monolog.yaml +++ /dev/null @@ -1,9 +0,0 @@ -monolog: - handlers: - main: - type: stream - path: "%kernel.logs_dir%/%kernel.environment%.log" - level: debug - firephp: - type: firephp - level: info diff --git a/tests/Application/config/packages/dev/routing.yaml b/tests/Application/config/packages/dev/routing.yaml deleted file mode 100644 index 4116679a..00000000 --- a/tests/Application/config/packages/dev/routing.yaml +++ /dev/null @@ -1,3 +0,0 @@ -framework: - router: - strict_requirements: true diff --git a/tests/Application/config/packages/dev/web_profiler.yaml b/tests/Application/config/packages/dev/web_profiler.yaml deleted file mode 100644 index 1f1cb2bb..00000000 --- a/tests/Application/config/packages/dev/web_profiler.yaml +++ /dev/null @@ -1,3 +0,0 @@ -web_profiler: - toolbar: true - intercept_redirects: false diff --git a/tests/Application/config/packages/doctrine.yaml b/tests/Application/config/packages/doctrine.yaml deleted file mode 100644 index dc76b940..00000000 --- a/tests/Application/config/packages/doctrine.yaml +++ /dev/null @@ -1,25 +0,0 @@ -parameters: - # Adds a fallback DATABASE_URL if the env var is not set. - # This allows you to run cache:warmup even if your - # environment variables are not available yet. - # You should not need to change this value. - env(DATABASE_URL): '' - -doctrine: - dbal: - driver: 'pdo_mysql' - server_version: '5.7' - charset: UTF8 - - url: '%env(resolve:DATABASE_URL)%' - - orm: - auto_generate_proxy_classes: '%kernel.debug%' - auto_mapping: true - mappings: - App: - is_bundle: false - type: annotation - dir: '%kernel.project_dir%/Model' - prefix: 'Setono\SyliusGiftCardPlugin\Tests\Application\Model' - alias: App diff --git a/tests/Application/config/packages/doctrine_migrations.yaml b/tests/Application/config/packages/doctrine_migrations.yaml deleted file mode 100644 index cdbc01ae..00000000 --- a/tests/Application/config/packages/doctrine_migrations.yaml +++ /dev/null @@ -1,4 +0,0 @@ -doctrine_migrations: - storage: - table_storage: - table_name: sylius_migrations diff --git a/tests/Application/config/packages/fos_rest.yaml b/tests/Application/config/packages/fos_rest.yaml deleted file mode 100644 index eaebb277..00000000 --- a/tests/Application/config/packages/fos_rest.yaml +++ /dev/null @@ -1,11 +0,0 @@ -fos_rest: - exception: true - view: - formats: - json: true - xml: true - empty_content: 204 - format_listener: - rules: - - { path: '^/api/v1/.*', priorities: ['json', 'xml'], fallback_format: json, prefer_extension: true } - - { path: '^/', stop: true } diff --git a/tests/Application/config/packages/framework.yaml b/tests/Application/config/packages/framework.yaml deleted file mode 100644 index 3df2c0ad..00000000 --- a/tests/Application/config/packages/framework.yaml +++ /dev/null @@ -1,9 +0,0 @@ -framework: - secret: '%env(APP_SECRET)%' - ide: phpstorm - form: - enabled: true - legacy_error_messages: false - csrf_protection: true - session: - handler_id: ~ diff --git a/tests/Application/config/packages/jms_serializer.yaml b/tests/Application/config/packages/jms_serializer.yaml deleted file mode 100644 index ed7bc613..00000000 --- a/tests/Application/config/packages/jms_serializer.yaml +++ /dev/null @@ -1,4 +0,0 @@ -jms_serializer: - visitors: - xml_serialization: - format_output: '%kernel.debug%' diff --git a/tests/Application/config/packages/lexik_jwt_authentication.yaml b/tests/Application/config/packages/lexik_jwt_authentication.yaml deleted file mode 100644 index edfb69dc..00000000 --- a/tests/Application/config/packages/lexik_jwt_authentication.yaml +++ /dev/null @@ -1,4 +0,0 @@ -lexik_jwt_authentication: - secret_key: '%env(resolve:JWT_SECRET_KEY)%' - public_key: '%env(resolve:JWT_PUBLIC_KEY)%' - pass_phrase: '%env(JWT_PASSPHRASE)%' diff --git a/tests/Application/config/packages/liip_imagine.yaml b/tests/Application/config/packages/liip_imagine.yaml deleted file mode 100644 index bb2e7ceb..00000000 --- a/tests/Application/config/packages/liip_imagine.yaml +++ /dev/null @@ -1,6 +0,0 @@ -liip_imagine: - resolvers: - default: - web_path: - web_root: "%kernel.project_dir%/public" - cache_prefix: "media/cache" diff --git a/tests/Application/config/packages/mailer.yaml b/tests/Application/config/packages/mailer.yaml deleted file mode 100644 index 56a650d8..00000000 --- a/tests/Application/config/packages/mailer.yaml +++ /dev/null @@ -1,3 +0,0 @@ -framework: - mailer: - dsn: '%env(MAILER_DSN)%' diff --git a/tests/Application/config/packages/prod/doctrine.yaml b/tests/Application/config/packages/prod/doctrine.yaml deleted file mode 100644 index 2f16f0fd..00000000 --- a/tests/Application/config/packages/prod/doctrine.yaml +++ /dev/null @@ -1,31 +0,0 @@ -doctrine: - orm: - metadata_cache_driver: - type: service - id: doctrine.system_cache_provider - query_cache_driver: - type: service - id: doctrine.system_cache_provider - result_cache_driver: - type: service - id: doctrine.result_cache_provider - -services: - doctrine.result_cache_provider: - class: Symfony\Component\Cache\DoctrineProvider - public: false - arguments: - - '@doctrine.result_cache_pool' - doctrine.system_cache_provider: - class: Symfony\Component\Cache\DoctrineProvider - public: false - arguments: - - '@doctrine.system_cache_pool' - -framework: - cache: - pools: - doctrine.result_cache_pool: - adapter: cache.app - doctrine.system_cache_pool: - adapter: cache.system diff --git a/tests/Application/config/packages/prod/jms_serializer.yaml b/tests/Application/config/packages/prod/jms_serializer.yaml deleted file mode 100644 index c2881820..00000000 --- a/tests/Application/config/packages/prod/jms_serializer.yaml +++ /dev/null @@ -1,10 +0,0 @@ -jms_serializer: - visitors: - json_serialization: - options: - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION - json_deserialization: - options: - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/packages/prod/monolog.yaml b/tests/Application/config/packages/prod/monolog.yaml deleted file mode 100644 index 64612114..00000000 --- a/tests/Application/config/packages/prod/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/routing.yaml b/tests/Application/config/packages/routing.yaml deleted file mode 100644 index 368bc7f4..00000000 --- a/tests/Application/config/packages/routing.yaml +++ /dev/null @@ -1,3 +0,0 @@ -framework: - router: - strict_requirements: ~ diff --git a/tests/Application/config/packages/security.yaml b/tests/Application/config/packages/security.yaml deleted file mode 100644 index 2f5c6875..00000000 --- a/tests/Application/config/packages/security.yaml +++ /dev/null @@ -1,122 +0,0 @@ -security: - enable_authenticator_manager: true - providers: - sylius_admin_user_provider: - id: sylius.admin_user_provider.email_or_name_based - sylius_api_admin_user_provider: - id: sylius.admin_user_provider.email_or_name_based - sylius_shop_user_provider: - id: sylius.shop_user_provider.email_or_name_based - sylius_api_shop_user_provider: - id: sylius.shop_user_provider.email_or_name_based - - password_hashers: - Sylius\Component\User\Model\UserInterface: argon2i - firewalls: - admin: - switch_user: true - context: admin - pattern: "%sylius.security.admin_regex%" - provider: sylius_admin_user_provider - form_login: - provider: sylius_admin_user_provider - login_path: sylius_admin_login - check_path: sylius_admin_login_check - failure_path: sylius_admin_login - default_target_path: sylius_admin_dashboard - use_forward: false - use_referer: true - enable_csrf: true - csrf_parameter: _csrf_admin_security_token - csrf_token_id: admin_authenticate - remember_me: - secret: "%env(APP_SECRET)%" - path: "/%sylius_admin.path_name%" - name: APP_ADMIN_REMEMBER_ME - lifetime: 31536000 - remember_me_parameter: _remember_me - logout: - path: sylius_admin_logout - target: sylius_admin_login - - new_api_admin_user: - pattern: "%sylius.security.new_api_admin_regex%/.*" - provider: sylius_api_admin_user_provider - stateless: true - entry_point: jwt - json_login: - check_path: "%sylius.security.new_api_admin_route%/authentication-token" - username_path: email - password_path: password - success_handler: lexik_jwt_authentication.handler.authentication_success - failure_handler: lexik_jwt_authentication.handler.authentication_failure - jwt: true - - new_api_shop_user: - pattern: "%sylius.security.new_api_shop_regex%/.*" - provider: sylius_api_shop_user_provider - stateless: true - entry_point: jwt - json_login: - check_path: "%sylius.security.new_api_shop_route%/authentication-token" - username_path: email - password_path: password - success_handler: lexik_jwt_authentication.handler.authentication_success - failure_handler: lexik_jwt_authentication.handler.authentication_failure - jwt: true - - shop: - switch_user: { role: ROLE_ALLOWED_TO_SWITCH } - context: shop - pattern: "%sylius.security.shop_regex%" - provider: sylius_shop_user_provider - form_login: - success_handler: sylius.authentication.success_handler - failure_handler: sylius.authentication.failure_handler - provider: sylius_shop_user_provider - login_path: sylius_shop_login - check_path: sylius_shop_login_check - failure_path: sylius_shop_login - default_target_path: sylius_shop_homepage - use_forward: false - use_referer: true - enable_csrf: true - csrf_parameter: _csrf_shop_security_token - csrf_token_id: shop_authenticate - remember_me: - secret: "%env(APP_SECRET)%" - name: APP_SHOP_REMEMBER_ME - lifetime: 31536000 - remember_me_parameter: _remember_me - logout: - path: sylius_shop_logout - target: sylius_shop_homepage - invalidate_session: false - - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - - access_control: - - { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } - - - { path: "%sylius.security.admin_regex%/forgotten-password", role: PUBLIC_ACCESS } - - - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS } - - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } - - - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS } - - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS } - - - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } - - - { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } - - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } diff --git a/tests/Application/config/packages/setono_sylius_gift_card.yaml b/tests/Application/config/packages/setono_sylius_gift_card.yaml deleted file mode 100644 index ccb4949d..00000000 --- a/tests/Application/config/packages/setono_sylius_gift_card.yaml +++ /dev/null @@ -1,3 +0,0 @@ -imports: - - { resource: "@SetonoSyliusGiftCardPlugin/Resources/config/app/config.yaml" } - - { resource: "@SetonoSyliusGiftCardPlugin/Resources/config/app/fixtures.yaml" } diff --git a/tests/Application/config/packages/stof_doctrine_extensions.yaml b/tests/Application/config/packages/stof_doctrine_extensions.yaml deleted file mode 100644 index 7770f74e..00000000 --- a/tests/Application/config/packages/stof_doctrine_extensions.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Read the documentation: https://symfony.com/doc/current/bundles/StofDoctrineExtensionsBundle/index.html -# See the official DoctrineExtensions documentation for more details: https://github.com/Atlantic18/DoctrineExtensions/tree/master/doc/ -stof_doctrine_extensions: - default_locale: '%locale%' diff --git a/tests/Application/config/packages/sylius_api.yaml b/tests/Application/config/packages/sylius_api.yaml deleted file mode 100644 index cd01aaf7..00000000 --- a/tests/Application/config/packages/sylius_api.yaml +++ /dev/null @@ -1,2 +0,0 @@ -sylius_api: - enabled: true diff --git a/tests/Application/config/packages/test/framework.yaml b/tests/Application/config/packages/test/framework.yaml deleted file mode 100644 index fc1d3c13..00000000 --- a/tests/Application/config/packages/test/framework.yaml +++ /dev/null @@ -1,4 +0,0 @@ -framework: - test: ~ - session: - storage_factory_id: session.storage.factory.mock_file diff --git a/tests/Application/config/packages/test/mailer.yaml b/tests/Application/config/packages/test/mailer.yaml deleted file mode 100644 index 092eb288..00000000 --- a/tests/Application/config/packages/test/mailer.yaml +++ /dev/null @@ -1,7 +0,0 @@ -framework: - mailer: - dsn: 'null://null' - cache: - pools: - test.mailer_pool: - adapter: cache.adapter.filesystem diff --git a/tests/Application/config/packages/test/monolog.yaml b/tests/Application/config/packages/test/monolog.yaml deleted file mode 100644 index 7e2b9e3a..00000000 --- a/tests/Application/config/packages/test/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/security.yaml b/tests/Application/config/packages/test/security.yaml deleted file mode 100644 index 4071d319..00000000 --- a/tests/Application/config/packages/test/security.yaml +++ /dev/null @@ -1,6 +0,0 @@ -security: - password_hashers: - Sylius\Component\User\Model\UserInterface: - algorithm: argon2i - time_cost: 3 - memory_cost: 10 diff --git a/tests/Application/config/packages/test/setono_sylius_gift_card.yaml b/tests/Application/config/packages/test/setono_sylius_gift_card.yaml deleted file mode 100644 index 9a091d6c..00000000 --- a/tests/Application/config/packages/test/setono_sylius_gift_card.yaml +++ /dev/null @@ -1,9 +0,0 @@ -setono_sylius_gift_card: - pdf_rendering: - default_orientation: 'Landscape' - available_orientations: - - Landscape - default_page_size: 'B0' - available_page_sizes: - - A5 - - B0 diff --git a/tests/Application/config/packages/test/sylius_theme.yaml b/tests/Application/config/packages/test/sylius_theme.yaml deleted file mode 100644 index 4d34199f..00000000 --- a/tests/Application/config/packages/test/sylius_theme.yaml +++ /dev/null @@ -1,3 +0,0 @@ -sylius_theme: - sources: - test: ~ diff --git a/tests/Application/config/packages/test/web_profiler.yaml b/tests/Application/config/packages/test/web_profiler.yaml deleted file mode 100644 index 03752de2..00000000 --- a/tests/Application/config/packages/test/web_profiler.yaml +++ /dev/null @@ -1,6 +0,0 @@ -web_profiler: - toolbar: false - intercept_redirects: false - -framework: - profiler: { collect: false } diff --git a/tests/Application/config/packages/translation.yaml b/tests/Application/config/packages/translation.yaml deleted file mode 100644 index 1f4f9664..00000000 --- a/tests/Application/config/packages/translation.yaml +++ /dev/null @@ -1,8 +0,0 @@ -framework: - default_locale: '%locale%' - translator: - paths: - - '%kernel.project_dir%/translations' - fallbacks: - - '%locale%' - - 'en' diff --git a/tests/Application/config/packages/twig.yaml b/tests/Application/config/packages/twig.yaml deleted file mode 100644 index 8545473d..00000000 --- a/tests/Application/config/packages/twig.yaml +++ /dev/null @@ -1,12 +0,0 @@ -twig: - paths: ['%kernel.project_dir%/templates'] - debug: '%kernel.debug%' - strict_variables: '%kernel.debug%' - -services: - _defaults: - public: false - autowire: true - autoconfigure: true - - Twig\Extra\Intl\IntlExtension: ~ diff --git a/tests/Application/config/packages/twig_extensions.yaml b/tests/Application/config/packages/twig_extensions.yaml deleted file mode 100644 index 0881cc95..00000000 --- a/tests/Application/config/packages/twig_extensions.yaml +++ /dev/null @@ -1,11 +0,0 @@ -services: - _defaults: - public: false - autowire: true - autoconfigure: true - - # Uncomment any lines below to activate that Twig extension - #Twig\Extensions\ArrayExtension: ~ - #Twig\Extensions\DateExtension: ~ - #Twig\Extensions\IntlExtension: ~ - #Twig\Extensions\TextExtension: ~ diff --git a/tests/Application/config/packages/validator.yaml b/tests/Application/config/packages/validator.yaml deleted file mode 100644 index 61807db6..00000000 --- a/tests/Application/config/packages/validator.yaml +++ /dev/null @@ -1,3 +0,0 @@ -framework: - validation: - enable_annotations: true diff --git a/tests/Application/config/packages/webpack_encore.yaml b/tests/Application/config/packages/webpack_encore.yaml deleted file mode 100644 index 9bee2488..00000000 --- a/tests/Application/config/packages/webpack_encore.yaml +++ /dev/null @@ -1,5 +0,0 @@ -webpack_encore: - output_path: '%kernel.project_dir%/public/build/default' - builds: - shop: '%kernel.project_dir%/public/build/shop' - admin: '%kernel.project_dir%/public/build/admin' diff --git a/tests/Application/config/routes.yaml b/tests/Application/config/routes.yaml deleted file mode 100644 index c1e265d0..00000000 --- a/tests/Application/config/routes.yaml +++ /dev/null @@ -1,2 +0,0 @@ -setono_sylius_gift_card: - resource: "@SetonoSyliusGiftCardPlugin/Resources/config/routes.yaml" diff --git a/tests/Application/config/routes/dev/web_profiler.yaml b/tests/Application/config/routes/dev/web_profiler.yaml deleted file mode 100644 index 3e79dc21..00000000 --- a/tests/Application/config/routes/dev/web_profiler.yaml +++ /dev/null @@ -1,7 +0,0 @@ -_wdt: - resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml" - prefix: /_wdt - -_profiler: - resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml" - prefix: /_profiler diff --git a/tests/Application/config/routes/liip_imagine.yaml b/tests/Application/config/routes/liip_imagine.yaml deleted file mode 100644 index 201cbd5d..00000000 --- a/tests/Application/config/routes/liip_imagine.yaml +++ /dev/null @@ -1,2 +0,0 @@ -_liip_imagine: - resource: "@LiipImagineBundle/Resources/config/routing.yaml" diff --git a/tests/Application/config/routes/sylius_admin.yaml b/tests/Application/config/routes/sylius_admin.yaml deleted file mode 100644 index b9c12c22..00000000 --- a/tests/Application/config/routes/sylius_admin.yaml +++ /dev/null @@ -1,3 +0,0 @@ -sylius_admin: - resource: "@SyliusAdminBundle/Resources/config/routing.yml" - prefix: '/%sylius_admin.path_name%' diff --git a/tests/Application/config/routes/sylius_api.yaml b/tests/Application/config/routes/sylius_api.yaml deleted file mode 100644 index ae01ffce..00000000 --- a/tests/Application/config/routes/sylius_api.yaml +++ /dev/null @@ -1,3 +0,0 @@ -sylius_api: - resource: "@SyliusApiBundle/Resources/config/routing.yml" - prefix: "%sylius.security.new_api_route%" diff --git a/tests/Application/config/routes/sylius_shop.yaml b/tests/Application/config/routes/sylius_shop.yaml deleted file mode 100644 index 22e7a4a9..00000000 --- a/tests/Application/config/routes/sylius_shop.yaml +++ /dev/null @@ -1,23 +0,0 @@ -sylius_shop: - resource: "@SyliusShopBundle/Resources/config/routing.yml" - prefix: /{_locale} - requirements: - _locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$ - -sylius_shop_payum: - resource: "@SyliusShopBundle/Resources/config/routing/payum.yml" - -sylius_shop_default_locale: - path: / - methods: [GET] - defaults: - _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/config/secrets/test/.gitignore b/tests/Application/config/secrets/test/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/Application/config/secrets/test_cached/.gitignore b/tests/Application/config/secrets/test_cached/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/Application/config/serialization/.gitignore b/tests/Application/config/serialization/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/Application/config/services.yaml b/tests/Application/config/services.yaml deleted file mode 100644 index 615506eb..00000000 --- a/tests/Application/config/services.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Put parameters here that don't need to change on each machine where the app is deployed -# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration -parameters: - locale: en_US diff --git a/tests/Application/config/services_test.yaml b/tests/Application/config/services_test.yaml deleted file mode 100644 index d9b02e3d..00000000 --- a/tests/Application/config/services_test.yaml +++ /dev/null @@ -1,3 +0,0 @@ -imports: - - { resource: "../../Behat/Resources/services.xml" } - - { resource: "../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" } diff --git a/tests/Application/docker-compose.yaml b/tests/Application/docker-compose.yaml deleted file mode 100644 index b547ffa7..00000000 --- a/tests/Application/docker-compose.yaml +++ /dev/null @@ -1,8 +0,0 @@ -version: '3.7' - -services: - mailer: - image: "schickling/mailcatcher:latest" - ports: - - "1080" - - "1025" diff --git a/tests/Application/package.json b/tests/Application/package.json deleted file mode 100644 index 8f62c4c7..00000000 --- a/tests/Application/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "dependencies": { - "chart.js": "^3.9", - "jquery": "^3.6", - "jquery.dirtyforms": "^2.0", - "lightbox2": "^2.9", - "semantic-ui-css": "^2.2", - "slick-carousel": "^1.8" - }, - "devDependencies": { - "@symfony/webpack-encore": "^1.8", - "eslint": "^8.18", - "eslint-config-airbnb-base": "^15.0", - "eslint-import-resolver-babel-module": "^5.3", - "eslint-plugin-import": "^2.26", - "node-sass": "^7.0", - "sass-loader": "^12.0" - }, - "scripts": { - "dev": "encore dev", - "build": "encore production", - "watch": "encore dev --watch" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Sylius/Sylius.git" - }, - "author": "Paweł Jędrzejewski", - "license": "MIT" -} diff --git a/tests/Application/public/.htaccess b/tests/Application/public/.htaccess deleted file mode 100644 index 99ed00df..00000000 --- a/tests/Application/public/.htaccess +++ /dev/null @@ -1,25 +0,0 @@ -DirectoryIndex app.php - - - RewriteEngine On - - RewriteCond %{HTTP:Authorization} ^(.*) - RewriteRule .* - [e=HTTP_AUTHORIZATION:%1] - - RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ - RewriteRule ^(.*) - [E=BASE:%1] - - RewriteCond %{ENV:REDIRECT_STATUS} ^$ - RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] - - RewriteCond %{REQUEST_FILENAME} -f - RewriteRule .? - [L] - - RewriteRule .? %{ENV:BASE}/index.php [L] - - - - - RedirectMatch 302 ^/$ /index.php/ - - diff --git a/tests/Application/public/favicon.ico b/tests/Application/public/favicon.ico deleted file mode 100644 index 592f7a8e..00000000 Binary files a/tests/Application/public/favicon.ico and /dev/null differ diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php deleted file mode 100644 index b550b6a8..00000000 --- a/tests/Application/public/index.php +++ /dev/null @@ -1,29 +0,0 @@ -handle($request); -$response->send(); -$kernel->terminate($request, $response); diff --git a/tests/Application/public/media/image/.gitignore b/tests/Application/public/media/image/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/Application/public/robots.txt b/tests/Application/public/robots.txt deleted file mode 100644 index 214e4119..00000000 --- a/tests/Application/public/robots.txt +++ /dev/null @@ -1,4 +0,0 @@ -# www.robotstxt.org/ -# www.google.com/support/webmasters/bin/answer.py?hl=en&answer=156449 - -User-agent: * diff --git a/tests/Application/templates/.gitignore b/tests/Application/templates/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Form/imagesTheme.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Form/imagesTheme.html.twig deleted file mode 100644 index 39599d88..00000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/Form/imagesTheme.html.twig +++ /dev/null @@ -1,17 +0,0 @@ -{% extends '@!SyliusAdmin/Form/imagesTheme.html.twig' %} - -{% block setono_sylius_gift_card_gift_card_configuration_image_widget %} - {%- if form.type is defined -%} - {{- form_row(form.type) -}} - {%- endif -%} - - {%- if form.vars.value.path|default(null) is not null -%} - {{ form.vars.value.type }} - {%- endif -%} - -
- {{- form_errors(form.file) -}} -
-{% endblock %} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_item.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_item.html.twig deleted file mode 100644 index 878d5b9f..00000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_item.html.twig +++ /dev/null @@ -1,58 +0,0 @@ -{# @var \Sylius\Component\Core\Model\OrderItemInterface item #} -{% import "@SyliusAdmin/Common/Macro/money.html.twig" as money %} - -{% set orderPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT') %} -{% set unitPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT') %} -{% set shippingAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::SHIPPING_ADJUSTMENT') %} -{% set taxAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::TAX_ADJUSTMENT') %} - -{% set variant = item.variant %} -{% set product = variant.product %} - -{% set aggregatedUnitPromotionAdjustments = item.getAdjustmentsTotalRecursively(unitPromotionAdjustment) + item.getAdjustmentsTotalRecursively(orderPromotionAdjustment) %} -{% set subtotal = (item.unitPrice * item.quantity) + aggregatedUnitPromotionAdjustments %} - -{% set taxIncluded = sylius_admin_order_unit_tax_included(item) %} -{% set taxExcluded = sylius_admin_order_unit_tax_excluded(item) %} - - - - {% include '@SyliusAdmin/Product/_info.html.twig' %} - {# @var \Setono\SyliusGiftCardPlugin\Model\OrderItemUnitInterface itemUnit #} - {% for itemUnit in item.units %} - {% set giftCard = itemUnit.giftCard %} - {% if giftCard is not null %} - {{ giftCard.code }} - {% endif %} - {% endfor %} - - - {{ money.format(item.unitPrice, order.currencyCode) }} - - - {{ money.format(item.units.first.adjustmentsTotal(unitPromotionAdjustment), order.currencyCode) }} - - - ~ {{ money.format(item.units.first.adjustmentsTotal(orderPromotionAdjustment), order.currencyCode) }} - - - {{ money.format(item.fullDiscountedUnitPrice, order.currencyCode) }} - - - {{ item.quantity }} - - - {{ money.format(subtotal, order.currencyCode) }} - - -
{{ money.format(taxExcluded, order.currencyCode) }}
-
-
{{ money.format(taxIncluded, order.currencyCode) }} -
- ({{ 'sylius.ui.included_in_price'|trans }}) -
- - - {{ money.format(item.total, order.currencyCode) }} - - diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_totals.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_totals.html.twig deleted file mode 100644 index d7c5fe17..00000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_totals.html.twig +++ /dev/null @@ -1,67 +0,0 @@ -{% import "@SyliusAdmin/Common/Macro/money.html.twig" as money %} - -{% set orderPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT') %} -{% set orderShippingPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_SHIPPING_PROMOTION_ADJUSTMENT') %} -{% set itemPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT') %} -{% set shippingAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::SHIPPING_ADJUSTMENT') %} -{% set taxAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::TAX_ADJUSTMENT') %} - -{% set orderShippingPromotions = sylius_aggregate_adjustments(order.getAdjustmentsRecursively(orderShippingPromotionAdjustment)) %} - - - - - {{ 'sylius.ui.tax_total'|trans }}: - {{ money.format(order.taxTotal, order.currencyCode) }} - - - {{ 'sylius.ui.items_total'|trans }}: - {{ money.format(order.itemsTotal, order.currencyCode) }} - - - - - {% if not order.adjustments(shippingAdjustment).isEmpty() %} -
-
{{ 'sylius.ui.shipping'|trans }}:
- {% for adjustment in order.adjustments(shippingAdjustment) %} -
-
{{ money.format(adjustment.amount, order.currencyCode) }}
-
-
- {{ adjustment.label }}: -
-
-
- {% endfor %} -
- {% else %} -

{{ 'sylius.ui.no_shipping_charges'|trans }}

- {% endif %} - - {% if not orderShippingPromotions is empty %} - -
-
{{ 'sylius.ui.shipping_discount'|trans }}:
- {% for label, amount in orderShippingPromotions %} -
-
- {{ money.format(amount, order.currencyCode) }} -
-
- {% endfor %} -
- - {% endif %} - - {{ 'sylius.ui.shipping_total'|trans }}: - {{ money.format(order.shippingTotal, order.currencyCode) }} - - -{% include '@SetonoSyliusGiftCardPlugin/templates/bundles/SyliusAdminBundle/Order/Show/Summary/_totals.html.twig' %} - - - {{ 'sylius.ui.order_total'|trans }}: - {{ money.format(order.total, order.currencyCode) }} - - diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Product/Tab/_details.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Product/Tab/_details.html.twig deleted file mode 100644 index d386b12b..00000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/Product/Tab/_details.html.twig +++ /dev/null @@ -1,70 +0,0 @@ -{% from '@SyliusAdmin/Macro/translationForm.html.twig' import translationFormWithSlug %} - -
-

{{ 'sylius.ui.details'|trans }}

- -
- {{ form_errors(form) }} - -
-
-
- {{ form_row(form.code) }} - {{ form_row(form.enabled) }} - {{ form_row(form.giftCard) }} - {{ form_row(form.giftCardAmountConfigurable) }} - {% if product.simple %} - {{ form_row(form.variant.shippingRequired) }} - {% else %} - {{ form_row(form.options) }} - {{ form_row(form.variantSelectionMethod) }} - {% endif %} - - {# Nothing to see here. #} - -
-
-
- {{ form_row(form.channels) }} -
-
- {% if product.simple %} -
-
-

{{ 'sylius.ui.pricing'|trans }}

- {% include "@SyliusAdmin/Product/_channel_pricing.html.twig" with { product: product, variantForm: form.variant } only %} -
-
- {% endif %} - - {{ translationFormWithSlug(form.translations, '@SyliusAdmin/Product/_slugField.html.twig', product) }} - {% if product.simple %} - -
-
-

{{ 'sylius.ui.shipping'|trans }}

-
- {{ form_row(form.variant.shippingCategory) }} - {{ form_row(form.variant.width) }} - {{ form_row(form.variant.height) }} - {{ form_row(form.variant.depth) }} - {{ form_row(form.variant.weight) }} -
-
-
-

{{ 'sylius.ui.taxes'|trans }}

-
- {{ form_row(form.variant.taxCategory) }} -
-
-
- {% endif %} - - {{ sylius_template_event(['sylius.admin.product.' ~ action ~ '.tab_details', 'sylius.admin.product.tab_details'], {'form': form}) }} -
-
diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/_logo.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/_logo.html.twig deleted file mode 100644 index 1b65d7f2..00000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/_logo.html.twig +++ /dev/null @@ -1,5 +0,0 @@ - -
- Sylius -
-
diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig deleted file mode 100644 index f5f98358..00000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ encore_entry_script_tags('admin-entry', null, 'admin') }} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig deleted file mode 100644 index a96144cd..00000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ encore_entry_link_tags('admin-entry', null, 'admin') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Cart/Summary/_items.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Cart/Summary/_items.html.twig deleted file mode 100644 index c3aff79c..00000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/Cart/Summary/_items.html.twig +++ /dev/null @@ -1,36 +0,0 @@ -
- {{ form_start(form, {'action': path('sylius_shop_cart_save'), 'attr': {'class': 'ui loadable form', 'novalidate': 'novalidate', 'id': form.vars.id}}) }} - {{ form_errors(form) }} - - {{ form_row(form._token) }} - {{ form_end(form, {'render_rest': false}) }} - - {{ sylius_template_event('sylius.shop.cart.summary.items', {'cart': cart, 'form': form}) }} - - - - - - - - - - - - - {% for key, item in cart.items %} - {% include '@SyliusShop/Cart/Summary/_item.html.twig' with {'item': item, 'form': form.items[key], 'main_form': form.vars.id, 'loop_index': loop.index} %} - {% endfor %} - -
{{ 'sylius.ui.item'|trans }}{{ 'sylius.ui.unit_price'|trans }}{{ 'sylius.ui.qty'|trans }}{{ 'sylius.ui.total'|trans }}
- {% if form.promotionCoupon is defined %} - - - {{ sylius_template_event('sylius.shop.cart.coupon', {'cart': cart, 'form': form, 'main_form': form.vars.id}) }} - - {% endif %} - - {% include '@SetonoSyliusGiftCardPlugin/Cart/_giftCard.html.twig' with {'order': cart} %} - - {% include '@SyliusShop/Cart/Summary/_update.html.twig' with {'main_form': form.vars.id} %} -
diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Cart/Summary/_totals.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Cart/Summary/_totals.html.twig deleted file mode 100644 index 2f1d93ad..00000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/Cart/Summary/_totals.html.twig +++ /dev/null @@ -1,67 +0,0 @@ -{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} - -{% set itemsSubtotal = sylius_order_items_subtotal(cart) %} -{% set taxIncluded = sylius_order_tax_included(cart) %} -{% set taxExcluded = sylius_order_tax_excluded(cart) %} - -
-

{{ 'sylius.ui.summary'|trans }}

- - {{ sylius_template_event('sylius.shop.cart.summary.totals', {'cart': cart}) }} - - - - - - - - {% if cart.orderPromotionTotal %} - - - - - {% endif %} - {% include '@SetonoSyliusGiftCardPlugin/templates/bundles/SyliusShopBundle/Cart/Summary/_totals.html.twig' %} - {% if cart.shipments is not empty %} - - - - - {% endif %} - - - - - - - - - {% if cart.currencyCode is not same as(sylius.currencyCode) %} - - - - - {% endif %} - -
{{ 'sylius.ui.items_total'|trans }}:{{ money.convertAndFormat(itemsSubtotal) }}
{{ 'sylius.ui.discount'|trans }}:{{ money.convertAndFormat(cart.orderPromotionTotal) }}
{{ 'sylius.ui.shipping_estimated_cost'|trans }}: - {% if cart.getAdjustmentsTotal('shipping') > cart.shippingTotal %} - {{ money.convertAndFormat(cart.getAdjustmentsTotal('shipping')) }} - {% endif %} - {{ money.convertAndFormat(cart.shippingTotal) }} -
{{ 'sylius.ui.taxes_total'|trans }}: - {% if not taxIncluded and not taxExcluded %} -
{{ money.convertAndFormat(0) }}
- {% endif %} - {% if taxExcluded %} -
{{ money.convertAndFormat(taxExcluded) }}
- {% endif %} - {% if taxIncluded %} -
- ({{ 'sylius.ui.included_in_price'|trans }}) - {{ money.convertAndFormat(taxIncluded) }} -
- {% endif %} -
{{ 'sylius.ui.order_total'|trans }}:{{ money.convertAndFormat(cart.total) }}
{{ 'sylius.ui.base_currency_order_total'|trans }}:{{ money.format(cart.total, cart.currencyCode) }}
-
- -{% include '@SetonoSyliusGiftCardPlugin/templates/bundles/SyliusShopBundle/Cart/summary.html.twig' %} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Cart/summary.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Cart/summary.html.twig deleted file mode 100644 index bb44ee4e..00000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/Cart/summary.html.twig +++ /dev/null @@ -1,31 +0,0 @@ -{# @see https://symfony.com/blog/new-in-symfony-3-4-improved-the-overriding-of-templates#overriding-and-extending-templates #} -{% extends '@!SyliusShop/Cart/summary.html.twig' %} -{% import '@SyliusUi/Macro/messages.html.twig' as messages %} - -{% block content %} - {% if not cart.empty %} - {{ sylius_template_event('sylius.shop.cart.header', {'header': header, 'cart': cart}) }} -
-
- {{ sylius_template_event('sylius.shop.cart.items', {'cart': cart, 'form': form}) }} -
-
- {{ sylius_template_event('sylius.shop.cart.summary', {'cart': cart}) }} -
-
- {{ sylius_template_event('sylius.shop.cart.suggestions', {'cart': cart}) }} - {% else %} - {{ messages.info('sylius.ui.your_cart_is_empty') }} - {% endif %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Checkout/_summary.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Checkout/_summary.html.twig deleted file mode 100644 index 4e544208..00000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/Checkout/_summary.html.twig +++ /dev/null @@ -1,89 +0,0 @@ -{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} - -{% set itemsSubtotal = sylius_order_items_subtotal(order) %} -{% set taxIncluded = sylius_order_tax_included(order) %} -{% set taxExcluded = sylius_order_tax_excluded(order) %} - -
- - - - - - - - - - {% for item in order.items %} - - - - - - {% endfor %} - - - - - - - - - - - {% include '@SetonoSyliusGiftCardPlugin/templates/bundles/SyliusShopBundle/Checkout/_summary.html.twig' %} - - - - - {% if order.shipments is not empty %} - - - - - {% endif %} - - - - - -
{{ 'sylius.ui.item'|trans }}{{ 'sylius.ui.qty'|trans }}{{ 'sylius.ui.subtotal'|trans }}
{{ item.getVariant.product.name }} - {{ item.quantity }} - - {{ money.convertAndFormat(item.subtotal) }} -
- {{ 'sylius.ui.items_total'|trans }}: - - {{ money.convertAndFormat(itemsSubtotal) }} -
- {{ 'sylius.ui.taxes_total'|trans }}: - - {% if not taxIncluded and not taxExcluded %} -
{{ money.convertAndFormat(0) }}
- {% endif %} - {% if taxExcluded %} -
{{ money.convertAndFormat(taxExcluded) }}
- {% endif %} - {% if taxIncluded %} -
- {{ money.convertAndFormat(taxIncluded) }} -
({{ 'sylius.ui.included_in_price'|trans }})
-
- {% endif %} -
- {{ 'sylius.ui.discount'|trans }}: - - {{ money.convertAndFormat(order.orderPromotionTotal) }} -
- {{ 'sylius.ui.shipping_estimated_cost'|trans }}: - - {% if order.getAdjustmentsTotal('shipping') > order.shippingTotal %} -
{{ money.convertAndFormat(order.getAdjustmentsTotal('shipping')) }}
- {% endif %} - {{ money.convertAndFormat(order.shippingTotal) }} -
- {{ 'sylius.ui.order_total'|trans }}: - - {{ money.convertAndFormat(order.total) }} -
-
diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Common/Order/Table/_totals.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Common/Order/Table/_totals.html.twig deleted file mode 100644 index 07a23642..00000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/Common/Order/Table/_totals.html.twig +++ /dev/null @@ -1,64 +0,0 @@ -{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} - -{% set itemsSubtotal = sylius_order_items_subtotal(order) %} -{% set taxIncluded = sylius_order_tax_included(order) %} -{% set taxExcluded = sylius_order_tax_excluded(order) %} - -{% set orderPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT') %} -{% set orderPromotions = sylius_aggregate_adjustments(order.adjustmentsRecursively(orderPromotionAdjustment)) %} - - - - {{ 'sylius.ui.items_total'|trans }}: {{ money.convertAndFormat(itemsSubtotal) }} - - - - -
-
{{ 'sylius.ui.taxes_total'|trans }}: 
-
- {% if not taxIncluded and not taxExcluded %} -
{{ money.convertAndFormat(0) }}
- {% endif %} - {% if taxExcluded %} -
{{ money.convertAndFormat(taxExcluded) }}
- {% endif %} - {% if taxIncluded %} -
- ({{ 'sylius.ui.included_in_price'|trans }}) - {{ money.convertAndFormat(taxIncluded) }} -
- {% endif %} -
-
- - - - - {{ 'sylius.ui.discount'|trans }}: {{ money.convertAndFormat(order.orderPromotionTotal) }} - {% if order.orderPromotionTotal != 0 %} - - - {% endif %} - - -{% include '@SetonoSyliusGiftCardPlugin/templates/bundles/SyliusShopBundle/Common/Order/Table/_totals.html.twig' %} - - {% include '@SyliusShop/Common/Order/Table/_shipping.html.twig' with {'order': order} %} - - - - {{ 'sylius.ui.total'|trans }}: {{ money.convertAndFormat(order.total) }} - - -{% if order.currencyCode is not same as(sylius.currencyCode) %} - - - {{ 'sylius.ui.total_in_base_currency'|trans }}: {{ money.format(order.total, order.currencyCode) }} - - -{% endif %} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig deleted file mode 100644 index bb594f7a..00000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig +++ /dev/null @@ -1,2 +0,0 @@ -Sylius - diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Footer/Grid/_plus.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Layout/Footer/Grid/_plus.html.twig deleted file mode 100644 index 0bf5a064..00000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Footer/Grid/_plus.html.twig +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig deleted file mode 100644 index 39110d6d..00000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Taxon/_horizontalMenu.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Taxon/_horizontalMenu.html.twig deleted file mode 100644 index 6df10378..00000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/Taxon/_horizontalMenu.html.twig +++ /dev/null @@ -1,25 +0,0 @@ -{% macro item(taxon) %} - {% import _self as macros %} - - {% if taxon.children|length > 0 %} - - {% else %} - {{ taxon.name }} - {% endif %} -{% endmacro %} - -{% import _self as macros %} - -{% if taxons|length > 0 %} - {% for taxon in taxons %} - {{ macros.item(taxon) }} - {% endfor %} -{% endif %} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig deleted file mode 100644 index d1655bb9..00000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ encore_entry_script_tags('shop-entry', null, 'shop') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig deleted file mode 100644 index fd2c7cb4..00000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ encore_entry_link_tags('shop-entry', null, 'shop') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/layout.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/layout.html.twig deleted file mode 100644 index 637479d9..00000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/layout.html.twig +++ /dev/null @@ -1,18 +0,0 @@ -{# @see https://symfony.com/blog/new-in-symfony-3-4-improved-the-overriding-of-templates#overriding-and-extending-templates #} -{% extends '@!SyliusShop/layout.html.twig' %} - -{% block header %} -
- {% include '@SyliusShop/_header.html.twig' %} - - {{ sylius_template_event('sylius.shop.layout.after_header') }} - - -
-{% endblock %} diff --git a/tests/Application/translations/.gitignore b/tests/Application/translations/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/Application/var/.gitignore b/tests/Application/var/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/Application/webpack.config.js b/tests/Application/webpack.config.js deleted file mode 100644 index fae14296..00000000 --- a/tests/Application/webpack.config.js +++ /dev/null @@ -1,47 +0,0 @@ -const path = require('path'); -const Encore = require('@symfony/webpack-encore'); - -const syliusBundles = path.resolve(__dirname, '../../vendor/sylius/sylius/src/Sylius/Bundle/'); -const uiBundleScripts = path.resolve(syliusBundles, 'UiBundle/Resources/private/js/'); -const uiBundleResources = path.resolve(syliusBundles, 'UiBundle/Resources/private/'); - -// Shop config -Encore - .setOutputPath('public/build/shop/') - .setPublicPath('/build/shop') - .addEntry('shop-entry', './assets/shop/entry.js') - .disableSingleRuntimeChunk() - .cleanupOutputBeforeBuild() - .enableSourceMaps(!Encore.isProduction()) - .enableVersioning(Encore.isProduction()) - .enableSassLoader(); - -const shopConfig = Encore.getWebpackConfig(); - -shopConfig.resolve.alias['sylius/ui'] = uiBundleScripts; -shopConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources; -shopConfig.resolve.alias['sylius/bundle'] = syliusBundles; -shopConfig.name = 'shop'; - -Encore.reset(); - -// Admin config -Encore - .setOutputPath('public/build/admin/') - .setPublicPath('/build/admin') - .addEntry('admin-entry', './assets/admin/entry.js') - .disableSingleRuntimeChunk() - .cleanupOutputBeforeBuild() - .enableSourceMaps(!Encore.isProduction()) - .enableVersioning(Encore.isProduction()) - .enableSassLoader(); - -const adminConfig = Encore.getWebpackConfig(); - -adminConfig.resolve.alias['sylius/ui'] = uiBundleScripts; -adminConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources; -adminConfig.resolve.alias['sylius/bundle'] = syliusBundles; -adminConfig.externals = Object.assign({}, adminConfig.externals, { window: 'window', document: 'document' }); -adminConfig.name = 'admin'; - -module.exports = [shopConfig, adminConfig]; diff --git a/tests/Behat/Context/Api/Admin/ManagingGiftCardConfigurationsContext.php b/tests/Behat/Context/Api/Admin/ManagingGiftCardConfigurationsContext.php deleted file mode 100644 index 2ef92e00..00000000 --- a/tests/Behat/Context/Api/Admin/ManagingGiftCardConfigurationsContext.php +++ /dev/null @@ -1,238 +0,0 @@ -client = $client; - $this->responseChecker = $responseChecker; - $this->iriConverter = $iriConverter; - } - - /** - * @When I browse gift card configurations - */ - public function iBrowseGiftCardConfigurations(): void - { - $this->client->index(); - } - - /** - * @When I want to create a new gift card configuration - */ - public function iWantToCreateGiftCardConfiguration(): void - { - $this->client->buildCreateRequest(); - } - - /** - * @When I want to update gift card configuration :code - */ - public function iWantToUpdateGiftCardConfiguration(string $code): void - { - $this->client->buildUpdateRequest($code); - } - - /** - * @When /^I associate gift card configuration ([^"]+) to (channel "[^"]+") and locale ([^"]+)$/ - */ - public function iAssociateGiftCardConfigurationToChannelAndLocale( - string $code, - ChannelInterface $channel, - string $localeCode, - ): void { - $request = Request::customItemAction( - 'admin', - 'gift-card-configurations', - $code, - HTTPRequest::METHOD_PATCH, - 'associate-channel', - ); - - $request->setContent([ - 'localeCode' => $localeCode, - 'channelCode' => $channel->getCode(), - ]); - - $this->client->executeCustomRequest($request); - } - - /** - * @When I (try to) add it - */ - public function iAddIt(): void - { - $this->client->create(); - } - - /** - * @When I save my changes - */ - public function iSaveMyChanges(): void - { - $this->client->update(); - } - - /** - * @When I delete gift card configuration :code - */ - public function iDeleteGiftCardConfiguration(string $code): void - { - $this->client->delete($code); - } - - /** - * @Then /^I should see a gift card configuration with code "([^"]+)"$/ - */ - public function iShouldSeeGiftCardConfiguration(string $code): void - { - $response = $this->client->show($code); - - Assert::same($this->responseChecker->getValue($response, 'code'), $code); - } - - /** - * @Then /^I should not see a gift card configuration with code "([^"]+)"$/ - */ - public function iShouldNotSeeGiftCardConfiguration(string $code): void - { - $response = $this->client->index(); - - Assert::false( - $this->responseChecker->hasItemWithValue($response, 'code', $code), - sprintf('Gift card configuration with code %s still exists, but it should not', $code), - ); - } - - /** - * @When I specify its code as :code - */ - public function iSpecifyItsCodeAs(string $code): void - { - $this->client->addRequestData('code', $code); - } - - /** - * @When I enable it - */ - public function iEnableIt(): void - { - $this->client->addRequestData('enabled', true); - } - - /** - * @When I disable it - */ - public function iDisableIt(): void - { - $this->client->addRequestData('enabled', false); - } - - /** - * @When I specify it as default configuration - */ - public function iSpecifyItAsDefaultConfiguration(): void - { - $this->client->addRequestData('default', true); - } - - /** - * @Then It should be enabled - */ - public function itShouldBeEnabled(): void - { - $response = $this->client->getLastResponse(); - - Assert::true($this->responseChecker->getValue($response, 'enabled')); - } - - /** - * @Then It should not be enabled - * @Then It should be disabled - */ - public function itShouldNotBeEnabled(): void - { - $response = $this->client->getLastResponse(); - - Assert::false($this->responseChecker->getValue($response, 'enabled')); - } - - /** - * @Then It should be default configuration - */ - public function itShouldBeDefaultConfiguration(): void - { - $response = $this->client->getLastResponse(); - - Assert::true($this->responseChecker->getValue($response, 'default')); - } - - /** - * @Then It should not be default configuration - */ - public function itShouldNotBeDefaultConfiguration(): void - { - $response = $this->client->getLastResponse(); - - Assert::false($this->responseChecker->getValue($response, 'default')); - } - - /** - * @Then /^It should have channel configuration for (channel "[^"]+") and locale ([^"]+)$/ - */ - public function itShouldHave(ChannelInterface $channel, string $localeCode): void - { - $response = $this->client->getLastResponse(); - - $channelConfigurations = $this->responseChecker->getValue($response, 'channelConfigurations'); - Assert::same($channelConfigurations[0]['channel'], $this->iriConverter->getIriFromItem($channel)); - Assert::same($channelConfigurations[0]['locale'], $this->iriConverter->getIriFromResourceClass(Locale::class) . '/' . $localeCode); - } - - /** - * @Then I should be notified that it has been successfully created - */ - public function iShouldBeNotifiedThatItHasBeenSuccessfullyCreated(): void - { - Assert::true($this->responseChecker->isCreationSuccessful($this->client->getLastResponse())); - } - - /** - * @Then I should be notified that it has been successfully updated - */ - public function iShouldBeNotifiedThatItHasBeenSuccessfullyUpdated(): void - { - Assert::true($this->responseChecker->isUpdateSuccessful($this->client->getLastResponse())); - } - - /** - * @Then I should be notified that it has been successfully deleted - */ - public function iShouldBeNotifiedThatItHasBeenSuccessfullyDelete(): void - { - Assert::true($this->responseChecker->isDeletionSuccessful($this->client->getLastResponse())); - } -} diff --git a/tests/Behat/Context/Api/Admin/ManagingGiftCardsBalanceContext.php b/tests/Behat/Context/Api/Admin/ManagingGiftCardsBalanceContext.php deleted file mode 100644 index dfe97e19..00000000 --- a/tests/Behat/Context/Api/Admin/ManagingGiftCardsBalanceContext.php +++ /dev/null @@ -1,53 +0,0 @@ -client = $client; - $this->responseChecker = $responseChecker; - } - - /** - * @When I browse gift cards balance - */ - public function iBrowseGiftCardsBalance(): void - { - $this->client->index(); - } - - /** - * @Then /^I should see a gift card balance of ("[^"]+") in ("[^"]+" currency)$/ - */ - public function iShouldSeeGiftCardPricedAtForCustomer(int $price, CurrencyInterface $currency): void - { - $response = $this->client->getLastResponse(); - - $items = $this->responseChecker->getCollection($response); - foreach ($items as $item) { - if ($item['total'] === $price) { - Assert::same($item['currencyCode'], $currency->getCode()); - - return; - } - } - - Assert::false(true); - } -} diff --git a/tests/Behat/Context/Api/Admin/ManagingGiftCardsContext.php b/tests/Behat/Context/Api/Admin/ManagingGiftCardsContext.php deleted file mode 100644 index 4139c661..00000000 --- a/tests/Behat/Context/Api/Admin/ManagingGiftCardsContext.php +++ /dev/null @@ -1,244 +0,0 @@ -client = $client; - $this->responseChecker = $responseChecker; - $this->iriConverter = $iriConverter; - } - - /** - * @When I browse gift cards - */ - public function iBrowseGiftCards(): void - { - $this->client->index(); - } - - /** - * @When I want to create a new gift card - */ - public function iWantToCreateGiftCard(): void - { - $this->client->buildCreateRequest(); - } - - /** - * @When I (try to) add it - */ - public function iAddIt(): void - { - $this->client->create(); - } - - /** - * @When I open the gift card :code page - */ - public function iOpenGiftCardPage(string $code): void - { - $this->client->show($code); - } - - /** - * @When I want to edit the gift card :code - */ - public function iWantToEditGiftCard(string $code): void - { - $this->client->buildUpdateRequest($code); - } - - /** - * @When I save my changes - */ - public function iSaveMyChanges(): void - { - $this->client->update(); - } - - /** - * @When I delete the gift card :code - */ - public function iDeleteGiftCard(string $code): void - { - $this->client->delete($code); - } - - /** - * @Then /^I should see a gift card with code "([^"]+)" valued at ("[^"]+")$/ - * @Then /^I should see a gift card with code "([^"]+)" valued at ("[^"]+") associated to the customer "([^"]+)"$/ - */ - public function iShouldSeeGiftCardPricedAtForCustomer(string $code, int $price, string $customerEmail = null): void - { - $response = $this->client->show($code); - - $giftCardPrice = $this->responseChecker->getValue($response, 'amount'); - Assert::same($price, $giftCardPrice); - - if (null !== $customerEmail) { - $giftCardCustomer = $this->responseChecker->getValue($response, 'customer'); - Assert::same($customerEmail, $giftCardCustomer['email']); - } - } - - /** - * @Then this gift card should have api origin - */ - public function giftCardShouldHaveAPIOrigin(): void - { - $response = $this->client->getLastResponse(); - - $origin = $this->responseChecker->getValue($response, 'origin'); - Assert::same(GiftCardInterface::ORIGIN_API, $origin); - } - - /** - * @Then /^I should no longer see a gift card with code "([^"]+)"$/ - */ - public function iShouldNotSeeGiftCard(string $code): void - { - $response = $this->client->index(); - - Assert::false( - $this->responseChecker->hasItemWithValue($response, 'code', $code), - sprintf('Gift card with code %s still exists, but it should not', $code), - ); - } - - /** - * @When I do not specify its customer - * @When I specify its customer as :customer - */ - public function iSpecifyItsCustomerAs(?CustomerInterface $customer = null): void - { - $this->client->addRequestData('customer', null !== $customer ? $this->iriConverter->getIriFromItem($customer) : null); - } - - /** - * @When I specify its code as :code - */ - public function iSpecifyItsCodeAs(string $code): void - { - $this->client->addRequestData('code', $code); - } - - /** - * @When /^I specify its amount as ("[^"]+")$/ - */ - public function iSpecifyItsAmountAs(string $amount): void - { - $this->client->addRequestData('amount', (int) $amount); - } - - /** - * @When I specify its currency code as :currency - */ - public function iSpecifyItsCurrencyCodeAs(string $currencyCode): void - { - $this->client->addRequestData('currencyCode', $currencyCode); - } - - /** - * @When I specify its channel as :channel - */ - public function iSpecifyItsChannelAs(ChannelInterface $channel): void - { - $this->client->addRequestData('channel', $this->iriConverter->getIriFromItem($channel)); - } - - /** - * @When I disable it - */ - public function iDisableIt(): void - { - $this->client->addRequestData('enabled', false); - } - - /** - * @Then I should be notified that it has been successfully created - */ - public function iShouldBeNotifiedThatItHasBeenSuccessfullyCreated(): void - { - Assert::true($this->responseChecker->isCreationSuccessful($this->client->getLastResponse())); - } - - /** - * @Then I should be notified that it has been successfully updated - */ - public function iShouldBeNotifiedThatItHasBeenSuccessfullyUpdated(): void - { - Assert::true($this->responseChecker->isUpdateSuccessful($this->client->getLastResponse())); - } - - /** - * @Then I should be notified that it has been successfully deleted - */ - public function iShouldBeNotifiedThatItHasBeenSuccessfullyDelete(): void - { - Assert::true($this->responseChecker->isDeletionSuccessful($this->client->getLastResponse())); - } - - /** - * @Then /^It should be valued at ("[^"]+")$/ - */ - public function itShouldBeValuedAt(int $amount): void - { - Assert::same($this->responseChecker->getValue($this->client->getLastResponse(), 'amount'), $amount); - } - - /** - * @Then /^It should be initially valued at ("[^"]+")$/ - */ - public function itShouldBeInitiallyValuedAt(int $amount): void - { - Assert::same($this->responseChecker->getValue($this->client->getLastResponse(), 'initialAmount'), $amount); - } - - /** - * @Then It should be on channel :channel - */ - public function itShouldBeOnChannel(ChannelInterface $channel): void - { - Assert::same($this->responseChecker->getValue($this->client->getLastResponse(), 'channel')['code'], $channel->getCode()); - } - - /** - * @Then It should have :currency currency - */ - public function itShouldHaveCurrency(CurrencyInterface $currency): void - { - Assert::same($this->responseChecker->getValue($this->client->getLastResponse(), 'currencyCode'), $currency->getCode()); - } - - /** - * @Then It should be disabled - */ - public function itShouldBeDisabled(): void - { - Assert::same($this->responseChecker->getValue($this->client->getLastResponse(), 'enabled'), false); - } -} diff --git a/tests/Behat/Context/Api/Shop/CartContext.php b/tests/Behat/Context/Api/Shop/CartContext.php deleted file mode 100644 index f4f9f05d..00000000 --- a/tests/Behat/Context/Api/Shop/CartContext.php +++ /dev/null @@ -1,73 +0,0 @@ -cartsClient = $cartsClient; - $this->responseChecker = $responseChecker; - $this->sharedStorage = $sharedStorage; - $this->productVariantResolver = $productVariantResolver; - $this->iriConverter = $iriConverter; - } - - /** - * @When /^I add (this product) to the cart with amount ("[^"]+") and custom message "([^"]+)"$/ - */ - public function iAddProductWithAmountAndMessage(ProductInterface $product, int $amount, string $message): void - { - $tokenValue = $tokenValue ?? $this->pickupCart(); - - $request = Request::customItemAction('shop', 'orders', $tokenValue, HttpRequest::METHOD_PATCH, 'items'); - - $request->updateContent([ - 'productVariant' => $this->productVariantResolver->getVariant($product)->getCode(), - 'quantity' => 1, - 'amount' => $amount, - 'customMessage' => $message, - ]); - - $this->cartsClient->executeCustomRequest($request); - } - - private function pickupCart(): string - { - $this->cartsClient->buildCreateRequest(); - $this->cartsClient->addRequestData('localeCode', null); - - $tokenValue = $this->responseChecker->getValue($this->cartsClient->create(), 'tokenValue'); - - $this->sharedStorage->set('cart_token', $tokenValue); - - return $tokenValue; - } -} diff --git a/tests/Behat/Context/Api/Shop/ManagingGiftCardsContext.php b/tests/Behat/Context/Api/Shop/ManagingGiftCardsContext.php deleted file mode 100644 index ee4f8777..00000000 --- a/tests/Behat/Context/Api/Shop/ManagingGiftCardsContext.php +++ /dev/null @@ -1,159 +0,0 @@ -client = $client; - $this->responseChecker = $responseChecker; - $this->sharedStorage = $sharedStorage; - } - - /** - * @When I browse gift cards - */ - public function iBrowseGiftCards(): void - { - $this->client->index(); - } - - /** - * @When I open the gift card :code page - */ - public function iOpenGiftCardPage(string $code): void - { - $this->client->show($code); - } - - /** - * @Given I apply gift card with code :code - */ - public function iApplyGiftCardToOrder(string $code): void - { - $this->applyGiftCardToOrder($code); - } - - /** - * @Given I remove gift card with code :code - */ - public function iRemoveGiftCardFromOrder(string $code): void - { - $this->removeGiftCardFromOrder($code); - } - - /** - * @Then /^Gift cards list should contain a gift card with code "([^"]+)"$/ - */ - public function giftCardsListShouldContain(string $code): void - { - $response = $this->client->index(); - - Assert::notEmpty($this->responseChecker->getCollectionItemsWithValue($response, 'code', $code)); - } - - /** - * @Then /^Gift cards list should not contain a gift card with code "([^"]+)"$/ - */ - public function giftCardsListShouldNotContain(string $code): void - { - $response = $this->client->index(); - - Assert::isEmpty($this->responseChecker->getCollectionItemsWithValue($response, 'code', $code)); - } - - /** - * @Then /^It should be valued at ("[^"]+")$/ - */ - public function itShouldBeValuedAt(int $amount): void - { - Assert::same($this->responseChecker->getValue($this->client->getLastResponse(), 'amount'), $amount); - } - - /** - * @Then /^It should be initially valued at ("[^"]+")$/ - */ - public function itShouldBeInitiallyValuedAt(int $amount): void - { - Assert::same($this->responseChecker->getValue($this->client->getLastResponse(), 'initialAmount'), $amount); - } - - /** - * @Then It should have :currency currency - */ - public function itShouldHaveCurrency(CurrencyInterface $currency): void - { - Assert::same($this->responseChecker->getValue($this->client->getLastResponse(), 'currencyCode'), $currency->getCode()); - } - - /** - * @Then the gift card :code should be disabled - */ - public function theGiftCardShouldBeDisabled(string $code): void - { - $this->client->show($code); - - Assert::same($this->responseChecker->getValue($this->client->getLastResponse(), 'enabled'), false); - } - - /** - * @Then the gift card :code should (still) be enabled - */ - public function theGiftCardShouldBeEnabled(string $code): void - { - $this->client->show($code); - - Assert::same($this->responseChecker->getValue($this->client->getLastResponse(), 'enabled'), true); - } - - private function applyGiftCardToOrder(string $giftCardCode): void - { - $request = Request::customItemAction( - 'shop', - 'gift-cards', - $giftCardCode, - HTTPRequest::METHOD_PATCH, - 'add-to-order', - ); - - $request->setContent(['orderTokenValue' => $this->sharedStorage->get('cart_token')]); - - $this->client->executeCustomRequest($request); - } - - private function removeGiftCardFromOrder(string $giftCardCode): void - { - $request = Request::customItemAction( - 'shop', - 'gift-cards', - $giftCardCode, - HTTPRequest::METHOD_PATCH, - 'remove-from-order', - ); - - $request->setContent(['orderTokenValue' => $this->sharedStorage->get('cart_token')]); - - $this->client->executeCustomRequest($request); - } -} diff --git a/tests/Behat/Context/Setup/GiftCardContext.php b/tests/Behat/Context/Setup/GiftCardContext.php index 4c751f63..df0a4b87 100644 --- a/tests/Behat/Context/Setup/GiftCardContext.php +++ b/tests/Behat/Context/Setup/GiftCardContext.php @@ -6,14 +6,16 @@ use Behat\Behat\Context\Context; use Doctrine\Persistence\ObjectManager; -use Setono\SyliusGiftCardPlugin\Api\Command\AddGiftCardToOrder; +use Setono\SyliusGiftCardPlugin\Applicator\GiftCardApplicatorInterface; use Setono\SyliusGiftCardPlugin\Factory\GiftCardFactoryInterface; +use Setono\SyliusGiftCardPlugin\Model\OrderInterface; use Setono\SyliusGiftCardPlugin\Model\ProductInterface; use Setono\SyliusGiftCardPlugin\Repository\GiftCardRepositoryInterface; +use Setono\SyliusGiftCardPlugin\Repository\OrderRepositoryInterface; use Sylius\Behat\Service\SharedStorageInterface; use Sylius\Component\Core\Model\ChannelInterface; use Sylius\Component\Core\Model\CustomerInterface; -use Symfony\Component\Messenger\MessageBusInterface; +use Webmozart\Assert\Assert; final class GiftCardContext implements Context { @@ -25,20 +27,24 @@ final class GiftCardContext implements Context private ObjectManager $productManager; - private MessageBusInterface $messageBus; + private OrderRepositoryInterface $orderRepository; + + private GiftCardApplicatorInterface $giftCardApplicator; public function __construct( SharedStorageInterface $sharedStorage, GiftCardRepositoryInterface $giftCardRepository, GiftCardFactoryInterface $giftCardFactory, ObjectManager $productManager, - MessageBusInterface $messageBus, + OrderRepositoryInterface $orderRepository, + GiftCardApplicatorInterface $giftCardApplicator, ) { $this->sharedStorage = $sharedStorage; $this->giftCardRepository = $giftCardRepository; $this->giftCardFactory = $giftCardFactory; $this->productManager = $productManager; - $this->messageBus = $messageBus; + $this->orderRepository = $orderRepository; + $this->giftCardApplicator = $giftCardApplicator; } /** @@ -116,8 +122,11 @@ public function theStoreHasGiftCardWithCodeForCustomer( public function iApplyGiftCardToOrder(string $code): void { $cartToken = $this->sharedStorage->get('cart_token'); - $message = new AddGiftCardToOrder($cartToken); - $message->setGiftCardCode($code); - $this->messageBus->dispatch($message); + + /** @var OrderInterface|null $order */ + $order = $this->orderRepository->findOneBy(['tokenValue' => $cartToken]); + Assert::notNull($order); + + $this->giftCardApplicator->apply($order, $code); } } diff --git a/tests/Behat/Page/Admin/Product/CreateSimpleProductPage.php b/tests/Behat/Page/Admin/Product/CreateSimpleProductPage.php index 5cb66e32..902ac270 100644 --- a/tests/Behat/Page/Admin/Product/CreateSimpleProductPage.php +++ b/tests/Behat/Page/Admin/Product/CreateSimpleProductPage.php @@ -16,7 +16,7 @@ public function specifyGiftCard(bool $val): void protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'gift_card' => '#sylius_product_giftCard', + 'gift_card' => '#sylius_admin_product_giftCard', ]); } } diff --git a/tests/Behat/Resources/api.xml b/tests/Behat/Resources/api.xml deleted file mode 100644 index 1a7616ae..00000000 --- a/tests/Behat/Resources/api.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - diff --git a/tests/Behat/Resources/api/clients.xml b/tests/Behat/Resources/api/clients.xml deleted file mode 100644 index bf39b963..00000000 --- a/tests/Behat/Resources/api/clients.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - gift-card-configurations - admin - - - - gift-cards - admin - - - - gift-cards/balance - admin - - - - - gift-cards - shop - - - diff --git a/tests/Behat/Resources/context/api.xml b/tests/Behat/Resources/context/api.xml deleted file mode 100644 index c288acde..00000000 --- a/tests/Behat/Resources/context/api.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/Behat/Resources/context/setup.xml b/tests/Behat/Resources/context/setup.xml index 843ff317..265ff9fa 100644 --- a/tests/Behat/Resources/context/setup.xml +++ b/tests/Behat/Resources/context/setup.xml @@ -17,7 +17,8 @@ - + + diff --git a/tests/Behat/Resources/contexts.xml b/tests/Behat/Resources/contexts.xml index 08adb3d6..3b4b5538 100644 --- a/tests/Behat/Resources/contexts.xml +++ b/tests/Behat/Resources/contexts.xml @@ -3,7 +3,6 @@ - diff --git a/tests/Behat/Resources/page/admin.xml b/tests/Behat/Resources/page/admin.xml index 64d973eb..fdc2d236 100644 --- a/tests/Behat/Resources/page/admin.xml +++ b/tests/Behat/Resources/page/admin.xml @@ -7,6 +7,7 @@ class="Setono\SyliusGiftCardPlugin\Tests\Behat\Page\Admin\Product\CreateSimpleProductPage" parent="sylius.behat.page.admin.crud.create" public="false"> setono_sylius_gift_card_admin_product_create_gift_card + diff --git a/tests/Behat/Resources/services.xml b/tests/Behat/Resources/services.xml index 4ada45d2..1e04458f 100644 --- a/tests/Behat/Resources/services.xml +++ b/tests/Behat/Resources/services.xml @@ -3,7 +3,6 @@ - diff --git a/tests/Behat/Resources/suites.yml b/tests/Behat/Resources/suites.yml index 35a31110..b1ad8e87 100644 --- a/tests/Behat/Resources/suites.yml +++ b/tests/Behat/Resources/suites.yml @@ -2,10 +2,3 @@ imports: - suites/ui/managing_gift_cards.yml - suites/ui/buying_gift_card.yml - suites/ui/applying_gift_card.yml - - - suites/api/applying_gift_card.yml - - suites/api/buying_gift_card.yml - - suites/api/managing_gift_card_configurations.yml - - suites/api/managing_gift_cards.yml - - suites/api/managing_gift_cards_balance.yml - - suites/api/managing_shop_gift_cards.yml diff --git a/tests/Behat/Resources/suites/api/applying_gift_card.yml b/tests/Behat/Resources/suites/api/applying_gift_card.yml deleted file mode 100644 index 8d75473e..00000000 --- a/tests/Behat/Resources/suites/api/applying_gift_card.yml +++ /dev/null @@ -1,39 +0,0 @@ -default: - suites: - ui_applying_gift_card: - contexts: - - sylius.behat.context.hook.doctrine_orm - - - sylius.behat.context.transform.cart - - sylius.behat.context.transform.channel - - sylius.behat.context.transform.lexical - - sylius.behat.context.transform.locale - - sylius.behat.context.transform.order - - sylius.behat.context.transform.product - - sylius.behat.context.transform.shared_storage - - sylius.behat.context.transform.user - - - sylius.behat.context.setup.cart - - sylius.behat.context.setup.channel - - sylius.behat.context.setup.checkout - - sylius.behat.context.setup.customer - - sylius.behat.context.setup.locale - - sylius.behat.context.setup.payment - - sylius.behat.context.setup.product - - sylius.behat.context.setup.promotion - - sylius.behat.context.setup.shipping - - sylius.behat.context.setup.shop_api_security - - sylius.behat.context.setup.user - - sylius.behat.context.setup.zone - - - sylius.behat.context.api.shop.cart - - sylius.behat.context.api.shop.channel - - sylius.behat.context.api.shop.checkout - - sylius.behat.context.api.shop.order - - - setono_sylius_gift_card.behat.context.transform.gift_card - - setono_sylius_gift_card.behat.context.setup.gift_card - - - setono_sylius_gift_card.behat.context.api.shop.managing_gift_cards - filters: - tags: "@applying_gift_card && @api" diff --git a/tests/Behat/Resources/suites/api/buying_gift_card.yml b/tests/Behat/Resources/suites/api/buying_gift_card.yml deleted file mode 100644 index 3bf6cbc1..00000000 --- a/tests/Behat/Resources/suites/api/buying_gift_card.yml +++ /dev/null @@ -1,24 +0,0 @@ -default: - suites: - api_buying_gift_card: - contexts: - - sylius.behat.context.hook.doctrine_orm - - sylius.behat.context.hook.email_spool - - - sylius.behat.context.transform.lexical - - sylius.behat.context.transform.product - - sylius.behat.context.transform.shared_storage - - - sylius.behat.context.setup.channel - - sylius.behat.context.setup.payment - - sylius.behat.context.setup.product - - sylius.behat.context.setup.shop_security - - sylius.behat.context.setup.shipping - - - setono_sylius_gift_card.behat.context.setup.gift_card - - - sylius.behat.context.api.shop.cart - - - setono_sylius_gift_card.behat.context.api.shop.cart - filters: - tags: "@buying_gift_card && @api" diff --git a/tests/Behat/Resources/suites/api/managing_gift_card_configurations.yml b/tests/Behat/Resources/suites/api/managing_gift_card_configurations.yml deleted file mode 100644 index a10fb734..00000000 --- a/tests/Behat/Resources/suites/api/managing_gift_card_configurations.yml +++ /dev/null @@ -1,25 +0,0 @@ -default: - suites: - api_managing_gift_card_configurations: - contexts: - - sylius.behat.context.hook.doctrine_orm - - - sylius.behat.context.transform.lexical - - sylius.behat.context.transform.locale - - sylius.behat.context.transform.shared_storage - - sylius.behat.context.transform.channel - - sylius.behat.context.transform.currency - - sylius.behat.context.transform.customer - - - sylius.behat.context.setup.admin_api_security - - sylius.behat.context.setup.locale - - sylius.behat.context.setup.channel - - sylius.behat.context.setup.customer - - - setono_sylius_gift_card.behat.context.setup.gift_card_configuration - - setono_sylius_gift_card.behat.context.transform.gift_card_configuration - - - setono_sylius_gift_card.behat.context.api.admin.managing_gift_card_configurations - filters: - tags: "@managing_gift_card_configurations && @api" - javascript: false diff --git a/tests/Behat/Resources/suites/api/managing_gift_cards.yml b/tests/Behat/Resources/suites/api/managing_gift_cards.yml deleted file mode 100644 index bbae7769..00000000 --- a/tests/Behat/Resources/suites/api/managing_gift_cards.yml +++ /dev/null @@ -1,23 +0,0 @@ -default: - suites: - api_managing_gift_cards: - contexts: - - sylius.behat.context.hook.doctrine_orm - - - sylius.behat.context.transform.lexical - - sylius.behat.context.transform.shared_storage - - sylius.behat.context.transform.channel - - sylius.behat.context.transform.currency - - sylius.behat.context.transform.customer - - - sylius.behat.context.setup.admin_api_security - - sylius.behat.context.setup.channel - - sylius.behat.context.setup.customer - - - setono_sylius_gift_card.behat.context.setup.gift_card - - setono_sylius_gift_card.behat.context.transform.gift_card - - - setono_sylius_gift_card.behat.context.api.admin.managing_gift_cards - filters: - tags: "@managing_gift_cards && @api" - javascript: false diff --git a/tests/Behat/Resources/suites/api/managing_gift_cards_balance.yml b/tests/Behat/Resources/suites/api/managing_gift_cards_balance.yml deleted file mode 100644 index b3e9712e..00000000 --- a/tests/Behat/Resources/suites/api/managing_gift_cards_balance.yml +++ /dev/null @@ -1,21 +0,0 @@ -default: - suites: - api_managing_gift_cards_balance: - contexts: - - sylius.behat.context.hook.doctrine_orm - - - sylius.behat.context.transform.lexical - - sylius.behat.context.transform.shared_storage - - sylius.behat.context.transform.channel - - sylius.behat.context.transform.currency - - - sylius.behat.context.setup.admin_api_security - - sylius.behat.context.setup.channel - - sylius.behat.context.setup.currency - - - setono_sylius_gift_card.behat.context.setup.gift_card - - - setono_sylius_gift_card.behat.context.api.admin.managing_gift_cards_balance - filters: - tags: "@managing_gift_cards_balance && @api" - javascript: false diff --git a/tests/Behat/Resources/suites/api/managing_shop_gift_cards.yml b/tests/Behat/Resources/suites/api/managing_shop_gift_cards.yml deleted file mode 100644 index 1cbfae86..00000000 --- a/tests/Behat/Resources/suites/api/managing_shop_gift_cards.yml +++ /dev/null @@ -1,24 +0,0 @@ -default: - suites: - api_managing_shop_gift_cards: - contexts: - - sylius.behat.context.hook.doctrine_orm - - - sylius.behat.context.transform.lexical - - sylius.behat.context.transform.shared_storage - - sylius.behat.context.transform.channel - - sylius.behat.context.transform.currency - - sylius.behat.context.transform.customer - - - sylius.behat.context.setup.channel - - sylius.behat.context.setup.customer - - sylius.behat.context.setup.shop_api_security - - sylius.behat.context.setup.user - - - setono_sylius_gift_card.behat.context.setup.gift_card - - setono_sylius_gift_card.behat.context.transform.gift_card - - - setono_sylius_gift_card.behat.context.api.shop.managing_gift_cards - filters: - tags: "@managing_shop_gift_cards && @api" - javascript: false diff --git a/tests/Behat/Resources/suites/ui/buying_gift_card.yml b/tests/Behat/Resources/suites/ui/buying_gift_card.yml index 688fe450..1cdf73d1 100644 --- a/tests/Behat/Resources/suites/ui/buying_gift_card.yml +++ b/tests/Behat/Resources/suites/ui/buying_gift_card.yml @@ -3,7 +3,7 @@ default: ui_buying_gift_card: contexts: - sylius.behat.context.hook.doctrine_orm - - sylius.behat.context.hook.email_spool + - sylius.behat.context.hook.mailer - sylius.behat.context.transform.lexical - sylius.behat.context.transform.product diff --git a/tests/TestApplication/.env b/tests/TestApplication/.env new file mode 100644 index 00000000..608f18b3 --- /dev/null +++ b/tests/TestApplication/.env @@ -0,0 +1,13 @@ +DATABASE_URL=mysql://root@127.0.0.1/setono_sylius_gift_card_plugin_%kernel.environment% + +BEHAT_BASE_URL="https://127.0.0.1:8080/" +BEHAT_CHROME_URL="http://127.0.0.1:9222" + +# Default to the standard apt install location (used by CI); override +# locally if wkhtmltopdf/wkhtmltoimage live somewhere else (e.g. Docker). +KNP_SNAPPY_PDF_BINARY=/usr/bin/wkhtmltopdf +KNP_SNAPPY_IMAGE_BINARY=/usr/bin/wkhtmltoimage + +SYLIUS_TEST_APP_BUNDLES_REPLACE_PATH="tests/TestApplication/config/bundles.php" +SYLIUS_TEST_APP_CONFIGS_TO_IMPORT="../../../../tests/TestApplication/config/config.yaml" +SYLIUS_TEST_APP_ROUTES_TO_IMPORT="../../../../tests/TestApplication/config/routes.yaml" diff --git a/tests/Application/Model/Order.php b/tests/TestApplication/Entity/Order.php similarity index 84% rename from tests/Application/Model/Order.php rename to tests/TestApplication/Entity/Order.php index 3a482a03..26ef4c9d 100644 --- a/tests/Application/Model/Order.php +++ b/tests/TestApplication/Entity/Order.php @@ -2,18 +2,15 @@ declare(strict_types=1); -namespace Setono\SyliusGiftCardPlugin\Tests\Application\Model; +namespace Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity; use Doctrine\ORM\Mapping as ORM; use Setono\SyliusGiftCardPlugin\Model\OrderInterface as SetonoSyliusGiftCardOrderInterface; use Setono\SyliusGiftCardPlugin\Model\OrderTrait as SetonoSyliusGiftCardOrderTrait; use Sylius\Component\Core\Model\Order as BaseOrder; -/** - * @ORM\Entity - * - * @ORM\Table(name="sylius_order") - */ +#[ORM\Entity] +#[ORM\Table(name: 'sylius_order')] class Order extends BaseOrder implements SetonoSyliusGiftCardOrderInterface { use SetonoSyliusGiftCardOrderTrait { diff --git a/tests/Application/Model/OrderItem.php b/tests/TestApplication/Entity/OrderItem.php similarity index 74% rename from tests/Application/Model/OrderItem.php rename to tests/TestApplication/Entity/OrderItem.php index 6c27b5d4..b322c197 100644 --- a/tests/Application/Model/OrderItem.php +++ b/tests/TestApplication/Entity/OrderItem.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Setono\SyliusGiftCardPlugin\Tests\Application\Model; +namespace Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity; use Doctrine\ORM\Mapping as ORM; use Setono\SyliusGiftCardPlugin\Model\OrderItemTrait; @@ -10,12 +10,10 @@ use Sylius\Component\Core\Model\OrderItem as BaseOrderItem; /** - * @ORM\Entity - * - * @ORM\Table(name="sylius_order_item") - * * @method ProductInterface|null getProduct() */ +#[ORM\Entity] +#[ORM\Table(name: 'sylius_order_item')] class OrderItem extends BaseOrderItem { use OrderItemTrait; diff --git a/tests/Application/Model/OrderItemUnit.php b/tests/TestApplication/Entity/OrderItemUnit.php similarity index 78% rename from tests/Application/Model/OrderItemUnit.php rename to tests/TestApplication/Entity/OrderItemUnit.php index 390b0e61..fb1fcaf4 100644 --- a/tests/Application/Model/OrderItemUnit.php +++ b/tests/TestApplication/Entity/OrderItemUnit.php @@ -2,18 +2,15 @@ declare(strict_types=1); -namespace Setono\SyliusGiftCardPlugin\Tests\Application\Model; +namespace Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity; use Doctrine\ORM\Mapping as ORM; use Setono\SyliusGiftCardPlugin\Model\OrderItemUnitInterface as SetonoSyliusGiftCardOrderItemUnitInterface; use Setono\SyliusGiftCardPlugin\Model\OrderItemUnitTrait as SetonoSyliusGiftCardOrderItemUnitTrait; use Sylius\Component\Core\Model\OrderItemUnit as BaseOrderItemUnit; -/** - * @ORM\Entity - * - * @ORM\Table(name="sylius_order_item_unit") - */ +#[ORM\Entity] +#[ORM\Table(name: 'sylius_order_item_unit')] class OrderItemUnit extends BaseOrderItemUnit implements SetonoSyliusGiftCardOrderItemUnitInterface { use SetonoSyliusGiftCardOrderItemUnitTrait; diff --git a/tests/Application/Model/Product.php b/tests/TestApplication/Entity/Product.php similarity index 77% rename from tests/Application/Model/Product.php rename to tests/TestApplication/Entity/Product.php index 620639da..963c1415 100644 --- a/tests/Application/Model/Product.php +++ b/tests/TestApplication/Entity/Product.php @@ -2,18 +2,15 @@ declare(strict_types=1); -namespace Setono\SyliusGiftCardPlugin\Tests\Application\Model; +namespace Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity; use Doctrine\ORM\Mapping as ORM; use Setono\SyliusGiftCardPlugin\Model\ProductInterface as SetonoSyliusGiftCardProductInterface; use Setono\SyliusGiftCardPlugin\Model\ProductTrait as SetonoSyliusGiftCardProductTrait; use Sylius\Component\Core\Model\Product as BaseProduct; -/** - * @ORM\Entity - * - * @ORM\Table(name="sylius_product") - */ +#[ORM\Entity] +#[ORM\Table(name: 'sylius_product')] class Product extends BaseProduct implements SetonoSyliusGiftCardProductInterface { use SetonoSyliusGiftCardProductTrait; diff --git a/tests/Application/Doctrine/ORM/CustomerRepository.php b/tests/TestApplication/Repository/CustomerRepository.php similarity index 88% rename from tests/Application/Doctrine/ORM/CustomerRepository.php rename to tests/TestApplication/Repository/CustomerRepository.php index e5dcf397..abb11ea3 100644 --- a/tests/Application/Doctrine/ORM/CustomerRepository.php +++ b/tests/TestApplication/Repository/CustomerRepository.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Setono\SyliusGiftCardPlugin\Tests\Application\Doctrine\ORM; +namespace Setono\SyliusGiftCardPlugin\Tests\TestApplication\Repository; use Setono\SyliusGiftCardPlugin\Doctrine\ORM\CustomerRepositoryTrait as SetonoSyliusGiftCardPluginCustomerRepositoryTrait; use Setono\SyliusGiftCardPlugin\Repository\CustomerRepositoryInterface as SetonoSyliusGiftCardPluginCustomerRepositoryInterface; diff --git a/tests/Application/Doctrine/ORM/OrderRepository.php b/tests/TestApplication/Repository/OrderRepository.php similarity index 88% rename from tests/Application/Doctrine/ORM/OrderRepository.php rename to tests/TestApplication/Repository/OrderRepository.php index 45faa96c..b86a3519 100644 --- a/tests/Application/Doctrine/ORM/OrderRepository.php +++ b/tests/TestApplication/Repository/OrderRepository.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Setono\SyliusGiftCardPlugin\Tests\Application\Doctrine\ORM; +namespace Setono\SyliusGiftCardPlugin\Tests\TestApplication\Repository; use Setono\SyliusGiftCardPlugin\Doctrine\ORM\OrderRepositoryTrait as SetonoSyliusGiftCardPluginOrderRepositoryTrait; use Setono\SyliusGiftCardPlugin\Repository\OrderRepositoryInterface as SetonoSyliusGiftCardPluginOrderRepositoryInterface; diff --git a/tests/Application/config/bundles.php b/tests/TestApplication/config/bundles.php similarity index 72% rename from tests/Application/config/bundles.php rename to tests/TestApplication/config/bundles.php index fdf32a28..4344a12b 100644 --- a/tests/Application/config/bundles.php +++ b/tests/TestApplication/config/bundles.php @@ -2,7 +2,7 @@ declare(strict_types=1); -return [ +$bundles = [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], @@ -30,22 +30,13 @@ Sylius\Bundle\CoreBundle\SyliusCoreBundle::class => ['all' => true], Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true], - // Begin: In test app, those 3 needs to be loaded before our plugin or the Api Resource override won't work - Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], - ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], - Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true], - // End: In test app, those 3 needs to be loaded before our plugin or the Api Resource override won't work - + // The plugin must be registered before SyliusGridBundle, see README Setono\SyliusGiftCardPlugin\SetonoSyliusGiftCardPlugin::class => ['all' => true], + Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true], - winzou\Bundle\StateMachineBundle\winzouStateMachineBundle::class => ['all' => true], - Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true], - Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle::class => ['all' => true], - JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true], - FOS\RestBundle\FOSRestBundle::class => ['all' => true], Knp\Bundle\GaufretteBundle\KnpGaufretteBundle::class => ['all' => true], Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true], - League\FlysystemBundle\FlysystemBundle::class => ['all' => true], + Knp\Bundle\SnappyBundle\KnpSnappyBundle::class => ['all' => true], Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true], Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true], Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], @@ -55,13 +46,30 @@ Sylius\Bundle\ThemeBundle\SyliusThemeBundle::class => ['all' => true], Sylius\Bundle\AdminBundle\SyliusAdminBundle::class => ['all' => true], Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true], - Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true], - Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], - FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true], - Knp\Bundle\SnappyBundle\KnpSnappyBundle::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], + ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], + Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true], + Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], - SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], - Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], + League\FlysystemBundle\FlysystemBundle::class => ['all' => true], + Sylius\TwigExtra\Symfony\SyliusTwigExtraBundle::class => ['all' => true], + Sylius\TwigHooks\SyliusTwigHooksBundle::class => ['all' => true], + Symfony\UX\Icons\UXIconsBundle::class => ['all' => true], + Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true], + Symfony\UX\LiveComponent\LiveComponentBundle::class => ['all' => true], + Symfony\UX\Autocomplete\AutocompleteBundle::class => ['all' => true], + Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true], + Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class => ['all' => true], + Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true], + Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true], + Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true], ]; + +if (class_exists('FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle')) { + $bundles[FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class] = ['test' => true, 'test_cached' => true]; +} + +return $bundles; diff --git a/tests/TestApplication/config/config.yaml b/tests/TestApplication/config/config.yaml new file mode 100644 index 00000000..0639c881 --- /dev/null +++ b/tests/TestApplication/config/config.yaml @@ -0,0 +1,64 @@ +imports: + - { resource: "packages/*.yaml" } + - { resource: "@SetonoSyliusGiftCardPlugin/config/app/config.yaml" } + - { resource: "@SetonoSyliusGiftCardPlugin/config/app/fixtures.yaml" } + - { resource: "services_test.php" } + +twig: + paths: + '%kernel.project_dir%/../../../tests/TestApplication/templates': ~ + +sylius_api: + enabled: true + +sylius_customer: + resources: + customer: + classes: + repository: Setono\SyliusGiftCardPlugin\Tests\TestApplication\Repository\CustomerRepository + +sylius_order: + resources: + order: + classes: + model: Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\Order + repository: Setono\SyliusGiftCardPlugin\Tests\TestApplication\Repository\OrderRepository + order_item: + classes: + model: Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\OrderItem + order_item_unit: + classes: + model: Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\OrderItemUnit + +sylius_product: + resources: + product: + classes: + model: Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\Product + +when@test: + setono_sylius_gift_card: + pdf_rendering: + default_orientation: 'Landscape' + available_orientations: + - Landscape + default_page_size: 'B0' + available_page_sizes: + - A5 + - B0 + + sylius_theme: + sources: + test: ~ + +# Remove if you do not need to extend entities +doctrine: + orm: + entity_managers: + default: + mappings: + TestApplication: + is_bundle: false + type: attribute + dir: '%kernel.project_dir%/../../../tests/TestApplication/Entity' + prefix: Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity diff --git a/tests/TestApplication/config/packages/knp_snappy.yaml b/tests/TestApplication/config/packages/knp_snappy.yaml new file mode 100644 index 00000000..6dad7cc9 --- /dev/null +++ b/tests/TestApplication/config/packages/knp_snappy.yaml @@ -0,0 +1,5 @@ +knp_snappy: + pdf: + binary: '%env(KNP_SNAPPY_PDF_BINARY)%' + image: + binary: '%env(KNP_SNAPPY_IMAGE_BINARY)%' diff --git a/tests/TestApplication/config/packages/monolog.yaml b/tests/TestApplication/config/packages/monolog.yaml new file mode 100644 index 00000000..62e6ab01 --- /dev/null +++ b/tests/TestApplication/config/packages/monolog.yaml @@ -0,0 +1,10 @@ +when@dev: + monolog: + handlers: + main: + type: stream + path: "%kernel.logs_dir%/%kernel.environment%.log" + level: warning + firephp: + type: firephp + level: info diff --git a/tests/TestApplication/config/routes.yaml b/tests/TestApplication/config/routes.yaml new file mode 100644 index 00000000..1dc350e9 --- /dev/null +++ b/tests/TestApplication/config/routes.yaml @@ -0,0 +1,2 @@ +setono_sylius_gift_card: + resource: "@SetonoSyliusGiftCardPlugin/config/routes.yaml" diff --git a/tests/TestApplication/config/services_test.php b/tests/TestApplication/config/services_test.php new file mode 100644 index 00000000..33f6522e --- /dev/null +++ b/tests/TestApplication/config/services_test.php @@ -0,0 +1,12 @@ +env(), 'test')) { + $container->import('../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml'); + $container->import('@SetonoSyliusGiftCardPlugin/tests/Behat/Resources/services.xml'); + } +}; diff --git a/tests/Application/config/secrets/prod/.gitignore b/tests/TestApplication/templates/.gitkeep similarity index 100% rename from tests/Application/config/secrets/prod/.gitignore rename to tests/TestApplication/templates/.gitkeep diff --git a/tests/Unit/Api/Command/AddGiftCardToOrderTest.php b/tests/Unit/Api/Command/AddGiftCardToOrderTest.php deleted file mode 100644 index eb9688ac..00000000 --- a/tests/Unit/Api/Command/AddGiftCardToOrderTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertInstanceOf(GiftCardCodeAwareInterface::class, $command); - } - - /** - * @test - */ - public function it_has_nullable_gift_card_code(): void - { - $command = new AddGiftCardToOrder('order_token_vaue'); - - $this->assertNull($command->getGiftCardCode()); - $command->setGiftCardCode('gc_code'); - $this->assertEquals('gc_code', $command->getGiftCardCode()); - } -} diff --git a/tests/Unit/Api/Command/AddItemToCartTest.php b/tests/Unit/Api/Command/AddItemToCartTest.php deleted file mode 100644 index 34f7e6db..00000000 --- a/tests/Unit/Api/Command/AddItemToCartTest.php +++ /dev/null @@ -1,54 +0,0 @@ -assertInstanceOf(AddItemToCart::class, $command); - } - - /** - * @test - */ - public function it_has_its_parents_properties(): void - { - $command = new AddItemToCart('variant', 1); - - $this->assertEquals('variant', $command->productVariantCode); - $this->assertEquals(1, $command->quantity); - } - - /** - * @test - */ - public function it_has_nullable_amount(): void - { - $command = new AddItemToCart('variant', 1); - $this->assertNull($command->getAmount()); - $command = new AddItemToCart('variant', 1, 150); - $this->assertEquals(150, $command->getAmount()); - } - - /** - * @test - */ - public function it_has_nullable_custom_message(): void - { - $command = new AddItemToCart('variant', 1); - $this->assertNull($command->getCustomMessage()); - $command = new AddItemToCart('variant', 1, null, 'Custom message'); - $this->assertEquals('Custom message', $command->getCustomMessage()); - } -} diff --git a/tests/Unit/Api/Command/AssociateConfigurationToChannelTest.php b/tests/Unit/Api/Command/AssociateConfigurationToChannelTest.php deleted file mode 100644 index 85ba15e6..00000000 --- a/tests/Unit/Api/Command/AssociateConfigurationToChannelTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertInstanceOf(ConfigurationCodeAwareInterface::class, $command); - } - - /** - * @test - */ - public function it_has_nullable_configuration_code(): void - { - $command = new AssociateConfigurationToChannel('locale_code', 'channel_code'); - - $this->assertNull($command->getConfigurationCode()); - $command->setConfigurationCode('configuration_code'); - $this->assertEquals('configuration_code', $command->getConfigurationCode()); - } -} diff --git a/tests/Unit/Api/Command/CreateGiftCardConfigurationTest.php b/tests/Unit/Api/Command/CreateGiftCardConfigurationTest.php deleted file mode 100644 index adb52290..00000000 --- a/tests/Unit/Api/Command/CreateGiftCardConfigurationTest.php +++ /dev/null @@ -1,57 +0,0 @@ -assertInstanceOf(CreateGiftCardConfiguration::class, $command); - } - - /** - * @test - */ - public function it_has_nullable_default_validity_period(): void - { - $command = new CreateGiftCardConfiguration('code', false, false); - $this->assertNull($command->defaultValidityPeriod); - } - - /** - * @test - */ - public function it_has_nullable_page_size(): void - { - $command = new CreateGiftCardConfiguration('code', false, false); - $this->assertNull($command->pageSize); - } - - /** - * @test - */ - public function it_has_nullable_orientation(): void - { - $command = new CreateGiftCardConfiguration('code', false, false); - $this->assertNull($command->orientation); - } - - /** - * @test - */ - public function it_has_nullable_template(): void - { - $command = new CreateGiftCardConfiguration('code', false, false); - $this->assertNull($command->template); - } -} diff --git a/tests/Unit/Api/Command/RemoveGiftCardFromOrderTest.php b/tests/Unit/Api/Command/RemoveGiftCardFromOrderTest.php deleted file mode 100644 index b17422c1..00000000 --- a/tests/Unit/Api/Command/RemoveGiftCardFromOrderTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertInstanceOf(GiftCardCodeAwareInterface::class, $command); - } - - /** - * @test - */ - public function it_has_nullable_gift_card_code(): void - { - $command = new RemoveGiftCardFromOrder('order_token_vaue'); - - $this->assertNull($command->getGiftCardCode()); - $command->setGiftCardCode('gc_code'); - $this->assertEquals('gc_code', $command->getGiftCardCode()); - } -} diff --git a/tests/Unit/Api/CommandHandler/AddGiftCardToOrderHandlerTest.php b/tests/Unit/Api/CommandHandler/AddGiftCardToOrderHandlerTest.php deleted file mode 100644 index 17abca48..00000000 --- a/tests/Unit/Api/CommandHandler/AddGiftCardToOrderHandlerTest.php +++ /dev/null @@ -1,117 +0,0 @@ -setGiftCardCode('gc_code'); - - $giftCardRepository = $this->prophesize(GiftCardRepositoryInterface::class); - $orderRepository = $this->prophesize(OrderRepositoryInterface::class); - $giftCardApplicator = $this->prophesize(GiftCardApplicatorInterface::class); - - $giftCardRepository->findOneByCode('gc_code')->willReturn($giftCard); - $orderRepository->findOneBy(['tokenValue' => 'order_token_value'])->willReturn($order); - $giftCardApplicator->apply($order, $giftCard)->shouldBeCalled(); - - $addGiftCardToOrderHandler = new AddGiftCardToOrderHandler( - $giftCardRepository->reveal(), - $orderRepository->reveal(), - $giftCardApplicator->reveal(), - ); - $addGiftCardToOrderHandler($command); - } - - /** - * @test - */ - public function it_throws_error_if_gift_card_code_is_null(): void - { - $command = new AddGiftCardToOrder('order_token_value'); - - $giftCardRepository = $this->prophesize(GiftCardRepositoryInterface::class); - $orderRepository = $this->prophesize(OrderRepositoryInterface::class); - $giftCardApplicator = $this->prophesize(GiftCardApplicatorInterface::class); - - $this->expectException(InvalidArgumentException::class); - - $addGiftCardToOrderHandler = new AddGiftCardToOrderHandler( - $giftCardRepository->reveal(), - $orderRepository->reveal(), - $giftCardApplicator->reveal(), - ); - $addGiftCardToOrderHandler($command); - } - - /** - * @test - */ - public function it_throws_error_if_gift_card_not_found(): void - { - $command = new AddGiftCardToOrder('order_token_value'); - $command->setGiftCardCode('gc_code'); - - $giftCardRepository = $this->prophesize(GiftCardRepositoryInterface::class); - $orderRepository = $this->prophesize(OrderRepositoryInterface::class); - $giftCardApplicator = $this->prophesize(GiftCardApplicatorInterface::class); - - $this->expectException(InvalidArgumentException::class); - - $addGiftCardToOrderHandler = new AddGiftCardToOrderHandler( - $giftCardRepository->reveal(), - $orderRepository->reveal(), - $giftCardApplicator->reveal(), - ); - $addGiftCardToOrderHandler($command); - } - - /** - * @test - */ - public function it_throws_exception_if_order_not_found(): void - { - $giftCard = new GiftCard(); - - $command = new AddGiftCardToOrder('order_token_value'); - $command->setGiftCardCode('gc_code'); - - $giftCardRepository = $this->prophesize(GiftCardRepositoryInterface::class); - $orderRepository = $this->prophesize(OrderRepositoryInterface::class); - $giftCardApplicator = $this->prophesize(GiftCardApplicatorInterface::class); - - $giftCardRepository->findOneByCode('gc_code')->willReturn($giftCard); - - $this->expectException(InvalidArgumentException::class); - - $addGiftCardToOrderHandler = new AddGiftCardToOrderHandler( - $giftCardRepository->reveal(), - $orderRepository->reveal(), - $giftCardApplicator->reveal(), - ); - $addGiftCardToOrderHandler($command); - } -} diff --git a/tests/Unit/Api/CommandHandler/AddItemToCartHandlerTest.php b/tests/Unit/Api/CommandHandler/AddItemToCartHandlerTest.php deleted file mode 100644 index ea9c923d..00000000 --- a/tests/Unit/Api/CommandHandler/AddItemToCartHandlerTest.php +++ /dev/null @@ -1,236 +0,0 @@ -prophesize(OrderRepositoryInterface::class); - $productVariantRepository = $this->prophesize(ProductVariantRepositoryInterface::class); - $orderModifier = $this->prophesize(OrderModifierInterface::class); - $cartItemFactory = $this->prophesize(CartItemFactoryInterface::class); - $orderItemQuantityModifier = $this->prophesize(OrderItemQuantityModifierInterface::class); - $giftCardFactory = $this->prophesize(GiftCardFactoryInterface::class); - $giftCardManager = $this->prophesize(EntityManagerInterface::class); - - $handler = new AddItemToCartHandler( - $orderRepository->reveal(), - $productVariantRepository->reveal(), - $orderModifier->reveal(), - $cartItemFactory->reveal(), - $orderItemQuantityModifier->reveal(), - $giftCardFactory->reveal(), - $giftCardManager->reveal(), - ); - - $this->assertInstanceOf(AddItemToCartHandler::class, $handler); - } - - /** - * @test - */ - public function it_adds_configurable_gift_card_to_cart(): void - { - $orderTokenValue = 'orderTokenValue'; - - $orderRepository = $this->prophesize(OrderRepositoryInterface::class); - $productVariantRepository = $this->prophesize(ProductVariantRepositoryInterface::class); - $orderModifier = $this->prophesize(OrderModifierInterface::class); - $cartItemFactory = $this->prophesize(CartItemFactoryInterface::class); - $orderItemQuantityModifier = $this->prophesize(OrderItemQuantityModifierInterface::class); - $giftCardFactory = $this->prophesize(GiftCardFactoryInterface::class); - $giftCardManager = $this->prophesize(EntityManagerInterface::class); - - $product = new Product(); - $product->setGiftCard(true); - $product->setGiftCardAmountConfigurable(true); - $productVariant = new ProductVariant(); - $productVariant->setProduct($product); - $cart = new Order(); - $cart->setTokenValue($orderTokenValue); - $cartItem = new OrderItem(); - - $productVariantRepository - ->findOneBy(['code' => 'variant']) - ->willReturn($productVariant); - $orderRepository - ->findCartByTokenValue($orderTokenValue) - ->willReturn($cart); - $cartItemFactory - ->createNew() - ->willReturn($cartItem); - - $orderItemQuantityModifier->modify($cartItem, 1)->shouldBeCalled(); - $orderModifier->addToOrder($cart, $cartItem)->shouldBeCalled(); - - $cartItemUnit = new OrderItemUnit($cartItem); - $cartItem->addUnit($cartItemUnit); - - $giftCard = new GiftCard(); - $giftCardFactory - ->createFromOrderItemUnitAndCart($cartItemUnit, $cart) - ->willReturn($giftCard); - $giftCardManager->persist($giftCard)->shouldBeCalled(); - - $handler = new AddItemToCartHandler( - $orderRepository->reveal(), - $productVariantRepository->reveal(), - $orderModifier->reveal(), - $cartItemFactory->reveal(), - $orderItemQuantityModifier->reveal(), - $giftCardFactory->reveal(), - $giftCardManager->reveal(), - ); - $message = new SetonoSyliusGiftCardAddItemToCart('variant', 1, 1500, 'Custom message'); - $message->setOrderTokenValue($orderTokenValue); - $handler($message); - } - - /** - * @test - */ - public function it_adds_simple_item_to_cart(): void - { - $orderTokenValue = 'orderTokenValue'; - - $orderRepository = $this->prophesize(OrderRepositoryInterface::class); - $productVariantRepository = $this->prophesize(ProductVariantRepositoryInterface::class); - $orderModifier = $this->prophesize(OrderModifierInterface::class); - $cartItemFactory = $this->prophesize(CartItemFactoryInterface::class); - $orderItemQuantityModifier = $this->prophesize(OrderItemQuantityModifierInterface::class); - $giftCardFactory = $this->prophesize(GiftCardFactoryInterface::class); - $giftCardManager = $this->prophesize(EntityManagerInterface::class); - - $productVariant = $this->prophesize(ProductVariant::class); - $cart = new Order(); - $cart->setTokenValue($orderTokenValue); - $cartItem = $this->prophesize(OrderItem::class); - $cartItem->setVariant($productVariant)->shouldBeCalled(); - - $productVariantRepository - ->findOneBy(['code' => 'variant']) - ->willReturn($productVariant); - $orderRepository - ->findCartByTokenValue($orderTokenValue) - ->willReturn($cart); - $cartItemFactory - ->createNew() - ->willReturn($cartItem); - - $productVariant->getProduct()->shouldNotBeCalled(); - - $orderItemQuantityModifier->modify($cartItem, 1)->shouldBeCalled(); - $orderModifier->addToOrder($cart, $cartItem)->shouldBeCalled(); - - $cartItem->getUnits()->shouldNotBeCalled(); - - $handler = new AddItemToCartHandler( - $orderRepository->reveal(), - $productVariantRepository->reveal(), - $orderModifier->reveal(), - $cartItemFactory->reveal(), - $orderItemQuantityModifier->reveal(), - $giftCardFactory->reveal(), - $giftCardManager->reveal(), - ); - $message = new SyliusAddItemToCart('variant', 1); - $message->setOrderTokenValue($orderTokenValue); - $handler($message); - } - - /** - * @test - */ - public function it_adds_simple_gift_card_to_cart(): void - { - $orderTokenValue = 'orderTokenValue'; - - $orderRepository = $this->prophesize(OrderRepositoryInterface::class); - $productVariantRepository = $this->prophesize(ProductVariantRepositoryInterface::class); - $orderModifier = $this->prophesize(OrderModifierInterface::class); - $cartItemFactory = $this->prophesize(CartItemFactoryInterface::class); - $orderItemQuantityModifier = $this->prophesize(OrderItemQuantityModifierInterface::class); - $giftCardFactory = $this->prophesize(GiftCardFactoryInterface::class); - $giftCardManager = $this->prophesize(EntityManagerInterface::class); - - $product = new Product(); - $product->setGiftCard(true); - $product->setGiftCardAmountConfigurable(false); - $productVariant = new ProductVariant(); - $productVariant->setProduct($product); - $cart = new Order(); - $cart->setTokenValue($orderTokenValue); - $cartItem = $this->prophesize(OrderItem::class); - $cartItem->setVariant($productVariant)->shouldBeCalled(); - - $productVariantRepository - ->findOneBy(['code' => 'variant']) - ->willReturn($productVariant); - $orderRepository - ->findCartByTokenValue($orderTokenValue) - ->willReturn($cart); - $cartItemFactory - ->createNew() - ->willReturn($cartItem); - - $cartItem->setUnitPrice(Argument::any())->shouldNotBeCalled(); - $cartItem->setImmutable(true)->shouldNotBeCalled(); - - $orderItemQuantityModifier->modify($cartItem, 1)->shouldBeCalled(); - $orderModifier->addToOrder($cart, $cartItem)->shouldBeCalled(); - - $cartItemUnit = new OrderItemUnit($cartItem->reveal()); - $cartItem->addUnit($cartItemUnit)->shouldBeCalled(); - $cartItem - ->getUnits() - ->willReturn(new ArrayCollection([$cartItemUnit])); - - $giftCard = new GiftCard(); - $giftCardFactory - ->createFromOrderItemUnitAndCart($cartItemUnit, $cart) - ->willReturn($giftCard); - $giftCardManager->persist($giftCard)->shouldBeCalled(); - - $handler = new AddItemToCartHandler( - $orderRepository->reveal(), - $productVariantRepository->reveal(), - $orderModifier->reveal(), - $cartItemFactory->reveal(), - $orderItemQuantityModifier->reveal(), - $giftCardFactory->reveal(), - $giftCardManager->reveal(), - ); - $message = new SetonoSyliusGiftCardAddItemToCart('variant', 1); - $message->setOrderTokenValue($orderTokenValue); - $handler($message); - } -} diff --git a/tests/Unit/Api/CommandHandler/AssociateConfigurationToChannelHandlerTest.php b/tests/Unit/Api/CommandHandler/AssociateConfigurationToChannelHandlerTest.php deleted file mode 100644 index 54c0b619..00000000 --- a/tests/Unit/Api/CommandHandler/AssociateConfigurationToChannelHandlerTest.php +++ /dev/null @@ -1,250 +0,0 @@ -prophesize(RepositoryInterface::class); - $channelRepository = $this->prophesize(ChannelRepositoryInterface::class); - $localeRepository = $this->prophesize(RepositoryInterface::class); - $giftCardChannelConfigurationRepository = $this->prophesize(RepositoryInterface::class); - $giftCardChannelConfigurationFactory = $this->prophesize(FactoryInterface::class); - - $command = new AssociateConfigurationToChannel('en_GB', 'super_channel'); - $command->setConfigurationCode('super_configuration'); - - $giftCardConfigurationRepository - ->findOneBy(['code' => 'super_configuration']) - ->willReturn($configuration); - $channelRepository - ->findOneByCode('super_channel') - ->willReturn($channel); - $localeRepository - ->findOneBy(['code' => 'en_GB']) - ->willReturn($locale); - - $giftCardChannelConfigurationRepository - ->findOneBy([ - 'configuration' => $configuration, - 'channel' => $channel, - 'locale' => $locale, - ]) - ->willReturn(null); - - $giftCardChannelConfigurationFactory->createNew()->willReturn($giftCardChannelConfiguration); - - $handler = new AssociateConfigurationToChannelHandler( - $giftCardConfigurationRepository->reveal(), - $channelRepository->reveal(), - $localeRepository->reveal(), - $giftCardChannelConfigurationRepository->reveal(), - $giftCardChannelConfigurationFactory->reveal(), - ); - $returnedConfiguration = $handler($command); - - self::assertEquals(1, $returnedConfiguration->getChannelConfigurations()->count()); - /** @var GiftCardChannelConfiguration $returnedChannelConfiguration */ - $returnedChannelConfiguration = $returnedConfiguration->getChannelConfigurations()->first(); - - self::assertEquals($channel, $returnedChannelConfiguration->getChannel()); - self::assertEquals($locale, $returnedChannelConfiguration->getLocale()); - } - - /** - * @test - */ - public function it_does_nothing_if_association_already_exists(): void - { - $configuration = new GiftCardConfiguration(); - $channel = new Channel(); - $locale = new Locale(); - $existingGiftCardChannelConfiguration = new GiftCardChannelConfiguration(); - - $giftCardConfigurationRepository = $this->prophesize(RepositoryInterface::class); - $channelRepository = $this->prophesize(ChannelRepositoryInterface::class); - $localeRepository = $this->prophesize(RepositoryInterface::class); - $giftCardChannelConfigurationRepository = $this->prophesize(RepositoryInterface::class); - $giftCardChannelConfigurationFactory = $this->prophesize(FactoryInterface::class); - - $command = new AssociateConfigurationToChannel('en_GB', 'super_channel'); - $command->setConfigurationCode('super_configuration'); - - $giftCardConfigurationRepository - ->findOneBy(['code' => 'super_configuration']) - ->willReturn($configuration); - $channelRepository - ->findOneByCode('super_channel') - ->willReturn($channel); - $localeRepository - ->findOneBy(['code' => 'en_GB']) - ->willReturn($locale); - - $giftCardChannelConfigurationRepository - ->findOneBy([ - 'configuration' => $configuration, - 'channel' => $channel, - 'locale' => $locale, - ]) - ->willReturn(new ArrayCollection([$existingGiftCardChannelConfiguration])); - - $giftCardChannelConfigurationFactory->createNew()->shouldNotBeCalled(); - - $handler = new AssociateConfigurationToChannelHandler( - $giftCardConfigurationRepository->reveal(), - $channelRepository->reveal(), - $localeRepository->reveal(), - $giftCardChannelConfigurationRepository->reveal(), - $giftCardChannelConfigurationFactory->reveal(), - ); - $returnedConfiguration = $handler($command); - - self::assertEquals(0, $returnedConfiguration->getChannelConfigurations()->count()); - } - - /** - * @test - */ - public function it_throws_exception_if_configuration_code_empty(): void - { - $giftCardConfigurationRepository = $this->prophesize(RepositoryInterface::class); - $channelRepository = $this->prophesize(ChannelRepositoryInterface::class); - $localeRepository = $this->prophesize(RepositoryInterface::class); - $giftCardChannelConfigurationRepository = $this->prophesize(RepositoryInterface::class); - $giftCardChannelConfigurationFactory = $this->prophesize(FactoryInterface::class); - - $command = new AssociateConfigurationToChannel('en_GB', 'super_channel'); - - $this->expectException(InvalidArgumentException::class); - - $handler = new AssociateConfigurationToChannelHandler( - $giftCardConfigurationRepository->reveal(), - $channelRepository->reveal(), - $localeRepository->reveal(), - $giftCardChannelConfigurationRepository->reveal(), - $giftCardChannelConfigurationFactory->reveal(), - ); - $handler($command); - } - - /** - * @test - */ - public function it_throws_exception_if_configuration_not_found(): void - { - $giftCardConfigurationRepository = $this->prophesize(RepositoryInterface::class); - $channelRepository = $this->prophesize(ChannelRepositoryInterface::class); - $localeRepository = $this->prophesize(RepositoryInterface::class); - $giftCardChannelConfigurationRepository = $this->prophesize(RepositoryInterface::class); - $giftCardChannelConfigurationFactory = $this->prophesize(FactoryInterface::class); - - $command = new AssociateConfigurationToChannel('en_GB', 'super_channel'); - $command->setConfigurationCode('super_configuration'); - - $this->expectException(InvalidArgumentException::class); - - $handler = new AssociateConfigurationToChannelHandler( - $giftCardConfigurationRepository->reveal(), - $channelRepository->reveal(), - $localeRepository->reveal(), - $giftCardChannelConfigurationRepository->reveal(), - $giftCardChannelConfigurationFactory->reveal(), - ); - $handler($command); - } - - /** - * @test - */ - public function it_throws_eception_if_channel_not_found(): void - { - $configuration = new GiftCardConfiguration(); - - $giftCardConfigurationRepository = $this->prophesize(RepositoryInterface::class); - $channelRepository = $this->prophesize(ChannelRepositoryInterface::class); - $localeRepository = $this->prophesize(RepositoryInterface::class); - $giftCardChannelConfigurationRepository = $this->prophesize(RepositoryInterface::class); - $giftCardChannelConfigurationFactory = $this->prophesize(FactoryInterface::class); - - $command = new AssociateConfigurationToChannel('en_GB', 'super_channel'); - $command->setConfigurationCode('super_configuration'); - - $giftCardConfigurationRepository - ->findOneBy(['code' => 'super_configuration']) - ->willReturn($configuration); - - $this->expectException(InvalidArgumentException::class); - - $handler = new AssociateConfigurationToChannelHandler( - $giftCardConfigurationRepository->reveal(), - $channelRepository->reveal(), - $localeRepository->reveal(), - $giftCardChannelConfigurationRepository->reveal(), - $giftCardChannelConfigurationFactory->reveal(), - ); - $handler($command); - } - - /** - * @test - */ - public function if_throws_exception_if_locale_not_found(): void - { - $configuration = new GiftCardConfiguration(); - $channel = new Channel(); - - $giftCardConfigurationRepository = $this->prophesize(RepositoryInterface::class); - $channelRepository = $this->prophesize(ChannelRepositoryInterface::class); - $localeRepository = $this->prophesize(RepositoryInterface::class); - $giftCardChannelConfigurationRepository = $this->prophesize(RepositoryInterface::class); - $giftCardChannelConfigurationFactory = $this->prophesize(FactoryInterface::class); - - $command = new AssociateConfigurationToChannel('en_GB', 'super_channel'); - $command->setConfigurationCode('super_configuration'); - - $giftCardConfigurationRepository - ->findOneBy(['code' => 'super_configuration']) - ->willReturn($configuration); - $channelRepository - ->findOneByCode('super_channel') - ->willReturn($channel); - - $this->expectException(InvalidArgumentException::class); - - $handler = new AssociateConfigurationToChannelHandler( - $giftCardConfigurationRepository->reveal(), - $channelRepository->reveal(), - $localeRepository->reveal(), - $giftCardChannelConfigurationRepository->reveal(), - $giftCardChannelConfigurationFactory->reveal(), - ); - $handler($command); - } -} diff --git a/tests/Unit/Api/CommandHandler/CreateGiftCardConfigurationHandlerTest.php b/tests/Unit/Api/CommandHandler/CreateGiftCardConfigurationHandlerTest.php deleted file mode 100644 index 2649006f..00000000 --- a/tests/Unit/Api/CommandHandler/CreateGiftCardConfigurationHandlerTest.php +++ /dev/null @@ -1,86 +0,0 @@ -prophesize(GiftCardConfigurationFactoryInterface::class)->reveal(), - $this->prophesize(ObjectManager::class)->reveal(), - ); - - $this->assertInstanceOf(CreateGiftCardConfigurationHandler::class, $handler); - } - - /** - * @test - */ - public function it_creates_gift_card_configuration(): void - { - $giftCardConfigurationFactory = $this->prophesize(GiftCardConfigurationFactoryInterface::class); - $giftCardConfigurationManager = $this->prophesize(ObjectManager::class); - - $giftCardConfiguration = $this->prophesize(GiftCardConfigurationInterface::class); - - $giftCardConfigurationFactory->createNew()->willReturn($giftCardConfiguration->reveal()); - - $handler = new CreateGiftCardConfigurationHandler( - $giftCardConfigurationFactory->reveal(), - $giftCardConfigurationManager->reveal(), - ); - - $giftCardConfigurationManager->persist($giftCardConfiguration->reveal())->shouldBeCalled(); - - $command = new CreateGiftCardConfiguration('test', false, false); - $handler->__invoke($command); - } - - /** - * @test - */ - public function it_does_not_set_values_if_null(): void - { - $giftCardConfigurationFactory = $this->prophesize(GiftCardConfigurationFactoryInterface::class); - $giftCardConfigurationManager = $this->prophesize(ObjectManager::class); - - $giftCardConfiguration = $this->prophesize(GiftCardConfigurationInterface::class); - - $giftCardConfigurationFactory->createNew()->willReturn($giftCardConfiguration->reveal()); - - $handler = new CreateGiftCardConfigurationHandler( - $giftCardConfigurationFactory->reveal(), - $giftCardConfigurationManager->reveal(), - ); - - $giftCardConfigurationManager->persist($giftCardConfiguration->reveal())->shouldBeCalled(); - - $giftCardConfiguration->setCode('test')->shouldBeCalled(); - $giftCardConfiguration->setEnabled(false)->shouldBeCalled(); - $giftCardConfiguration->setDefault(false)->shouldBeCalled(); - $giftCardConfiguration->setDefaultValidityPeriod(Argument::any())->shouldNotBeCalled(); - $giftCardConfiguration->setPageSize(Argument::any())->shouldNotBeCalled(); - $giftCardConfiguration->setOrientation(Argument::any())->shouldNotBeCalled(); - $giftCardConfiguration->setTemplate(Argument::any())->shouldNotBeCalled(); - - $command = new CreateGiftCardConfiguration('test', false, false); - $handler->__invoke($command); - } -} diff --git a/tests/Unit/Api/CommandHandler/RemoveGiftCardFromOrderHandlerTest.php b/tests/Unit/Api/CommandHandler/RemoveGiftCardFromOrderHandlerTest.php deleted file mode 100644 index 5ec6209b..00000000 --- a/tests/Unit/Api/CommandHandler/RemoveGiftCardFromOrderHandlerTest.php +++ /dev/null @@ -1,117 +0,0 @@ -setGiftCardCode('gc_code'); - - $giftCardRepository = $this->prophesize(GiftCardRepositoryInterface::class); - $orderRepository = $this->prophesize(OrderRepositoryInterface::class); - $giftCardApplicator = $this->prophesize(GiftCardApplicatorInterface::class); - - $giftCardRepository->findOneByCode('gc_code')->willReturn($giftCard); - $orderRepository->findOneBy(['tokenValue' => 'order_token_value'])->willReturn($order); - $giftCardApplicator->remove($order, $giftCard)->shouldBeCalled(); - - $removeGiftCardFromOrderHandler = new RemoveGiftCardFromOrderHandler( - $giftCardRepository->reveal(), - $orderRepository->reveal(), - $giftCardApplicator->reveal(), - ); - $removeGiftCardFromOrderHandler($command); - } - - /** - * @test - */ - public function it_throws_error_if_gift_card_code_is_null(): void - { - $command = new RemoveGiftCardFromOrder('order_token_value'); - - $giftCardRepository = $this->prophesize(GiftCardRepositoryInterface::class); - $orderRepository = $this->prophesize(OrderRepositoryInterface::class); - $giftCardApplicator = $this->prophesize(GiftCardApplicatorInterface::class); - - $this->expectException(InvalidArgumentException::class); - - $removeGiftCardFromOrderHandler = new RemoveGiftCardFromOrderHandler( - $giftCardRepository->reveal(), - $orderRepository->reveal(), - $giftCardApplicator->reveal(), - ); - $removeGiftCardFromOrderHandler($command); - } - - /** - * @test - */ - public function it_throws_error_if_gift_card_not_found(): void - { - $command = new RemoveGiftCardFromOrder('order_token_value'); - $command->setGiftCardCode('gc_code'); - - $giftCardRepository = $this->prophesize(GiftCardRepositoryInterface::class); - $orderRepository = $this->prophesize(OrderRepositoryInterface::class); - $giftCardApplicator = $this->prophesize(GiftCardApplicatorInterface::class); - - $this->expectException(InvalidArgumentException::class); - - $removeGiftCardFromOrderHandler = new RemoveGiftCardFromOrderHandler( - $giftCardRepository->reveal(), - $orderRepository->reveal(), - $giftCardApplicator->reveal(), - ); - $removeGiftCardFromOrderHandler($command); - } - - /** - * @test - */ - public function it_throws_exception_if_order_not_found(): void - { - $giftCard = new GiftCard(); - - $command = new RemoveGiftCardFromOrder('order_token_value'); - $command->setGiftCardCode('gc_code'); - - $giftCardRepository = $this->prophesize(GiftCardRepositoryInterface::class); - $orderRepository = $this->prophesize(OrderRepositoryInterface::class); - $giftCardApplicator = $this->prophesize(GiftCardApplicatorInterface::class); - - $giftCardRepository->findOneByCode('gc_code')->willReturn($giftCard); - - $this->expectException(InvalidArgumentException::class); - - $removeGiftCardFromOrderHandler = new RemoveGiftCardFromOrderHandler( - $giftCardRepository->reveal(), - $orderRepository->reveal(), - $giftCardApplicator->reveal(), - ); - $removeGiftCardFromOrderHandler($command); - } -} diff --git a/tests/Unit/Api/Controller/Action/DownloadGiftCardPdfActionTest.php b/tests/Unit/Api/Controller/Action/DownloadGiftCardPdfActionTest.php deleted file mode 100644 index 5ae20137..00000000 --- a/tests/Unit/Api/Controller/Action/DownloadGiftCardPdfActionTest.php +++ /dev/null @@ -1,46 +0,0 @@ -Gift card content'); - - $configurationProvider = $this->prophesize(GiftCardConfigurationProviderInterface::class); - $giftCardPDFRenderer = $this->prophesize(PdfRendererInterface::class); - - $configurationProvider->getConfigurationForGiftCard($giftCard)->willReturn($configuration); - $giftCardPDFRenderer - ->render($giftCard, $configuration) - ->willReturn($expectedPdfResponse); - - $downloadGiftCardPdfAction = new DownloadGiftCardPdfAction( - $configurationProvider->reveal(), - $giftCardPDFRenderer->reveal(), - ); - - $response = $downloadGiftCardPdfAction($giftCard); - - $this->assertEquals($expectedPdfResponse, $response); - } -} diff --git a/tests/Unit/Api/Controller/Action/GiftCardBalanceActionTest.php b/tests/Unit/Api/Controller/Action/GiftCardBalanceActionTest.php deleted file mode 100644 index 0d5f0e91..00000000 --- a/tests/Unit/Api/Controller/Action/GiftCardBalanceActionTest.php +++ /dev/null @@ -1,56 +0,0 @@ -setCurrencyCode('EUR'); - $giftCard1->setAmount(25); - $giftCard2 = new GiftCard(); - $giftCard2->setCurrencyCode('EUR'); - $giftCard2->setAmount(56); - - $giftCard3 = new GiftCard(); - $giftCard3->setCurrencyCode('USD'); - $giftCard3->setAmount(31); - $giftCard4 = new GiftCard(); - $giftCard4->setCurrencyCode('USD'); - $giftCard4->setAmount(84); - $giftCard5 = new GiftCard(); - $giftCard5->setCurrencyCode('USD'); - $giftCard5->setAmount(86); - - $expectedBalanceCollection = new GiftCardBalanceCollection(); - $expectedBalanceCollection->addGiftCard($giftCard1); - $expectedBalanceCollection->addGiftCard($giftCard2); - $expectedBalanceCollection->addGiftCard($giftCard3); - $expectedBalanceCollection->addGiftCard($giftCard4); - $expectedBalanceCollection->addGiftCard($giftCard5); - - $giftCardRepository = $this->prophesize(GiftCardRepositoryInterface::class); - - $giftCardRepository->findEnabled()->willReturn([$giftCard1, $giftCard2, $giftCard3, $giftCard4, $giftCard5]); - - $giftCardBalanceAction = new GiftCardBalanceAction($giftCardRepository->reveal()); - $returnedBalanceCollection = $giftCardBalanceAction(); - - self::assertEquals($expectedBalanceCollection, $returnedBalanceCollection); - } -} diff --git a/tests/Unit/Api/Controller/Action/ResendGiftCardEmailActionTest.php b/tests/Unit/Api/Controller/Action/ResendGiftCardEmailActionTest.php deleted file mode 100644 index 9e6178f0..00000000 --- a/tests/Unit/Api/Controller/Action/ResendGiftCardEmailActionTest.php +++ /dev/null @@ -1,82 +0,0 @@ -setOrder($order); - $orderItemUnit = new OrderItemUnit($orderItem); - - $giftCard->setOrderItemUnit($orderItemUnit); - - $expectedResponse = new Response(null, Response::HTTP_NO_CONTENT); - - $giftCardEmailManager = $this->prophesize(GiftCardEmailManagerInterface::class); - $giftCardEmailManager->sendEmailWithGiftCardsFromOrder($order, [$giftCard])->shouldBeCalled(); - - $resendGiftCardEmailAction = new ResendGiftCardEmailAction($giftCardEmailManager->reveal()); - $response = $resendGiftCardEmailAction($giftCard); - - self::assertEquals($expectedResponse, $response); - } - - /** - * @test - */ - public function it_resends_email_for_customer(): void - { - $giftCard = new GiftCard(); - $customer = new Customer(); - - $giftCard->setCustomer($customer); - - $expectedResponse = new Response(null, Response::HTTP_NO_CONTENT); - - $giftCardEmailManager = $this->prophesize(GiftCardEmailManagerInterface::class); - $giftCardEmailManager->sendEmailToCustomerWithGiftCard($customer, $giftCard)->shouldBeCalled(); - - $resendGiftCardEmailAction = new ResendGiftCardEmailAction($giftCardEmailManager->reveal()); - $response = $resendGiftCardEmailAction($giftCard); - - self::assertEquals($expectedResponse, $response); - } - - /** - * @test - */ - public function it_throws_error_if_gift_card_has_no_order_nor_customer(): void - { - $giftCard = new GiftCard(); - - $giftCardEmailManager = $this->prophesize(GiftCardEmailManagerInterface::class); - - $this->expectException(BadRequestHttpException::class); - - $resendGiftCardEmailAction = new ResendGiftCardEmailAction($giftCardEmailManager->reveal()); - $resendGiftCardEmailAction($giftCard); - } -} diff --git a/tests/Unit/Api/Controller/Action/UploadGiftCardConfigurationImageActionTest.php b/tests/Unit/Api/Controller/Action/UploadGiftCardConfigurationImageActionTest.php deleted file mode 100644 index 69f90985..00000000 --- a/tests/Unit/Api/Controller/Action/UploadGiftCardConfigurationImageActionTest.php +++ /dev/null @@ -1,214 +0,0 @@ - 'background', - 'owner' => 'super-iri', - ], [], [], [ - 'file' => $file, - ]); - $giftCardConfigurationImageFactory = $this->prophesize(FactoryInterface::class); - $iriConverter = $this->prophesize(IriConverterInterface::class); - $imageUploader = $this->prophesize(ImageUploaderInterface::class); - $giftCardConfigurationImageRepository = $this->prophesize(RepositoryInterface::class); - - $giftCardConfigurationImageFactory - ->createNew() - ->willReturn($image); - - $iriConverter - ->getItemFromIri('super-iri') - ->willReturn($owner); - - $uploadGiftCardConfigurationImageAction = new UploadGiftCardConfigurationImageAction( - $giftCardConfigurationImageFactory->reveal(), - $giftCardConfigurationImageRepository->reveal(), - $imageUploader->reveal(), - $iriConverter->reveal(), - ); - $returnedImage = $uploadGiftCardConfigurationImageAction($request); - - self::assertSame($owner, $returnedImage->getOwner()); - self::assertSame('background', $returnedImage->getType()); - self::assertSame($file, $returnedImage->getFile()); - } - - /** - * @test - */ - public function it_throws_error_if_image_empty(): void - { - $image = new GiftCardConfigurationImage(); - - $request = new Request([], [ - 'type' => null, - 'owner' => 'super-iri', - ]); - $giftCardConfigurationImageFactory = $this->prophesize(FactoryInterface::class); - $iriConverter = $this->prophesize(IriConverterInterface::class); - $imageUploader = $this->prophesize(ImageUploaderInterface::class); - $giftCardConfigurationImageRepository = $this->prophesize(RepositoryInterface::class); - - $giftCardConfigurationImageFactory - ->createNew() - ->willReturn($image); - - $this->expectException(InvalidArgumentException::class); - - $uploadGiftCardConfigurationImageAction = new UploadGiftCardConfigurationImageAction( - $giftCardConfigurationImageFactory->reveal(), - $giftCardConfigurationImageRepository->reveal(), - $imageUploader->reveal(), - $iriConverter->reveal(), - ); - $uploadGiftCardConfigurationImageAction($request); - } - - /** - * @test - */ - public function it_throws_error_if_owner_iri_empty(): void - { - $file = new UploadedFile(__DIR__ . '/file.jpg', 'file.jpg'); - $image = new GiftCardConfigurationImage(); - - $request = new Request([], [ - 'type' => 'background', - 'owner' => 'super-iri', - ], [], [], [ - 'file' => $file, - ]); - $giftCardConfigurationImageFactory = $this->prophesize(FactoryInterface::class); - $iriConverter = $this->prophesize(IriConverterInterface::class); - $imageUploader = $this->prophesize(ImageUploaderInterface::class); - $giftCardConfigurationImageRepository = $this->prophesize(RepositoryInterface::class); - - $giftCardConfigurationImageFactory - ->createNew() - ->willReturn($image); - - $this->expectException(InvalidArgumentException::class); - - $uploadGiftCardConfigurationImageAction = new UploadGiftCardConfigurationImageAction( - $giftCardConfigurationImageFactory->reveal(), - $giftCardConfigurationImageRepository->reveal(), - $imageUploader->reveal(), - $iriConverter->reveal(), - ); - $uploadGiftCardConfigurationImageAction($request); - } - - /** - * @test - */ - public function it_throws_error_if_owner_not_found(): void - { - $file = new UploadedFile(__DIR__ . '/file.jpg', 'file.jpg'); - $image = new GiftCardConfigurationImage(); - - $request = new Request([], [ - 'type' => 'background', - 'owner' => 'super-iri', - ], [], [], [ - 'file' => $file, - ]); - $giftCardConfigurationImageFactory = $this->prophesize(FactoryInterface::class); - $iriConverter = $this->prophesize(IriConverterInterface::class); - $imageUploader = $this->prophesize(ImageUploaderInterface::class); - $giftCardConfigurationImageRepository = $this->prophesize(RepositoryInterface::class); - - $giftCardConfigurationImageFactory - ->createNew() - ->willReturn($image); - - $iriConverter - ->getItemFromIri('super-iri') - ->willReturn(null); - - $this->expectException(InvalidArgumentException::class); - - $uploadGiftCardConfigurationImageAction = new UploadGiftCardConfigurationImageAction( - $giftCardConfigurationImageFactory->reveal(), - $giftCardConfigurationImageRepository->reveal(), - $imageUploader->reveal(), - $iriConverter->reveal(), - ); - $uploadGiftCardConfigurationImageAction($request); - } - - /** - * @test - */ - public function it_deletes_old_image_of_same_type(): void - { - $file = new UploadedFile(__DIR__ . '/file.jpg', 'file.jpg'); - $image = new GiftCardConfigurationImage(); - $oldImage = new GiftCardConfigurationImage(); - $oldImage->setType('background'); - $owner = new GiftCardConfiguration(); - - $owner->addImage($oldImage); - - $request = new Request([], [ - 'type' => 'background', - 'owner' => 'super-iri', - ], [], [], [ - 'file' => $file, - ]); - $giftCardConfigurationImageFactory = $this->prophesize(FactoryInterface::class); - $iriConverter = $this->prophesize(IriConverterInterface::class); - $imageUploader = $this->prophesize(ImageUploaderInterface::class); - $giftCardConfigurationImageRepository = $this->prophesize(RepositoryInterface::class); - - $giftCardConfigurationImageFactory - ->createNew() - ->willReturn($image); - - $iriConverter - ->getItemFromIri('super-iri') - ->willReturn($owner); - - $giftCardConfigurationImageRepository->remove($oldImage)->shouldBeCalled(); - - $uploadGiftCardConfigurationImageAction = new UploadGiftCardConfigurationImageAction( - $giftCardConfigurationImageFactory->reveal(), - $giftCardConfigurationImageRepository->reveal(), - $imageUploader->reveal(), - $iriConverter->reveal(), - ); - $returnedImage = $uploadGiftCardConfigurationImageAction($request); - - self::assertEquals(1, $owner->getImagesByType('background')->count()); - $image = $owner->getImagesByType('background')->first(); - self::assertEquals($returnedImage, $image); - } -} diff --git a/tests/Unit/Api/Controller/Action/file.jpg b/tests/Unit/Api/Controller/Action/file.jpg deleted file mode 100644 index 889021d3..00000000 Binary files a/tests/Unit/Api/Controller/Action/file.jpg and /dev/null differ diff --git a/tests/Unit/Api/DataPersister/GiftCardDataPersisterTest.php b/tests/Unit/Api/DataPersister/GiftCardDataPersisterTest.php deleted file mode 100644 index 69eb4b6b..00000000 --- a/tests/Unit/Api/DataPersister/GiftCardDataPersisterTest.php +++ /dev/null @@ -1,60 +0,0 @@ -prophesize(ContextAwareDataPersisterInterface::class); - $dataPersister = new GiftCardDataPersister($decoratedDataPersister->reveal()); - - $this->assertTrue($dataPersister->supports(new GiftCard())); - } - - /** - * @test - */ - public function it_removes_data(): void - { - $decoratedDataPersister = $this->prophesize(ContextAwareDataPersisterInterface::class); - $dataPersister = new GiftCardDataPersister($decoratedDataPersister->reveal()); - - $data = new GiftCard(); - $context = []; - $decoratedDataPersister->remove($data, $context)->shouldBeCalled(); - $dataPersister->remove($data, $context); - } - - /** - * @test - */ - public function it_persists_data(): void - { - $decoratedDataPersister = $this->prophesize(ContextAwareDataPersisterInterface::class); - $dataPersister = new GiftCardDataPersister($decoratedDataPersister->reveal()); - - $data = new GiftCard(); - $context = []; - $decoratedDataPersister->persist($data, $context)->shouldBeCalled(); - $decoratedDataPersister->persist($data, $context)->willReturn($data); - /** @var GiftCardInterface $giftCard */ - $giftCard = $dataPersister->persist($data, $context); - - $this->assertSame(GiftCardInterface::ORIGIN_API, $giftCard->getOrigin()); - } -} diff --git a/tests/Unit/Api/DataTransformer/GiftCardCodeAwareInputCommandDataTransformerTest.php b/tests/Unit/Api/DataTransformer/GiftCardCodeAwareInputCommandDataTransformerTest.php deleted file mode 100644 index 324be62e..00000000 --- a/tests/Unit/Api/DataTransformer/GiftCardCodeAwareInputCommandDataTransformerTest.php +++ /dev/null @@ -1,44 +0,0 @@ -supportsTransformation('anything')); - self::assertTrue($dataTransformer->supportsTransformation(new AddGiftCardToOrder('token_value'))); - } - - /** - * @test - */ - public function it_adds_gift_card_code_to_object(): void - { - $dataTransformer = new GiftCardCodeAwareInputCommandDataTransformer(); - - $addGiftCardToOrder = new AddGiftCardToOrder('token_value'); - $giftCard = new GiftCard(); - $giftCard->setCode('gc_code'); - - $transformedCommand = $dataTransformer->transform( - $addGiftCardToOrder, - GiftCardCodeAwareInterface::class, - ['object_to_populate' => $giftCard], - ); - self::assertEquals('gc_code', $transformedCommand->getGiftCardCode()); - } -} diff --git a/tests/Unit/Api/Doctrine/QueryCollectionExtension/GiftCardsByLoggedInUserExtensionTest.php b/tests/Unit/Api/Doctrine/QueryCollectionExtension/GiftCardsByLoggedInUserExtensionTest.php deleted file mode 100644 index 83c3e657..00000000 --- a/tests/Unit/Api/Doctrine/QueryCollectionExtension/GiftCardsByLoggedInUserExtensionTest.php +++ /dev/null @@ -1,146 +0,0 @@ -setCustomer($customer); - - $userContext = $this->prophesize(UserContextInterface::class); - $queryBuilder = $this->prophesize(QueryBuilder::class); - $queryNameGenerator = $this->prophesize(QueryNameGeneratorInterface::class); - - $userContext - ->getUser() - ->willReturn($shopUser); - $queryBuilder - ->getRootAliases() - ->willReturn([0 => 'root_alias']); - - $queryBuilder - ->andWhere('root_alias.customer = :customer') - ->willReturn($queryBuilder->reveal()); - - $queryBuilder - ->setParameter('customer', $customer->getId(), Types::INTEGER) - ->shouldBeCalled(); - - $giftCardsByLoggedInUserExtension = new GiftCardsByLoggedInUserExtension($userContext->reveal()); - $giftCardsByLoggedInUserExtension->applyToCollection( - $queryBuilder->reveal(), - $queryNameGenerator->reveal(), - GiftCardInterface::class, - ); - } - - /** - * @test - */ - public function it_does_not_apply_filter_for_other_collections(): void - { - $shopUser = new ShopUser(); - $customer = new Customer(); - $shopUser->setCustomer($customer); - - $userContext = $this->prophesize(UserContextInterface::class); - $queryBuilder = $this->prophesize(QueryBuilder::class); - $queryNameGenerator = $this->prophesize(QueryNameGeneratorInterface::class); - - $userContext - ->getUser() - ->shouldNotBeCalled(); - $queryBuilder - ->andWhere('root_alias.customer = :customer') - ->shouldNotBeCalled(); - - $giftCardsByLoggedInUserExtension = new GiftCardsByLoggedInUserExtension($userContext->reveal()); - $giftCardsByLoggedInUserExtension->applyToCollection( - $queryBuilder->reveal(), - $queryNameGenerator->reveal(), - ShopUser::class, - ); - } - - /** - * @test - */ - public function it_does_not_apply_filter_if_user_is_admin(): void - { - $user = new AdminUser(); - - $userContext = $this->prophesize(UserContextInterface::class); - $queryBuilder = $this->prophesize(QueryBuilder::class); - $queryNameGenerator = $this->prophesize(QueryNameGeneratorInterface::class); - - $userContext - ->getUser() - ->willReturn($user); - $queryBuilder - ->getRootAliases() - ->shouldNotBeCalled(); - - $queryBuilder - ->andWhere('root_alias.customer = :customer') - ->shouldNotBeCalled(); - - $giftCardsByLoggedInUserExtension = new GiftCardsByLoggedInUserExtension($userContext->reveal()); - $giftCardsByLoggedInUserExtension->applyToCollection( - $queryBuilder->reveal(), - $queryNameGenerator->reveal(), - GiftCardInterface::class, - ); - } - - /** - * @test - */ - public function it_throws_exception_if_user_is_logged_out(): void - { - $userContext = $this->prophesize(UserContextInterface::class); - $queryBuilder = $this->prophesize(QueryBuilder::class); - $queryNameGenerator = $this->prophesize(QueryNameGeneratorInterface::class); - - $userContext - ->getUser() - ->willReturn(null); - $queryBuilder - ->getRootAliases() - ->shouldNotBeCalled(); - - $queryBuilder - ->andWhere('root_alias.customer = :customer') - ->shouldNotBeCalled(); - - $this->expectException(AccessDeniedException::class); - $giftCardsByLoggedInUserExtension = new GiftCardsByLoggedInUserExtension($userContext->reveal()); - $giftCardsByLoggedInUserExtension->applyToCollection( - $queryBuilder->reveal(), - $queryNameGenerator->reveal(), - GiftCardInterface::class, - ); - } -} diff --git a/tests/Unit/EventSubscriber/DefaultGiftCardConfigurationSubscriberTest.php b/tests/Unit/EventSubscriber/DefaultGiftCardConfigurationSubscriberTest.php index bb758820..827e3e04 100644 --- a/tests/Unit/EventSubscriber/DefaultGiftCardConfigurationSubscriberTest.php +++ b/tests/Unit/EventSubscriber/DefaultGiftCardConfigurationSubscriberTest.php @@ -62,10 +62,10 @@ public function it_sets_all_existing_to_not_default_when_updating_existing(): vo self::assertTrue($giftCardConfiguration->isDefault()); } - private function getExistingGiftCardConfiguration(int $id = null, bool $default = true): GiftCardConfigurationInterface + private function getExistingGiftCardConfiguration(?int $id = null, bool $default = true): GiftCardConfigurationInterface { $obj = new class($id) extends GiftCardConfiguration { - public function __construct(int $id = null) + public function __construct(?int $id = null) { parent::__construct(); diff --git a/tests/Unit/Factory/GiftCardFactoryTest.php b/tests/Unit/Factory/GiftCardFactoryTest.php index 94031a27..09be4625 100644 --- a/tests/Unit/Factory/GiftCardFactoryTest.php +++ b/tests/Unit/Factory/GiftCardFactoryTest.php @@ -12,15 +12,14 @@ use Setono\SyliusGiftCardPlugin\Model\GiftCardConfiguration; use Setono\SyliusGiftCardPlugin\Model\GiftCardInterface; use Setono\SyliusGiftCardPlugin\Provider\GiftCardConfigurationProviderInterface; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\Order; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\OrderItem; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\OrderItemUnit; -use Sylius\Bundle\ShippingBundle\Provider\Calendar; -use Sylius\Bundle\ShippingBundle\Provider\DateTimeProvider; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\Order; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\OrderItem; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\OrderItemUnit; use Sylius\Component\Core\Model\Channel; use Sylius\Component\Core\Model\Customer; use Sylius\Component\Currency\Context\CurrencyContextInterface; use Sylius\Component\Resource\Factory\FactoryInterface; +use Symfony\Component\Clock\MockClock; final class GiftCardFactoryTest extends TestCase { @@ -45,7 +44,7 @@ public function it_creates_a_new_gift_card_with_code(): void $decoratedFactory->reveal(), $giftCardCodeGenerator->reveal(), $configurationProvider->reveal(), - new Calendar(), + new MockClock(), $currencyContext->reveal(), ); $createdGiftCard = $factory->createNew(); @@ -75,7 +74,7 @@ public function it_creates_a_new_gift_card_for_channel(): void $decoratedFactory->reveal(), $giftCardCodeGenerator->reveal(), $configurationProvider->reveal(), - new Calendar(), + new MockClock(), $currencyContext->reveal(), ); $createdGiftCard = $factory->createForChannel($channel); @@ -99,19 +98,17 @@ public function it_creates_a_new_gift_card_for_channel_with_expiration_date(): v $decoratedFactory = $this->prophesize(FactoryInterface::class); $giftCardCodeGenerator = $this->prophesize(GiftCardCodeGeneratorInterface::class); $configurationProvider = $this->prophesize(GiftCardConfigurationProviderInterface::class); - $calendar = $this->prophesize(DateTimeProvider::class); $currencyContext = $this->prophesize(CurrencyContextInterface::class); $decoratedFactory->createNew()->willReturn($giftCard); $giftCardCodeGenerator->generate()->willReturn('super-code'); $configurationProvider->getConfigurationForGiftCard($giftCard)->willReturn($giftCardConfiguration); - $calendar->today()->willReturn(new \DateTimeImmutable('2022-01-01 12:00:00')); $factory = new GiftCardFactory( $decoratedFactory->reveal(), $giftCardCodeGenerator->reveal(), $configurationProvider->reveal(), - $calendar->reveal(), + new MockClock('2022-01-01 12:00:00', new \DateTimeZone(date_default_timezone_get())), $currencyContext->reveal(), ); $createdGiftCard = $factory->createForChannel($channel); @@ -142,7 +139,7 @@ public function it_creates_a_new_gift_card_for_channel_from_admin(): void $decoratedFactory->reveal(), $giftCardCodeGenerator->reveal(), $configurationProvider->reveal(), - new Calendar(), + new MockClock(), $currencyContext->reveal(), ); $createdGiftCard = $factory->createForChannelFromAdmin($channel); @@ -179,7 +176,7 @@ public function it_creates_a_new_gift_card_for_order_item_unit_and_cart(): void $decoratedFactory->reveal(), $giftCardCodeGenerator->reveal(), $configurationProvider->reveal(), - new Calendar(), + new MockClock(), $currencyContext->reveal(), ); $createdGiftCard = $factory->createFromOrderItemUnitAndCart($orderItemUnit->reveal(), $cart); @@ -226,7 +223,7 @@ public function it_creates_a_new_gift_card_for_order_item_unit(): void $decoratedFactory->reveal(), $giftCardCodeGenerator->reveal(), $configurationProvider->reveal(), - new Calendar(), + new MockClock(), $currencyContext->reveal(), ); $createdGiftCard = $factory->createFromOrderItemUnit($orderItemUnit->reveal()); @@ -261,7 +258,7 @@ public function it_creates_example_gift_card(): void $decoratedFactory->reveal(), $giftCardCodeGenerator->reveal(), $configurationProvider->reveal(), - new Calendar(), + new MockClock(), $currencyContext->reveal(), ); $returnedGiftCard = $factory->createExample(); diff --git a/tests/Unit/Form/Extension/AddToCartTypeExtensionTest.php b/tests/Unit/Form/Extension/AddToCartTypeExtensionTest.php index f5d988bc..e94d9ee3 100644 --- a/tests/Unit/Form/Extension/AddToCartTypeExtensionTest.php +++ b/tests/Unit/Form/Extension/AddToCartTypeExtensionTest.php @@ -13,10 +13,10 @@ use Setono\SyliusGiftCardPlugin\Model\GiftCardInterface; use Setono\SyliusGiftCardPlugin\Order\AddToCartCommand; use Setono\SyliusGiftCardPlugin\Order\GiftCardInformationInterface; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\Order; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\OrderItem; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\OrderItemUnit; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\Product; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\Order; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\OrderItem; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\OrderItemUnit; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\Product; use Sylius\Component\Core\Model\ChannelInterface; use Sylius\Component\Core\Model\ChannelPricingInterface; use Sylius\Component\Core\Model\ProductVariantInterface; @@ -38,10 +38,13 @@ public function it_populates_cart_item_for_configurable_gift_card(): void $orderItem->getUnits()->willReturn(new ArrayCollection([$orderItemUnit->reveal()])); + $variant = $this->prophesize(ProductVariantInterface::class); + $orderItem->getVariant()->willReturn($variant); + $product = $this->prophesize(Product::class); $product->isGiftCard()->willReturn(true); $product->isGiftCardAmountConfigurable()->willReturn(true); - $orderItem->getProduct()->willReturn($product); + $variant->getProduct()->willReturn($product); $giftCardInformation->getAmount()->willReturn(100); $giftCardInformation->getCustomMessage()->willReturn('custom message'); @@ -85,9 +88,9 @@ public function it_populates_cart_item_for_not_configurable_gift_card(): void $product = $this->prophesize(Product::class); $product->isGiftCard()->willReturn(true); $product->isGiftCardAmountConfigurable()->willReturn(false); - $orderItem->getProduct()->willReturn($product); $cart->getChannel()->willReturn($channel); $orderItem->getVariant()->willReturn($variant); + $variant->getProduct()->willReturn($product); $variant->getChannelPricingForChannel($channel)->willReturn($channelPricing); $channelPricing->getPrice()->willReturn(100); diff --git a/tests/Unit/Model/GiftCardTest.php b/tests/Unit/Model/GiftCardTest.php index f9b76d0e..0b7d922a 100644 --- a/tests/Unit/Model/GiftCardTest.php +++ b/tests/Unit/Model/GiftCardTest.php @@ -8,7 +8,7 @@ use Prophecy\PhpUnit\ProphecyTrait; use Setono\SyliusGiftCardPlugin\Model\GiftCard; use Setono\SyliusGiftCardPlugin\Model\OrderItemUnitInterface; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\OrderItem; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\OrderItem; use Sylius\Component\Core\Model\Channel; use Sylius\Component\Core\Model\Customer; use Sylius\Component\Core\Model\Order; diff --git a/tests/Unit/Model/OrderItemTraitTest.php b/tests/Unit/Model/OrderItemTraitTest.php index 336e314f..8cad4e4e 100644 --- a/tests/Unit/Model/OrderItemTraitTest.php +++ b/tests/Unit/Model/OrderItemTraitTest.php @@ -5,8 +5,8 @@ namespace Setono\SyliusGiftCardPlugin\Tests\Unit\Model; use PHPUnit\Framework\TestCase; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\OrderItem; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\Product; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\OrderItem; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\Product; use Sylius\Component\Core\Model\ProductVariant; final class OrderItemTraitTest extends TestCase diff --git a/tests/Unit/Model/ProductTraitTest.php b/tests/Unit/Model/ProductTraitTest.php index a8148aac..8d1f098e 100644 --- a/tests/Unit/Model/ProductTraitTest.php +++ b/tests/Unit/Model/ProductTraitTest.php @@ -5,7 +5,7 @@ namespace Setono\SyliusGiftCardPlugin\Tests\Unit\Model; use PHPUnit\Framework\TestCase; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\Product; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\Product; final class ProductTraitTest extends TestCase { diff --git a/tests/Unit/Operator/GiftCardOperatorTest.php b/tests/Unit/Operator/GiftCardOperatorTest.php index 06d42c9a..d8ce5427 100644 --- a/tests/Unit/Operator/GiftCardOperatorTest.php +++ b/tests/Unit/Operator/GiftCardOperatorTest.php @@ -11,10 +11,10 @@ use Setono\SyliusGiftCardPlugin\EmailManager\GiftCardEmailManagerInterface; use Setono\SyliusGiftCardPlugin\Model\GiftCard; use Setono\SyliusGiftCardPlugin\Operator\OrderGiftCardOperator; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\Order; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\OrderItem; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\OrderItemUnit; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\Product; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\Order; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\OrderItem; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\OrderItemUnit; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\Product; use Sylius\Component\Core\Model\Customer; use Sylius\Component\Core\Model\ProductVariant; diff --git a/tests/Unit/Order/AddToCartCommandTest.php b/tests/Unit/Order/AddToCartCommandTest.php index f8be01ec..7eea5d1a 100644 --- a/tests/Unit/Order/AddToCartCommandTest.php +++ b/tests/Unit/Order/AddToCartCommandTest.php @@ -7,8 +7,8 @@ use PHPUnit\Framework\TestCase; use Setono\SyliusGiftCardPlugin\Order\AddToCartCommand; use Setono\SyliusGiftCardPlugin\Order\GiftCardInformation; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\Order; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\OrderItem; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\Order; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\OrderItem; final class AddToCartCommandTest extends TestCase { diff --git a/tests/Unit/Order/Factory/AddToCardCommandFactoryTest.php b/tests/Unit/Order/Factory/AddToCardCommandFactoryTest.php index a7c4e725..07fc2038 100644 --- a/tests/Unit/Order/Factory/AddToCardCommandFactoryTest.php +++ b/tests/Unit/Order/Factory/AddToCardCommandFactoryTest.php @@ -9,8 +9,8 @@ use Setono\SyliusGiftCardPlugin\Order\Factory\AddToCartCommandFactory; use Setono\SyliusGiftCardPlugin\Order\Factory\GiftCardInformationFactory; use Setono\SyliusGiftCardPlugin\Order\GiftCardInformation; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\Order; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\OrderItem; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\Order; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\OrderItem; final class AddToCardCommandFactoryTest extends TestCase { diff --git a/tests/Unit/Order/Factory/GiftCardInformationFactoryTest.php b/tests/Unit/Order/Factory/GiftCardInformationFactoryTest.php index 6d2ce10d..0523b8f2 100644 --- a/tests/Unit/Order/Factory/GiftCardInformationFactoryTest.php +++ b/tests/Unit/Order/Factory/GiftCardInformationFactoryTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Setono\SyliusGiftCardPlugin\Order\Factory\GiftCardInformationFactory; use Setono\SyliusGiftCardPlugin\Order\GiftCardInformation; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\OrderItem; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\OrderItem; final class GiftCardInformationFactoryTest extends TestCase { diff --git a/tests/Unit/Provider/OrderEligibleTotalProviderTest.php b/tests/Unit/Provider/OrderEligibleTotalProviderTest.php index d4e81726..d4b3f85d 100644 --- a/tests/Unit/Provider/OrderEligibleTotalProviderTest.php +++ b/tests/Unit/Provider/OrderEligibleTotalProviderTest.php @@ -8,7 +8,7 @@ use Prophecy\PhpUnit\ProphecyTrait; use Setono\SyliusGiftCardPlugin\Model\GiftCard; use Setono\SyliusGiftCardPlugin\Provider\OrderEligibleTotalProvider; -use Setono\SyliusGiftCardPlugin\Tests\Application\Model\Order; +use Setono\SyliusGiftCardPlugin\Tests\TestApplication\Entity\Order; final class OrderEligibleTotalProviderTest extends TestCase { diff --git a/src/Resources/translations/flashes.da.yml b/translations/flashes.da.yml similarity index 100% rename from src/Resources/translations/flashes.da.yml rename to translations/flashes.da.yml diff --git a/src/Resources/translations/flashes.en.yml b/translations/flashes.en.yml similarity index 100% rename from src/Resources/translations/flashes.en.yml rename to translations/flashes.en.yml diff --git a/src/Resources/translations/flashes.fr.yml b/translations/flashes.fr.yml similarity index 100% rename from src/Resources/translations/flashes.fr.yml rename to translations/flashes.fr.yml diff --git a/src/Resources/translations/messages.da.yml b/translations/messages.da.yml similarity index 100% rename from src/Resources/translations/messages.da.yml rename to translations/messages.da.yml diff --git a/src/Resources/translations/messages.en.yml b/translations/messages.en.yml similarity index 100% rename from src/Resources/translations/messages.en.yml rename to translations/messages.en.yml diff --git a/src/Resources/translations/messages.fr.yml b/translations/messages.fr.yml similarity index 100% rename from src/Resources/translations/messages.fr.yml rename to translations/messages.fr.yml diff --git a/src/Resources/translations/validators.da.yml b/translations/validators.da.yml similarity index 100% rename from src/Resources/translations/validators.da.yml rename to translations/validators.da.yml diff --git a/src/Resources/translations/validators.en.yml b/translations/validators.en.yml similarity index 100% rename from src/Resources/translations/validators.en.yml rename to translations/validators.en.yml diff --git a/src/Resources/translations/validators.fr.yml b/translations/validators.fr.yml similarity index 100% rename from src/Resources/translations/validators.fr.yml rename to translations/validators.fr.yml