Review main Merged

95275[TASK] Remove needless getAccessibleMock() usages

Benni Mack CR +2 V +2 Hard +436 −339 updated 08/12/26, 08:08

Commit message

getAccessibleMock() of the testing framework builds an eval()'d proxy
subclass that adds _call(), _set() and _get() to reach protected
members of the doubled class. A test that never uses one of those
methods gains nothing from the proxy, but pays for it with a generated
class per call and a test double that no longer carries the type of
the class it doubles.

Get rid of it where it is not needed:

* Use a plain getMockBuilder()->onlyMethods() chain in the test classes
  that never touch the accessible API. Protected methods can be
  configured on a regular mock as well, the proxy is not involved in
  that.

* Call methods directly that have become public in the meantime, such
  as PackageManager->scanAvailablePackages(), YamlSource->load() or
  JsonView->assign(). Two of them are static by now, so
  CommandUtility::getCommand() and
  EnableFileService::removeFirstInstallFile() do not need an instance
  at all anymore.

* Use the real class where the double did not double anything: Export,
  FormDefinition and CoreVersionService are instantiated directly,
  FormRuntime, ExtensionRepository and EmConfUtility are stubs now.

* Drop the subject property of ResourceFactoryTest, which has been
  dead since every test creates its own subject.

* Read the protected property with \ReflectionProperty in
  FileBackendTest, the only thing the proxy was used for there.

This brings the number of getAccessibleMock() calls down from 556 to
444 and the number of test classes using it from 104 to 81.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Wouter Wolters +1
    • Garvin Hicking +1
  • Verified V +2 Done
    • Benni Mack +2
    • Wouter Wolters +1
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 1

Files 30

Show 10 more files

Review log 56

  1. Benni Mack uploaded patch set 1 08/12/26, 06:16

  2. core-ci voted on patch set 1 V +1 08/12/26, 06:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/106489

  3. Wouter Wolters voted on patch set 1 CR +1 V +1 08/12/26, 08:00

  4. Garvin Hicking voted on patch set 1 CR +1 V +1 08/12/26, 08:07

  5. Benni Mack voted on patch set 1 CR +2 V +2 08/12/26, 08:08

  6. Benni Mack merged patch set 2 08/12/26, 08:08