Mockery shouldReceive()->once() doesn't seem to work

mockery, php

Solution

You need to call `Mockery:close()` to run verifications for your expectations. It also handles the cleanup of the mockery container for the next testcase.

public function tearDown()
{
    parent::tearDown();
    m::close();
}

Problem

I'm trying to get Mockery to assert that a given method is called at least once. My test class is: ``` use \Mockery as m; class MyTest extends \PHPUnit_Framework_TestCase { public function testSetUriIsCalled() { $uri = 'http://localhost'; $httpClient = m::mock('Zend\Http\Client'); $httpClient->shouldReceive('setUri')->with($uri)->atLeast()->once(); } } ``` As you can see, there's one test that (hopefully) creates an expectation that setUri will be called. Since there isn't any other code involved, I can't imagine that it could be called and yet my test passes. Can anyone explain why?

Original source