Skip to content

IBX-12606: Migrated the test suites to PHPUnit 11 - #149

Merged
mikadamczyk merged 1 commit into
6.0from
phpunit-11
Sep 17, 2026
Merged

mikadamczyk merged 1 commit into
6.0from
phpunit-11

Conversation

@ViniTou

@ViniTou ViniTou commented Sep 15, 2026

Copy link
Copy Markdown
Contributor
🎫 Issue IBX-12606

Note

User login providers tests / browser-tests is red on 6.0 itself at this PR's base commit 15f94b1 (run 34843258920, same two failing scenarios: Current page "/login" does not match the regex "/Users"). Unrelated to this PR; all other 13 checks pass.

Description:

  • Migrates phpunit/phpunit ^9.6^11.5 and matthiasnoback/symfony-dependency-injection-test
    ^5.0^6.0 (symfony/phpunit-bridge ^7.4 was already satisfied). composer update ... --with-all-dependencies
    resolved cleanly, no conflicts.
  • Migrates phpunit.xml (the only config in this repo, covering unit + integration in one file) to
    the 11.5 schema: <coverage> auto-renamed to <source>, cacheDirectory=".phpunit.cache" added.
    <listeners><listener class="...SymfonyTestsListener"/></listeners> was silently dropped by
    --migrate-configuration (no warning) and replaced by hand with
    <extensions><bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension"/></extensions>.
  • Adds .phpunit.cache/ to .gitignore (alongside the pre-existing .phpunit.result.cache entry).
  • Rector (PHPUnitSetList::PHPUNIT_100, PHPUNIT_110, ANNOTATIONS_TO_ATTRIBUTES via a temporary
    config, deleted after use) converted 12 @dataProvider annotations and one @group/@coversNothing
    pair to attributes (9 files, all providers made static), rewrote 4 ->withConsecutive(...) call
    sites to matcher + willReturnCallback, and converted 9 createMock() calls to createStub()
    where the double is only ever used as a constructor/call argument or a fixed return value with no
    expects()/method() configured on it directly — each conversion re-verified by hand, not
    accepted blindly.
  • Hand fixes beyond the automated passes, found via PHPUnit/PHPStan runtime errors:
    • WithConsecutiveRector always attaches ->expects($this->exactly(N)), even though the original
      UserPermissionsLimitationTypeTest::testValidatePass had no invocation-count assertion at all
      (some data-provider sets pass empty arrays, causing the mocked methods to legitimately be called
      zero times). Relaxed the matcher back to self::any() there to match the original, intentional
      behavior; a real test failure otherwise.
    • The same rewrite's return self::throwException(new NotFoundException(...)) inside a
      willReturnCallback closure (testValidateError) does not actually throw — self::throwException()
      builds a stub object meant for ->will()/return slots. Replaced with a real throw statement to
      preserve the original willReturnOnConsecutiveCalls semantics (first call throws, second returns
      a value).
    • Switching that matcher to self::any() turned a match ($matcher->numberOfInvocations())
      expression non-exhaustive for PHPStan (AnyInvokedCount's count isn't statically bounded);
      rewritten as plain if/else rather than adding an ignore.
    • Ibexa\Tests\Core\Limitation\Base::getUserMock() — a shared test helper shipped by ibexa/core
      (consumed here as a path dependency) — still calls the PHPUnit-11-removed
      MockBuilder::setMethods(), confirmed present on ibexa/core's own origin/6.0 (not just a
      stale local checkout). This broke UserPermissionsLimitationTypeTest::testEvaluate (6 data
      sets). Fixed entirely within this repo, without touching ibexa/core: replaced the one call site
      with a plain $this->createStub(APIUser::class), since UserPermissionsLimitationType::evaluate()
      never reads its $currentUser argument. ibexa/core's own PHPUnit 11 migration will need the
      equivalent fix in Base::getUserMock() for every other 6.0 consumer that relies on it.
  • composer fix-cs cleaned up stray docblock/import-ordering artifacts left by the Rector pass (4
    files); phpstan-baseline.neon needed no pruning and no new ignores were added.
  • getMockForAbstractClass() (2 sites, UserPasswordValidatorTest.php) left as-is: deprecated in
    PHPUnit 11, removed in 12.

For QA:

N/A

Documentation:

N/A

@sonarqubecloud

Copy link
Copy Markdown

@mikadamczyk
mikadamczyk merged commit 5a773a6 into 6.0 Sep 17, 2026
21 of 22 checks passed
@mikadamczyk
mikadamczyk deleted the phpunit-11 branch September 17, 2026 09:14
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.

3 participants