public function testCan() { $securityMock = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); $this->object->setSecurityContext($securityMock); $that = $this; $stateful = $this->object->getObject(); $addIsGrandedExpectation = function($return, $transition) use ($that, $securityMock, $stateful) { static $at = 0; $securityMock ->expects($that->at($at++)) ->method('isGranted') ->with($transition, $stateful) ->will($that->returnValue($return)); }; $addIsGrandedExpectation(true, 't12'); $addIsGrandedExpectation(true, 't23'); $addIsGrandedExpectation(false, 't12'); $addIsGrandedExpectation(true, 't23'); $this->assertTrue($this->object->can('t12')); $this->assertFalse($this->object->can('t23')); $this->assertFalse($this->object->can('t12')); $this->assertFalse($this->object->can('t23')); }