gpt4 book ai didi

php - 无法在@dataProvider PHPUnit 中返回对象

转载 作者:行者123 更新时间:2023-12-03 23:55:38 26 4
gpt4 key购买 nike

是否允许从 @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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com