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