John Smith
John Smith

Reputation: 6207

Phpunit, how to remove mock objects?

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

Upvotes: 7

Views: 6097

Answers (2)

Joyful
Joyful

Reputation: 1243

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

...    
public function tearDown()
{
    Mockery::close();
}
...

Upvotes: 7

Alister Bulman
Alister Bulman

Reputation: 35169

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.

Upvotes: 4

Related Questions