Skip to content

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

Merged
konradoboza merged 2 commits into
6.0from
phpunit-11
Sep 17, 2026
Merged

konradoboza merged 2 commits into
6.0from
phpunit-11

Conversation

@ViniTou

@ViniTou ViniTou commented Sep 15, 2026

Copy link
Copy Markdown
Contributor
🎫 Issue IBX-12606
--- ---

Note

The red Run code style check job fails in its PHPStan step on a pre-existing error in src/lib/Mapper/PagerSearchContentToDataMapper::setTranslatedContentTypesNames() (array-shape mismatch) that is identical on origin/6.0 with PHPUnit 9; not introduced here.

Description:

  • Migrates phpunit/phpunit ^9.6^11.5 and matthiasnoback/symfony-dependency-injection-test
    ^5.0^6.0 in composer.json require-dev. symfony/phpunit-bridge and
    dama/doctrine-test-bundle are not dependencies of this repo, so left untouched (not force-added).
    Local vendor/lock was stale (still resolving ibexa/core/ibexa/doctrine-schema/ibexa/rector at
    5.0.x-dev despite composer.json requiring ~6.0.x-dev), so a full composer update (not a
    partial one scoped to the phpunit packages) was required to resolve cleanly; this also
    incidentally fixed most of the pre-existing PHPStan baseline drift (see below).
  • Migrates phpunit.xml to the PHPUnit 11.5 schema via --migrate-configuration plus hand review:
    drops convert*ToExceptions/backupStaticAttributes (renamed to backupStaticProperties), old
    <filter><whitelist> converted automatically to <source><include>/<exclude>, adds
    cacheDirectory=".phpunit.cache". This repo had no <listeners> block and no
    symfony/phpunit-bridge dependency to begin with, so no <extensions> block was needed/added.
  • Adds .phpunit.cache/ to .gitignore (the pre-existing .phpunit.result.cache entry was already
    there).
  • Rector (PHPUnitSetList::PHPUNIT_100, PHPUNIT_110, ANNOTATIONS_TO_ATTRIBUTES via a temporary
    config, deleted after use) touched 5 files: converted 2 @dataProvider annotations and 1
    @covers-with-value annotation to attributes, made 1 data-provider method static, and converted 5
    createMock() calls to createStub() where the double was only used as a constructor/call
    argument with no expects()/argument matching configured (verified safe, no reverts needed there).
  • Hand fixes beyond Rector's automated passes:
    • use PHPUnit\Framework\Attributes\{CoversClass,DataProvider}; imports added and the FQCN
      attributes shortened, in SuggestionParserTest.php and SearchQueryTypeTest.php.
    • SearchQueryTypeTest::dataProviderForGetQuery() used $this-> to build fixture data including a
      User mock (needed as PHPUnit 11 hard-errors on non-static providers). Made the provider and all
      its helper methods (createSearchDataWithAllCriteria, createContentTypesList,
      createExpectedQueryForAllCriteria, createExpectedAggregations, createUser) static.
    • createUser()'s double needed ->method('__get')->with('id')->willReturn($id), but PHPUnit 11's
      Stub-returned InvocationStubber has no with() (argument matching is MockObject-only);
      Rector's CreateStubOverCreateMockArgRector had wrongly converted this one. Fixed by keeping it
      on the Stub API but replacing ->with() with a willReturnCallback that checks the property
      name itself, instead of reverting to a full createMock() (which would have been unusable from
      the now-static method anyway).
    • SearchQueryTypeTest::$sortingDefinitionRegistry property: PropertyCreateMockToCreateStubRector
      had narrowed its declared type from SortingDefinitionRegistryInterface to bare
      PHPUnit\Framework\MockObject\Stub, which broke PHPStan where the property is passed to
      SearchQueryType's constructor (still typed with the interface). Reverted the declared type to
      SortingDefinitionRegistryInterface, kept the Stub-intersection PHPDoc hint.
  • No setMethods(, withConsecutive(, ->at(/self::at(, assertObjectHasAttribute,
    getMockForAbstractClass, abstract *Test.php base classes, integration PHPUnit config, or
    deptrac config exist anywhere in this repo (confirmed by full-population rg sweep of all 17 test
    files, not sampled) — so those recipe steps are no-ops here.
  • composer fix-cs made no changes (no stray docblock artifacts from the Rector pass, cs-fixer's own
    hook kept files clean throughout).
  • phpstan-baseline.neon needed no pruning: 17 pre-migration errors were almost entirely stale-vendor
    artifacts against outdated upstream ibexa/core/Symfony types (fixed once vendor was properly
    updated to the ~6.0.x-dev the repo actually requires); the 1 remaining error
    (PagerSearchContentToDataMapper.php:179, a by-ref array-shape mismatch) is pre-existing,
    unrelated to this migration, and present identically before and after.

For QA:

N/A

Documentation:

N/A

@sonarqubecloud

Copy link
Copy Markdown

@konradoboza
konradoboza merged commit 4d96de6 into 6.0 Sep 17, 2026
10 checks passed
@konradoboza
konradoboza deleted the phpunit-11 branch September 17, 2026 09:53
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.

5 participants