我正在尝试使用 Mockery 来确定我的控制器是否被正确调用。
我从我的测试用例中调用该函数并且该方法正确返回。然而,嘲弄似乎没有抓住那个电话。
我尝试使用 $this->call 和 $this->client->request 进行通话。两个调用都返回结果,所以 Mockery 应该计算对控制器的调用。
public function testIndex()
{
/**$entity = \Entity\Classes\Entity::get();
var_dump($entity); **/
//This works, and is returning all the entities for that entity
$headers = array();
$mock = Mockery::mock('\Entity\Classes\Entity');
$mock->shouldReceive('index')->once();
$crawler = $this->custom_request('GET', '/entity/entities/114', $headers);
//echo $response = $this->client->getResponse()->getContent();
//This also works, so the call is being made. custom_request calls $this->client->request method
//$this->call('GET', 'http://myurl:1000/entity/entities/114');
//This alternate method to make the call also work
$this->assertResponseOk();
}
错误:
1) ClassTest::testIndex
Mockery\Exception\InvalidCountException: Method index() from
Mockery_0_Entity_Classes_Entity should be called
exactly 1 times but called 0 times.