Goal
Provide a runnable PHPUnit test suite and a CI workflow so PRs run tests
on every change.
Background
Issue #10 (Set up GitHub Actions for coding standards and tests) bundled
two halves. The coding-standards half landed in #4 (eight workflow files
from the symfony-8 template). The test-suite half was never started —
no phpunit dependency, no phpunit.xml, no tests/ directory, no
PHPUnit workflow. This issue captures only that remaining test-suite
work.
The upstream
itk-dev/devops_itkdev-docker
template repo does not ship a PHPUnit workflow template for either
Symfony or Drupal (only php.yaml / twig.yaml / styles.yaml /
javascript.yaml). So the workflow we add here is a project-local
file and will not carry the upstream "Do not edit this file!" header.
An optional follow-up is to contribute it upstream — out of scope here.
The App\Tests\ PSR-4 namespace is already reserved in composer.json
(autoload-dev points at tests/), so the wiring is half there.
Steps
-
Install the test runner inside the container:
itkdev-docker-compose composer require --dev symfony/test-pack
This brings in phpunit/phpunit, symfony/phpunit-bridge, and the
Symfony recipe installs phpunit.xml.dist and tests/bootstrap.php.
-
Commit the recipe-installed files (phpunit.xml.dist,
tests/bootstrap.php, updated symfony.lock, .env.test if added).
-
Add a trivial smoke test at tests/SmokeTest.php so CI has something
real to run.
-
Verify locally:
itkdev-docker-compose vendor/bin/phpunit
-
Add .github/workflows/phpunit.yaml modelled on the existing
php.yaml. Trigger on **/*.php, composer.json, composer.lock,
docker-compose.yml, phpunit.xml*. Inside the job:
docker compose run --rm phpfpm composer install
docker compose run --rm phpfpm vendor/bin/phpunit
-
Update CHANGELOG.md under [Unreleased] (Added).
Acceptance criteria
Optional follow-up (not blocking)
- Open a PR against
itk-dev/devops_itkdev-docker adding
github/workflows/symfony/phpunit.yaml so future Symfony projects
pick it up automatically.
References
Goal
Provide a runnable PHPUnit test suite and a CI workflow so PRs run tests
on every change.
Background
Issue #10 (Set up GitHub Actions for coding standards and tests) bundled
two halves. The coding-standards half landed in #4 (eight workflow files
from the
symfony-8template). The test-suite half was never started —no
phpunitdependency, nophpunit.xml, notests/directory, noPHPUnit workflow. This issue captures only that remaining test-suite
work.
The upstream
itk-dev/devops_itkdev-dockertemplate repo does not ship a PHPUnit workflow template for either
Symfony or Drupal (only
php.yaml/twig.yaml/styles.yaml/javascript.yaml). So the workflow we add here is a project-localfile and will not carry the upstream "Do not edit this file!" header.
An optional follow-up is to contribute it upstream — out of scope here.
The
App\Tests\PSR-4 namespace is already reserved incomposer.json(
autoload-devpoints attests/), so the wiring is half there.Steps
Install the test runner inside the container:
This brings in
phpunit/phpunit,symfony/phpunit-bridge, and theSymfony recipe installs
phpunit.xml.distandtests/bootstrap.php.Commit the recipe-installed files (
phpunit.xml.dist,tests/bootstrap.php, updatedsymfony.lock,.env.testif added).Add a trivial smoke test at
tests/SmokeTest.phpso CI has somethingreal to run.
Verify locally:
Add
.github/workflows/phpunit.yamlmodelled on the existingphp.yaml. Trigger on**/*.php,composer.json,composer.lock,docker-compose.yml,phpunit.xml*. Inside the job:Update
CHANGELOG.mdunder[Unreleased](Added).Acceptance criteria
phpunit/phpunit(viasymfony/test-packor directly) is inrequire-dev.phpunit.xml.distand at least one passing test undertests/are committed.
itkdev-docker-compose vendor/bin/phpunitexits 0 locally..github/workflows/phpunit.yamlruns the test suite on PRs andpushes to
main/develop.CHANGELOG.mdupdated.Optional follow-up (not blocking)
itk-dev/devops_itkdev-dockeraddinggithub/workflows/symfony/phpunit.yamlso future Symfony projectspick it up automatically.
References
CLAUDE.md(PR docs: add CLAUDE.md and refocus README as human-facing docs #30)..github/workflows/php.yaml.