使用 laravel 5 应用程序并遇到 phpspec 问题。为什么我下面的 Phpspec 单元测试会失败,或者更准确地说,我怎样才能让 stdClass 对象键匹配,这样它就不会失败?
我的规格文件:
function it_checks_add_starting_date_to_flow()
{
$dealflows = new \stdClass ();
this->add_starting_date_to_flow($dealflows)->shouldReturn((object)[]);
}
我正在测试的辅助函数:
public static function add_starting_date_to_flow($dealflows)
{
$dealflows= new \stdClass();
return $dealflows;
}
从 phpspec 我得到以下响应:
App/libraries/Mmdealhelpers
65 - 它检查添加开始日期以流预期 [obj:stdClass],但得到 [obj:stdClass]。
@@ -1,1 +1,1 @@
-stdClass Object &000000001d025295000000007dd68060 ()
+stdClass Object &000000001d02529a000000007dd68060 ()
80 // ]
81 // ));
82 $this->add_starting_date_to_flow($dealflows)->shouldReturn((object)[]);
83
84 }
85
0 vendor/phpspec/phpspec/src/PhpSpec/Matcher/IdentityMatcher.php:78
throw new PhpSpec\Exception\Example\NotEqualException("Expected [obj:stdC...")
1 [internal]
spec\App\libraries\MmdealhelpersSpec->it_checks_add_starting_date_to_flow()