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


PHP ManagerRegistry::expects方法代码示例

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


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

示例1: prepareRegistry

 /**
  * @param bool $expects
  */
 protected function prepareRegistry($expects = false)
 {
     $this->categoryRepository = $this->getMockBuilder('OroB2B\\Bundle\\CatalogBundle\\Entity\\Repository\\CategoryRepository')->disableOriginalConstructor()->getMock();
     $entityManager = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
     $entityManager->expects($expects ? $this->once() : $this->never())->method('getRepository')->with('OroB2BCatalogBundle:Category')->willReturn($this->categoryRepository);
     $this->registry->expects($expects ? $this->once() : $this->never())->method('getManagerForClass')->with('OroB2BCatalogBundle:Category')->willReturn($entityManager);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:10,代码来源:ProductFormExtensionTest.php

示例2: testIsApplicableOnEmailCampaign

 /**
  * @param EmailCampaign $emailCampaign
  * @param Campaign $campaign
  * @param bool $expected
  * @dataProvider staticCampaignProvider
  */
 public function testIsApplicableOnEmailCampaign($emailCampaign, $campaign, $expected)
 {
     $this->entityRepository->expects($this->any())->method('findOneBy')->will($this->returnValue($campaign));
     $this->managerRegistry->expects($this->any())->method('getManager')->will($this->returnValue($this->entityManager));
     $this->entityManager->expects($this->any())->method('getRepository')->will($this->returnValue($this->entityRepository));
     $this->assertEquals($expected, $this->placeholderFilter->isApplicableOnEmailCampaign($emailCampaign));
 }
开发者ID:aculvi,项目名称:OroCRMMailChimpBundle,代码行数:13,代码来源:EmailCampaignPlaceholderFilterTest.php

示例3: testSubmit

 public function testSubmit()
 {
     $choice = new \stdClass();
     $choice->{$identifierPath = 'id'} = $id = 1;
     $choice->{$labelPath = 'label'} = $label = 'label';
     $this->resource->expects($this->once())->method('getModel')->will($this->returnValue($model = get_class($choice)));
     $this->resource->expects($this->once())->method('getIdPropertyPath')->will($this->returnValue($identifierPath));
     $this->resource->expects($this->once())->method('getLabelPropertyPath')->will($this->returnValue($labelPath));
     $this->managerRegistry->expects($this->once())->method('getManagerForClass')->with($this->identicalTo($model))->will($this->returnValue($entityManager = $this->createEntityManagerMock()));
     $entityManager->expects($this->once())->method('getRepository')->with($this->identicalTo($model))->will($this->returnValue($repository = $this->createRepositoryMock()));
     $entityManager->expects($this->exactly(3))->method('getClassMetadata')->with($this->identicalTo($model))->will($this->returnValue($classMetadata = $this->createClassMetadataMock()));
     $classMetadata->expects($this->once())->method('getName')->will($this->returnValue($model));
     $classMetadata->expects($this->once())->method('getIdentifierFieldNames')->will($this->returnValue([$identifier = $identifierPath]));
     $classMetadata->expects($this->exactly(2))->method('getTypeOfField')->with($this->identicalTo($identifier))->will($this->returnValue('integer'));
     $repository->expects($this->once())->method('createQueryBuilder')->will($this->returnValue($queryBuilder = $this->createQueryBuilderMock($entityManager)));
     $queryBuilder->expects($this->exactly(2))->method('getQuery')->will($this->returnValue($query = $this->createQueryMock()));
     $query->expects($this->once())->method('execute')->will($this->returnValue($choices = [$choice]));
     $queryBuilder->expects($this->once())->method('getRootAliases')->will($this->returnValue([$rootAlias = 'root_alias']));
     $queryBuilder->expects($this->once())->method('expr')->will($this->returnValue($expr = $this->createExprMock()));
     $queryBuilder->expects($this->once())->method('getEntityManager')->will($this->returnValue($entityManager));
     $queryBuilder->expects($this->once())->method('getRootEntities')->will($this->returnValue([$model]));
     $expr->expects($this->once())->method('in')->with($this->identicalTo($rootAlias . '.' . $identifier), $this->identicalTo(':' . ($parameter = 'ORMQueryBuilderLoader_getEntitiesByIds_' . $identifier)))->will($this->returnValue($where = 'where'));
     $queryBuilder->expects($this->once())->method('andWhere')->with($this->identicalTo($where))->will($this->returnSelf());
     $query->expects($this->once())->method('setParameter')->with($this->identicalTo($parameter), $this->identicalTo([(string) $id]), $this->identicalTo(Connection::PARAM_INT_ARRAY))->will($this->returnSelf());
     $query->expects($this->once())->method('getResult')->will($this->returnValue([$choice]));
     $entityManager->expects($this->exactly(2))->method('contains')->with($this->identicalTo($choice))->will($this->returnValue(true));
     $classMetadata->expects($this->exactly(2))->method('getIdentifierValues')->with($this->identicalTo($choice))->will($this->returnValue([$id]));
     $form = $this->factory->create(ResourceChoiceType::class, null, ['resource' => $this->resource])->submit($id);
     $this->assertSame($this->resource, $form->getConfig()->getOption('resource'));
     $this->assertSame($identifierPath, $form->getConfig()->getOption('choice_value'));
     $this->assertSame($labelPath, $form->getConfig()->getOption('choice_label'));
     $this->assertSame('', $form->getConfig()->getOption('placeholder'));
     $this->assertSame($choice, $form->getData());
     $form->createView();
 }
开发者ID:blazarecki,项目名称:lug,代码行数:35,代码来源:ResourceChoiceTypeTest.php

示例4: testSubmit

 public function testSubmit()
 {
     $choice = new \stdClass();
     $choice->{$identifierPath = 'id'} = $id = 1;
     $choice->{$labelPath = 'label'} = $label = 'label';
     $this->resource->expects($this->once())->method('getModel')->will($this->returnValue($model = get_class($choice)));
     $this->resource->expects($this->once())->method('getIdPropertyPath')->will($this->returnValue($identifierPath));
     $this->resource->expects($this->once())->method('getLabelPropertyPath')->will($this->returnValue($labelPath));
     $this->managerRegistry->expects($this->once())->method('getManagerForClass')->with($this->identicalTo($model))->will($this->returnValue($documentManager = $this->createDocumentManagerMock()));
     $documentManager->expects($this->once())->method('getRepository')->with($this->identicalTo($model))->will($this->returnValue($repository = $this->createRepositoryMock()));
     $documentManager->expects($this->exactly(2))->method('getClassMetadata')->with($this->identicalTo($model))->will($this->returnValue($classMetadata = $this->createClassMetadataMock()));
     $classMetadata->expects($this->once())->method('getName')->will($this->returnValue($model));
     $classMetadata->expects($this->once())->method('getIdentifierFieldNames')->will($this->returnValue([$identifier = $identifierPath]));
     $classMetadata->expects($this->once())->method('getTypeOfField')->with($this->identicalTo($identifier))->will($this->returnValue('integer'));
     $repository->expects($this->once())->method('createQueryBuilder')->will($this->returnValue($queryBuilder = $this->createQueryBuilderMock($documentManager)));
     $queryBuilder->expects($this->once())->method('getQuery')->will($this->returnValue($query = $this->createQueryMock()));
     $query->expects($this->once())->method('execute')->will($this->returnValue($iterator = $this->createIteratorMock()));
     $iterator->expects($this->once())->method('toArray')->will($this->returnValue([$choice]));
     $form = $this->factory->create(ResourceChoiceType::class, null, ['resource' => $this->resource])->submit($id);
     $this->assertSame($this->resource, $form->getConfig()->getOption('resource'));
     $this->assertSame($identifierPath, $form->getConfig()->getOption('choice_value'));
     $this->assertSame($labelPath, $form->getConfig()->getOption('choice_label'));
     $this->assertSame('', $form->getConfig()->getOption('placeholder'));
     $this->assertSame($choice, $form->getData());
     $form->createView();
 }
开发者ID:php-lug,项目名称:lug,代码行数:26,代码来源:ResourceChoiceTypeTest.php

示例5: setUp

 protected function setUp()
 {
     $encoder = new TokenEncoder($this->secret);
     $this->doctrine = $this->createDoctrineMock();
     $this->doctrine->expects($this->any())->method('getManager')->willReturn($this->getMockForAbstractClass(EntityManagerInterface::class));
     $this->manager = new TokenManager($encoder, $this->doctrine);
 }
开发者ID:treehouselabs,项目名称:keystone-bundle,代码行数:7,代码来源:TokenManagerTest.php

示例6: testGetTree

 public function testGetTree()
 {
     $accountUserRepository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $accountUserManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $accountUserManager->expects($this->any())->method('getRepository')->with(self::ACCOUNT_USER_CLASS)->willReturn($accountUserRepository);
     $customerRepository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $customerManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $customerManager->expects($this->any())->method('getRepository')->with(self::CUSTOMER_CLASS)->willReturn($customerRepository);
     $this->ownershipMetadataProvider->expects($this->any())->method('getBasicLevelClass')->willReturn(self::ACCOUNT_USER_CLASS);
     $this->ownershipMetadataProvider->expects($this->any())->method('getLocalLevelClass')->willReturn(self::CUSTOMER_CLASS);
     $this->managerRegistry->expects($this->any())->method('getManagerForClass')->willReturnMap([[self::ACCOUNT_USER_CLASS, $accountUserManager], [self::CUSTOMER_CLASS, $customerManager]]);
     list($accountUsers, $customers) = $this->getTestData();
     $accountUserRepository->expects($this->any())->method('findAll')->will($this->returnValue($accountUsers));
     $customerRepository->expects($this->any())->method('findAll')->will($this->returnValue($customers));
     $metadata = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock();
     $accountUserManager->expects($this->any())->method('getClassMetadata')->will($this->returnValue($metadata));
     $metadata->expects($this->any())->method('getTableName')->will($this->returnValue('test'));
     $connection = $this->getMockBuilder('Doctrine\\DBAL\\Connection')->disableOriginalConstructor()->getMock();
     $accountUserManager->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
     $connection->expects($this->any())->method('isConnected')->will($this->returnValue(true));
     $schemaManager = $this->getMockBuilder('Doctrine\\DBAL\\Schema\\MySqlSchemaManager')->disableOriginalConstructor()->getMock();
     $connection->expects($this->any())->method('getSchemaManager')->will($this->returnValue($schemaManager));
     $schemaManager->expects($this->any())->method('listTableNames')->will($this->returnValue(['test']));
     $this->treeProvider->warmUpCache();
     /** @var OwnerTree $tree */
     $tree = $this->treeProvider->getTree();
     $this->assertTestData($tree);
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:28,代码来源:FrontendOwnerTreeProviderTest.php

示例7: testIsApplicableOnMarketingList

 /**
  * @param null|StaticSegment $staticSegment
  * @param bool $expected
  * @dataProvider staticSegmentDataProvider
  */
 public function testIsApplicableOnMarketingList($staticSegment, $expected)
 {
     $this->entityRepository->expects($this->once())->method('findOneBy')->will($this->returnValue($staticSegment));
     $this->managerRegistry->expects($this->once())->method('getManager')->will($this->returnValue($this->entityManager));
     $this->entityManager->expects($this->once())->method('getRepository')->will($this->returnValue($this->entityRepository));
     $entity = new MarketingList();
     $this->assertEquals($expected, $this->placeholderFilter->isApplicableOnMarketingList($entity));
 }
开发者ID:aculvi,项目名称:OroCRMMailChimpBundle,代码行数:13,代码来源:MarketingListPlaceholderFilterTest.php

示例8: assertPaymentTermRepositoryCall

 /**
  * @return \PHPUnit_Framework_MockObject_MockObject
  */
 protected function assertPaymentTermRepositoryCall()
 {
     $repository = $this->getMockBuilder('OroB2B\\Bundle\\PaymentBundle\\Entity\\Repository\\PaymentTermRepository')->disableOriginalConstructor()->getMock();
     $manager = $this->getMock('Doctrine\\ORM\\EntityManagerInterface');
     $manager->expects($this->any())->method('getRepository')->with($this->paymentTermClass)->willReturn($repository);
     $this->registry->expects($this->any())->method('getManagerForClass')->with($this->paymentTermClass)->willReturn($manager);
     return $repository;
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:11,代码来源:PaymentTermProviderTest.php

示例9: setUp

 protected function setUp()
 {
     $this->registry = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ManagerRegistry')->disableOriginalConstructor()->getMock();
     $this->manager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $this->registry->expects($this->any())->method('getManagerForClass')->with($this->objectClass)->will($this->returnValue($this->manager));
     $this->repository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository', array('customQueryBuilderCreator', 'createQueryBuilder', 'find', 'findAll', 'findBy', 'findOneBy', 'getClassName'));
     $this->manager->expects($this->any())->method('getRepository')->with($this->objectClass)->will($this->returnValue($this->repository));
 }
开发者ID:anteros,项目名称:FOSElasticaBundle,代码行数:8,代码来源:ElasticaToModelTransformerTest.php

示例10: setUp

 protected function setUp()
 {
     $this->registry = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ManagerRegistry')->disableOriginalConstructor()->getMock();
     $this->repository = $this->getMockBuilder('OroB2B\\Bundle\\PricingBundle\\Entity\\Repository\\PriceListRepository')->disableOriginalConstructor()->getMock();
     $manager = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ObjectManager')->disableOriginalConstructor()->getMock();
     $manager->expects($this->any())->method('getRepository')->willReturn($this->repository);
     $this->registry->expects($this->any())->method('getManagerForClass')->willReturn($manager);
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:8,代码来源:AbstractPriceListExtensionTest.php

示例11: testGetAvailableCurrencies

 public function testGetAvailableCurrencies()
 {
     $data = ['USD' => 'USD', 'EUR' => 'EUR'];
     $repository = $this->getMockBuilder('OroB2B\\Bundle\\PricingBundle\\Entity\\Repository\\ProductPriceRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($this->once())->method('getAvailableCurrencies')->willReturn($data);
     $this->registry->expects($this->once())->method('getRepository')->with($this->equalTo('\\stdClass'))->willReturn($repository);
     $this->assertEquals($data, $this->provider->getAvailableCurrencies());
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:8,代码来源:CurrencyProviderTest.php

示例12: testGetChartData

 /**
  * @dataProvider chartDataProvider
  *
  * @param array $channelsData
  * @param array $averageData
  * @param array $expectedResult
  * @param array $dates
  */
 public function testGetChartData(array $channelsData, array $averageData, array $expectedResult, array $dates)
 {
     $channelRepo = $this->getMockBuilder('OroCRM\\Bundle\\ChannelBundle\\Entity\\Repository\\ChannelRepository')->disableOriginalConstructor()->getMock();
     $averageRepo = $this->getMockBuilder('OroCRM\\Bundle\\ChannelBundle\\Entity\\Repository\\LifetimeValueAverageAggregationRepository')->disableOriginalConstructor()->getMock();
     $channelRepo->expects($this->once())->method('getAvailableChannelNames')->with($this->aclHelper)->will($this->returnValue($channelsData));
     $averageRepo->expects($this->once())->method('findForPeriod')->with($this->isInstanceOf('\\DateTime'), $this->isInstanceOf('\\DateTime'), array_keys($channelsData))->will($this->returnValue($averageData));
     $this->registry->expects($this->any())->method('getRepository')->will($this->returnValueMap([['OroCRMChannelBundle:Channel', null, $channelRepo], ['OroCRMChannelBundle:LifetimeValueAverageAggregation', null, $averageRepo]]));
     $this->assertEquals($expectedResult, $this->provider->getChartData($dates));
 }
开发者ID:antrampa,项目名称:crm,代码行数:17,代码来源:AverageLifetimeWidgetProviderTest.php

示例13: testValidate

 /**
  * @param string $sku
  * @param Product|null $product
  * @dataProvider validateProvider
  */
 public function testValidate($sku, $product)
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|ProductRepository */
     $repository = $this->getMockBuilder('OroB2B\\Bundle\\ProductBundle\\Entity\\Repository\\ProductRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($this->once())->method('findOneBySku')->with($sku)->will($this->returnValue($product));
     $this->registry->expects($this->once())->method('getRepository')->with(self::PRODUCT_CLASS)->will($this->returnValue($repository));
     $this->context->expects($product ? $this->never() : $this->once())->method('addViolation')->with($this->constraint->message);
     $this->validator->validate($sku, $this->constraint);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:14,代码来源:ProductBySkuValidatorTest.php

示例14: testGetCurrentWebsite

 public function testGetCurrentWebsite()
 {
     $repository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($this->once())->method('findOneBy')->with($this->isType('array'), $this->isType('array'))->willReturn(new Website());
     $objectManager = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
     $objectManager->expects($this->once())->method('getRepository')->with('OroB2BWebsiteBundle:Website')->willReturn($repository);
     $this->managerRegistry->expects($this->once())->method('getManagerForClass')->with('OroB2BWebsiteBundle:Website')->willReturn($objectManager);
     $this->assertEquals(new Website(), $this->manager->getCurrentWebsite());
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:9,代码来源:WebsiteManagerTest.php

示例15: testIsApplicableOnNonSupportedTarget

 public function testIsApplicableOnNonSupportedTarget()
 {
     $repo = $this->getMockBuilder('Oro\\Bundle\\ActivityListBundle\\Entity\\Repository\\ActivityListRepository')->disableOriginalConstructor()->getMock();
     $this->doctrine->expects($this->any())->method('getRepository')->will($this->returnValue($repo));
     $repo->expects($this->any())->method('getRecordsCountForTargetClassAndId')->with('Oro\\Bundle\\ActivityListBundle\\Tests\\Unit\\Placeholder\\Fixture\\TestNonActiveTarget', 123)->willReturn(true);
     $entity = new TestNonActiveTarget(123);
     $this->setConfigProviderEntitySupport($entity, '\\Oro\\Bundle\\ActivityBundle\\EntityConfig\\ActivityScope::VIEW_PAGE');
     $this->assertTrue($this->filter->isApplicable($entity, ActivityScope::VIEW_PAGE));
 }
开发者ID:Maksold,项目名称:platform,代码行数:9,代码来源:PlaceholderFilterTest.php


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