diff --git a/.docker/nginx/nginx.conf b/.docker/nginx/nginx.conf new file mode 100644 index 0000000..6bfbd29 --- /dev/null +++ b/.docker/nginx/nginx.conf @@ -0,0 +1,48 @@ +user www-data; +worker_processes auto; +daemon off; +pid /run/nginx.pid; + +include /etc/nginx/modules-enabled/*.conf; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + server_tokens off; + + client_max_body_size 64m; + sendfile on; + tcp_nodelay on; + tcp_nopush on; + + gzip_vary on; + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + server { + listen 80; + + root /app/tests/Application/public; + index index.php; + + location / { + try_files $uri /index.php$is_args$args; + } + + location ~ \.php$ { + include fastcgi_params; + + fastcgi_pass unix:/var/run/php8-fpm.sock; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + } + } +} diff --git a/.docker/php/php.ini b/.docker/php/php.ini new file mode 100644 index 0000000..13f0abe --- /dev/null +++ b/.docker/php/php.ini @@ -0,0 +1,5 @@ +[PHP] +memory_limit=512M + +[date] +date.timezone=${PHP_DATE_TIMEZONE} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b5f72a5 --- /dev/null +++ b/.editorconfig @@ -0,0 +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 = space +indent_size = 4 + +[*.{yaml,yml}] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = false + +[.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/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..92faea2 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @Sylius/core-team diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..bab287a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,43 @@ +version: 2 +updates: +- package-ecosystem: composer + directory: "/" + schedule: + interval: daily + time: "10:00" + open-pull-requests-limit: 10 + ignore: + - dependency-name: vimeo/psalm + versions: + - 4.5.0 + - 4.5.1 + - 4.5.2 + - 4.6.0 + - 4.6.1 + - 4.6.2 + - 4.6.3 + - 4.7.0 + - 4.7.1 + - dependency-name: phpstan/phpstan + versions: + - 0.12.70 + - 0.12.71 + - 0.12.73 + - 0.12.75 + - 0.12.76 + - 0.12.77 + - 0.12.78 + - 0.12.80 + - 0.12.81 + - 0.12.83 + - 0.12.84 + - dependency-name: sylius-labs/coding-standard + versions: + - 4.0.2 + - dependency-name: phpstan/phpstan-doctrine + versions: + - 0.12.32 + - dependency-name: phpstan/phpstan-webmozart-assert + versions: + - 0.12.10 + - 0.12.11 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..dc279a0 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,190 @@ +name: Build + +on: + push: + branches-ignore: + - 'dependabot/**' + pull_request: ~ + release: + types: [created] + schedule: + - + cron: "0 1 * * 6" # Run at 1am every Saturday + workflow_dispatch: ~ + +jobs: + tests: + runs-on: ubuntu-latest + + name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" + + strategy: + fail-fast: false + matrix: + php: ["8.0", "8.1"] + symfony: ["5.4.*", "^6.0"] + sylius: ["^1.12"] + node: ["14.x", "16.x", "18.x"] + mysql: ["5.7", "8.0"] + + env: + APP_ENV: test + DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" + + steps: + - + uses: actions/checkout@v3 + + - + name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + extensions: intl + tools: flex,symfony + coverage: none + + - + name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: "${{ matrix.node }}" + + - + name: Shutdown default MySQL + run: sudo service mysql stop + + - + name: Setup MySQL + uses: mirromutth/mysql-action@v1.1 + with: + mysql version: "${{ matrix.mysql }}" + mysql root password: "root" + + - + name: Output PHP version for Symfony CLI + run: php -v | head -n 1 | awk '{ print $2 }' > .php-version + + - + name: Install certificates + run: symfony server:ca:install + + - + name: Run Chrome Headless + run: google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 & + + - + name: Run webserver + run: (cd tests/Application && symfony server:start --port=8080 --dir=public --daemon) + + - + name: Get Composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - + name: Cache Composer + uses: actions/cache@v3 + with: + 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: Configure global composer + run: | + composer global config --no-plugins allow-plugins.symfony/flex true + composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^2.2.2" + + - + name: Restrict Symfony version + if: matrix.symfony != '' + run: | + composer config extra.symfony.require "${{ matrix.symfony }}" + + - + name: Restrict Sylius version + if: matrix.sylius != '' + run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction + + - + name: Install PHP dependencies + run: composer install --no-interaction + env: + SYMFONY_REQUIRE: ${{ matrix.symfony }} + + - + name: Get Yarn cache directory + id: yarn-cache + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - + name: Cache Yarn + uses: actions/cache@v3 + with: + 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: Install JS dependencies + run: (cd tests/Application && yarn install) + + - + name: Prepare test application database + run: | + (cd tests/Application && bin/console doctrine:database:create -vvv) + (cd tests/Application && bin/console doctrine:schema:create -vvv) + + - + name: Prepare test application assets + run: | + (cd tests/Application && bin/console assets:install public -vvv) + (cd tests/Application && yarn build:prod) + + - + name: Prepare test application cache + run: (cd tests/Application && bin/console cache:warmup -vvv) + + - + name: Load fixtures in test application + run: (cd tests/Application && bin/console sylius:fixtures:load -n) + + - + name: Validate composer.json + run: composer validate --ansi --strict + + - + name: Validate database schema + run: (cd tests/Application && bin/console doctrine:schema:validate) + + - + name: Run PHPStan + run: vendor/bin/phpstan analyse -c phpstan.neon -l max src/ + + - + name: Run Psalm + run: vendor/bin/psalm + + - + name: Run PHPSpec + run: vendor/bin/phpspec run --ansi -f progress --no-interaction + + - + name: Run PHPUnit + run: vendor/bin/phpunit --colors=always + + - + name: Run Behat + run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun + + - + name: Upload Behat logs + uses: actions/upload-artifact@v3 + if: failure() + with: + name: Behat logs + path: etc/build/ + if-no-files-found: ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5cefda9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +/vendor/ +/node_modules/ +/composer.lock + +/etc/build/* +!/etc/build/.gitignore + +/tests/Application/yarn.lock + +/.phpunit.result.cache +/behat.yml +/phpspec.yml +/phpunit.xml +.phpunit.result.cache + +# Symfony CLI https://symfony.com/doc/current/setup/symfony_server.html#different-php-settings-per-project +/.php-version +/php.ini diff --git a/CONFLICTS.md b/CONFLICTS.md new file mode 100644 index 0000000..dab299f --- /dev/null +++ b/CONFLICTS.md @@ -0,0 +1,9 @@ +# CONFLICTS + +This document explains why certain conflicts were added to `composer.json` and +references related issues. + +- `symfony/framework-bundle:6.2.8`: + + This version is missing the service alias `validator.expression` + which causes ValidatorException exception to be thrown when using `Expression` constraint. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..01d9607 --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +phpunit: + vendor/bin/phpunit + +phpspec: + vendor/bin/phpspec run --ansi --no-interaction -f dot + +phpstan: + vendor/bin/phpstan analyse + +psalm: + vendor/bin/psalm + +behat-js: + APP_ENV=test vendor/bin/behat --colors --strict --no-interaction -vvv -f progress + +install: + composer install --no-interaction --no-scripts + +backend: + tests/Application/bin/console sylius:install --no-interaction + tests/Application/bin/console sylius:fixtures:load default --no-interaction + +frontend: + (cd tests/Application && yarn install --pure-lockfile) + (cd tests/Application && GULP_ENV=prod yarn build) + +behat: + APP_ENV=test vendor/bin/behat --colors --strict --no-interaction -vvv -f progress + +init: install backend frontend + +ci: init phpstan psalm phpunit phpspec behat + +integration: init phpunit behat + +static: install phpspec phpstan psalm diff --git a/README.md b/README.md new file mode 100644 index 0000000..9b2984a --- /dev/null +++ b/README.md @@ -0,0 +1,122 @@ +

+ + + +

+ +

Plugin Skeleton

+ +

Skeleton for starting Sylius plugins.

+ +## Documentation + +For a comprehensive guide on Sylius Plugins development please go to Sylius documentation, +there you will find the Plugin Development Guide, that is full of examples. + +## Quickstart Installation + +### Traditional + +1. Run `composer create-project sylius/plugin-skeleton ProjectName`. + +2. From the plugin skeleton root directory, run the following commands: + + ```bash + $ (cd tests/Application && yarn install) + $ (cd tests/Application && yarn build) + $ (cd tests/Application && APP_ENV=test bin/console assets:install public) + + $ (cd tests/Application && APP_ENV=test bin/console doctrine:database:create) + $ (cd tests/Application && APP_ENV=test bin/console doctrine:schema:create) + ``` + +To be able to set up a plugin's database, remember to configure you database credentials in `tests/Application/.env` and `tests/Application/.env.test`. + +### Docker + +1. Execute `docker compose up -d` + +2. Initialize plugin `docker compose exec app make init` + +3. See your browser `open localhost` + +## Usage + +### Running plugin tests + + - PHPUnit + + ```bash + vendor/bin/phpunit + ``` + + - PHPSpec + + ```bash + vendor/bin/phpspec run + ``` + + - Behat (non-JS scenarios) + + ```bash + vendor/bin/behat --strict --tags="~@javascript" + ``` + + - Behat (JS scenarios) + + 1. [Install Symfony CLI command](https://symfony.com/download). + + 2. Start Headless Chrome: + + ```bash + 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 + ``` + + 3. Install SSL certificates (only once needed) and run test application's webserver on `127.0.0.1:8080`: + + ```bash + symfony server:ca:install + APP_ENV=test symfony server:start --port=8080 --dir=tests/Application/public --daemon + ``` + + 4. Run Behat: + + ```bash + vendor/bin/behat --strict --tags="@javascript" + ``` + + - Static Analysis + + - Psalm + + ```bash + vendor/bin/psalm + ``` + + - PHPStan + + ```bash + vendor/bin/phpstan analyse -c phpstan.neon -l max src/ + ``` + + - Coding Standard + + ```bash + vendor/bin/ecs check + ``` + +### Opening Sylius with your plugin + +- Using `test` environment: + + ```bash + (cd tests/Application && APP_ENV=test bin/console sylius:fixtures:load) + (cd tests/Application && APP_ENV=test bin/console server:run -d public) + ``` + +- Using `dev` environment: + + ```bash + (cd tests/Application && APP_ENV=dev bin/console sylius:fixtures:load) + (cd tests/Application && APP_ENV=dev bin/console server:run -d public) + ``` diff --git a/UPGRADE.md b/UPGRADE.md new file mode 100644 index 0000000..8c28fba --- /dev/null +++ b/UPGRADE.md @@ -0,0 +1,122 @@ +# UPGRADE FROM `v1.3.X` TO `v1.4.0` + +First step is upgrading Sylius with composer + +- `composer require sylius/sylius:~1.4.0` + +### Test application database + +#### Migrations + +If you provide migrations with your plugin, take a look at following changes: + +* Change base `AbstractMigration` namespace to `Doctrine\Migrations\AbstractMigration` +* Add `: void` return types to both `up` and `down` functions + +#### Schema update + +If you don't use migrations, just run `(cd tests/Application && bin/console doctrine:schema:update --force)` to update the test application's database schema. + +### Dotenv + +* `composer require symfony/dotenv:^4.2 --dev` +* Follow [Symfony dotenv update guide](https://symfony.com/doc/current/configuration/dot-env-changes.html) to incorporate required changes in `.env` files structure. Remember - they should be done on `tests/Application/` level! Optionally, you can take a look at [corresponding PR](https://github.com/Sylius/PluginSkeleton/pull/156/) introducing these changes in **PluginSkeleton** (this PR also includes changes with Behat - see below) + +Don't forget to clear the cache (`tests/Application/bin/console cache:clear`) to be 100% everything is loaded properly. + +### Test application kernel + +The kernel of the test application needs to be replaced with this [file](https://github.com/Sylius/PluginSkeleton/blob/1.4/tests/Application/Kernel.php). +The location of the kernel is: `tests/Application/Kernel.php` (replace the content with the content of the file above). +The container cleanup method is removed in the new version and keeping it will cause problems with for example the `TagAwareAdapter` which will call `commit()` on its pool from its destructor. If its pool is `TraceableAdapter` with pool `ArrayAdapter`, then the pool property of `TraceableAdapter` will be nullified before the destructor is executed and cause an error. + +--- + +### Behat + +If you're using Behat and want to be up-to-date with our configuration + +* Update required extensions with `composer require friends-of-behat/symfony-extension:^2.0 friends-of-behat/page-object-extension:^0.3 --dev` +* Remove extensions that are not needed yet with `composer remove friends-of-behat/context-service-extension friends-of-behat/cross-container-extension friends-of-behat/service-container-extension --dev` +* Update your `behat.yml` - look at the diff [here](https://github.com/Sylius/Sylius-Standard/pull/322/files#diff-7bde54db60a6e933518d8b61b929edce) +* Add `SymfonyExtensionBundle` to your `tests/Application/config/bundles.php`: + ```php + return [ + //... + FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true], + ]; + ``` +* If you use our Travis CI configuration, follow [these changes](https://github.com/Sylius/PluginSkeleton/pull/156/files#diff-354f30a63fb0907d4ad57269548329e3) introduced in `.travis.yml` file +* Create `tests/Application/config/services_test.yaml` file with the following code and add these your own Behat services as well: + ```yaml + imports: + - { resource: "../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" } + ``` +* Remove all `__symfony__` prefixes in your Behat services +* Remove all `` tags from your Behat services +* Make your Behat services public by default with `` +* Change `contexts_services ` in your suite definitions to `contexts` +* Take a look at [SymfonyExtension UPGRADE guide](https://github.com/FriendsOfBehat/SymfonyExtension/blob/master/UPGRADE-2.0.md) if you have any more problems + +### Phpstan + +* Fix the container XML path parameter in the `phpstan.neon` file as done [here](https://github.com/Sylius/PluginSkeleton/commit/37fa614dbbcf8eb31b89eaf202b4bd4d89a5c7b3) + +# UPGRADE FROM `v1.2.X` TO `v1.4.0` + +Firstly, check out the [PluginSkeleton 1.3 upgrade guide](https://github.com/Sylius/PluginSkeleton/blob/1.4/UPGRADE-1.3.md) to update Sylius version step by step. +To upgrade to Sylius 1.4 follow instructions from [the previous section](https://github.com/Sylius/PluginSkeleton/blob/1.4/UPGRADE-1.4.md#upgrade-from-v13x-to-v140) with following changes: + +### Doctrine migrations + +* Change namespaces of copied migrations to `Sylius\Migrations` + +### Dotenv + +* These changes are not required, but can be done as well, if you've changed application directory structure in `1.2.x` to `1.3` update + +### Behat + +* Add `\FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle()` to your bundles lists in `tests/Application/AppKernel.php` (preferably only in `test` environment) +* Import Sylius Behat services in `tests/Application/config/config_test.yml` and your own Behat services as well: + ```yaml + imports: + - { resource: "../../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" } + ``` +* Specify test application's kernel path in `behat.yml`: + ```yaml + FriendsOfBehat\SymfonyExtension: + kernel: + class: AppKernel + path: tests/Application/app/AppKernel.php + ``` + + +# UPGRADE FROM `v1.2.X` TO `v1.3.0` + +## Application + +* Run `composer require sylius/sylius:~1.3.0 --no-update` + +* Add the following code in your `behat.yml(.dist)` file: + + ```yaml + default: + extensions: + FriendsOfBehat\SymfonyExtension: + env_file: ~ + ``` + +* Incorporate changes from the following files into plugin's test application: + + * [`tests/Application/package.json`](https://github.com/Sylius/PluginSkeleton/blob/1.3/tests/Application/package.json) ([see diff](https://github.com/Sylius/PluginSkeleton/pull/134/files#diff-726e1353c14df7d91379c0dea6b30eef)) + * [`tests/Application/.babelrc`](https://github.com/Sylius/PluginSkeleton/blob/1.3/tests/Application/.babelrc) ([see diff](https://github.com/Sylius/PluginSkeleton/pull/134/files#diff-a2527d9d8ad55460b2272274762c9386)) + * [`tests/Application/.eslintrc.js`](https://github.com/Sylius/PluginSkeleton/blob/1.3/tests/Application/.eslintrc.js) ([see diff](https://github.com/Sylius/PluginSkeleton/pull/134/files#diff-396c8c412b119deaa7dd84ae28ae04ca)) + +* Update PHP and JS dependencies by running `composer update` and `(cd tests/Application && yarn upgrade)` + +* Clear cache by running `(cd tests/Application && bin/console cache:clear)` + +* Install assets by `(cd tests/Application && bin/console assets:install web)` and `(cd tests/Application && yarn build)` + +* optionally, remove the build for PHP 7.1. in `.travis.yml` diff --git a/behat.yml.dist b/behat.yml.dist new file mode 100644 index 0000000..b9401b7 --- /dev/null +++ b/behat.yml.dist @@ -0,0 +1,55 @@ +imports: + - vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml + - tests/Behat/Resources/suites.yml + +default: + extensions: + DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~ + + FriendsOfBehat\MinkDebugExtension: + directory: etc/build + clean_start: false + screenshot: true + + Behat\MinkExtension: + files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/" + base_url: "https://127.0.0.1:8080/" + default_session: symfony + javascript_session: chrome_headless + sessions: + symfony: + symfony: ~ + chrome_headless: + chrome: + api_url: http://127.0.0.1:9222 + validate_certificate: false + chrome: + selenium2: + browser: chrome + capabilities: + browserName: chrome + browser: chrome + version: "" + marionette: null # https://github.com/Behat/MinkExtension/pull/311 + chrome: + switches: + - "start-fullscreen" + - "start-maximized" + - "no-sandbox" + extra_capabilities: + unexpectedAlertBehaviour: accept + firefox: + selenium2: + browser: firefox + show_auto: false + + FriendsOfBehat\SymfonyExtension: + bootstrap: tests/Application/config/bootstrap.php + kernel: + class: Tests\Acme\SyliusExamplePlugin\Application\Kernel + + FriendsOfBehat\VariadicExtension: ~ + + FriendsOfBehat\SuiteSettingsExtension: + paths: + - "features" diff --git a/bin/create_node_symlink.php b/bin/create_node_symlink.php new file mode 100644 index 0000000..10d69b4 --- /dev/null +++ b/bin/create_node_symlink.php @@ -0,0 +1,45 @@ + `' . NODE_MODULES_FOLDER_NAME . '` already exists as a link or folder, keeping existing as may be intentional.' . PHP_EOL; + exit(0); + } else { + echo '> Invalid symlink `' . NODE_MODULES_FOLDER_NAME . '` detected, recreating...' . PHP_EOL; + if (!@unlink(NODE_MODULES_FOLDER_NAME)) { + echo '> Could not delete file `' . NODE_MODULES_FOLDER_NAME . '`.' . PHP_EOL; + exit(1); + } + } +} + +/* try to create the symlink using PHP internals... */ +$success = @symlink(PATH_TO_NODE_MODULES, NODE_MODULES_FOLDER_NAME); + +/* if case it has failed, but OS is Windows... */ +if (!$success && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + /* ...then try a different approach which does not require elevated permissions and folder to exist */ + echo '> This system is running Windows, creation of links requires elevated privileges,' . PHP_EOL; + echo '> and target path to exist. Fallback to NTFS Junction:' . PHP_EOL; + exec(sprintf('mklink /J %s %s 2> NUL', NODE_MODULES_FOLDER_NAME, PATH_TO_NODE_MODULES), $output, $returnCode); + $success = $returnCode === 0; + if (!$success) { + echo '> Failed o create the required symlink' . PHP_EOL; + exit(2); + } +} + +$path = @readlink(NODE_MODULES_FOLDER_NAME); +/* check if link points to the intended directory */ +if ($path && realpath($path) === realpath(PATH_TO_NODE_MODULES)) { + echo '> Successfully created the symlink.' . PHP_EOL; + exit(0); +} + +echo '> Failed to create the symlink to `' . NODE_MODULES_FOLDER_NAME . '`.' . PHP_EOL; +exit(3); diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..aae1f3f --- /dev/null +++ b/composer.json @@ -0,0 +1,92 @@ +{ + "name": "sylius/plugin-skeleton", + "type": "sylius-plugin", + "description": "Acme example plugin for Sylius.", + "keywords": [ + "sylius", + "sylius-plugin" + ], + "license": "MIT", + "require": { + "php": "^8.0", + "sylius/sylius": "^1.12", + "sylius/mailer-bundle": "^1.8 || ^2.0@beta", + "symfony/webpack-encore-bundle": "^1.15" + }, + "require-dev": { + "behat/behat": "^3.6.1", + "behat/mink-selenium2-driver": "^1.4", + "dmore/behat-chrome-extension": "^1.3", + "dmore/chrome-mink-driver": "^2.7", + "friends-of-behat/mink": "^1.8", + "friends-of-behat/mink-browserkit-driver": "^1.4", + "friends-of-behat/mink-debug-extension": "^2.0.0", + "friends-of-behat/mink-extension": "^2.4", + "friends-of-behat/page-object-extension": "^0.3", + "friends-of-behat/suite-settings-extension": "^1.0", + "friends-of-behat/symfony-extension": "^2.1", + "friends-of-behat/variadic-extension": "^1.3", + "phpspec/phpspec": "^7.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^1.8.1", + "phpstan/phpstan-doctrine": "1.3.40", + "phpstan/phpstan-strict-rules": "^1.3.0", + "phpstan/phpstan-webmozart-assert": "^1.2.0", + "phpunit/phpunit": "^9.5", + "polishsymfonycommunity/symfony-mocker-container": "^1.0", + "sylius-labs/coding-standard": "^4.2", + "symfony/browser-kit": "^5.4 || ^6.0", + "symfony/debug-bundle": "^5.4 || ^6.0", + "symfony/dotenv": "^5.4 || ^6.0", + "symfony/flex": "^2.2.2", + "symfony/intl": "^5.4 || ^6.0", + "symfony/web-profiler-bundle": "^5.4 || ^6.0", + "vimeo/psalm": "5.12.0" + }, + "conflict": { + "symfony/framework-bundle": "6.2.8" + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": false, + "phpstan/extension-installer": true, + "symfony/flex": true + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.12-dev" + }, + "symfony": { + "require": "^5.4 || ^6.0" + } + }, + "autoload": { + "psr-4": { + "Acme\\SyliusExamplePlugin\\": "src/", + "Tests\\Acme\\SyliusExamplePlugin\\": "tests/" + } + }, + "autoload-dev": { + "classmap": [ + "tests/Application/Kernel.php" + ] + }, + "scripts": { + "post-install-cmd": [ + "php bin/create_node_symlink.php" + ], + "post-update-cmd": [ + "php bin/create_node_symlink.php" + ], + "post-create-project-cmd": [ + "php bin/create_node_symlink.php" + ], + "auto-scripts": { + "cache:clear": "symfony-cmd", + "assets:install %PUBLIC_DIR%": "symfony-cmd", + "security-checker security:check": "script" + } + } +} diff --git a/config/admin_routing.yml b/config/admin_routing.yml new file mode 100644 index 0000000..4ba2ca1 --- /dev/null +++ b/config/admin_routing.yml @@ -0,0 +1 @@ +# Define your own admin routes here diff --git a/config/services.xml b/config/services.xml new file mode 100644 index 0000000..7a3a6ac --- /dev/null +++ b/config/services.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/config/shop_routing.yml b/config/shop_routing.yml new file mode 100644 index 0000000..7f47db1 --- /dev/null +++ b/config/shop_routing.yml @@ -0,0 +1,13 @@ +# Delete these routes and define your own shop routes here + +acme_sylius_example_static_welcome: + path: /static-welcome/{name} + defaults: + _controller: Acme\SyliusExamplePlugin\Controller\GreetingController::staticallyGreetAction + name: ~ + +acme_sylius_example_dynamic_welcome: + path: /dynamic-welcome/{name} + defaults: + _controller: Acme\SyliusExamplePlugin\Controller\GreetingController::dynamicallyGreetAction + name: ~ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a3e00ab --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,42 @@ +services: + app: + image: sylius/standard:1.11-traditional-alpine + environment: + APP_ENV: "dev" + DATABASE_URL: "mysql://root:mysql@mysql/sylius_%kernel.environment%?charset=utf8mb4" +# DATABASE_URL: "pgsql://root:postgres@postgres/sylius_%kernel.environment%?charset=utf8" # When using postgres + PHP_DATE_TIMEZONE: "Europe/Warsaw" + volumes: + - ./:/app:delegated + - ./.docker/php/php.ini:/etc/php8/php.ini:delegated + - ./.docker/nginx/nginx.conf:/etc/nginx/nginx.conf:delegated + ports: + - 80:80 + depends_on: + - mysql + networks: + - sylius + + mysql: + image: mysql:8.0 + platform: linux/amd64 + environment: + MYSQL_ROOT_PASSWORD: mysql + ports: + - ${MYSQL_PORT:-3306}:3306 + networks: + - sylius + +# postgres: +# image: postgres:14-alpine +# environment: +# POSTGRES_USER: root +# POSTGRES_PASSWORD: postgres +# ports: +# - ${POSTGRES_PORT:-5432}:5432 +# networks: +# - sylius + +networks: + sylius: + driver: bridge diff --git a/ecs.php b/ecs.php new file mode 100644 index 0000000..3cf43de --- /dev/null +++ b/ecs.php @@ -0,0 +1,21 @@ +paths([ + __DIR__ . '/src', + __DIR__ . '/tests/Behat', + __DIR__ . '/ecs.php', + ]); + + $ecsConfig->import('vendor/sylius-labs/coding-standard/ecs.php'); + + $ecsConfig->skip([ + VisibilityRequiredFixer::class => ['*Spec.php'], + ]); +}; + diff --git a/etc/build/.gitignore b/etc/build/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/features/dynamically_greeting_a_customer.feature b/features/dynamically_greeting_a_customer.feature new file mode 100644 index 0000000..5dc5dd7 --- /dev/null +++ b/features/dynamically_greeting_a_customer.feature @@ -0,0 +1,17 @@ +@greeting_customer @javascript +Feature: Dynamically greeting a customer + In order to provide an ultimate customer experience + As a Store Owner + I want to welcome new customers dynamically + + Scenario: Dynamically greeting a customer with an unknown name + When a customer with an unknown name visits dynamic welcome page + Then they should be dynamically greeted with "Hello!" + + Scenario: Dynamically greeting a customer with a known name + When a customer named "Krzysztof" visits dynamic welcome page + Then they should be dynamically greeted with "Hello, Krzysztof!" + + Scenario: Dynamically greeting Lionel Richie + When a customer named "Lionel Richie" visits dynamic welcome page + Then they should be dynamically greeted with "Hello, is it me you're looking for?" diff --git a/features/running_a_sylius_feature.feature b/features/running_a_sylius_feature.feature new file mode 100644 index 0000000..6090db1 --- /dev/null +++ b/features/running_a_sylius_feature.feature @@ -0,0 +1,42 @@ +# Sylius/Sylius:features/product/managing_products/adding_product_with_associations.feature + +@managing_products +Feature: Adding a new product with associations + In order to associate my product with others + As an Administrator + I want to add a new product with associated products + + Background: + Given the store operates on a single channel in "United States" + And the store has "Accessories" and "Alternatives" product association types + And the store has "LG headphones", "LG earphones", "LG G4" and "LG G5" products + And I am logged in as an administrator + + @ui @javascript + Scenario: Adding a new product with associations + When I want to create a new simple product + And I specify its code as "lg_g3" + And I name it "LG G3" in "English (United States)" + And I set its price to "$400.00" for "United States" channel + And I associate as "Accessories" the "LG headphones" and "LG earphones" products + And I associate as "Alternatives" the "LG G4" and "LG G5" products + And I add it + Then I should be notified that it has been successfully created + And this product should have an association "Accessories" with products "LG headphones" and "LG earphones" + And this product should also have an association "Alternatives" with products "LG G4" and "LG G5" + And the product "LG G3" should appear in the store + + @ui @javascript + Scenario: Adding a new product with associations after changing associated items + When I want to create a new simple product + And I specify its code as "lg_g3" + And I name it "LG G3" in "English (United States)" + And I set its price to "$400.00" for "United States" channel + And I associate as "Accessories" the "LG headphones" and "LG earphones" products + And I remove an associated product "LG earphones" from "Accessories" + And I add it + Then I should be notified that it has been successfully created + And this product should have an association "Accessories" with product "LG headphones" + And this product should not have an association "Accessories" with product "LG earphones" + And the product "LG G3" should appear in the store + diff --git a/features/statically_greeting_a_customer.feature b/features/statically_greeting_a_customer.feature new file mode 100644 index 0000000..484eb24 --- /dev/null +++ b/features/statically_greeting_a_customer.feature @@ -0,0 +1,17 @@ +@greeting_customer +Feature: Statically greeting a customer + In order to provide an ultimate customer experience + As a Store Owner + I want to welcome new customers + + Scenario: Statically greeting a customer with an unknown name + When a customer with an unknown name visits static welcome page + Then they should be statically greeted with "Hello!" + + Scenario: Statically greeting a customer with a known name + When a customer named "Krzysztof" visits static welcome page + Then they should be statically greeted with "Hello, Krzysztof!" + + Scenario: Statically greeting Lionel Richie + When a customer named "Lionel Richie" visits static welcome page + Then they should be statically greeted with "Hello, is it me you're looking for?" diff --git a/migrations/.gitignore b/migrations/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/node_modules b/node_modules new file mode 120000 index 0000000..9270531 --- /dev/null +++ b/node_modules @@ -0,0 +1 @@ +tests/Application/node_modules \ No newline at end of file diff --git a/phpspec.yml.dist b/phpspec.yml.dist new file mode 100644 index 0000000..ae371ee --- /dev/null +++ b/phpspec.yml.dist @@ -0,0 +1,4 @@ +suites: + main: + namespace: Acme\SyliusExamplePlugin + psr4_prefix: Acme\SyliusExamplePlugin diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..2235744 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,18 @@ +parameters: + level: max + reportUnmatchedIgnoredErrors: false + checkMissingIterableValueType: false + paths: + - src + - tests/Behat + + excludes_analyse: + # Makes PHPStan crash + - 'src/DependencyInjection/Configuration.php' + + # Test dependencies + - 'tests/Application/app/**.php' + - 'tests/Application/src/**.php' + + ignoreErrors: + - '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./' diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..042a638 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,22 @@ + + + + + + tests + + + + + + + + + + + + + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..3240886 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/public/greeting.js b/public/greeting.js new file mode 100644 index 0000000..3d7adfd --- /dev/null +++ b/public/greeting.js @@ -0,0 +1,3 @@ +setTimeout(function () { + document.getElementById('greeting').innerHTML = document.getElementById('greeting').dataset.greeting; +}, 1000); diff --git a/src/AcmeSyliusExamplePlugin.php b/src/AcmeSyliusExamplePlugin.php new file mode 100644 index 0000000..7b076f6 --- /dev/null +++ b/src/AcmeSyliusExamplePlugin.php @@ -0,0 +1,18 @@ +render('@AcmeSyliusExamplePlugin/static_greeting.html.twig', ['greeting' => $this->getGreeting($name)]); + } + + public function dynamicallyGreetAction(?string $name): Response + { + return $this->render('@AcmeSyliusExamplePlugin/dynamic_greeting.html.twig', ['greeting' => $this->getGreeting($name)]); + } + + private function getGreeting(?string $name): string + { + switch ($name) { + case null: + return 'Hello!'; + case 'Lionel Richie': + return 'Hello, is it me you\'re looking for?'; + default: + return sprintf('Hello, %s!', $name); + } + } +} diff --git a/src/DependencyInjection/AcmeSyliusExampleExtension.php b/src/DependencyInjection/AcmeSyliusExampleExtension.php new file mode 100644 index 0000000..5ca970b --- /dev/null +++ b/src/DependencyInjection/AcmeSyliusExampleExtension.php @@ -0,0 +1,47 @@ +load('services.xml'); + } + + public function prepend(ContainerBuilder $container): void + { + $this->prependDoctrineMigrations($container); + } + + protected function getMigrationsNamespace(): string + { + return 'DoctrineMigrations'; + } + + protected function getMigrationsDirectory(): string + { + return '@AcmeSyliusExamplePlugin/migrations'; + } + + protected function getNamespacesOfMigrationsExecutedBefore(): array + { + return [ + 'Sylius\Bundle\CoreBundle\Migrations', + ]; + } +} diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php new file mode 100644 index 0000000..56465a1 --- /dev/null +++ b/src/DependencyInjection/Configuration.php @@ -0,0 +1,22 @@ +getRootNode(); + + return $treeBuilder; + } +} diff --git a/symfony.lock b/symfony.lock new file mode 100644 index 0000000..d488cbc --- /dev/null +++ b/symfony.lock @@ -0,0 +1,415 @@ +{ + "api-platform/core": { + "version": "2.7", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "2.5", + "ref": "05b57782a78c21a664a42055dc11cf1954ca36bb" + }, + "files": [ + "config/packages/api_platform.yaml", + "config/routes/api_platform.yaml", + "src/Entity/.gitignore" + ] + }, + "babdev/pagerfanta-bundle": { + "version": "v3.7.0" + }, + "doctrine/annotations": { + "version": "2.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "1.10", + "ref": "64d8583af5ea57b7afa4aba4b159907f3a148b05" + } + }, + "doctrine/doctrine-bundle": { + "version": "2.9", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "2.4", + "ref": "013b823e7fee65890b23e40f31e6667a1ac519ac" + }, + "files": [ + "config/packages/doctrine.yaml", + "src/Entity/.gitignore", + "src/Repository/.gitignore" + ] + }, + "doctrine/doctrine-migrations-bundle": { + "version": "3.2", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "3.1", + "ref": "1d01ec03c6ecbd67c3375c5478c9a423ae5d6a33" + }, + "files": [ + "config/packages/doctrine_migrations.yaml", + "migrations/.gitignore" + ] + }, + "friends-of-behat/symfony-extension": { + "version": "2.4", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "2.0", + "ref": "1e012e04f573524ca83795cd19df9ea690adb604" + } + }, + "friendsofsymfony/rest-bundle": { + "version": "3.5", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "3.0", + "ref": "3762cc4e4f2d6faabeca5a151b41c8c791bd96e5" + } + }, + "jms/serializer-bundle": { + "version": "4.2", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "4.0", + "ref": "cc04e10cf7171525b50c18b36004edf64cb478be" + } + }, + "knplabs/knp-gaufrette-bundle": { + "version": "v0.8.0" + }, + "knplabs/knp-menu-bundle": { + "version": "v3.2.0" + }, + "league/flysystem-bundle": { + "version": "2.4", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "1.0", + "ref": "913dc3d7a5a1af0d2b044c5ac3a16e2f851d7380" + }, + "files": [ + "config/packages/flysystem.yaml", + "var/storage/.gitignore" + ] + }, + "lexik/jwt-authentication-bundle": { + "version": "2.17", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "2.5", + "ref": "e9481b233a11ef7e15fe055a2b21fd3ac1aa2bb7" + }, + "files": [ + "config/packages/lexik_jwt_authentication.yaml" + ] + }, + "liip/imagine-bundle": { + "version": "2.10", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "1.8", + "ref": "d1227d002b70d1a1f941d91845fcd7ac7fbfc929" + } + }, + "payum/payum-bundle": { + "version": "2.5", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "2.4", + "ref": "518ac22defa04a8a1d82479ed362e2921487adf0" + } + }, + "phpunit/phpunit": { + "version": "9.6", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "9.3", + "ref": "a6249a6c4392e9169b87abf93225f7f9f59025e6" + }, + "files": [ + ".env.test", + "phpunit.xml.dist", + "tests/bootstrap.php" + ] + }, + "sonata-project/block-bundle": { + "version": "4.19", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "4.11", + "ref": "b4edd2a1e6ac1827202f336cac2771cb529de542" + } + }, + "sonata-project/doctrine-extensions": { + "version": "2.1", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "1.8", + "ref": "4ea4a4b6730f83239608d7d4c849533645c70169" + } + }, + "sonata-project/form-extensions": { + "version": "1.18", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "1.4", + "ref": "9c8a1e8ce2b1f215015ed16652c4ed18eb5867fd" + } + }, + "squizlabs/php_codesniffer": { + "version": "3.7", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "3.6", + "ref": "1019e5c08d4821cb9b77f4891f8e9c31ff20ac6f" + } + }, + "stof/doctrine-extensions-bundle": { + "version": "1.7", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "1.2", + "ref": "e805aba9eff5372e2d149a9ff56566769e22819d" + } + }, + "sylius-labs/doctrine-migrations-extra-bundle": { + "version": "v0.2.0" + }, + "sylius/calendar": { + "version": "v0.4.0" + }, + "sylius/fixtures-bundle": { + "version": "v1.8.0" + }, + "sylius/grid-bundle": { + "version": "v1.12.0" + }, + "sylius/mailer-bundle": { + "version": "v2.0.0" + }, + "sylius/resource-bundle": { + "version": "1.10", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "1.6", + "ref": "bfd4306c8e26b4aed0790ebde89a2c949e1398a2" + } + }, + "sylius/theme-bundle": { + "version": "v2.3.0" + }, + "symfony/console": { + "version": "6.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "5.3", + "ref": "da0c8be8157600ad34f10ff0c9cc91232522e047" + }, + "files": [ + "bin/console" + ] + }, + "symfony/debug-bundle": { + "version": "6.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "5.3", + "ref": "5aa8aa48234c8eb6dbdd7b3cd5d791485d2cec4b" + }, + "files": [ + "config/packages/debug.yaml" + ] + }, + "symfony/flex": { + "version": "2.2", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "1.0", + "ref": "146251ae39e06a95be0fe3d13c807bcf3938b172" + }, + "files": [ + ".env" + ] + }, + "symfony/framework-bundle": { + "version": "6.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "5.4", + "ref": "3cd216a4d007b78d8554d44a5b1c0a446dab24fb" + }, + "files": [ + "config/packages/cache.yaml", + "config/packages/framework.yaml", + "config/preload.php", + "config/routes/framework.yaml", + "config/services.yaml", + "public/index.php", + "src/Controller/.gitignore", + "src/Kernel.php" + ] + }, + "symfony/mailer": { + "version": "6.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "4.3", + "ref": "2bf89438209656b85b9a49238c4467bff1b1f939" + }, + "files": [ + "config/packages/mailer.yaml" + ] + }, + "symfony/messenger": { + "version": "6.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "6.0", + "ref": "ba1ac4e919baba5644d31b57a3284d6ba12d52ee" + }, + "files": [ + "config/packages/messenger.yaml" + ] + }, + "symfony/monolog-bundle": { + "version": "3.8", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "3.7", + "ref": "213676c4ec929f046dfde5ea8e97625b81bc0578" + }, + "files": [ + "config/packages/monolog.yaml" + ] + }, + "symfony/routing": { + "version": "6.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "6.0", + "ref": "eb3b377a4dc07006c4bdb2c773652cc9434f5246" + }, + "files": [ + "config/packages/routing.yaml", + "config/routes.yaml" + ] + }, + "symfony/security-bundle": { + "version": "6.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "6.0", + "ref": "8a5b112826f7d3d5b07027f93786ae11a1c7de48" + }, + "files": [ + "config/packages/security.yaml" + ] + }, + "symfony/translation": { + "version": "6.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "5.3", + "ref": "da64f5a2b6d96f5dc24914517c0350a5f91dee43" + }, + "files": [ + "config/packages/translation.yaml", + "translations/.gitignore" + ] + }, + "symfony/twig-bundle": { + "version": "6.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "5.4", + "ref": "bb2178c57eee79e6be0b297aa96fc0c0def81387" + }, + "files": [ + "config/packages/twig.yaml", + "templates/base.html.twig" + ] + }, + "symfony/validator": { + "version": "6.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "5.3", + "ref": "c32cfd98f714894c4f128bb99aa2530c1227603c" + }, + "files": [ + "config/packages/validator.yaml" + ] + }, + "symfony/web-profiler-bundle": { + "version": "6.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "5.3", + "ref": "24bbc3d84ef2f427f82104f766014e799eefcc3e" + }, + "files": [ + "config/packages/web_profiler.yaml", + "config/routes/web_profiler.yaml" + ] + }, + "symfony/webpack-encore-bundle": { + "version": "1.16", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "1.10", + "ref": "f8fc53f1942f76679e9ee3c25fd44865355707b5" + }, + "files": [ + "assets/app.js", + "assets/bootstrap.js", + "assets/controllers.json", + "assets/controllers/hello_controller.js", + "assets/styles/app.css", + "config/packages/webpack_encore.yaml", + "package.json", + "webpack.config.js" + ] + }, + "willdurand/hateoas-bundle": { + "version": "2.5", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "2.0", + "ref": "34df072c6edaa61ae19afb2f3a239f272fecab87" + } + }, + "winzou/state-machine-bundle": { + "version": "0.6.0" + } +} diff --git a/templates/dynamic_greeting.html.twig b/templates/dynamic_greeting.html.twig new file mode 100644 index 0000000..743e4f2 --- /dev/null +++ b/templates/dynamic_greeting.html.twig @@ -0,0 +1,8 @@ + + + + + +
Loading...
+ + diff --git a/templates/static_greeting.html.twig b/templates/static_greeting.html.twig new file mode 100644 index 0000000..516667f --- /dev/null +++ b/templates/static_greeting.html.twig @@ -0,0 +1,5 @@ + + +
{{ greeting }}
+ + diff --git a/tests/Application/.env b/tests/Application/.env new file mode 100644 index 0000000..888c0b3 --- /dev/null +++ b/tests/Application/.env @@ -0,0 +1,33 @@ +# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file +# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production. +# 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 http://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/acme_sylius_example_plugin_%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/mailer ### +MAILER_DSN=null://null +###< symfony/mailer ### + +###> symfony/messenger ### +SYLIUS_MESSENGER_TRANSPORT_MAIN_DSN=doctrine://default +SYLIUS_MESSENGER_TRANSPORT_MAIN_FAILED_DSN=doctrine://default?queue_name=main_failed +SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_DSN=doctrine://default?queue_name=catalog_promotion_removal +SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_FAILED_DSN=doctrine://default?queue_name=catalog_promotion_removal_failed +###< symfony/messenger ### diff --git a/tests/Application/.env.test b/tests/Application/.env.test new file mode 100644 index 0000000..62d1bee --- /dev/null +++ b/tests/Application/.env.test @@ -0,0 +1,11 @@ +APP_SECRET='ch4mb3r0f5ecr3ts' + +KERNEL_CLASS='Tests\Acme\SyliusExamplePlugin\Application\Kernel' + +###> symfony/messenger ### +# Sync transport turned for testing env for the ease of testing +SYLIUS_MESSENGER_TRANSPORT_MAIN_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_MAIN_FAILED_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_DSN=sync:// +SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_FAILED_DSN=sync:// +###< symfony/messenger ### diff --git a/tests/Application/.eslintrc.js b/tests/Application/.eslintrc.js new file mode 100644 index 0000000..92c4cee --- /dev/null +++ b/tests/Application/.eslintrc.js @@ -0,0 +1,20 @@ +module.exports = { + extends: 'airbnb-base', + env: { + node: true, + }, + rules: { + 'object-shorthand': ['error', 'always', { + avoidQuotes: true, + avoidExplicitReturnArrows: true, + }], + 'function-paren-newline': ['error', 'consistent'], + 'max-len': ['warn', 120, 2, { + ignoreUrls: true, + ignoreComments: false, + ignoreRegExpLiterals: true, + ignoreStrings: true, + ignoreTemplateLiterals: true, + }], + }, +}; diff --git a/tests/Application/.gitignore b/tests/Application/.gitignore new file mode 100644 index 0000000..bc600a8 --- /dev/null +++ b/tests/Application/.gitignore @@ -0,0 +1,23 @@ +/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 new file mode 100644 index 0000000..0bedc86 --- /dev/null +++ b/tests/Application/Kernel.php @@ -0,0 +1,97 @@ +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() && class_exists(MockerContainer::class)) { + return MockerContainer::class; + } + + return parent::getContainerBaseClass(); + } + + private function isTestEnvironment(): bool + { + return 0 === strpos($this->getEnvironment(), 'test'); + } + + 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'; + $syliusConfigDir = $this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION; + if (is_dir($syliusConfigDir)) { + yield $syliusConfigDir; + } + $symfonyConfigDir = $this->getProjectDir() . '/config/symfony/' . BaseKernel::MAJOR_VERSION . '.' . BaseKernel::MINOR_VERSION; + if (is_dir($symfonyConfigDir)) { + yield $symfonyConfigDir; + } + } +} diff --git a/tests/Application/assets/admin/entry.js b/tests/Application/assets/admin/entry.js new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/assets/shop/entry.js b/tests/Application/assets/shop/entry.js new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/bin/console b/tests/Application/bin/console new file mode 100755 index 0000000..bf889e9 --- /dev/null +++ b/tests/Application/bin/console @@ -0,0 +1,38 @@ +#!/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 new file mode 100644 index 0000000..326735f --- /dev/null +++ b/tests/Application/composer.json @@ -0,0 +1,5 @@ +{ + "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/api_platform/.gitignore b/tests/Application/config/api_platform/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php new file mode 100644 index 0000000..c9951a7 --- /dev/null +++ b/tests/Application/config/bootstrap.php @@ -0,0 +1,27 @@ +=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.'); +} elseif (method_exists(Dotenv::class, 'bootEnv')) { + (new Dotenv())->bootEnv(dirname(__DIR__) . '/.env'); + + return; +} else { + // load all the .env files + (new Dotenv(true))->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/bundles.php b/tests/Application/config/bundles.php new file mode 100644 index 0000000..cc60221 --- /dev/null +++ b/tests/Application/config/bundles.php @@ -0,0 +1,61 @@ + ['all' => true], + Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], + Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], + Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], + Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], + Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true], + Sylius\Bundle\MoneyBundle\SyliusMoneyBundle::class => ['all' => true], + Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle::class => ['all' => true], + Sylius\Bundle\LocaleBundle\SyliusLocaleBundle::class => ['all' => true], + Sylius\Bundle\ProductBundle\SyliusProductBundle::class => ['all' => true], + Sylius\Bundle\ChannelBundle\SyliusChannelBundle::class => ['all' => true], + Sylius\Bundle\AttributeBundle\SyliusAttributeBundle::class => ['all' => true], + Sylius\Bundle\TaxationBundle\SyliusTaxationBundle::class => ['all' => true], + Sylius\Bundle\ShippingBundle\SyliusShippingBundle::class => ['all' => true], + Sylius\Bundle\PaymentBundle\SyliusPaymentBundle::class => ['all' => true], + Sylius\Bundle\MailerBundle\SyliusMailerBundle::class => ['all' => true], + Sylius\Bundle\PromotionBundle\SyliusPromotionBundle::class => ['all' => true], + Sylius\Bundle\AddressingBundle\SyliusAddressingBundle::class => ['all' => true], + Sylius\Bundle\InventoryBundle\SyliusInventoryBundle::class => ['all' => true], + Sylius\Bundle\TaxonomyBundle\SyliusTaxonomyBundle::class => ['all' => true], + Sylius\Bundle\UserBundle\SyliusUserBundle::class => ['all' => true], + Sylius\Bundle\CustomerBundle\SyliusCustomerBundle::class => ['all' => true], + Sylius\Bundle\UiBundle\SyliusUiBundle::class => ['all' => true], + Sylius\Bundle\ReviewBundle\SyliusReviewBundle::class => ['all' => true], + Sylius\Bundle\CoreBundle\SyliusCoreBundle::class => ['all' => true], + Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true], + Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true], + winzou\Bundle\StateMachineBundle\winzouStateMachineBundle::class => ['all' => true], + Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true], + Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle::class => ['all' => true], + JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true], + FOS\RestBundle\FOSRestBundle::class => ['all' => true], + Knp\Bundle\GaufretteBundle\KnpGaufretteBundle::class => ['all' => true], + Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true], + Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true], + Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true], + Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], + Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], + Sylius\Bundle\FixturesBundle\SyliusFixturesBundle::class => ['all' => true], + Sylius\Bundle\PayumBundle\SyliusPayumBundle::class => ['all' => true], + Sylius\Bundle\ThemeBundle\SyliusThemeBundle::class => ['all' => true], + Sylius\Bundle\AdminBundle\SyliusAdminBundle::class => ['all' => true], + Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true], + Acme\SyliusExamplePlugin\AcmeSyliusExamplePlugin::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], + FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true], + Sylius\Behat\Application\SyliusTestPlugin\SyliusTestPlugin::class => ['test' => true, 'test_cached' => true], + ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], + Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], + Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true], + SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], + BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], + SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], + Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], + Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], + League\FlysystemBundle\FlysystemBundle::class => ['all' => true], +]; diff --git a/tests/Application/config/jwt/private.pem b/tests/Application/config/jwt/private.pem new file mode 100644 index 0000000..2bcf023 --- /dev/null +++ b/tests/Application/config/jwt/private.pem @@ -0,0 +1,54 @@ +-----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 new file mode 100644 index 0000000..cb4e13d --- /dev/null +++ b/tests/Application/config/jwt/public.pem @@ -0,0 +1,14 @@ +-----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 new file mode 100644 index 0000000..18acdd4 --- /dev/null +++ b/tests/Application/config/packages/_sylius.yaml @@ -0,0 +1,18 @@ +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 diff --git a/tests/Application/config/packages/api_platform.yaml b/tests/Application/config/packages/api_platform.yaml new file mode 100644 index 0000000..b428304 --- /dev/null +++ b/tests/Application/config/packages/api_platform.yaml @@ -0,0 +1,10 @@ +api_platform: + mapping: + paths: + - '%kernel.project_dir%/../../vendor/sylius/sylius/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources' + - '%kernel.project_dir%/config/api_platform' + - '%kernel.project_dir%/src/Entity' + 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 new file mode 100644 index 0000000..2468901 --- /dev/null +++ b/tests/Application/config/packages/assets.yaml @@ -0,0 +1,7 @@ +framework: + assets: + packages: + shop: + json_manifest_path: '%kernel.project_dir%/public/build/shop/manifest.json' + admin: + json_manifest_path: '%kernel.project_dir%/public/build/admin/manifest.json' diff --git a/tests/Application/config/packages/dev/framework.yaml b/tests/Application/config/packages/dev/framework.yaml new file mode 100644 index 0000000..4b116de --- /dev/null +++ b/tests/Application/config/packages/dev/framework.yaml @@ -0,0 +1,2 @@ +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 new file mode 100644 index 0000000..2f32a9b --- /dev/null +++ b/tests/Application/config/packages/dev/jms_serializer.yaml @@ -0,0 +1,12 @@ +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 new file mode 100644 index 0000000..da2b092 --- /dev/null +++ b/tests/Application/config/packages/dev/monolog.yaml @@ -0,0 +1,9 @@ +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 new file mode 100644 index 0000000..4116679 --- /dev/null +++ b/tests/Application/config/packages/dev/routing.yaml @@ -0,0 +1,3 @@ +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 new file mode 100644 index 0000000..1f1cb2b --- /dev/null +++ b/tests/Application/config/packages/dev/web_profiler.yaml @@ -0,0 +1,3 @@ +web_profiler: + toolbar: true + intercept_redirects: false diff --git a/tests/Application/config/packages/doctrine.yaml b/tests/Application/config/packages/doctrine.yaml new file mode 100644 index 0000000..f51ba5a --- /dev/null +++ b/tests/Application/config/packages/doctrine.yaml @@ -0,0 +1,14 @@ +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)%' diff --git a/tests/Application/config/packages/doctrine_migrations.yaml b/tests/Application/config/packages/doctrine_migrations.yaml new file mode 100644 index 0000000..cdbc01a --- /dev/null +++ b/tests/Application/config/packages/doctrine_migrations.yaml @@ -0,0 +1,4 @@ +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 new file mode 100644 index 0000000..eaebb27 --- /dev/null +++ b/tests/Application/config/packages/fos_rest.yaml @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..8be076b --- /dev/null +++ b/tests/Application/config/packages/framework.yaml @@ -0,0 +1,9 @@ +framework: + secret: '%env(APP_SECRET)%' + form: true + csrf_protection: true + session: + handler_id: ~ + serializer: + mapping: + paths: [ '%kernel.project_dir%/config/serialization' ] diff --git a/tests/Application/config/packages/jms_serializer.yaml b/tests/Application/config/packages/jms_serializer.yaml new file mode 100644 index 0000000..ed7bc61 --- /dev/null +++ b/tests/Application/config/packages/jms_serializer.yaml @@ -0,0 +1,4 @@ +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 new file mode 100644 index 0000000..edfb69d --- /dev/null +++ b/tests/Application/config/packages/lexik_jwt_authentication.yaml @@ -0,0 +1,4 @@ +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 new file mode 100644 index 0000000..bb2e7ce --- /dev/null +++ b/tests/Application/config/packages/liip_imagine.yaml @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..56a650d --- /dev/null +++ b/tests/Application/config/packages/mailer.yaml @@ -0,0 +1,3 @@ +framework: + mailer: + dsn: '%env(MAILER_DSN)%' diff --git a/tests/Application/config/packages/prod/doctrine.yaml b/tests/Application/config/packages/prod/doctrine.yaml new file mode 100644 index 0000000..2f16f0f --- /dev/null +++ b/tests/Application/config/packages/prod/doctrine.yaml @@ -0,0 +1,31 @@ +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 new file mode 100644 index 0000000..c288182 --- /dev/null +++ b/tests/Application/config/packages/prod/jms_serializer.yaml @@ -0,0 +1,10 @@ +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 new file mode 100644 index 0000000..6461211 --- /dev/null +++ b/tests/Application/config/packages/prod/monolog.yaml @@ -0,0 +1,10 @@ +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 new file mode 100644 index 0000000..368bc7f --- /dev/null +++ b/tests/Application/config/packages/routing.yaml @@ -0,0 +1,3 @@ +framework: + router: + strict_requirements: ~ diff --git a/tests/Application/config/packages/security.yaml b/tests/Application/config/packages/security.yaml new file mode 100644 index 0000000..4ed342f --- /dev/null +++ b/tests/Application/config/packages/security.yaml @@ -0,0 +1,124 @@ +security: + enable_authenticator_manager: true + providers: + sylius_admin_user_provider: + id: sylius.admin_user_provider.email_or_name_based + sylius_api_admin_user_provider: + id: sylius.admin_user_provider.email_or_name_based + sylius_shop_user_provider: + id: sylius.shop_user_provider.email_or_name_based + sylius_api_shop_user_provider: + id: sylius.shop_user_provider.email_or_name_based + + password_hashers: + Sylius\Component\User\Model\UserInterface: argon2i + firewalls: + admin: + switch_user: true + context: admin + pattern: "%sylius.security.admin_regex%" + provider: sylius_admin_user_provider + form_login: + provider: sylius_admin_user_provider + login_path: sylius_admin_login + check_path: sylius_admin_login_check + failure_path: sylius_admin_login + default_target_path: sylius_admin_dashboard + use_forward: false + use_referer: true + enable_csrf: true + csrf_parameter: _csrf_admin_security_token + csrf_token_id: admin_authenticate + remember_me: + secret: "%env(APP_SECRET)%" + path: "/%sylius_admin.path_name%" + name: APP_ADMIN_REMEMBER_ME + lifetime: 31536000 + remember_me_parameter: _remember_me + logout: + path: sylius_admin_logout + target: sylius_admin_login + + new_api_admin_user: + pattern: "%sylius.security.new_api_admin_regex%/.*" + provider: sylius_api_admin_user_provider + stateless: true + entry_point: jwt + json_login: + check_path: "%sylius.security.new_api_admin_route%/authentication-token" + username_path: email + password_path: password + success_handler: lexik_jwt_authentication.handler.authentication_success + failure_handler: lexik_jwt_authentication.handler.authentication_failure + jwt: true + + new_api_shop_user: + pattern: "%sylius.security.new_api_shop_regex%/.*" + provider: sylius_api_shop_user_provider + stateless: true + entry_point: jwt + json_login: + check_path: "%sylius.security.new_api_shop_route%/authentication-token" + username_path: email + password_path: password + success_handler: lexik_jwt_authentication.handler.authentication_success + failure_handler: lexik_jwt_authentication.handler.authentication_failure + jwt: true + + shop: + switch_user: { role: ROLE_ALLOWED_TO_SWITCH } + context: shop + pattern: "%sylius.security.shop_regex%" + provider: sylius_shop_user_provider + form_login: + success_handler: sylius.authentication.success_handler + failure_handler: sylius.authentication.failure_handler + provider: sylius_shop_user_provider + login_path: sylius_shop_login + check_path: sylius_shop_login_check + failure_path: sylius_shop_login + default_target_path: sylius_shop_homepage + use_forward: false + use_referer: true + enable_csrf: true + csrf_parameter: _csrf_shop_security_token + csrf_token_id: shop_authenticate + remember_me: + secret: "%env(APP_SECRET)%" + name: APP_SHOP_REMEMBER_ME + lifetime: 31536000 + remember_me_parameter: _remember_me + logout: + path: sylius_shop_logout + target: sylius_shop_homepage + invalidate_session: false + + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + + image_resolver: + pattern: ^/media/cache/resolve + security: false + + access_control: + - { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } + - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } + + - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } + + - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS } + + - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } + - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } + + - { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } + - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } + - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } diff --git a/tests/Application/config/packages/staging/monolog.yaml b/tests/Application/config/packages/staging/monolog.yaml new file mode 100644 index 0000000..6461211 --- /dev/null +++ b/tests/Application/config/packages/staging/monolog.yaml @@ -0,0 +1,10 @@ +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/stof_doctrine_extensions.yaml b/tests/Application/config/packages/stof_doctrine_extensions.yaml new file mode 100644 index 0000000..7770f74 --- /dev/null +++ b/tests/Application/config/packages/stof_doctrine_extensions.yaml @@ -0,0 +1,4 @@ +# 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/test/framework.yaml b/tests/Application/config/packages/test/framework.yaml new file mode 100644 index 0000000..fc1d3c1 --- /dev/null +++ b/tests/Application/config/packages/test/framework.yaml @@ -0,0 +1,4 @@ +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 new file mode 100644 index 0000000..52610d6 --- /dev/null +++ b/tests/Application/config/packages/test/mailer.yaml @@ -0,0 +1,5 @@ +framework: + 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 new file mode 100644 index 0000000..7e2b9e3 --- /dev/null +++ b/tests/Application/config/packages/test/monolog.yaml @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..4071d31 --- /dev/null +++ b/tests/Application/config/packages/test/security.yaml @@ -0,0 +1,6 @@ +security: + password_hashers: + Sylius\Component\User\Model\UserInterface: + algorithm: argon2i + time_cost: 3 + memory_cost: 10 diff --git a/tests/Application/config/packages/test/sylius_theme.yaml b/tests/Application/config/packages/test/sylius_theme.yaml new file mode 100644 index 0000000..4d34199 --- /dev/null +++ b/tests/Application/config/packages/test/sylius_theme.yaml @@ -0,0 +1,3 @@ +sylius_theme: + sources: + test: ~ diff --git a/tests/Application/config/packages/test/sylius_uploader.yaml b/tests/Application/config/packages/test/sylius_uploader.yaml new file mode 100644 index 0000000..ab9d6ca --- /dev/null +++ b/tests/Application/config/packages/test/sylius_uploader.yaml @@ -0,0 +1,3 @@ +services: + Sylius\Component\Core\Generator\ImagePathGeneratorInterface: + class: Sylius\Behat\Service\Generator\UploadedImagePathGenerator diff --git a/tests/Application/config/packages/test/web_profiler.yaml b/tests/Application/config/packages/test/web_profiler.yaml new file mode 100644 index 0000000..03752de --- /dev/null +++ b/tests/Application/config/packages/test/web_profiler.yaml @@ -0,0 +1,6 @@ +web_profiler: + toolbar: false + intercept_redirects: false + +framework: + profiler: { collect: false } diff --git a/tests/Application/config/packages/test_cached/doctrine.yaml b/tests/Application/config/packages/test_cached/doctrine.yaml new file mode 100644 index 0000000..4952860 --- /dev/null +++ b/tests/Application/config/packages/test_cached/doctrine.yaml @@ -0,0 +1,16 @@ +doctrine: + orm: + entity_managers: + default: + result_cache_driver: + type: memcached + host: localhost + port: 11211 + query_cache_driver: + type: memcached + host: localhost + port: 11211 + metadata_cache_driver: + type: memcached + host: localhost + port: 11211 diff --git a/tests/Application/config/packages/test_cached/fos_rest.yaml b/tests/Application/config/packages/test_cached/fos_rest.yaml new file mode 100644 index 0000000..2b4189d --- /dev/null +++ b/tests/Application/config/packages/test_cached/fos_rest.yaml @@ -0,0 +1,3 @@ +fos_rest: + exception: + debug: true diff --git a/tests/Application/config/packages/test_cached/framework.yaml b/tests/Application/config/packages/test_cached/framework.yaml new file mode 100644 index 0000000..e9dd6ee --- /dev/null +++ b/tests/Application/config/packages/test_cached/framework.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: ../test/framework.yaml } diff --git a/tests/Application/config/packages/test_cached/mailer.yaml b/tests/Application/config/packages/test_cached/mailer.yaml new file mode 100644 index 0000000..16f3170 --- /dev/null +++ b/tests/Application/config/packages/test_cached/mailer.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: "../test/mailer.yaml" } diff --git a/tests/Application/config/packages/test_cached/monolog.yaml b/tests/Application/config/packages/test_cached/monolog.yaml new file mode 100644 index 0000000..7e2b9e3 --- /dev/null +++ b/tests/Application/config/packages/test_cached/monolog.yaml @@ -0,0 +1,6 @@ +monolog: + handlers: + main: + type: stream + path: "%kernel.logs_dir%/%kernel.environment%.log" + level: error diff --git a/tests/Application/config/packages/test_cached/security.yaml b/tests/Application/config/packages/test_cached/security.yaml new file mode 100644 index 0000000..76e9273 --- /dev/null +++ b/tests/Application/config/packages/test_cached/security.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: ../test/security.yaml } diff --git a/tests/Application/config/packages/test_cached/sylius_channel.yaml b/tests/Application/config/packages/test_cached/sylius_channel.yaml new file mode 100644 index 0000000..bab83ef --- /dev/null +++ b/tests/Application/config/packages/test_cached/sylius_channel.yaml @@ -0,0 +1,2 @@ +sylius_channel: + debug: true diff --git a/tests/Application/config/packages/test_cached/sylius_theme.yaml b/tests/Application/config/packages/test_cached/sylius_theme.yaml new file mode 100644 index 0000000..4d34199 --- /dev/null +++ b/tests/Application/config/packages/test_cached/sylius_theme.yaml @@ -0,0 +1,3 @@ +sylius_theme: + sources: + test: ~ diff --git a/tests/Application/config/packages/test_cached/sylius_uploader.yaml b/tests/Application/config/packages/test_cached/sylius_uploader.yaml new file mode 100644 index 0000000..cfa727e --- /dev/null +++ b/tests/Application/config/packages/test_cached/sylius_uploader.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: "../test/sylius_uploader.yaml" } diff --git a/tests/Application/config/packages/test_cached/twig.yaml b/tests/Application/config/packages/test_cached/twig.yaml new file mode 100644 index 0000000..8c6e0b4 --- /dev/null +++ b/tests/Application/config/packages/test_cached/twig.yaml @@ -0,0 +1,2 @@ +twig: + strict_variables: true diff --git a/tests/Application/config/packages/translation.yaml b/tests/Application/config/packages/translation.yaml new file mode 100644 index 0000000..1f4f966 --- /dev/null +++ b/tests/Application/config/packages/translation.yaml @@ -0,0 +1,8 @@ +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 new file mode 100644 index 0000000..8545473 --- /dev/null +++ b/tests/Application/config/packages/twig.yaml @@ -0,0 +1,12 @@ +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/validator.yaml b/tests/Application/config/packages/validator.yaml new file mode 100644 index 0000000..61807db --- /dev/null +++ b/tests/Application/config/packages/validator.yaml @@ -0,0 +1,3 @@ +framework: + validation: + enable_annotations: true diff --git a/tests/Application/config/packages/webpack_encore.yaml b/tests/Application/config/packages/webpack_encore.yaml new file mode 100644 index 0000000..9bee248 --- /dev/null +++ b/tests/Application/config/packages/webpack_encore.yaml @@ -0,0 +1,5 @@ +webpack_encore: + output_path: '%kernel.project_dir%/public/build/default' + builds: + shop: '%kernel.project_dir%/public/build/shop' + admin: '%kernel.project_dir%/public/build/admin' diff --git a/tests/Application/config/routes.yaml b/tests/Application/config/routes.yaml new file mode 100644 index 0000000..876801b --- /dev/null +++ b/tests/Application/config/routes.yaml @@ -0,0 +1,9 @@ +acme_sylius_example_shop: + resource: "@AcmeSyliusExamplePlugin/config/shop_routing.yml" + prefix: /{_locale} + requirements: + _locale: ^[a-z]{2}(?:_[A-Z]{2})?$ + +acme_sylius_example_admin: + resource: "@AcmeSyliusExamplePlugin/config/admin_routing.yml" + prefix: /admin diff --git a/tests/Application/config/routes/dev/web_profiler.yaml b/tests/Application/config/routes/dev/web_profiler.yaml new file mode 100644 index 0000000..3e79dc2 --- /dev/null +++ b/tests/Application/config/routes/dev/web_profiler.yaml @@ -0,0 +1,7 @@ +_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 new file mode 100644 index 0000000..201cbd5 --- /dev/null +++ b/tests/Application/config/routes/liip_imagine.yaml @@ -0,0 +1,2 @@ +_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 new file mode 100644 index 0000000..1ba48d6 --- /dev/null +++ b/tests/Application/config/routes/sylius_admin.yaml @@ -0,0 +1,3 @@ +sylius_admin: + resource: "@SyliusAdminBundle/Resources/config/routing.yml" + prefix: /admin diff --git a/tests/Application/config/routes/sylius_api.yaml b/tests/Application/config/routes/sylius_api.yaml new file mode 100644 index 0000000..ae01ffc --- /dev/null +++ b/tests/Application/config/routes/sylius_api.yaml @@ -0,0 +1,3 @@ +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 new file mode 100644 index 0000000..fae46cb --- /dev/null +++ b/tests/Application/config/routes/sylius_shop.yaml @@ -0,0 +1,14 @@ +sylius_shop: + resource: "@SyliusShopBundle/Resources/config/routing.yml" + prefix: /{_locale} + requirements: + _locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$ + +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 diff --git a/tests/Application/config/routes/test/routing.yaml b/tests/Application/config/routes/test/routing.yaml new file mode 100644 index 0000000..0ca57d9 --- /dev/null +++ b/tests/Application/config/routes/test/routing.yaml @@ -0,0 +1,5 @@ +sylius_test_plugin_main: + path: /test/main + controller: FrameworkBundle:Template:template + defaults: + template: "@SyliusTestPlugin/main.html.twig" diff --git a/tests/Application/config/routes/test/sylius_test_plugin.yaml b/tests/Application/config/routes/test/sylius_test_plugin.yaml new file mode 100644 index 0000000..0ca57d9 --- /dev/null +++ b/tests/Application/config/routes/test/sylius_test_plugin.yaml @@ -0,0 +1,5 @@ +sylius_test_plugin_main: + path: /test/main + controller: FrameworkBundle:Template:template + defaults: + template: "@SyliusTestPlugin/main.html.twig" diff --git a/tests/Application/config/routes/test_cached/routing.yaml b/tests/Application/config/routes/test_cached/routing.yaml new file mode 100644 index 0000000..0ca57d9 --- /dev/null +++ b/tests/Application/config/routes/test_cached/routing.yaml @@ -0,0 +1,5 @@ +sylius_test_plugin_main: + path: /test/main + controller: FrameworkBundle:Template:template + defaults: + template: "@SyliusTestPlugin/main.html.twig" diff --git a/tests/Application/config/routes/test_cached/sylius_test_plugin.yaml b/tests/Application/config/routes/test_cached/sylius_test_plugin.yaml new file mode 100644 index 0000000..0ca57d9 --- /dev/null +++ b/tests/Application/config/routes/test_cached/sylius_test_plugin.yaml @@ -0,0 +1,5 @@ +sylius_test_plugin_main: + path: /test/main + controller: FrameworkBundle:Template:template + defaults: + template: "@SyliusTestPlugin/main.html.twig" diff --git a/tests/Application/config/secrets/dev/.gitignore b/tests/Application/config/secrets/dev/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/config/secrets/prod/.gitignore b/tests/Application/config/secrets/prod/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/config/secrets/test/.gitignore b/tests/Application/config/secrets/test/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/config/secrets/test_cached/.gitignore b/tests/Application/config/secrets/test_cached/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/config/serialization/.gitignore b/tests/Application/config/serialization/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/config/services.yaml b/tests/Application/config/services.yaml new file mode 100644 index 0000000..615506e --- /dev/null +++ b/tests/Application/config/services.yaml @@ -0,0 +1,4 @@ +# 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 new file mode 100644 index 0000000..af40901 --- /dev/null +++ b/tests/Application/config/services_test.yaml @@ -0,0 +1,8 @@ +imports: + - { resource: "../../Behat/Resources/services.xml" } + - { resource: "../../../vendor/sylius/sylius/src/Sylius/Behat/Resources/config/services.xml" } + +# workaround needed for strange "test.client.history" problem +# see https://github.com/FriendsOfBehat/SymfonyExtension/issues/88 +services: + Symfony\Component\BrowserKit\AbstractBrowser: '@test.client' diff --git a/tests/Application/config/services_test_cached.yaml b/tests/Application/config/services_test_cached.yaml new file mode 100644 index 0000000..0de380e --- /dev/null +++ b/tests/Application/config/services_test_cached.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: "services_test.yaml" } diff --git a/tests/Application/package.json b/tests/Application/package.json new file mode 100644 index 0000000..b428c24 --- /dev/null +++ b/tests/Application/package.json @@ -0,0 +1,13 @@ +{ + "license": "UNLICENSED", + "scripts": { + "build": "encore dev", + "build:prod": "encore production", + "postinstall": "semantic-ui-css-patch", + "lint": "yarn lint:js", + "watch": "encore dev --watch" + }, + "devDependencies": { + "@sylius-ui/frontend": "^1.0" + } +} diff --git a/tests/Application/public/.htaccess b/tests/Application/public/.htaccess new file mode 100644 index 0000000..99ed00d --- /dev/null +++ b/tests/Application/public/.htaccess @@ -0,0 +1,25 @@ +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 new file mode 100644 index 0000000..592f7a8 Binary files /dev/null and b/tests/Application/public/favicon.ico differ diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php new file mode 100644 index 0000000..af4ad7e --- /dev/null +++ b/tests/Application/public/index.php @@ -0,0 +1,29 @@ +handle($request); +$response->send(); +$kernel->terminate($request, $response); diff --git a/tests/Application/public/robots.txt b/tests/Application/public/robots.txt new file mode 100644 index 0000000..214e411 --- /dev/null +++ b/tests/Application/public/robots.txt @@ -0,0 +1,4 @@ +# www.robotstxt.org/ +# www.google.com/support/webmasters/bin/answer.py?hl=en&answer=156449 + +User-agent: * diff --git a/tests/Application/src/Entity/.gitignore b/tests/Application/src/Entity/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/templates/.gitignore b/tests/Application/templates/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_logo.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_logo.html.twig new file mode 100644 index 0000000..1d9fa7d --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_logo.html.twig @@ -0,0 +1,5 @@ + +
+ +
+
diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Security/_content.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Security/_content.html.twig new file mode 100644 index 0000000..ce17621 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/Security/_content.html.twig @@ -0,0 +1,6 @@ +{% include '@SyliusUi/Security/_login.html.twig' + with { + 'action': path('sylius_admin_login_check'), + 'paths': {'logo': asset('build/admin/images/logo.png', 'admin')} +} +%} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig new file mode 100644 index 0000000..f5f9835 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/_scripts.html.twig @@ -0,0 +1 @@ +{{ encore_entry_script_tags('admin-entry', null, 'admin') }} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig new file mode 100644 index 0000000..a96144c --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/_styles.html.twig @@ -0,0 +1 @@ +{{ encore_entry_link_tags('admin-entry', null, 'admin') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig new file mode 100644 index 0000000..8486493 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/Homepage/_banner.html.twig @@ -0,0 +1,9 @@ +
+
+ {{ 'sylius.homepage.banner_content'|trans }} +
+
+
{{ 'sylius.homepage.banner_content'|trans }}
+ {{ 'sylius.homepage.banner_button'|trans }} +
+
diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig new file mode 100644 index 0000000..84b8df5 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/Layout/Header/_logo.html.twig @@ -0,0 +1,5 @@ + diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig new file mode 100644 index 0000000..d1655bb --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig @@ -0,0 +1 @@ +{{ encore_entry_script_tags('shop-entry', null, 'shop') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig new file mode 100644 index 0000000..fd2c7cb --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig @@ -0,0 +1 @@ +{{ encore_entry_link_tags('shop-entry', null, 'shop') }} diff --git a/tests/Application/translations/.gitignore b/tests/Application/translations/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/var/.gitignore b/tests/Application/var/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/tests/Application/webpack.config.js b/tests/Application/webpack.config.js new file mode 100644 index 0000000..0d3d978 --- /dev/null +++ b/tests/Application/webpack.config.js @@ -0,0 +1,49 @@ +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', '../../vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/private/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.resolve.alias['chart.js/dist/Chart.min'] = path.resolve(__dirname, 'node_modules/chart.js/dist/chart.min.js'); +shopConfig.name = 'shop'; + +Encore.reset(); + +// Admin config +Encore + .setOutputPath('public/build/admin/') + .setPublicPath('/build/admin') + .addEntry('admin-entry', '../../vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/Resources/private/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.resolve.alias['chart.js/dist/Chart.min'] = path.resolve(__dirname, 'node_modules/chart.js/dist/chart.min.js'); +adminConfig.externals = Object.assign({}, adminConfig.externals, { window: 'window', document: 'document' }); +adminConfig.name = 'admin'; + +module.exports = [shopConfig, adminConfig]; diff --git a/tests/Behat/Context/Ui/Shop/WelcomeContext.php b/tests/Behat/Context/Ui/Shop/WelcomeContext.php new file mode 100644 index 0000000..a0d95b0 --- /dev/null +++ b/tests/Behat/Context/Ui/Shop/WelcomeContext.php @@ -0,0 +1,80 @@ +staticWelcomePage = $staticWelcomePage; + $this->dynamicWelcomePage = $dynamicWelcomePage; + } + + /** + * @When a customer with an unknown name visits static welcome page + */ + public function customerWithUnknownNameVisitsStaticWelcomePage(): void + { + $this->staticWelcomePage->open(); + } + + /** + * @When a customer named :name visits static welcome page + */ + public function namedCustomerVisitsStaticWelcomePage(string $name): void + { + $this->staticWelcomePage->open(['name' => $name]); + } + + /** + * @Then they should be statically greeted with :greeting + */ + public function theyShouldBeStaticallyGreetedWithGreeting(string $greeting): void + { + Assert::same($this->staticWelcomePage->getGreeting(), $greeting); + } + + /** + * @When a customer with an unknown name visits dynamic welcome page + */ + public function customerWithUnknownNameVisitsDynamicWelcomePage(): void + { + $this->dynamicWelcomePage->open(); + } + + /** + * @When a customer named :name visits dynamic welcome page + */ + public function namedCustomerVisitsDynamicWelcomePage(string $name): void + { + $this->dynamicWelcomePage->open(['name' => $name]); + } + + /** + * @Then they should be dynamically greeted with :greeting + */ + public function theyShouldBeDynamicallyGreetedWithGreeting(string $greeting): void + { + Assert::same($this->dynamicWelcomePage->getGreeting(), $greeting); + } +} diff --git a/tests/Behat/Page/Shop/DynamicWelcomePage.php b/tests/Behat/Page/Shop/DynamicWelcomePage.php new file mode 100644 index 0000000..08e5f8c --- /dev/null +++ b/tests/Behat/Page/Shop/DynamicWelcomePage.php @@ -0,0 +1,44 @@ +getSession()->getPage()->waitFor(3, function (): string { + $greeting = $this->getElement('greeting')->getText(); + + if ('Loading...' === $greeting) { + return ''; + } + + return $greeting; + }); + } + + /** + * {@inheritdoc} + */ + public function getRouteName(): string + { + return 'acme_sylius_example_dynamic_welcome'; + } + + /** + * {@inheritdoc} + */ + protected function getDefinedElements(): array + { + return array_merge(parent::getDefinedElements(), [ + 'greeting' => '#greeting', + ]); + } +} diff --git a/tests/Behat/Page/Shop/StaticWelcomePage.php b/tests/Behat/Page/Shop/StaticWelcomePage.php new file mode 100644 index 0000000..8f2a96b --- /dev/null +++ b/tests/Behat/Page/Shop/StaticWelcomePage.php @@ -0,0 +1,36 @@ +getElement('greeting')->getText(); + } + + /** + * {@inheritdoc} + */ + public function getRouteName(): string + { + return 'acme_sylius_example_static_welcome'; + } + + /** + * {@inheritdoc} + */ + protected function getDefinedElements(): array + { + return array_merge(parent::getDefinedElements(), [ + 'greeting' => '#greeting', + ]); + } +} diff --git a/tests/Behat/Page/Shop/WelcomePageInterface.php b/tests/Behat/Page/Shop/WelcomePageInterface.php new file mode 100644 index 0000000..7cd873c --- /dev/null +++ b/tests/Behat/Page/Shop/WelcomePageInterface.php @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + + diff --git a/tests/Behat/Resources/suites.yml b/tests/Behat/Resources/suites.yml new file mode 100644 index 0000000..6cfe415 --- /dev/null +++ b/tests/Behat/Resources/suites.yml @@ -0,0 +1,10 @@ +# Put your Behat suites definitions here + +default: + suites: + greeting_customer: + contexts: + - acme_sylius_example.context.ui.shop.welcome + + filters: + tags: "@greeting_customer" diff --git a/translations/.gitignore b/translations/.gitignore new file mode 100644 index 0000000..e69de29