Cannot run tests with phpunit 12 `Cannot override final method PHPUnit\Framework\TestCase::__construct()`

Author: tenzapCreated Aug 24, 2025Updated Aug 26, 2025

Command:

cd tests && phpunit

Output:

PHP Fatal error:  Cannot override final method PHPUnit\Framework\TestCase::__construct() in /src/tests/mocks/ci_testcase.php on line 29

Fatal error: Cannot override final method PHPUnit\Framework\TestCase::__construct() in /src/tests/mocks/ci_testcase.php on line 29

This is likely because of that change in phpunit.

TestCase::__construct() is now declared final (it was annotated with @final before and the announced changed from @final to final for PHPUnit 12 was forgotten)

See: https://github.com/sebastianbergmann/phpunit/blob/12.0.10/ChangeLog-12.0.md#1203---2025-02-18

Versions PHPUnit 12.3.6 by Sebastian Bergmann and contributors. PHP 8.4.11

How to fix this?