Based on my reading of the PHPUnit documentation, I expect the following code to create a mock of the AuthorizationChecker
class that will return false when the isGranted()
method is called. However, the original method is called instead. What am I doing wrong?
$auth = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\AuthorizationChecker')
->disableOriginalConstructor()
->setMethods(['isGranted'])
->getMock();
$auth->expects($this->any())
->method('isGranted')
->with($this->anything())
->will($this->returnValue(false));
$this->assertFalse($auth->isGranted('TEST'));
Replacing the argument to setMethods()
with null or an empty array, or removing the call entirely, has no effect. Nor does removing the expects()
and with()
calls.