コード例 #1
0
 /**
  * @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);
 }
 /**
  * @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));
 }
コード例 #3
0
 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();
 }
コード例 #4
0
 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();
 }
コード例 #5
0
 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);
 }
コード例 #6
0
 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);
 }
 /**
  * @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));
 }
コード例 #8
0
 /**
  * @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;
 }
コード例 #9
0
 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));
 }
コード例 #10
0
 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);
 }
コード例 #11
0
 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());
 }
コード例 #12
0
 /**
  * @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));
 }
コード例 #13
0
 /**
  * @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);
 }
コード例 #14
0
 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());
 }
コード例 #15
0
 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));
 }
コード例 #16
0
 public function testSuccessChange()
 {
     $this->registry->expects($this->once())->method('getManager')->will($this->returnValue($this->em));
     $this->registry->expects($this->once())->method('getRepository')->with('JMSJobQueueBundle:Job')->will($this->returnValue($this->repo));
     $this->repo->expects($this->once())->method('findOneBy')->with(['command' => LifetimeAverageAggregateCommand::COMMAND_NAME, 'state' => Job::STATE_PENDING])->will($this->returnValue($scheduled = false));
     $this->em->expects($this->once())->method('persist');
     $this->em->expects($this->once())->method('flush');
     $this->listener->onConfigUpdate(new ConfigUpdateEvent(['oro_locale.timezone' => ['old' => 1, 'new' => 2]]));
 }
コード例 #17
0
 protected function setUpExpects()
 {
     $metadataFactory = $this->setMetaMocks();
     $this->entityRepository->expects($this->any())->method('findOneBy')->will($this->returnArgument(0));
     $this->entityRepository->expects($this->any())->method('createQueryBuilder')->will($this->returnValue($this->queryBuilder));
     $this->entityManager->expects($this->once())->method('getRepository')->will($this->returnValue($this->entityRepository));
     $this->entityManager->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($metadataFactory));
     $this->managerRegistry->expects($this->once())->method('getManagerForClass')->with(self::TEST_ENTITY_CLASS)->will($this->returnValue($this->entityManager));
     $this->searchHandler->initDoctrinePropertiesByManagerRegistry($this->managerRegistry);
 }
コード例 #18
0
 public function testGetDefaultLoginPage()
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|ObjectRepository $objectRepository */
     $objectRepository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository');
     $objectRepository->expects($this->once())->method('findOneBy')->with([])->willReturn($this->loginPage);
     /** @var \PHPUnit_Framework_MockObject_MockObject|ObjectManager $objectManager */
     $objectManager = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
     $objectManager->expects($this->once())->method('getRepository')->with('OroB2BCMSBundle:LoginPage')->willReturn($objectRepository);
     $this->managerRegistry->expects($this->once())->method('getManagerForClass')->with('OroB2BCMSBundle:LoginPage')->willReturn($objectManager);
     $this->extension->getDefaultLoginPage();
 }
コード例 #19
0
 /**
  * @return ManagerRegistry
  */
 protected function setRegistryExpectations()
 {
     $query = $this->getMockBuilder('Doctrine\\ORM\\AbstractQuery')->disableOriginalConstructor()->setMethods(['getResult'])->getMockForAbstractClass();
     $query->expects($this->once())->method('getResult')->will($this->returnValue($this->getWebsites()));
     $queryBuilder = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock();
     $queryBuilder->expects($this->once())->method('addOrderBy')->with('website.id', 'ASC')->will($this->returnSelf());
     $queryBuilder->expects($this->once())->method('getQuery')->will($this->returnValue($query));
     $repository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($this->once())->method('createQueryBuilder')->with('website')->will($this->returnValue($queryBuilder));
     $this->registry->expects($this->once())->method('getRepository')->with(self::WEBSITE_CLASS)->will($this->returnValue($repository));
 }
コード例 #20
0
 public function setUp()
 {
     $this->routeMock = $this->buildMock('Symfony\\Cmf\\Bundle\\RoutingBundle\\Doctrine\\Orm\\Route');
     $this->route2Mock = $this->buildMock('Symfony\\Cmf\\Bundle\\RoutingBundle\\Doctrine\\Orm\\Route');
     $this->objectManagerMock = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
     $this->managerRegistryMock = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
     $this->objectRepositoryMock = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->setMethods(array('findByStaticPrefix', 'findOneBy', 'findBy'))->disableOriginalConstructor()->getMock();
     $this->candidatesMock = $this->getMock('Symfony\\Cmf\\Component\\Routing\\Candidates\\CandidatesInterface');
     $this->candidatesMock->expects($this->any())->method('isCandidate')->will($this->returnValue(true));
     $this->managerRegistryMock->expects($this->any())->method('getManager')->will($this->returnValue($this->objectManagerMock));
     $this->objectManagerMock->expects($this->any())->method('getRepository')->with('Route')->will($this->returnValue($this->objectRepositoryMock));
 }
