本文整理汇总了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();
}
示例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]));
}
示例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);
}