I'm writing functional tests for Symfony w/ PHPUnit, and my mocks aren't working. It's possible I misunderstood how they work though.
In my unit test's setUp()
method I have this code:
...
// Create a stub
$stub = $this->getMockBuilder('\\ApiBundle\\Util\\WordPressBridge')
->disableOriginalConstructor()
->getMock();
// Configure the stub.
$user = new WordPressUser();
$user->setUsername('dummy');
$stub->expects($this->any())
->method('checkCredentials')
->will($this->returnValue(true));
$stub->expects($this->any())
->method('getUser')
->will($this->returnValue($user));
...
In my Symfony application, I have a service defined:
services:
api.wp_bridge:
class: ApiBundle\Util\WordPressBridge
arguments: [@service_container]
It's my understanding that the mock should be replace the real WordPressBridge
, but that isn't what's happening. My original is still being used. Am I missing something?