Cannot override final method assertDirectoryDoesNotExist error

Hello, I am on CakepHP 4.4. I upgraded my PHPUnit to 10 from 9 and now when i try to run the tests, I get the below error:

[PHP Fatal error: Cannot override final method PHPUnit\Framework\Assert::assertDirectoryDoesNotExist() in \vendor\cakephp\cakephp\src\TestSuite\TestCase.php on line 159]

Fatal error: Cannot override final method PHPUnit\Framework\Assert::assertDirectoryDoesNotExist() in \vendor\cakephp\cakephp\src\TestSuite\TestCase.php on line 159

Did anyone else have a similar error? how did you fix it?

CakePHP 4 is not compatible with PHPUnit 10.

If you want/need PHPUnit 10 you need to upgrade to CakePHP 5

Thank you for your reply. So from the cakephp docs it looks like PHPUnit 9.3 is the recommended version for CakePHP 4.4.14

please learn what semantic versioning means and check Versions and constraints - Composer

Its not PHPUnit 9.3 but 9.6 since its the latest minor version of PHPUnit 9

1 Like