当前位置: 首页>>代码示例>>PHP>>正文


PHP EntityManager::expects方法代码示例

本文整理汇总了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);
 }
开发者ID:axelvnk,项目名称:KunstmaanBundlesCMS,代码行数:22,代码来源:AclNativeHelperTest.php

示例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);
 }
开发者ID:axelvnk,项目名称:KunstmaanBundlesCMS,代码行数:25,代码来源:AclHelperTest.php

示例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));
 }
开发者ID:erheme318,项目名称:simple-tv-listings,代码行数:9,代码来源:ListingRepositoryTest.php

示例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");
 }
开发者ID:erheme318,项目名称:simple-tv-listings,代码行数:8,代码来源:VideoProxyRepositoryTest.php


注:本文中的EntityManager::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。