Skip to content

test(CPD-32641): support PHPUnit 10 through 12 - #79

Closed
thaifanisalla wants to merge 2 commits into
masterfrom
feature/CPD-32641-upgrade-zatca-to-laravel-13
Closed

thaifanisalla wants to merge 2 commits into
masterfrom
feature/CPD-32641-upgrade-zatca-to-laravel-13

Conversation

@thaifanisalla

@thaifanisalla thaifanisalla commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

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 includes vendor/salla/zatca/tests in its phpunit.xml) went from 8 ZATCA tests to 0 without any signal while upgrading to Laravel 13 / PHPUnit 12.

phpunit.xml is also PHPUnit 8/9-era: backupStaticAttributes, verbose, convertErrorsToExceptions, convertNoticesToExceptions, convertWarningsToExceptions and filter/whitelist were all removed in PHPUnit 10, so the config itself will not load there.

What is the new behaviour?

  • the 8 test methods across SignInvoiceTest, GenerateCSRTest and GenerateQrCodeTest use #[Test]
  • phpunit/phpunit moves from ~8.0 to ^10.5|^11.5|^12.0
  • phpunit.xml is rewritten for the PHPUnit 10+ schema (filter/whitelist → <source>). The gating the removed convert*ToExceptions flags provided is kept through their PHPUnit 10+ equivalents, failOnNotice and failOnWarning, so a notice or warning still fails the build
  • cacheDirectory is set (and gitignored) so PHPUnit stops warning about the default cache location

Verified locally: 8 tests, 26 assertions green on PHPUnit 12.5.35 / PHP 8.3, with failOnNotice/failOnWarning active — previously 0 collected.

PHP requirement

Unchanged: require.php stays >=8.0. src/ and tests/ both lint clean on php: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.5 is the lowest line that reads attribute metadata. require-dev is 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's src/ declares final public const and fatals on 8.0, so its >=8.0 was 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) while master is 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

  • SallaApp/zatca-einvoicing#366 — the Laravel 13 upgrade that depends on this (it aliases dev-feature/CPD-32641-upgrade-zatca-to-laravel-13 until this is tagged)

RetriggerConfidence Score: 5/5

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.

  • Replaces PHPUnit doc-comment test metadata with #[Test] attributes so all eight tests remain discoverable.
  • Updates the PHPUnit development constraint and configuration schema.
  • Preserves warning and notice failure behavior and configures an ignored cache directory.
  • Restores and documents the PHP 8.0 consumer-facing runtime floor, which remains compatible with the production source and dependencies.

Reviews (3) · Last reviewed commit: "fix(CPD-32641): keep the consumer PHP fl..."

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.
@thaifanisalla
thaifanisalla requested a review from a team as a code owner September 21, 2026 13:35
@sallainternalbot
sallainternalbot Bot marked this pull request as draft September 21, 2026 13:35
@thaifanisalla thaifanisalla reopened this Sep 21, 2026
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication ✅ 0 (≤ 2 duplication)

View in Codacy

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.

Run reviewer

TIP This summary will be updated as you push new changes.

@thaifanisalla

Copy link
Copy Markdown
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.
@thaifanisalla

Copy link
Copy Markdown
Contributor Author

@greptile review again

@thaifanisalla

Copy link
Copy Markdown
Contributor Author

Superseded by #80 — same change squashed into a single commit on feature/CPD-32641-upgrade-zatca-to-laravel-13-v2. Closing this one; the branch is kept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant