Testing
PHP Testing
Chamilo uses PHPUnit for backend testing.
Test Database Setup
Tests require a dedicated database. Create .env.test.local with your test database credentials:
DATABASE_HOST='127.0.0.1'
DATABASE_PORT='3306'
DATABASE_NAME='chamilo_test'
DATABASE_USER='root'
DATABASE_PASSWORD='root'Then initialise the test database:
php bin/console --env=test cache:clear
php bin/console --env=test doctrine:database:create
php bin/console --env=test doctrine:schema:create
php bin/console --env=test doctrine:fixtures:load --no-interactionTo reset after schema changes:
php bin/console --env=test doctrine:schema:update --force --completeRunning Tests
Test Location
Tests are in the tests/ directory, which is not included in packaged Chamilo downloads — it only comes with a git clone. CoreBundle/ and CourseBundle/ mirror the subdirectory layout of src/CoreBundle/ and src/CourseBundle/:
See Project Structure for the full tests/ layout, including the non-test-suite folders (datafiller/, history/, procedures/, scripts/).
Test Types
Unit/Integration tests — PHPUnit tests in
CoreBundle/andCourseBundle/; most hit a real database (viadama/doctrine-test-bundle)Functional (API) tests — Extend
AbstractApiTestand test HTTP endpoints end-to-endPlaywright tests — Browser-level acceptance tests in
tests/playwright/(see below)
Playwright (End-to-End) Tests
Chamilo uses Playwright, driven through playwright-bdd so scenarios stay plain Gherkin. This replaced the old Behat suite; Behat's scenarios remain in git history and are worth consulting when adding coverage for an area it once tested (git ls-tree -r --name-only 98c77757ea6 tests/behat), but treat them only as a hint of which flows matter — the selectors have rotted, so verify against the live app.
Before the first run, seed the fixtures most scenarios assume exist, in this order:
Then run the suite (the seeds and the installer scenario are excluded from it):
yarn test:playwright:install covers the web installer itself. It recreates the database, so it is CI-only — never run it against an installation you care about.
After editing a .feature file or anything under tests/playwright/steps/, regenerate the compiled specs before trusting a run:
Frontend Checks
PHP Code Quality
Chamilo uses ECS (Easy Coding Standard), PHPStan, and Psalm for code quality. Composer shortcuts are available for each:
Note: there is no php-cs-fixer in this project. ECS (symplify/easy-coding-standard) is the code style tool.
Continuous Integration
Pull requests are automatically checked by four GitHub Actions workflows:
phpunit.yml
PHPUnit test suite
format_code.yml
ECS code style check
php_analysis.yml
Psalm, Doctrine schema validation, dependency requirements checker
playwright.yml
Playwright end-to-end tests (installs Chamilo via the web installer, then runs the suite)
Last updated
Was this helpful?