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


PHP ClassMetadata::expects方法代码示例

本文整理汇总了PHP中Doctrine\Common\Persistence\Mapping\ClassMetadata::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::expects方法的具体用法?PHP ClassMetadata::expects怎么用?PHP ClassMetadata::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\Common\Persistence\Mapping\ClassMetadata的用法示例。


在下文中一共展示了ClassMetadata::expects方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 public function setUp()
 {
     $this->class = 'Abc\\Bundle\\SequenceBundle\\Entity\\Sequence';
     $this->classMetaData = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata');
     $this->objectManager = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
     $this->repository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository');
     $this->objectManager->expects($this->any())->method('getClassMetadata')->will($this->returnValue($this->classMetaData));
     $this->classMetaData->expects($this->any())->method('getName')->will($this->returnValue($this->class));
     $this->objectManager->expects($this->any())->method('getRepository')->will($this->returnValue($this->repository));
     $this->subject = new SequenceManager($this->objectManager, $this->class);
 }
开发者ID:aboutcoders,项目名称:sequence-bundle,代码行数:11,代码来源:SequenceManagerTest.php

示例2: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $this->class = Schedule::class;
     $this->classMetaData = $this->createMock(ClassMetadata::class);
     $this->objectManager = $this->createMock(ObjectManager::class);
     $this->repository = $this->createMock(ObjectRepository::class);
     $this->objectManager->expects($this->any())->method('getClassMetadata')->will($this->returnValue($this->classMetaData));
     $this->classMetaData->expects($this->any())->method('getName')->will($this->returnValue($this->class));
     $this->objectManager->expects($this->any())->method('getRepository')->will($this->returnValue($this->repository));
     $this->subject = new ScheduleManager($this->objectManager, $this->class);
 }
开发者ID:aboutcoders,项目名称:scheduler-bundle,代码行数:14,代码来源:ScheduleManagerTest.php

示例3: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $this->class = Log::class;
     $this->classMetaData = $this->createMock(ClassMetadata::class);
     $this->objectManager = $this->createMock(ObjectManager::class);
     $this->repository = $this->createMock(ObjectRepository::class);
     $this->objectManager->expects($this->any())->method('getClassMetadata')->willReturn($this->classMetaData);
     $this->classMetaData->expects($this->any())->method('getName')->willReturn($this->class);
     $this->objectManager->expects($this->any())->method('getRepository')->willReturn($this->repository);
     $this->subject = $this->getMockForAbstractClass(LogManager::class, array($this->objectManager, $this->class));
 }
开发者ID:aboutcoders,项目名称:job-bundle,代码行数:14,代码来源:LogManagerTest.php

示例4: setUp

 public function setUp()
 {
     $this->class = ResourceLock::class;
     $this->classMetaData = $this->getMock(ClassMetadata::class);
     $this->objectManager = $this->getMock(ObjectManager::class);
     $this->repository = $this->getMock(ObjectRepository::class);
     $this->objectManager->expects($this->any())->method('getClassMetadata')->will($this->returnValue($this->classMetaData));
     $this->classMetaData->expects($this->any())->method('getName')->will($this->returnValue($this->class));
     $this->objectManager->expects($this->any())->method('getRepository')->will($this->returnValue($this->repository));
     $this->subject = new LockManager($this->objectManager, $this->class, $this->prefix);
 }
开发者ID:aboutcoders,项目名称:resource-lock-bundle,代码行数:11,代码来源:LockManagerTest.php

示例5: setUp

 public function setUp()
 {
     $this->class = 'Abc\\Bundle\\FileDistributionBundle\\Entity\\Definition';
     $this->classMetaData = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata');
     $this->objectManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $this->repository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository');
     $this->objectManager->expects($this->any())->method('getClassMetadata')->will($this->returnValue($this->classMetaData));
     $this->classMetaData->expects($this->any())->method('getName')->will($this->returnValue($this->class));
     $this->objectManager->expects($this->any())->method('getRepository')->will($this->returnValue($this->repository));
     $this->subject = new DefinitionManager($this->objectManager, $this->class);
 }
开发者ID:aboutcoders,项目名称:file-distribution-bundle,代码行数:11,代码来源:DefinitionManagerTest.php

示例6: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $this->class = Job::class;
     $this->classMetaData = $this->createMock(ClassMetadata::class);
     $this->objectManager = $this->createMock(ObjectManager::class);
     $this->repository = $this->createMock(ObjectRepository::class);
     $this->scheduleManager = $this->getMockBuilder(ScheduleManager::class)->disableOriginalConstructor()->getMock();
     $this->serializationHelper = $this->getMockBuilder(SerializationHelper::class)->disableOriginalConstructor()->getMock();
     $this->objectManager->expects($this->any())->method('getClassMetadata')->willReturn($this->classMetaData);
     $this->classMetaData->expects($this->any())->method('getName')->willReturn($this->class);
     $this->objectManager->expects($this->any())->method('getRepository')->willReturn($this->repository);
     $this->subject = $this->getMockForAbstractClass(JobManager::class, [$this->objectManager, $this->class, $this->scheduleManager, $this->serializationHelper]);
 }
