-
Notifications
You must be signed in to change notification settings - Fork 48
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
protected dataProvider method reported as required to be public #157
Comments
/cc @villfa |
Hi @janedbal, May you provide a repro? <?php
use PHPUnit\Framework\TestCase;
class DummyTest extends TestCase
{
/** @dataProvider provideValue */
public function test($arg): void
{
self::assertTrue($arg);
}
protected static function provideValue(): iterable
{
return [
[true],
];
}
} But I got this error:
I've also checked the documentation:
EDIT:
|
I'm using PHP 8.1 where you dont need to call setAccessible. That might be the reason. |
Confirmed, your example works on PHP 8.1 and does not on PHP 8.0. composer require phpunit/phpunit
composer require phpstan/phpstan-phpunit
nano DummyTest.php
# paste your contents
docker run --rm -it -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:8.0-cli php vendor/bin/phpunit DummyTest.php # fails
docker run --rm -it -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:8.1-cli php vendor/bin/phpunit DummyTest.php # works |
I confirm it too (tried with PHP 8.1.13). I don't know if it is possible, nor if it's aligned with the PHPStan's way of doing things, but here a proposal:
@ondrejmirtes WDYT? |
Oh god, what a mess. Well, first I'd ask over at PHPUnit to see whether this is intended or not. Documentation still states that dataProvider must be public. So I did: sebastianbergmann/phpunit#5115 |
In the future PHPUnit is gonan require dataProviders to be public again: sebastianbergmann/phpunit#5115 (comment) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
There is new check about dataProviders being public introduced in #150, but protected providers work just fine. I just tested private one and that also works (invocation over method reflection used behaind the scenes).
The text was updated successfully, but these errors were encountered: