Skip to content

Add PHPUnit test suite and CI workflow #31

@martinydeAI

Description

@martinydeAI

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

  1. 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.

  2. Commit the recipe-installed files (phpunit.xml.dist,
    tests/bootstrap.php, updated symfony.lock, .env.test if added).

  3. Add a trivial smoke test at tests/SmokeTest.php so CI has something
    real to run.

  4. Verify locally:

    itkdev-docker-compose vendor/bin/phpunit
  5. 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
  6. Update CHANGELOG.md under [Unreleased] (Added).

Acceptance criteria

  • phpunit/phpunit (via symfony/test-pack or directly) is in
    require-dev.
  • phpunit.xml.dist and at least one passing test under tests/
    are committed.
  • itkdev-docker-compose vendor/bin/phpunit exits 0 locally.
  • .github/workflows/phpunit.yaml runs the test suite on PRs and
    pushes to main / develop.
  • CI reports green on a fresh PR.
  • CHANGELOG.md updated.
  • Reviewed and merged via PR.

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No fields configured for Task.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions