This document provides essential information about the Ecotone monorepo project structure, development environment, and testing procedures.
Ecotone is organized as a monorepo containing multiple packages:
- The monorepo
- Each package is available under
packages/*directory - Core package is
packages/Ecotone, which is the foundation for all other packages - Each package is a separately delivered composer package with its own
composer.json - During release, each package is pushed to a separate read-only repository
- End-users can download specific packages directly from packagist.com
The project uses Docker for development:
- A
docker-compose.ymlfile in the root directory sets up all required containers - To start the environment:
docker-compose up -d - After starting, all packages are available to run and use
- To enter the development container:
docker exec -it ecotone_development /bin/bash - From inside the container, you can run tests that require access to other services
There are two main approaches to running tests:
# Enter the container
docker exec -it ecotone_development /bin/bash
# Run tests from inside the container
vendor/bin/phpunit# Run tests directly without entering the container
docker exec -it ecotone_development vendor/bin/phpunitThis method is faster and preferred for most testing scenarios.
Tests can be run in two different contexts:
When running tests from the root of the project, they execute in the context of the entire monorepo:
- Uses shared dependencies
- Runs on vendor packages compatible with all Ecotone packages
- Command:
vendor/bin/phpunit(from project root)
Tests can also be run in the context of a specific package:
cd ./packages/Dbal
composer update
vendor/bin/phpunitThis approach uses the package's own dependencies and is useful for isolated testing.
The preferred way to write tests is writing high level tests, which tests from end-user perspective.
The need for that is, that those tests are more reliable in long-term, and allows for refactoring without being broken.
This is done using Ecotone Lite, which bootstrap small Ecotone Application which can be run in isolation for specific set of classes.
You can read more about testing approaches under Testing Support page.
The project uses several testing tools:
Used for unit and integration testing:
- Run with:
vendor/bin/phpunitorcomposer tests:phpunit - Configuration: Each package has its own
phpunit.xml.distfile - Can run specific tests:
vendor/bin/phpunit --filter testMethodName tests/path/to/TestFile.php
Used for behavior-driven development (BDD) and feature testing:
- Run with:
vendor/bin/behatorcomposer tests:behat - Configuration: Each package that uses Behat has a
behat.ymlfile - Behat tests are organized in feature files with human-readable scenarios
Used for static code analysis to detect potential errors:
- Run with:
vendor/bin/phpstanorcomposer tests:phpstan - Helps identify type-related issues and other potential bugs without executing the code
Combined test suites for continuous integration:
- Run with:
composer tests:ci - Typically runs PHPStan, PHPUnit, and Behat tests in sequence
- Some packages may include additional checks in their CI process
# Run all PHPUnit tests in a package
cd packages/PackageName
composer tests:phpunit
# Run a specific test file
vendor/bin/phpunit tests/path/to/TestFile.php
# Run a specific test method
vendor/bin/phpunit --filter testMethodName tests/path/to/TestFile.php
# Run static analysis
composer tests:phpstan
# Run Behat tests (if available for the package)
composer tests:behat
# Run all tests for CI
composer tests:ciThe framework provides several testing utilities:
EcotoneLite::bootstrapForTesting()- Creates a test instance of EcotoneFlowTestSupport- Helps test message flowsMessagingTestSupport- Provides support for testing messaging components
For example Dbal may support version 3 and 4 of Doctrine DBAL.
To see which version is supported check related composer.json file in the package directory.
It's easy to verify lower and highest dependency versions by running from the package context
composer update --prefer-lowest
vendor/bin/phpunit
composer update --prefer-stable
vendor/bin/phpunitTests within the package will always run faster than in the monorepo context, as they are limited to specific context.
However it's still worth to run specific failure test with --filter testMethodName to have the quickest feedback loop.
- Some tests require specific environment variables to be set
- Database tests may require the Docker environment to be running
- Each package may have specific testing requirements defined in its README or phpunit.xml.dist file
- The Dbal package tests interact with actual databases, so they require the database containers to be running