我有一个方法,作为更大方法的一部分,使用不同的参数调用了多次。
$query->where("one", $id);
$query->where("two", "LIKE %{$name}%");
$query->where("three", false);
$query->where("four", true);
我正在使用 PHPUnit 10,我想为这个特定方法编写一个单元测试。我想检查 where 方法是否使用一些特定参数调用了 4 次。
例如:
$mockedQuery->expects($this->exactly(4))
->method("where")
->with(
// Here I'd like to specify the list of arguments
// or perhaps a map or something
)
->willReturn($mockedQuery);
上面的 ->will 不适用于为同一方法的连续调用指定不同的参数(或者至少我无法让它工作)。
我尝试过使用文档,但不知道到底要搜索什么,因此很难找到。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号