开发者ID:aboutcoders,项目名称:job-bundle,代码行数:16,代码来源:JobManagerTest.php

示例7: testCanHydrateOneToOneAssociationByReferenceWithNullableRelation

 public function testCanHydrateOneToOneAssociationByReferenceWithNullableRelation()
 {
     // When using hydration by reference, it won't use the public API of the entity to retrieve values (setters)
     $entity = new Asset\OneToOneEntity();
     $this->configureObjectManagerForOneToOneEntity();
     $data = array('toOne' => null);
     $this->metadata->expects($this->once())->method('hasAssociation');
     $object = $this->hydratorByReference->hydrate($data, $entity);
     $this->assertNull($object->getToOne(false));
 }
开发者ID:antoinealej,项目名称:HomeStuff,代码行数:10,代码来源:DoctrineObjectTest.php

示例8: testNotSupportedRole

 /**
  * @expectedException \RuntimeException
  * @expectedExceptionMessage Expected Symfony\Component\Security\Core\Role\RoleInterface, \stdClass given
  */
 public function testNotSupportedRole()
 {
     $user = new User();
     $this->metadata->expects($this->once())->method('getAssociationTargetClass')->willReturn('\\stdClass');
     $this->om->expects($this->never())->method('persist')->with($this->equalTo($user));
     $this->om->expects($this->never())->method('flush');
     $repository = $this->getMockBuilder('Oro\\Bundle\\UserBundle\\Entity\\Repository\\UserApiRepository')->disableOriginalConstructor()->getMock();
     $this->om->expects($this->any())->method('getRepository')->will($this->returnValue($repository));
     $this->userManager->updateUser($user);
 }
开发者ID:Maksold,项目名称:platform,代码行数:14,代码来源:UserManagerTest.php

示例9: testLabelGeneratorUsedForGetValueOptions

 public function testLabelGeneratorUsedForGetValueOptions()
 {
     $this->prepareProxy();
     $this->proxy->setOptions(array('label_generator' => function ($targetEntity) {
         return $targetEntity->getEmail();
     }));
     $this->metadata->expects($this->never())->method('hasField');
     $result = $this->proxy->getvalueOptions();
     $this->assertEquals($result[0]['label'], 'object one email');
     $this->assertEquals($result[1]['label'], 'object two email');
     $this->assertEquals($result[0]['value'], 1);
     $this->assertEquals($result[1]['value'], 2);
 }
开发者ID:KBO-Techo-Dev,项目名称:MagazinePro-zf25,代码行数:13,代码来源:ProxyTest.php

示例10: testIterationFlushesAtGivenBatchSizes

 /**
  * @dataProvider iterationFlushesProvider
  *
  * @param int $resultItemsCount
  * @param int $batchSize
  * @param int $expectedFlushesCount
  */
 public function testIterationFlushesAtGivenBatchSizes($resultItemsCount, $batchSize, $expectedFlushesCount)
 {
     $object = new \stdClass();
     $values = array_fill(0, $resultItemsCount, $object);
     $iterator = SimpleBatchIteratorAggregate::fromArrayResult(array_fill(0, $resultItemsCount, $object), $this->entityManager, $batchSize);
     $this->metadata->expects(self::any())->method('getIdentifierValues')->willReturn(['id' => 123]);
     $this->entityManager->expects(self::exactly($resultItemsCount))->method('find')->willReturn($object);
     $this->entityManager->expects(self::exactly($expectedFlushesCount))->method('flush');
     $this->entityManager->expects(self::exactly($expectedFlushesCount))->method('clear');
     $iteratedObjects = [];
     foreach ($iterator as $key => $value) {
         $iteratedObjects[$key] = $value;
     }
     $this->assertCount($resultItemsCount, $iteratedObjects);
 }
开发者ID:Ocramius,项目名称:DoctrineBatchUtils,代码行数:22,代码来源:SimpleBatchIteratorAggregateTest.php