コード例 #21
0
 protected function setUp()
 {
     $this->transportMock = $this->getMock('OroCRM\\Bundle\\MagentoBundle\\Provider\\Transport\\MagentoTransportInterface');
     $this->stepExecutionMock = $this->getMockBuilder('Akeneo\\Bundle\\BatchBundle\\Entity\\StepExecution')->setMethods(['getExecutionContext', 'getJobExecution'])->disableOriginalConstructor()->getMock();
     $this->executionContextMock = $this->getMock('Akeneo\\Bundle\\BatchBundle\\Item\\ExecutionContext');
     $this->jobExecutionMock = $this->getMock('Akeneo\\Bundle\\BatchBundle\\Entity\\JobExecution');
     $this->jobExecutionMock->expects($this->any())->method('getExecutionContext')->will($this->returnValue($this->executionContextMock));
     $this->stepExecutionMock->expects($this->any())->method('getJobExecution')->will($this->returnValue($this->jobExecutionMock));
     $this->managerRegistryMock = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ManagerRegistry')->disableOriginalConstructor()->getMock();
     $this->integrationRepositoryMock = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\Entity\\Repository\\ChannelRepository')->disableOriginalConstructor()->getMock();
     $this->managerRegistryMock->expects($this->any())->method('getRepository')->with('OroIntegrationBundle:Channel')->will($this->returnValue($this->integrationRepositoryMock));
 }
コード例 #22
0
 public function testOnFormPreSetData()
 {
     $id = 1;
     $key = 'oro_b2b_account___default_account_owner';
     $user = $this->getMockBuilder($this->userClass)->disableOriginalConstructor()->getMock();
     $event = $this->getEvent([$key => ['value' => $id]]);
     $event->expects($this->once())->method('setSettings')->with([$key => ['value' => $user]]);
     $manager = $this->getMockBuilder('\\Doctrine\\Common\\Persistence\\ObjectManager')->disableOriginalConstructor()->getMock();
     $manager->expects($this->once())->method('find')->with($this->userClass, $id)->will($this->returnValue($user));
     $this->registry->expects($this->once())->method('getManagerForClass')->with($this->userClass)->will($this->returnValue($manager));
     $this->listener->onFormPreSetData($event);
 }
コード例 #23
0
 protected function setUp()
 {
     parent::setUp();
     $this->registry = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ManagerRegistry')->disableOriginalConstructor()->getMock();
     $this->productUnitLabelFormatter = $this->getMockBuilder('OroB2B\\Bundle\\ProductBundle\\Formatter\\ProductUnitLabelFormatter')->disableOriginalConstructor()->getMock();
     $repository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($this->any())->method('findBy')->will($this->returnValue(['item' => 'item', 'kg' => 'kilogram']));
     $this->registry->expects($this->any())->method('getRepository')->with(self::PRODUCT_UNIT_CLASS)->will($this->returnValue($repository));
     $this->formType = new OrderLineItemType($this->registry, $this->productUnitLabelFormatter);
     $this->formType->setDataClass('OroB2B\\Bundle\\OrderBundle\\Entity\\OrderLineItem');
     $this->formType->setProductUnitClass(self::PRODUCT_UNIT_CLASS);
 }
コード例 #24
0
 protected function setUp()
 {
     $this->handler = $this->getMockBuilder('OroB2B\\Bundle\\ShoppingListBundle\\Handler\\ShoppingListLineItemHandler')->disableOriginalConstructor()->getMock();
     $this->productRepository = $this->getMockBuilder('OroB2B\\Bundle\\ProductBundle\\Entity\\Repository\\ProductRepository')->disableOriginalConstructor()->getMock();
     $this->registry = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
     $this->messageGenerator = $this->getMockBuilder('OroB2B\\Bundle\\ShoppingListBundle\\Generator\\MessageGenerator')->disableOriginalConstructor()->getMock();
     $em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $this->registry->expects($this->any())->method('getManagerForClass')->willReturn($em);
     $em->expects($this->any())->method('getRepository')->willReturn($this->productRepository);
     $this->processor = new QuickAddProcessor($this->handler, $this->registry, $this->messageGenerator);
     $this->processor->setProductClass('OroB2B\\Bundle\\ProductBundle\\Entity\\Product');
 }
コード例 #25
0
ファイル: UserManagerTest.php プロジェクト: Maksold/platform
 protected function setUp()
 {
     if (!interface_exists('Doctrine\\Common\\Persistence\\ObjectManager')) {
         $this->markTestSkipped('Doctrine Common has to be installed for this test to run.');
     }
     $this->ef = $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface');
     $this->om = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
     $this->registry = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
     $this->registry->expects($this->any())->method('getManagerForClass')->will($this->returnValue($this->om));
     $this->metadata = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock();
     $this->om->expects($this->any())->method('getClassMetadata')->willReturn($this->metadata);
     $this->userManager = new UserManager(static::USER_CLASS, $this->registry, $this->ef);
 }
