[mock] reset calls count
Oliboy50 opened this issue · comments
Oliver THEBAULT commented
Is it possible to reset the calls count of a mock?
For example, I'd like to make sure a request call is cached in a function, so if I call this function twice, I should see only 1 mock call:
$this
->if($my->func($client)
->then
->mock($client)
->call('request')
->exactly(1)
// ... reset the $client mock calls count
->if($my->func($client)
->then
->mock($client)
->call('request')
->exactly(0)
Grummfy commented
hello,
yes, of course is possible
https://docs.atoum.org/en/latest/how_to_write_test_cases.html#asserter
you can use
$mock->getMockController()->resetCalls() ;
// or
$this->resetMock($mock);
or
$this
->if($my->func($client)
->then
->mock($client)
->call('request')
->exactly(1)
->assert('Something else to test')
->if($my->func($client)
->then
->mock($client)
->call('request')
->exactly(0)
Telll me if it solve your issue
Oliver THEBAULT commented
yes it is exactly what I was looking for, thank you
the problem is that I didn't search in this part of the doc
only looked here https://docs.atoum.org/en/latest/asserters.html#mock and here https://docs.atoum.org/en/latest/mocking_systems.html