示例11: testAvoidFailingLookupsForEmptyArrayValues

 public function testAvoidFailingLookupsForEmptyArrayValues()
 {
     $data = array('categories' => array(1, 2, ''));
     $reflClass = $this->getMock('\\ReflectionClass', array(), array('Doctrine\\Common\\Collections\\ArrayCollection'));
     $reflProperty = $this->getMock('\\ReflProperty', array('setAccessible', 'getValue'));
     $this->metadata->expects($this->exactly(1))->method('getTypeOfField')->with($this->equalTo('categories'))->will($this->returnValue('array'));
     $this->metadata->expects($this->exactly(1))->method('hasAssociation')->with($this->equalTo('categories'))->will($this->returnValue(true));
     $this->metadata->expects($this->exactly(1))->method('getAssociationTargetClass')->with($this->equalTo('categories'))->will($this->returnValue('stdClass'));
     $this->metadata->expects($this->exactly(1))->method('isSingleValuedAssociation')->with($this->equalTo('categories'))->will($this->returnValue(false));
     $this->metadata->expects($this->exactly(1))->method('isCollectionValuedAssociation')->with($this->equalTo('categories'))->will($this->returnValue(true));
     $this->objectManager->expects($this->exactly(2))->method('find')->will($this->returnValue(new stdClass()));
     $this->metadata->expects($this->exactly(1))->method('getReflectionClass')->will($this->returnValue($reflClass));
     $reflClass->expects($this->exactly(1))->method('getProperty')->with($this->equalTo('categories'))->will($this->returnValue($reflProperty));
     $reflProperty->expects($this->exactly(1))->method('getValue')->withAnyParameters()->will($this->returnValue(new ArrayCollection($data)));
     $object = $this->hydrator->hydrate($data, new stdClass());
     $this->assertEquals(2, count($object->categories));
 }
开发者ID:rrmodi88,项目名称:DoctrineModule,代码行数:17,代码来源:DoctrineObjectTest.php

示例12: testHydrateOneToManyAssociationByReferenceWithArrayCausingDataModifications

 public function testHydrateOneToManyAssociationByReferenceWithArrayCausingDataModifications()
 {
     // When using hydration by value, it will use the public API of the entity to set values (setters)
     $data = array('entities' => array(array('id' => 2, 'field' => 'Modified By Hydrate'), array('id' => 3, 'field' => 'Modified By Hydrate')));
     $entityInDatabaseWithIdOfTwo = new Asset\SimpleEntity();
     $entityInDatabaseWithIdOfTwo->setId(2);
     $entityInDatabaseWithIdOfTwo->setField('Unmodified Value', false);
     $entityInDatabaseWithIdOfThree = new Asset\SimpleEntity();
     $entityInDatabaseWithIdOfThree->setId(3);
     $entityInDatabaseWithIdOfThree->setField('Unmodified Value', false);
     $entity = new Asset\OneToManyEntityWithEntities(new ArrayCollection(array($entityInDatabaseWithIdOfTwo, $entityInDatabaseWithIdOfThree)));
     $reflSteps = array(new ReflectionClass('DoctrineModuleTest\\Stdlib\\Hydrator\\Asset\\OneToManyEntityWithEntities'), new ReflectionClass('DoctrineModuleTest\\Stdlib\\Hydrator\\Asset\\SimpleEntity'), new ReflectionClass('DoctrineModuleTest\\Stdlib\\Hydrator\\Asset\\SimpleEntity'), new ReflectionClass('DoctrineModuleTest\\Stdlib\\Hydrator\\Asset\\OneToManyEntityWithEntities'));
     $this->metadata->expects($this->any())->method('getReflectionClass')->will($this->returnCallback(function () use(&$reflSteps) {
         $refl = array_shift($reflSteps);
         return $refl;
     }));
     $this->configureObjectManagerForOneToManyEntity();
     $this->objectManager->expects($this->exactly(2))->method('find')->with('DoctrineModuleTest\\Stdlib\\Hydrator\\Asset\\SimpleEntity', $this->logicalOr($this->equalTo(array('id' => 2)), $this->equalTo(array('id' => 3))))->will($this->returnCallback(function ($target, $arg) use($entityInDatabaseWithIdOfTwo, $entityInDatabaseWithIdOfThree) {
         if ($arg['id'] === 2) {
             return $entityInDatabaseWithIdOfTwo;
         } elseif ($arg['id'] === 3) {
             return $entityInDatabaseWithIdOfThree;
         }
         throw new \InvalidArgumentException();
     }));
     $entity = $this->hydratorByReference->hydrate($data, $entity);
     $this->assertInstanceOf('DoctrineModuleTest\\Stdlib\\Hydrator\\Asset\\OneToManyEntityWithEntities', $entity);
     /* @var $entity \DoctrineModuleTest\Stdlib\Hydrator\Asset\OneToManyEntity */
     $entities = $entity->getEntities(false);
     foreach ($entities as $en) {
         $this->assertInstanceOf('DoctrineModuleTest\\Stdlib\\Hydrator\\Asset\\SimpleEntity', $en);
         $this->assertInternalType('integer', $en->getId());
         $this->assertInternalType('string', $en->getField());
         $this->assertContains('Modified By Hydrate', $en->getField(false));
     }
     $this->assertEquals(2, $entities[0]->getId());
     $this->assertSame($entityInDatabaseWithIdOfTwo, $entities[0]);
     $this->assertEquals(3, $entities[1]->getId());
     $this->assertSame($entityInDatabaseWithIdOfThree, $entities[1]);
 }
开发者ID:KBO-Techo-Dev,项目名称:MagazinePro-zf25,代码行数:40,代码来源:DoctrineObjectTest.php


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