php - Mockery doesn't seem to be working properly -
i trying use mockery determine if controller called.
i make call function within test case , method returns properly. however, mockery doesn't seem catch call.
i tried doing call using both $this->call , $this->client->request. both calls return result, mockery should count call controller.
public function testindex() { /**$entity = \entity\classes\entity::get(); var_dump($entity); **/ //this works, , returning entities 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 works, call being made. custom_request calls $this->client->request method //$this->call('get', 'http://myurl:1000/entity/entities/114'); //this alternate method make call work $this->assertresponseok(); }
error:
1) classtest::testindex mockery\exception\invalidcountexception: method index() mockery_0_entity_classes_entity should called 1 times called 0 times.
usually you'd injecting mock something, right it's sitting around in test method , not being used. if you're using laravel, either need replacing actual entity\classes\entity
in ioc container mock, or if entity\classes\entity::index
static method, need use alias mocking, wouldn't recommend that, it's can of worms.
edit:
search "alias:" on page https://github.com/padraic/mockery/blob/master/docs/05-quick-reference.md alias mocking. note want run tests use alias mocking phpunit's process isolation.
Comments
Post a Comment