Repository navigation
test(CPD-32641): support PHPUnit 10 through 12 - #79
Closed
thaifanisalla wants to merge 2 commits into
Closed
thaifanisalla wants to merge 2 commits into
thaifanisalla wants to merge 2 commits into
Conversation
PHPUnit 12 removed doc-comment metadata. Every test in this package is marked with `/** @test */`, so under PHPUnit 10 or newer none of the 8 tests is collected any more: the suite reports success while running nothing, both here and in every application that includes this package's tests in its own suite. Replace the annotation with the `#[Test]` attribute, supported since PHPUnit 10. require-dev pinned phpunit/phpunit at ~8.0, which cannot be installed alongside a modern application; widen it to ^10.5|^11.5|^12.0. PHPUnit 10.5 needs PHP 8.1, so the package requirement moves to >=8.1 and the README requirement is aligned with it. phpunit.xml is rewritten for the PHPUnit 10+ schema: the removed attributes (backupStaticAttributes, verbose, convertErrorsToExceptions and friends) are dropped and the filter/whitelist block becomes `<source>`. The gating those convert* flags provided is kept through their PHPUnit 10+ equivalents, failOnNotice and failOnWarning, so a notice or warning still fails the build.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Duplication | ✅ 0 (≤ 2 duplication) |
AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
Contributor
Author
|
@greptile review |
The previous commit raised require.php to >=8.1 because PHPUnit 10.5 needs it. That conflates two different contracts: require.php is what consumers must run, require-dev is what someone developing this package must run. Only the latter needs 8.1. Unlike salla/einvoicing, whose src/ genuinely needs 8.1 (it declares final class constants and fatals on 8.0), this package's src/ and tests/ both lint clean on php:8.0-cli. Raising the floor would have stopped PHP 8.0 consumers from receiving this and every later release for no reason in the code. A dev install still needs PHP 8.1, which is where the supported PHPUnit line starts.
Contributor
Author
|
@greptile review again |
Contributor
Author
|
Superseded by #80 — same change squashed into a single commit on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the zatca-einvoicing Laravel 13 upgrade (CPD-32641).
What kind of change does this PR introduce?
Test tooling fix. No production code is touched.
What is the current behaviour?
Every test method in this suite is marked with
/** @test */. PHPUnit 12 removed metadata in doc-comments, so those methods are no longer collected — the suite does not fail, it reports nothing. Consumers that run the package tests as part of their own suite (zatca-einvoicing includesvendor/salla/zatca/testsin itsphpunit.xml) went from 8 ZATCA tests to 0 without any signal while upgrading to Laravel 13 / PHPUnit 12.phpunit.xmlis also PHPUnit 8/9-era:backupStaticAttributes,verbose,convertErrorsToExceptions,convertNoticesToExceptions,convertWarningsToExceptionsandfilter/whitelistwere all removed in PHPUnit 10, so the config itself will not load there.What is the new behaviour?
SignInvoiceTest,GenerateCSRTestandGenerateQrCodeTestuse#[Test]phpunit/phpunitmoves from~8.0to^10.5|^11.5|^12.0phpunit.xmlis rewritten for the PHPUnit 10+ schema (filter/whitelist→<source>). The gating the removedconvert*ToExceptionsflags provided is kept through their PHPUnit 10+ equivalents,failOnNoticeandfailOnWarning, so a notice or warning still fails the buildcacheDirectoryis set (and gitignored) so PHPUnit stops warning about the default cache locationVerified locally: 8 tests, 26 assertions green on PHPUnit 12.5.35 / PHP 8.3, with
failOnNotice/failOnWarningactive — previously 0 collected.PHP requirement
Unchanged:
require.phpstays>=8.0.src/andtests/both lint clean onphp:8.0-cli, so the consumer-facing floor has no reason to move — that contract describes what the library runs on, not what its test tooling needs.Developing the package does now need PHP 8.1, because
phpunit/phpunit ^10.5is the lowest line that reads attribute metadata.require-devis root-only, so this affects contributors on an end-of-life runtime, not anyone installing the package.(The sibling PR SallaApp/E-Invoicing#29 does raise its floor to
>=8.1— that package'ssrc/declaresfinal public constand fatals on 8.0, so its>=8.0was already inaccurate. This one is genuinely 8.0-clean.)Does this PR introduce a breaking change?
No. Test-only; the published
src/and the declared PHP floor are both unchanged.Follow-up
zatca-einvoicing pins
salla/zatca: ~3.0(locked at 3.0.5) whilemasteris tagged 4.0.1, so this fix needs either a 3.0.x patch release or a decision to move that app to^4.0.Related
dev-feature/CPD-32641-upgrade-zatca-to-laravel-13until this is tagged)The PR appears safe to merge; the current changes preserve test discovery across PHPUnit 10–12 without introducing a production compatibility regression.
Summary
This PR modernizes the package’s test tooling for PHPUnit 10 through 12 without changing production behavior.
#[Test]attributes so all eight tests remain discoverable.Reviews (3) · Last reviewed commit: "fix(CPD-32641): keep the consumer PHP fl..."