當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。