Creating and testing plugins using Test Application

Sylius PluginSkeleton is the official template designed to quickly start developing your own plugins for Sylius. It provides a structured and best-practice-driven boilerplate, making it easy to build, test, and publish plugins.

What PluginSkeleton Provides

PluginSkeleton includes:

  • A predefined plugin directory structure

  • Composer dependencies already set up

  • Example code for implementation and specifications

  • Integrated support for Behat (Behavior-Driven Development)

  • Git configuration ready to use

  • A working plugin bundle class and example feature to guide your development

For detailed examples and to access the latest version, visit the official GitHub repository: Sylius PluginSkeleton on GitHub

Testing Your Plugin with the New Test Application

The recommended testing method for Sylius plugins is now based on the Test Application provided by Sylius. Although the PluginSkeleton currently includes an older test setup (tests/Application), it will soon switch by default to using the new Test Application (tests/TestApplication).

Migrating to the Test Application (Current Approach)

Until the PluginSkeleton template is officially updated, follow these straightforward steps to modernize your plugin's testing setup:

  1. Install the Test Application:

    composer require --dev sylius/test-application
  2. Replace the old test setup: Delete the legacy tests/Application directory and create a new minimal tests/TestApplication directory.

  3. Configure the Test Application: Within the new tests/TestApplication directory, create:

    • .env.test

    • bundles.php

    • config.yaml

    These files register and configure your plugin within the shared testing environment.

    Example bundles.php:

    <?php
    
    return [
        YourVendor\YourPlugin\YourPluginBundle::class => ['all' => true],
    ];
  4. Customize Test Configuration (Optional): If your plugin requires additional services or Doctrine overrides for testing, add these configurations in config.yaml.

Future State (Coming Soon)

Very shortly, the PluginSkeleton will include the Test Application by default, simplifying this process even further. Until then, following these manual steps ensures your plugin aligns with the latest testing practices recommended by Sylius.

By completing these steps, you'll benefit from a modern, centralized, and maintainable testing environment that is consistent across all Sylius plugins.

Last updated

Was this helpful?