This project uses two distinct MariaDB instances during the testing phase to ensure data isolation:
- Purpose: Primary application database for functional testing.
- Data: Pre-seeded with
test.sqlandsecurityTests.sqlvia Docker'sinitdb.d. - Used By: Manual development, Behat (Gherkin/Selenium) suites.
- Purpose: A "Disposable Sandbox" for PHPUnit Integration Tests.
- Behavior: The
DatabaseTestCase.phpclass drops and recreates this database for every test run to ensure a clean schema build fromdb/cats_schema.sql.
To mirror the CI environment on your machine:
-
Prepare the environment:
cp test/config.php ./config.php touch ./INSTALL_BLOCK
-
Start the containers:
cd docker/ docker compose -f docker-compose-test.yml up -d -
Run the suites:
- PHPUnit:
docker exec -it opencats_test_php ./vendor/bin/phpunit src/OpenCATS/Tests/IntegrationTests - Behat:
docker exec -it opencats_test_php ./vendor/bin/behat -c ./test/behat.yml
- PHPUnit:
- Connection Errors: If tests fail to connect, verify the
integrationtestdbcontainer is healthy. The CI usesmysqladmin pingto ensure the DB is ready before PHP attempts to connect. - Risky Tests: PHPUnit may flag empty test methods (placeholders) as "Risky." These do not fail the build but should be implemented in future PRs.