本文整理汇总了PHP中EntityManager::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager::expects方法的具体用法?PHP EntityManager::expects怎么用?PHP EntityManager::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::expects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
$this->conn = $this->getMockBuilder('Doctrine\\DBAL\\Connection')->disableOriginalConstructor()->getMock();
$this->conn->expects($this->any())->method('getDatabase')->will($this->returnValue('myDatabase'));
/* @var $platform AbstractPlatform */
$platform = $this->getMockForAbstractClass('Doctrine\\DBAL\\Platforms\\AbstractPlatform');
$this->conn->expects($this->any())->method('getDatabasePlatform')->will($this->returnValue($platform));
$this->em->expects($this->any())->method('getConnection')->will($this->returnValue($this->conn));
/* @var $meta ClassMetadata */
$meta = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock();
$this->em->expects($this->any())->method('getClassMetadata')->will($this->returnValue($meta));
$this->sc = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\SecurityContextInterface')->getMock();
$this->token = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface')->getMock();
$this->sc->expects($this->any())->method('getToken')->will($this->returnValue($this->token));
$this->rh = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Role\\RoleHierarchyInterface')->getMock();
$this->object = new AclNativeHelper($this->em, $this->sc, $this->rh);
}
示例2: testGetAllowedEntityIds
/**
* @covers Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper::getAllowedEntityIds
* @covers Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper::getPermittedAclIdsSQLForUser
*/
public function testGetAllowedEntityIds()
{
$roles = array(new Role('ROLE_KING'));
$allRoles = array($roles[0], new Role('ROLE_SUBJECT'));
$this->token->expects($this->once())->method('getRoles')->will($this->returnValue($roles));
$this->rh->expects($this->once())->method('getReachableRoles')->with($roles)->will($this->returnValue($allRoles));
$user = $this->getMockBuilder('FOS\\UserBundle\\Model\\UserInterface')->getMock();
$user->expects($this->any())->method('getUsername')->will($this->returnValue('MyUser'));
$this->token->expects($this->any())->method('getUser')->will($this->returnValue($user));
$hydrator = $this->getMockBuilder('Doctrine\\ORM\\Internal\\Hydration\\ScalarHydrator')->disableOriginalConstructor()->getMock();
$rows = array(array('id' => 1), array('id' => 9));
$hydrator->expects($this->once())->method('hydrateAll')->will($this->returnValue($rows));
$this->em->expects($this->any())->method('newHydrator')->will($this->returnValue($hydrator));
/* @var $query NativeQuery */
$query = new NativeQuery($this->em);
$this->em->expects($this->once())->method('createNativeQuery')->will($this->returnValue($query));
$permissionDef = new PermissionDefinition(array('view'), 'Kunstmaan\\NodeBundle\\Entity\\Node', 'n');
/* @var $result array */
$result = $this->object->getAllowedEntityIds($permissionDef);
$this->assertEquals(array(1, 9), $result);
}
示例3: it_should_retrieve_all_listings_by_channel
/**
* @test
*/
public function it_should_retrieve_all_listings_by_channel()
{
$channel = new Channel("MNB", 'mnb.png');
$this->entityManager->expects($this->once())->method('findBy')->with($this->equalTo(Listing::class))->willReturn(array());
$this->assertEquals(array(), $this->repo->findBy($channel));
}
示例4: it_should_find_video_proxy_by_uuid
/**
* @test
*/
public function it_should_find_video_proxy_by_uuid()
{
$this->entityManager->expects($this->once())->method('findOneBy');
$this->repo->find("fake_uuid");
}