public function testGetSharedWithName() { $object = $this->getMockBuilder('Symfony\\Component\\Security\\Acl\\Model\\DomainObjectInterface')->disableOriginalConstructor()->getMock(); $object->expects($this->any())->method('getObjectIdentifier')->will($this->returnValue(1)); $user = new User(1); $user->setUsername('TestUser'); $sid = new UserSecurityIdentity('TestUser', get_class($user)); $ace = $this->getMockBuilder('Symfony\\Component\\Security\\Acl\\Domain\\Entry')->disableOriginalConstructor()->getMock(); $ace->expects($this->any())->method('getSecurityIdentity')->will($this->returnValue($sid)); $aces = [$ace]; $acl = $this->getMockBuilder('Symfony\\Component\\Security\\Acl\\Domain\\Acl')->disableOriginalConstructor()->getMock(); $acl->expects($this->any())->method('getObjectAces')->will($this->returnValue($aces)); $this->aclCache->expects($this->once())->method('getFromCacheByIdentity')->will($this->returnValue($acl)); $repository = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ObjectRepository')->disableOriginalConstructor()->getMock(); $repository->expects($this->any())->method('findOneBy')->will($this->returnValue($user)); $this->manager->expects($this->any())->method('getRepository')->will($this->returnValue($repository)); $this->nameFormatter->expects($this->any())->method('format')->will($this->returnValue($user->getUsername())); $this->assertEquals($user->getUsername(), $this->twigExtension->getSharedWithName($object)); }
public function testCheckResourceIsGranted() { $this->securityFacade->expects($this->once())->method('isGranted')->with($this->equalTo('test_acl'))->will($this->returnValue(true)); $this->assertTrue($this->twigExtension->checkResourceIsGranted('test_acl')); }