Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phpunit, how to remove mock objects?

Tags:

php

phpunit

I have two different testcases, both puts a mock on a method. Is there a way to clean up mocked objects? Because there are different expectations in the testmethods

like image 310
John Smith Avatar asked Oct 13 '14 15:10

John Smith


2 Answers

May be you need use Mock::close():

...    
public function tearDown()
{
    Mockery::close();
}
...
like image 148
Joyful Avatar answered Sep 25 '22 17:09

Joyful


Create (or recreate) the mock in a test method itself, rather than trying to re-use a pre-generated object (presumably in some kind of setUp function) if it's not suitable for your needs.

like image 36
Alister Bulman Avatar answered Sep 21 '22 17:09

Alister Bulman