是否允许从 @dataProviders
返回对象测试方法?
public function iOsMessages()
{
return [
'update available' => [1, new UpToDateMessage(), 'pl'],
];
}
/**
* @test
* @dataProvider iOsMessages
*/
public function success_create_message_for_ios(int $appVersion, MobileMessage $message, string $locale)
{
(...)
错误:
The data provider specified for Tests\Tests\Mobile\Classes\AppVersionTest::success_create_message_for_ios is invalid. Class 'Mobile\Classes\Messages\UpToDateMessage' not found
MobileMessage
是一个接口(interface),导入是正确的。
最佳答案
来自 documentation :
A data provider method must be public and either return an array of arrays or an object that implements the Iterator interface and yields an array for each iteration step.
关于php - 无法在@dataProvider PHPUnit 中返回对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48625741/