website/errors/phpunit.dataProviderMethod.md
<?php declare(strict_types = 1);
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class MyTest extends TestCase
{
#[DataProvider('provideData')]
public function testSomething(string $value): void
{
self::assertNotEmpty($value);
}
public static function provideItems(): iterable
{
yield ['foo'];
}
}
The #[DataProvider] attribute or @dataProvider annotation references a method that does not exist on the test class. PHPUnit will fail at runtime when it cannot find the data provider method.
Ensure the data provider method name matches exactly:
-#[DataProvider('provideData')]
+#[DataProvider('provideItems')]
public function testSomething(string $value): void
{
self::assertNotEmpty($value);
}
Or create the missing method:
+public static function provideData(): iterable
+{
+ yield ['foo'];
+}