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


PHP ClassMetadata::expects方法代码示例

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


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

示例1: setUp

 protected function setUp()
 {
     $this->meta = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->setMethods(['getName'])->getMock();
     $this->meta->expects($this->any())->method('getName')->will($this->returnValue('SR\\Doctrine\\ORM\\Id\\StringUuid4Generator'));
     $this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->setMethods(['getClassMetadata', 'find'])->getMock();
     $this->em->expects($this->any())->method('getClassMetadata')->will($this->returnValue($this->meta));
     $this->em->expects($this->any())->method('find')->will($this->returnValue(null));
     $this->entity = $this->getMockBuilder('SR\\Doctrine\\ORM\\Mapping\\Entity')->getMock();
 }
开发者ID:scr-be,项目名称:arthur-doctrine-uuid-library,代码行数:9,代码来源:StringUuid4PessimisticGeneratorTest.php

示例2: testFindOneBy

 public function testFindOneBy()
 {
     $this->classMetadata->expects($this->once())->method('getFieldNames')->will($this->returnValue([$translatableField = 'translatable_field', $bothField = 'both_field']));
     $this->classMetadata->expects($this->once())->method('getAssociationMapping')->with($this->identicalTo('translations'))->will($this->returnValue(['targetEntity' => $translationClass = TranslationTest::class]));
     $translationClassMetadata = $this->createClassMetadataMock();
     $translationClassMetadata->expects($this->once())->method('getFieldNames')->will($this->returnValue([$translationField = 'translation_field', $bothField]));
     $this->entityManager->expects($this->once())->method('getClassMetadata')->with($this->identicalTo($translationClass))->will($this->returnValue($translationClassMetadata));
     $this->resource->expects($this->once())->method('getName')->will($this->returnValue($name = 'resource'));
     $this->entityManager->expects($this->once())->method('createQueryBuilder')->will($this->returnValue($queryBuilder = $this->createQueryBuilderMock()));
     $queryBuilder->expects($this->once())->method('select')->with($this->identicalTo($name))->will($this->returnSelf());
     $queryBuilder->expects($this->once())->method('from')->with($this->identicalTo($this->class), $this->identicalTo($name), $this->isNull())->will($this->returnSelf());
     $queryBuilder->expects($this->once())->method('addSelect')->with($this->identicalTo('resource_translation'))->will($this->returnSelf());
     $queryBuilder->expects($this->exactly(5))->method('getRootAliases')->will($this->returnValue([$name]));
     $queryBuilder->expects($this->once())->method('leftJoin')->with($this->identicalTo($name . '.translations'), $this->identicalTo($translation = 'resource_translation'), $this->isNull(), $this->isNull(), $this->isNull())->will($this->returnSelf());
     $queryBuilder->expects($this->exactly(3))->method('expr')->will($this->returnValue($expr = $this->createExprMock()));
     $expr->expects($this->at(0))->method('eq')->with($this->identicalTo($name . '.' . $translatableField), $this->matchesRegularExpression('/:' . $name . '_' . $translatableField . '_[a-z0-9]{22}/'))->will($this->returnValue($translatableWhere = 'translatable_where'));
     $expr->expects($this->at(1))->method('eq')->with($this->identicalTo($translation . '.' . $translationField), $this->matchesRegularExpression('/:' . $translation . '_' . $translationField . '_[a-z0-9]{22}/'))->will($this->returnValue($translationWhere = 'translation_where'));
     $expr->expects($this->at(2))->method('eq')->with($this->identicalTo($name . '.' . $bothField), $this->matchesRegularExpression('/:' . $name . '_' . $bothField . '_[a-z0-9]{22}/'))->will($this->returnValue($bothWhere = 'both_where'));
     $queryBuilder->expects($this->exactly(3))->method('andWhere')->will($this->returnValueMap([[$translatableWhere, $queryBuilder], [$translationWhere, $queryBuilder], [$bothWhere, $queryBuilder]]));
     $queryBuilder->expects($this->at(9))->method('setParameter')->with($this->matchesRegularExpression('/' . $name . '_' . $translatableField . '_[a-z0-9]{22}/'), $this->identicalTo($translatableValue = 'translatable_value'), $this->isNull())->will($this->returnSelf());
     $queryBuilder->expects($this->at(13))->method('setParameter')->with($this->matchesRegularExpression('/' . $translation . '_' . $translationField . '_[a-z0-9]{22}/'), $this->identicalTo($translationValue = 'translation_value'), $this->isNull())->will($this->returnSelf());
     $queryBuilder->expects($this->at(17))->method('setParameter')->with($this->matchesRegularExpression('/' . $name . '_' . $bothField . '_[a-z0-9]{22}/'), $this->identicalTo($bothValue = 'both_value'), $this->isNull())->will($this->returnSelf());
     $queryBuilder->expects($this->once())->method('getQuery')->will($this->returnValue($query = $this->createQueryMock()));
     $query->expects($this->once())->method('getOneOrNullResult')->will($this->returnValue($result = 'result'));
     $this->assertSame($result, $this->translatableRepository->findOneBy([$translatableField => $translatableValue, $translationField => $translationValue, $bothField => $bothValue]));
 }
开发者ID:blazarecki,项目名称:lug,代码行数:26,代码来源:TranslatableRepositoryTest.php

示例3: testTypeIsSetFromAssociation

 public function testTypeIsSetFromAssociation()
 {
     $map = array('fieldName' => 'var1', 'targetEntity' => '\\stdClass');
     $this->classMetadata->expects($this->any())->method('hasField')->will($this->returnValue(false));
     $this->classMetadata->expects($this->any())->method('hasAssociation')->will($this->returnValue(true));
     $this->classMetadata->expects($this->any())->method('getAssociationMapping')->will($this->returnValue($map));
     $meta = $this->object->load($this->testClass);
     $this->assertSame('\\stdClass', $meta['var1']->type);
 }
开发者ID:voda,项目名称:formbuilder,代码行数:9,代码来源:DoctrineAnnotationLoaderTest.php


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