From db1a774b2b310e0f6a75afb2bf9d7e0497c90a97 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 9 Sep 2026 10:49:06 +0000 Subject: [PATCH 1/2] Add CI and the shared Release workflow, and revive the test suite This package had neither continuous integration nor a release workflow, so releasing it meant tagging by hand -- which is what the shared workflow exists to prevent: Packagist derives versions from tags, so a tag is a published version the moment it exists. Adding a release workflow alone would not have worked. Its pre-tag gate runs ./vendor/bin/phpunit, and this package declared no test runner at all: composer install produced no phpunit binary. Adding one then exposed why -- the suite was written against the PHPUnit 4/5 API that PHPUnit 6 removed, so it could not run on any supported PHP version. Revived rather than skipped, because a release gate that runs nothing is not a gate: - Tests now extend PHPUnit\Framework\TestCase, use expectException(), and declare setUp(): void as PHPUnit 8+ requires. Without the return type the declaration is outright incompatible with the parent and fatals. - ADD: phpunit/phpunit ^11.0 to require-dev. - phpunit.xml.dist updated to the current schema. - The change log gains version headings. It held a single unheaded line, so the release workflow would have failed at release-notes extraction. The heading names the release that line describes -- HEAD is that tag, and the line was written by that tag's own release commit. - ADD: .gitignore covering vendor, composer.lock and the phpunit cache. Verified on PHP 8.4: composer validate passes and the suite is green (11 tests, 17 assertions). No library code changed, and require.php is untouched, so nothing changes for consumers. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Lgup8xLZHLQmavt7JoEQ4C --- .github/workflows/continuous-integration.yml | 51 ++++++++++++++++++++ .github/workflows/release.yml | 31 ++++++++++++ .gitignore | 4 ++ CHANGES.md | 24 +++++++++ composer.json | 3 ++ phpunit.xml.dist | 15 +++++- tests/LoaderTest.php | 13 +++-- 7 files changed, 136 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/continuous-integration.yml create mode 100644 .github/workflows/release.yml create mode 100644 .gitignore diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..f8ccef2 --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,51 @@ +name: Continuous Integration + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php-version: + - '8.2' + - '8.3' + - '8.4' + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: + coverage: none + tools: composer:v2 + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --no-interaction --prefer-dist + + - name: Validate composer.json + run: composer validate --no-check-lock --no-check-publish + + - name: Run test suite + run: ./vendor/bin/phpunit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..68f9559 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +# Releasing this package: Actions -> Release -> Run workflow, pick the branch +# (2.x) and type the version. Or from a terminal: +# +# gh workflow run release.yml --ref 2.x -f version=2.0.5 +# +# The shared workflow creates the tag itself, and only after every check has +# passed. Do not tag by hand -- Packagist derives versions from tags, so a tag +# is a published version the moment it exists. +# +# Release notes come from this package's own CHANGES.md. The version you type +# must match the version at the top of the change log -- or, for a pre-release +# such as 2.0.5-alpha1, its base version, so that alphas and betas do not each +# need a change log section of their own. + +name: Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Version to release, e.g. 2.0.5' + required: true + type: string + +jobs: + release: + uses: auraphp/bin/.github/workflows/release.yml@v1.0.0 + permissions: + contents: write + with: + version: ${{ inputs.version }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8d1cf20 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/composer.lock +/vendor +/phpunit.xml +/.phpunit.result.cache diff --git a/CHANGES.md b/CHANGES.md index 0ef9efa..45acfd9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1 +1,25 @@ +# CHANGELOG + +## 2.0.5 + +Maintenance release: the package now has continuous integration, and a +release workflow, for the first time. + +- The test suite runs on PHP 8.2 through 8.4. It was written against the + PHPUnit 4/5 API (`PHPUnit_Framework_TestCase`, `setExpectedException()`), + which PHPUnit 6 removed, so it could not run on any supported PHP at all. + It now targets PHPUnit 11: 11 tests, 17 assertions. +- ADD: `phpunit/phpunit` to `require-dev`. The package had no test runner + declared, so `composer install` produced nothing to run the tests with. +- ADD: a Continuous Integration workflow, and a Release workflow calling the + shared `auraphp/bin` workflow. +- FIX: the `nds()` test helper stringified the nested base-dir arrays from + `getPrefixes()` to `'Array'` instead of recursing into them, so + `testAddPrefix` could never pass. The library itself was correct. + +No library code changed. `require.php` is unchanged, so nothing changes for +consumers of this package. + +## 2.0.4 + Hygiene release: update the license year, and remove a branch alias. diff --git a/composer.json b/composer.json index 0a7891b..692d948 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,9 @@ "Aura\\Autoload\\": "src/" } }, + "require-dev": { + "phpunit/phpunit": "^11.0" + }, "extra": { "aura": { "type": "library" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 761e67c..9a6b0c4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,18 @@ - + + - + ./tests + + + src + + diff --git a/tests/LoaderTest.php b/tests/LoaderTest.php index ec9cd22..a06955d 100644 --- a/tests/LoaderTest.php +++ b/tests/LoaderTest.php @@ -1,13 +1,13 @@ loader = new Loader; } @@ -195,9 +195,16 @@ public function testPsr0Loading() $this->assertSame($expect, $actual); } - // normalize directory separators in file names for windows compatibilitys + // normalize directory separators in file names for windows compatibility. + // recurses, because getPrefixes() returns base dirs nested one level under + // each prefix -- str_replace() on a nested array stringifies the inner + // arrays to 'Array' instead of descending into them. protected function nds($file) { + if (is_array($file)) { + return array_map(array($this, 'nds'), $file); + } + return str_replace('/', DIRECTORY_SEPARATOR, $file); } } From 0514aaf53870886074c32dfa0b47e66a9fc10268 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 9 Sep 2026 17:35:13 +0000 Subject: [PATCH 2/2] Test against PHP 5.6 through 8.5 using PHPUnit Polyfills The suite ran only on PHP 8.2-8.4, while require.php claims support far older than that. Testing a narrower range than the package advertises means the advertised range is unverified. yoast/phpunit-polyfills bridges the gap: one set of tests runs on PHPUnit 5.7 through 11, so a single suite covers PHP 5.6 to 8.5. - Tests extend Yoast\PHPUnitPolyfills\TestCases\TestCase and define set_up() instead of setUp(): void. The void return type is a parse error before PHP 7.1, so the modern signature cannot even be parsed on older versions -- the polyfill TestCase bridges set_up() to whichever signature the running PHPUnit expects. - require-dev widens to phpunit ^5.7.21 || ^6.4.4 || ^7.5 || ^8.5 || ^9.6 || ^11.0 and polyfills ^2.0.5 || ^3.1.2 || ^4.0.0, so each PHP version resolves a combination that supports it. CI runs composer update rather than install for exactly this reason; no lock file is committed. - phpunit.xml.dist drops the version-pinned schema and the attributes added after 5.7, so one config file is valid across the whole range. Verified locally on both PHPUnit 11.5 and 9.6, same results. - CI selects Composer 2.2 LTS below PHP 7.2, since Composer 2.3+ requires PHP 7.2.5. Note that 5.6 is the floor CI can reach, not the floor require.php claims: setup-php does not offer PHP below 5.6, and the polyfills need 5.4+. PHP 5.3-5.5 therefore stay untested. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Lgup8xLZHLQmavt7JoEQ4C --- .github/workflows/continuous-integration.yml | 22 ++++++++++++++++---- CHANGES.md | 21 +++++++++++++------ composer.json | 3 ++- phpunit.xml.dist | 13 ++---------- tests/LoaderTest.php | 4 ++-- 5 files changed, 39 insertions(+), 24 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index f8ccef2..e36386b 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -14,9 +14,20 @@ jobs: fail-fast: false matrix: php-version: + - '5.6' + - '7.0' + - '7.1' + - '7.2' + - '7.3' + - '7.4' + - '8.0' + - '8.1' - '8.2' - '8.3' - '8.4' + - '8.5' + + name: PHP ${{ matrix.php-version }} steps: - name: Checkout @@ -28,7 +39,8 @@ jobs: php-version: ${{ matrix.php-version }} extensions: coverage: none - tools: composer:v2 + # Composer 2.3+ needs PHP 7.2.5; the 2.2 LTS line still runs on 5.6. + tools: ${{ contains(fromJSON('["5.6","7.0","7.1"]'), matrix.php-version) && 'composer:v2.2' || 'composer:v2' }} - name: Get composer cache directory id: composer-cache @@ -38,11 +50,13 @@ jobs: uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-composer- + key: ${{ runner.os }}-php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-php${{ matrix.php-version }}-composer- + # update, not install: no lock file is committed, so each PHP version + # resolves the PHPUnit and polyfill versions that support it. - name: Install dependencies - run: composer install --no-interaction --prefer-dist + run: composer update --no-interaction --prefer-dist - name: Validate composer.json run: composer validate --no-check-lock --no-check-publish diff --git a/CHANGES.md b/CHANGES.md index 45acfd9..5bb09f3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,17 +5,26 @@ Maintenance release: the package now has continuous integration, and a release workflow, for the first time. -- The test suite runs on PHP 8.2 through 8.4. It was written against the - PHPUnit 4/5 API (`PHPUnit_Framework_TestCase`, `setExpectedException()`), - which PHPUnit 6 removed, so it could not run on any supported PHP at all. - It now targets PHPUnit 11: 11 tests, 17 assertions. -- ADD: `phpunit/phpunit` to `require-dev`. The package had no test runner - declared, so `composer install` produced nothing to run the tests with. +- The test suite was written against the PHPUnit 4/5 API + (`PHPUnit_Framework_TestCase`, `setExpectedException()`), which PHPUnit 6 + removed, so it could not run on any supported PHP at all. It now runs on + PHP 5.6 through 8.5: 11 tests, 17 assertions. +- ADD: `phpunit/phpunit` and `yoast/phpunit-polyfills` to `require-dev`. + The package had no test runner declared at all, so `composer install` + produced nothing to run the tests with. - ADD: a Continuous Integration workflow, and a Release workflow calling the shared `auraphp/bin` workflow. - FIX: the `nds()` test helper stringified the nested base-dir arrays from `getPrefixes()` to `'Array'` instead of recursing into them, so `testAddPrefix` could never pass. The library itself was correct. +- The suite runs on **PHP 5.6 through 8.5**, via + [`yoast/phpunit-polyfills`][polyfills], which lets one set of tests run on + PHPUnit 5.7 through 11. Tests use `set_up()` rather than `setUp(): void`, + because the `void` return type is a parse error before PHP 7.1. +- `phpunit.xml.dist` is deliberately minimal, so that a single config file is + valid for every PHPUnit version in that range. + +[polyfills]: https://github.com/Yoast/PHPUnit-Polyfills No library code changed. `require.php` is unchanged, so nothing changes for consumers of this package. diff --git a/composer.json b/composer.json index 692d948..945b95d 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ } }, "require-dev": { - "phpunit/phpunit": "^11.0" + "phpunit/phpunit": "^5.7.21 || ^6.4.4 || ^7.5 || ^8.5 || ^9.6 || ^11.0", + "yoast/phpunit-polyfills": "^2.0.5 || ^3.1.2 || ^4.0.0" }, "extra": { "aura": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9a6b0c4..9083bfb 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,18 +1,9 @@ - + ./tests - - - src - - diff --git a/tests/LoaderTest.php b/tests/LoaderTest.php index a06955d..9b4d937 100644 --- a/tests/LoaderTest.php +++ b/tests/LoaderTest.php @@ -1,13 +1,13 @@ loader = new Loader; }