Contributing
To contribute to this plugin clone this repository, create a branch for your feature or bugfix, do your changes and then make sure all tests are passing. For a comprehensive guide on Sylius Plugins development please go to Sylius documentation, there you will find the Plugin Development Guide - it’s a great place to start. For more information about the Test Application included in this plugin, please refer to the Sylius documentation.
Setting up Sylius locally
Installing Sylius and prepare database
Traditional way
- From the directory of the plugin run the following commands:
composer install (cd vendor/sylius/test-application && yarn install) (cd vendor/sylius/test-application && yarn build) vendor/bin/console assets:install vendor/bin/console doctrine:database:create vendor/bin/console doctrine:migrations:migrate -n # Optionally load data fixtures vendor/bin/console sylius:fixtures:load -nTo be able to run test you need a local database, you can use one locally installed on your machine and changing the parameters on your
tests/Application/.env.test.localfile or you can use Docker. You can use the docker compose sample template to only run mysql on Docker and leaving runtime on local PHP:To be able to set up a plugin’s database, remember to configure your database credentials in
tests/TestApplication/.envandtests/TestApplication/.env.test. - Run your local server:
symfony server:ca:install symfony server:start -d - Open your browser and navigate to
https://localhost:8000.
Docker way
-
Execute
make initto initialize the container and install the dependencies. -
Execute
make database-initto create the database and run migrations. -
(Optional) Execute
make load-fixturesto load the fixtures. -
Your app is available at
http://localhost.
Running plugin tests
- Code style
vendor/bin/ecs check - Static analysis
vendor/bin/phpstan analysevendor/bin/psalm - PHPUnit
vendor/bin/phpunit - PHPSpec
vendor/bin/phpspec run - Behat (non-JS scenarios)
vendor/bin/behat --strict --tags="~@javascript&&~@mink:chromedriver" - Behat (JS scenarios)
-
Start Headless Chrome:
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.1On MacOS you can use:
APP_ENV=test symfony server:start --port=8080 & "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --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 --disable-gpu --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' --crash-dumps-dir=/tmp https://127.0.0.1 & tee
- Install SSL certificates (only once needed) and run test application’s webserver on
127.0.0.1:8080:symfony server:ca:install APP_ENV=test symfony server:start --port=8080 --daemon - Run Behat:
vendor/bin/behat --strict --tags="@javascript,@mink:chromedriver"
Opening Sylius with your plugin
- Using
testenvironment:APP_ENV=test vendor/bin/console vendor/bin/console sylius:fixtures:load -n APP_ENV=test symfony server:start -d - Using
devenvironment:vendor/bin/console vendor/bin/console sylius:fixtures:load -n symfony server:start -d
How install a local version of Akeneo PIM and use it to test the plugin
First time Akeneo PIM install
If your tests/PIM directory is empty you have to download and install Akeneo PIM. To do so first run this command to download Akeneo:
rm tests/PIM/.gitkeep
composer create-project akeneo/pim-community-standard tests/PIM "7.0.*@stable" --ignore-platform-req=php --ignore-platform-req=ext-apcu --ignore-platform-req=ext-imagick
Then launch Akeneo installation with docker (the first time it will take a while… Consider having a coffee 😉:
(cd tests/PIM && make prod)
After all, we suggest to load a more fully loaded fixture than the minimal loaded by the prod env, launch the following command:
(cd tests/PIM && docker-compose run -u www-data --rm php php bin/console pim:installer:db --catalog vendor/akeneo/pim-community-dev/src/Akeneo/Platform/Bundle/InstallerBundle/Resources/fixtures/icecat_demo_dev)
Using Akeneo test installation
If you already have installed the PIM and you want just to start it launch the following command:
(cd tests/PIM && make up)
Now you can access to the PIM on http://localhost:8080/ with admin/admin as credentials.
If you want to stop the PIM you can run:
(cd tests/PIM && make stop)
Prepare Sylius installation to work with the Akeneo test installation
In Akeneo, go to Exports and launch a CSV export of categories and attributes (use the demo CSV downloads). Remember to launch in a cli shell the following command to launch a messenger consumer:
(cd tests/PIM && docker-compose run -u www-data --rm php php bin/console messenger:consume import_export_job)
You can terminate that consumer when those exports are completed.
In Akeneo create a new connection in Connect > Connection settings with type data destination and save the credentials in your tests/TestApplication/.env.local file:
WEBGRIFFE_SYLIUS_AKENEO_PLUGIN_BASE_URL=http://127.0.0.1:8080/
WEBGRIFFE_SYLIUS_AKENEO_PLUGIN_CLIENT_ID=SAMPLE
WEBGRIFFE_SYLIUS_AKENEO_PLUGIN_SECRET=SAMPLE
WEBGRIFFE_SYLIUS_AKENEO_PLUGIN_USERNAME=SAMPLE
WEBGRIFFE_SYLIUS_AKENEO_PLUGIN_PASSWORD=SAMPLE
WEBGRIFFE_SYLIUS_AKENEO_PLUGIN_WEBHOOK_SECRET=WEBHOOK_SECRET
Now you have to import the attributes and categories (taxa) from Akeneo on the local Sylius installation. Start the local Sylius instance (refer Opening Sylius with your plugin paragraph to do so), then clean it by loading the provided akeneo fixtures suite:
vendor/bin/console sylius:fixtures:load akeneo
Then you can proceed with the import of attributes:
vendor/bin/console app:attributes-import ~/Downloads/attribute.csv
And categories:
vendor/bin/console app:taxa-import ~/Downloads/category.csv
Now, if you want you can import products from Akeneo to Sylius by launching the command:
vendor/bin/console webgriffe:akeneo:import --all
vendor/bin/console messenger:consume main -vvv