Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPUnit 11 incompatibility #53

Closed
alebedev80 opened this issue Mar 13, 2024 · 5 comments
Closed

PHPUnit 11 incompatibility #53

alebedev80 opened this issue Mar 13, 2024 · 5 comments

Comments

@alebedev80
Copy link

alebedev80 commented Mar 13, 2024

I have set up PHPUnit 11 and started test:

PHP Fatal error:  Non-readonly class SebastianBergmann\CodeUnit\ClassUnit cannot extend readonly class SebastianBergmann\CodeUnit\CodeUnit in /Users/alm/code/api_client/vendor/sebastian/code-unit/src/ClassUnit.php on line 15

With PHPUnit 10.5.13 everything works fine.

@dg
Copy link
Owner

dg commented Mar 14, 2024

Isn't it possible that SebastianBergmann\CodeUnit\CodeUnit is loaded before BypassFinals is enabled?

@alebedev80
Copy link
Author

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);

@dg
Copy link
Owner

dg commented May 16, 2024

This error occurred because the cache was created with a different bypassReadOnly parameter setting than was used afterwards.

@finpension-aless
Copy link

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.

@dg
Copy link
Owner

dg commented Jul 2, 2024

@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.

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

No branches or pull requests

3 participants