sylius / test-application
Fund package maintenance!
sylius
Requires
- php: ^8.2
- sylius/sylius: ^2.0
- symfony/debug-bundle: *
- symfony/dotenv: *
- symfony/flex: *
- symfony/runtime: *
- symfony/web-profiler-bundle: *
- theofidry/alice-data-fixtures: *
This package is auto-updated.
Last update: 2025-05-07 09:48:31 UTC
README
TestApplication
Developer tool that provides a ready-to-use Sylius-based application for testing and running Sylius plugins.
⚠️ While TestApplication is still evolving, it is already being used internally and in official plugins. We encourage you to adopt it in your plugins, provide feedback, and contribute to improve the developer experience for the entire Sylius ecosystem.
Purpose
Previously, each plugin had to maintain its own copy of a test application, leading to duplicated configuration, maintenance overhead, and version incompatibilities.
This package solves that problem by:
- Extracting a reusable, standalone test application
- Providing an official, centrally maintained solution by the Sylius team
- Simplifying the setup and execution of tests within plugins
- Creating versioned variants aligned with specific Sylius versions (e.g.
1.14
,2.0
, etc.)
Installation and configuration in a Plugin
-
Require the TestApplication as a development dependency:
composer require sylius/test-application:2.0.x-dev --dev
-
Set environment variables in
tests/TestApplication/.env
:DATABASE_URL=mysql://root@127.0.0.1/test_application_%kernel.environment% BUNDLES_TO_ENABLE="Acme\Plugin\AcmePlugin" CONFIGS_TO_IMPORT="@AcmePlugin/tests/TestApplication/config/config.yaml" ROUTES_TO_IMPORT="@AcmePlugin/config/routes.yaml"
💡 The values provided above are examples and should be adjusted for your plugin.
-
If needed, place plugin-specific configuration files in the
tests/TestApplication/config
directory (e.g.services.yaml
,routes.yaml
) and load them by env variables. -
If your plugin requires additional JavaScript dependencies, add them to
tests/TestApplication/package.json
:{ "dependencies": { "trix": "^2.0.0" } }
This file will be merged with the main TestApplication
package.json
. -
If your plugin requires entity extensions, add them in
tests/TestApplication/src/Entity
and ensure:-
Doctrine mappings are configured:
doctrine: orm: entity_managers: default: mappings: TestApplication: is_bundle: false type: attribute dir: '%kernel.project_dir%/../../../tests/TestApplication/src/Entity' prefix: Tests\Acme\Plugin\TestApplication
-
The namespace is registered properly in the autoloader, in
composer.json
file{ "autoload-dev": { "psr-4": { "Tests\\Acme\\Plugin\\TestApplication\\": "tests/TestApplication/src/" } } }
-
-
Build the TestApplication in a Plugin:
vendor/bin/console doctrine:database:create vendor/bin/console doctrine:migration:migrate -n vendor/bin/console sylius:fixtures:load -n (cd vendor/sylius/test-application && yarn install) (cd vendor/sylius/test-application && yarn build) vendor/bin/console assets:install
-
Run your server locally:
symfony serve --dir=vendor/sylius/test-application/public
Example usage
See an example implementation in the pull request to Sylius/CmsPlugin.
Community
For online communication, we invite you to chat with us & other users on Sylius Slack.
License
This package is completely free and released under the MIT License.