[英]Cannot return objects in @dataProvider PHPUnit
Is it allowed to return objects from @dataProviders
to test methods?是否允许将对象从
@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)
{
(...)
Error:错误:
The data provider specified for Tests\\Tests\\Mobile\\Classes\\AppVersionTest::success_create_message_for_ios is invalid.
为 Tests\\Tests\\Mobile\\Classes\\AppVersionTest::success_create_message_for_ios 指定的数据提供程序无效。 Class 'Mobile\\Classes\\Messages\\UpToDateMessage' not found
找不到类“Mobile\\Classes\\Messages\\UpToDateMessage”
MobileMessage
is an interface, imports are correct. MobileMessage
是一个接口,导入是正确的。
From the 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.
数据提供者方法必须是公共的,并且要么返回一个数组数组,要么返回一个实现 Iterator 接口并为每个迭代步骤生成一个数组的对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.