Closed alebedev80 closed 4 months ago
Isn't it possible that SebastianBergmann\CodeUnit\CodeUnit
is loaded before BypassFinals is enabled?
I just used this bootstrap.php:
<?php
use DG\BypassFinals;
require dirname(__DIR__).'/vendor/autoload.php';
BypassFinals::enable();
$cacheDir = dirname(__DIR__).'.phpunit.bypass.cache';
if (!file_exists($cacheDir) && !mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $cacheDir));
}
BypassFinals::setCacheDirectory($cacheDir);
This error occurred because the cache was created with a different bypassReadOnly
parameter setting than was used afterwards.
This still seem to be an issue with PHPUnit 11 (11.2.5). Even if you use the Extension class recommended in the README I get the error "PHP Fatal error: Non-readonly class PHPUnit\Event\TestSuite\TestSuiteForTestClass cannot extend readonly class PHPUnit\Event\TestSuite\TestSuite in /builds/finpension/finpension-admins/vendor/phpunit/phpunit/src/Event/Value/TestSuite/TestSuiteForTestClass.php on line 19"
The only warkaround that works for me is, if I call "BypassFinals::enable(false, true);", with the readonly removal it won't work.
@finpension-aless it was caused by something else. I tried to modify the extension class to skip the PHPUnit code altogether. Please try the dev version to see if it works for you.
I have set up PHPUnit 11 and started test:
With PHPUnit 10.5.13 everything works fine.