πŸ†•Test Application

The Test Application is a shared testing environment designed to simplify Sylius plugin development. Instead of setting up a full application in every plugin, you now use a common, pre-configured application maintained by the Sylius team.

This guide introduces what the Test Application is, why it's useful, and how it changes plugin development. From here, you'll learn how to:

  • Migrate an existing plugin to use the new structure

  • Set up a brand new plugin with the TestApplication from the start

Why This Change?

Previously, each plugin contained its own Symfony application under tests/Application, leading to duplicated code and setup. The new approach uses a centralized package:

  • Shared base in vendor/sylius/test-application

  • Plugin-specific config in tests/TestApplication/

  • Simpler updates via Composer

This reduces maintenance, improves consistency, and speeds up development.

Key Benefits

βœ… No duplicate applications to maintain βœ… Minimal plugin-specific setup βœ… Faster upgrades and consistent environments βœ… Predictable and reliable testing across all plugins βœ… CI-friendly: works the same locally and in automation βœ… Easy onboarding for contributors, less setup overhead βœ… Supports PHPUnit, Behat, Doctrine migrations, and asset compilation

How to Set It Up

  1. Install the package:

    composer require --dev sylius/test-application:^2.0.0@alpha
  2. Add your plugin’s configuration:

    mkdir -p tests/TestApplication/config
    # Add your services.yaml and routes.yaml
  3. Set environment variables in .env:

    DATABASE_URL=mysql://[email protected]/test_application_%kernel.environment%
    
    SYLIUS_TEST_APP_CONFIGS_TO_IMPORT="@YourPlugin/config/config.yaml"
    SYLIUS_TEST_APP_ROUTES_TO_IMPORT="@YourPlugin/config/routes.yaml"
    SYLIUS_TEST_APP_BUNDLES_PATH="tests/TestApplication/config/bundles.php"
    
    # Optionally, replace the default bundles entirely
    SYLIUS_TEST_APP_BUNDLES_REPLACE_PATH="tests/TestApplication/config/bundles.php"
    # Optionally, use a semicolon-separated list to add needed bundles
    SYLIUS_TEST_APP_BUNDLES_TO_ENABLE="Your\Bundle\Namespace"
  4. Configure your plugin's bundles in tests/TestApplication/config/bundles.php if needed:

    <?php
    
    return [
        Some\Dependency\Bundle::class => ['all' => true],
        Your\Bundle\Namespace\Plugin::class => ['all' => true],
    ];

No need for a custom Symfony kernel or app skeleton.


Next: What Do You Want to Do?

πŸ‘‰ Already have a plugin using tests/Application? Learn how to switch to the new Test Application structure in the Migration Guide.

πŸ‘‰ Starting a brand new plugin? Jump straight into the Plugin Setup Guide for a clean setup using Test Application.

Last updated

Was this helpful?