Skip to content

Unit tests and PHP lint

William Jacoby edited this page Oct 28, 2026 · 1 revision

PHPUnit and PHP syntax checks

PHPUnit

phpbb-test-board/run-unit-tests.sh path/to/extension [-b 3.3.x|master] [-f PATTERN] [-- PHPUNIT_ARGS...]

Runs the extension's phpunit.xml.dist the way phpbb-extensions/test-framework does in CI: inside a phpBB checkout, with phpBB's own PHPUnit and tests/bootstrap.php. It needs no board.

  • The checkout is set up on first use in ~/.cache/phpbb-release-tools/phpbb-BRANCH (or --env DIR, or PHPBB_UNIT_ENV): a shallow clone of phpBB, its Composer dependencies, and on PHP 8 with phpBB 3.3.x the switch to PHPUnit 9 that phpBB's own CI makes, since 3.3.x ships PHPUnit 7.5. --update pulls it and reinstalls.
  • The extension is copied in afresh on every run (rsync --delete, without .git), into phpBB/ext/ under its composer.json name, so a test never runs against an old copy.
  • A tests/functional folder must exist, even an empty one (tests/functional/.gitkeep). The test framework runs with phpBB's own configuration, which lists it, and its PostgreSQL, MySQL, MSSQL and Windows jobs stop without it; the script refuses to run without it so that shows up before CI.
  • -f PATTERN runs only the matching tests; anything after -- goes to PHPUnit, for example -- --testdox or, on master, -- --display-skipped.

Exit status: PHPUnit's, 1 for a setup failure, 2 for bad arguments. Needs git, php, composer, rsync and jq.

Short Long Behavior
-b --branch BRANCH 3.3.x (default) or master.
-e --env DIR Explicit phpBB checkout, overriding PHPBB_UNIT_ENV and default cache.
-u --update Pull the checkout and reinstall dependencies.
-f --filter PATTERN PHPUnit test filter.
-h --help Usage.
run-unit-tests.sh -b 3.3.x /path/to/extension -- --testdox
run-unit-tests.sh -b master /path/to/extension

This runner copies the current extension directory with rsync, unlike the Git-ref-based board tools; uncommitted files may therefore be tested. --env is a managed test checkout: its extension destination is synchronized with deletion, and --update resets tracked checkout files before pulling. Do not point it at a checkout containing work you need to preserve. Keep separate environments for different phpBB branches.

PHP syntax and deprecations

phpbb-test-board/php-lint.sh path/to/extension [-p 7.4,8.4] [--strict]

Runs php -l on every PHP file under each PHP version (default 7.4 and 8.4), in a throwaway container from the official php:VERSION-cli image, so an extension can be checked against its minimum PHP without that PHP installed. The folder is mounted read-only, the container has no network and is removed afterwards; vendor/, node_modules/ and .git/ are skipped. Compile-time deprecation notices, such as implicitly nullable parameters on PHP 8.4, are shown, and fail the run only with --strict. It needs no board.

Exit status: 0 when every file passes on every version, 1 when a file fails or Docker fails, 2 for bad arguments. The first run of a version pulls its image.

Short Long Behavior
-p --php VERSIONS Comma-separated MAJOR.MINOR values; default 7.4,8.4.
-s --strict Fail for compile-time deprecations too.
-h --help Usage.
php-lint.sh /path/to/extension --php 7.4,8.4 --strict

Linting scans the supplied directory, including local edits. It does not establish runtime or phpBB compatibility. The selected official PHP images must be available to Docker; image pulls require network access even though lint containers run without network access.

Clone this wiki locally