/**
* @dataProvider dataProviderForB
*/
public function testB($user, $department, $module)
{
// ...
}我的数据提供程序是:
public function dataProviderForB()
{
return [
[User::first(), Department::first(), Module::first()],
];
}
PS C:\xampp\htdocs\w> .\vendor\bin\phpunit
PHPUnit 8.5.8 by Sebastian Bergmann and contributors.
W.. 3 / 3 (100%)
Time: 661 ms, Memory: 24.00 MB
There was 1 warning:我的错误是:
1) Warning
The data provider specified for Tests\Feature\BTest::testB is invalid.
PHPUnit\Util\Exception: Method dataProviderForB does not exist
WARNINGS!
Tests: 3, Assertions: 2, Warnings: 1.
PS C:\xampp\htdocs\w> .\vendor\bin\phpunit发布于 2020-12-06 23:19:22
测试中不会生成app()
您需要将参数传递给testFunction,如下所示:
public function dataProviderForB()
{
return [
[1, 1, 1],
];
}这将解决错误
https://stackoverflow.com/questions/65169648
复制相似问题