コード例 #26
0
 protected function setUp()
 {
     $this->registry = $this->getMockForAbstractClass('Doctrine\\Common\\Persistence\\ManagerRegistry');
     $this->processorRegistry = $this->getMockBuilder('Oro\\Bundle\\ImportExportBundle\\Processor\\ProcessorRegistry')->disableOriginalConstructor()->getMock();
     $this->jobExecutor = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\ImportExport\\Job\\Executor')->disableOriginalConstructor()->getMock();
     $this->typesRegistry = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\Manager\\TypesRegistry')->disableOriginalConstructor()->getMock();
     $this->eventDispatcher = $this->getMockBuilder('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface')->getMockForAbstractClass();
     $this->logger = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\Logger\\LoggerStrategy')->disableOriginalConstructor()->getMock();
     $this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $this->repository = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\Entity\\Repository\\ChannelRepository')->disableOriginalConstructor()->getMock();
     $this->registry->expects($this->any())->method('getManager')->will($this->returnValue($this->em));
     $this->registry->expects($this->any())->method('getRepository')->will($this->returnValue($this->repository));
 }
コード例 #27
0
 protected function setUp()
 {
     $this->classMetadata = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadataInfo')->disableOriginalConstructor()->setMethods(array('getSingleIdentifierFieldName'))->getMock();
     $this->classMetadata->expects($this->any())->method('getSingleIdentifierFieldName')->will($this->returnValue(self::TEST_IDENTIFIER));
     $this->ormConfiguration = $this->getMockBuilder('Doctrine\\ORM\\Configuration')->disableOriginalConstructor()->setMethods(array('addCustomHydrationMode'))->getMock();
     $this->entityManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->setMethods(array('getClassMetadata', 'getConfiguration'))->getMock();
     $this->entityManager->expects($this->any())->method('getClassMetadata')->with(self::TEST_CLASS)->will($this->returnValue($this->classMetadata));
     $this->entityManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->ormConfiguration));
     $this->registry = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ManagerRegistry')->disableOriginalConstructor()->setMethods('getManager', 'getRepository')->getMockForAbstractClass();
     $this->registry->expects($this->any())->method('getManager')->will($this->returnValue($this->entityManager));
     $this->registry->expects($this->any())->method('getRepository')->with(self::TEST_CLASS)->will($this->returnValue($this->getEntityRepository()));
     $this->type = new TranslatableEntityType($this->registry);
 }
コード例 #28
0
 protected function setUp()
 {
     $localeRepository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository');
     $localeRepository->expects($this->any())->method('find')->will($this->returnValueMap([[1, $this->getLocale(1)], [2, $this->getLocale(2)]]));
     $websiteRepository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository');
     $websiteRepository->expects($this->any())->method('find')->will($this->returnValueMap([[1, $this->getWebsite(1)], [2, $this->getWebsite(2)]]));
     $repositoriesMap = [['OroB2BWebsiteBundle:Locale', null, $localeRepository], ['OroB2BWebsiteBundle:Website', null, $websiteRepository]];
     $this->managerRegistry = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
     $this->managerRegistry->expects($this->any())->method('getRepository')->will($this->returnValueMap($repositoriesMap));
     $this->typeRegistry = new AttributeTypeRegistry();
     $this->typeRegistry->addType(new Text());
     $this->typeRegistry->addType(new Integer());
     $this->typeRegistry->addType(new Select());
 }
コード例 #29
0
 /**
  * @param mixed $value
  * @param mixed $formData
  * @param mixed $queryResult
  * @param bool $expectsViolation
  *
  * @dataProvider valueDataProvider
  */
 public function testValidate($value, $formData, $queryResult = null, $expectsViolation = false)
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|ExecutionContextInterface $context */
     $context = $this->getMock('Symfony\\Component\\Validator\\ExecutionContextInterface');
     $form = $this->getMock('Symfony\\Component\\Form\\FormInterface');
     $form->expects($this->any())->method('getData')->willReturn($formData);
     $context->expects($this->any())->method('getRoot')->willReturn($form);
     $context->expects($expectsViolation ? $this->once() : $this->never())->method('addViolationAt')->willReturn($form);
     $repository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($this->any())->method('createQueryBuilder')->willReturn($this->getQueryBuilder($queryResult));
     $this->registry->expects($this->any())->method('getRepository')->will($this->returnValue($repository));
     $this->validator->initialize($context);
     $this->validator->validate($value, new StartSyncDateConstraint());
 }
コード例 #30
0
 protected function setUp()
 {
     if (!interface_exists('Doctrine\\Common\\Persistence\\ManagerRegistry')) {
         $this->markTestSkipped('Doctrine Common is not present');
     }
     if (!class_exists('Doctrine\\ODM\\PHPCR\\DocumentManager')) {
         $this->markTestSkipped('Doctrine PHPCR is not present');
     }
     $this->registry = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ManagerRegistry')->disableOriginalConstructor()->getMock();
     $this->manager = $this->getMockBuilder('Doctrine\\ODM\\PHPCR\\DocumentManager')->disableOriginalConstructor()->getMock();
     $this->registry->expects($this->any())->method('getManager')->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));
 }