public function testNext() { $expectedResults = array(array(1), array(5), array(7)); $query = new MockQuery(); $query->setNextResult($expectedResults); $createQuery = function ($dql) use($query) { $query->setDQL($dql); return $query; }; $this->em->expects($this->any())->method('createQuery')->will($this->returnCallback($createQuery)); $qb = new \Doctrine\ORM\QueryBuilder($this->em); $qb->select('a.id, a.name')->from('A', 'a')->where('a.name = :name')->setParameter('name', 'abc'); // initialize Iterator $this->object->setQueryBuilder($qb); $this->object->setIterateBy('a.id'); $this->object->setPageSize(3); $this->object->setPullClosure(function ($arr) { return $arr[0]; }); // initial results $this->assertEquals($expectedResults, $this->object->next()); $this->assertEquals('SELECT a.id, a.name FROM A a WHERE a.name = :name ORDER BY a.id ASC', $query->getDQL()); $this->assertEquals(3, $query->getLastMaxResults()); $this->assertEquals(1, \count($query->getLastParameters())); // second results $query->setNextResult(array()); $this->assertEquals(array(), $this->object->next()); $this->assertEquals('SELECT a.id, a.name FROM A a WHERE a.name = :name AND a.id > 7 ORDER BY a.id ASC', $query->getDQL()); $this->assertEquals(3, $query->getLastMaxResults()); $this->assertEquals(1, \count($query->getLastParameters())); }
public function testBuild() { $type = 'history'; $userId = 1; $user = $this->getMockBuilder('stdClass')->setMethods(['getId'])->getMock(); $user->expects($this->once())->method('getId')->will($this->returnValue($userId)); $token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface'); $token->expects($this->once())->method('getUser')->will($this->returnValue($user)); $this->tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($token)); $item = $this->getMock('Oro\\Bundle\\NavigationBundle\\Entity\\NavigationItemInterface'); $this->factory->expects($this->once())->method('createItem')->with($type, [])->will($this->returnValue($item)); $repository = $this->getMockBuilder('Oro\\Bundle\\NavigationBundle\\Entity\\Repository\\HistoryItemRepository')->disableOriginalConstructor()->getMock(); $items = [['id' => 1, 'title' => 'test1', 'url' => '/'], ['id' => 2, 'title' => 'test2', 'url' => '/home']]; $repository->expects($this->once())->method('getNavigationItems')->with($userId, $type)->will($this->returnValue($items)); $this->em->expects($this->once())->method('getRepository')->with(get_class($item))->will($this->returnValue($repository)); $menu = $this->getMockBuilder('Knp\\Menu\\MenuItem')->disableOriginalConstructor()->getMock(); $childMock = $this->getMock('Knp\\Menu\\ItemInterface'); $childMock2 = clone $childMock; $children = [$childMock, $childMock2]; $matcher = $this->getMock('\\Knp\\Menu\\Matcher\\Matcher'); $matcher->expects($this->once())->method('isCurrent')->will($this->returnValue(true)); $this->builder->setMatcher($matcher); $menu->expects($this->exactly(2))->method('addChild'); $menu->expects($this->once())->method('setExtra')->with('type', $type); $menu->expects($this->once())->method('getChildren')->will($this->returnValue($children)); $menu->expects($this->once())->method('removeChild'); $n = rand(1, 10); $configMock = $this->getMockBuilder('Oro\\Bundle\\ConfigBundle\\Config\\UserConfigManager')->disableOriginalConstructor()->getMock(); $configMock->expects($this->once())->method('get')->with($this->equalTo('oro_navigation.maxItems'))->will($this->returnValue($n)); $this->manipulator->expects($this->once())->method('slice')->with($menu, 0, $n); $this->builder->setOptions($configMock); $this->builder->build($menu, [], $type); }
public function testRemoveTracker() { $tracker = $this->tracker(); $this->em->expects($this->once())->method('remove')->with($tracker); $this->em->expects($this->once())->method('flush'); $this->repository->removeTracker($tracker); }
public function testThrownException() { $this->em->expects($this->any())->method('find')->will($this->throwException(new \Doctrine\ORM\ORMException())); $this->setExpectedException('SR\\Doctrine\\Exception\\ORMException'); $g = new StringUuid4PessimisticGenerator(); $g->generate($this->em, $this->entity); }
/** * @dataProvider valueDataProvider * @param mixed $fieldValue */ public function testFixEntityAssociationFieldsEntity($fieldValue) { $entity = new \stdClass(); $entity->field = $fieldValue; $mapping = array(array('fieldName' => 'field')); if ($fieldValue instanceof ArrayCollection) { $linkedEntity = $fieldValue->getIterator()->offsetGet(0); } else { $linkedEntity = $fieldValue; } $metadata = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock(); $metadata->expects($this->once())->method('getAssociationMappings')->will($this->returnValue($mapping)); $metadata->expects($this->once())->method('getIdentifierValues')->with($linkedEntity)->will($this->returnValue('id')); $this->entityManager->expects($this->exactly(2))->method('getClassMetadata')->with(get_class($entity))->will($this->returnValue($metadata)); $uow = $this->getMockBuilder('\\Doctrine\\ORM\\UnitOfWork')->disableOriginalConstructor()->getMock(); $uow->expects($this->once())->method('getEntityState')->with($linkedEntity)->will($this->returnValue(UnitOfWork::STATE_DETACHED)); $this->entityManager->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($uow)); $this->entityManager->expects($this->once())->method('find')->with(get_class($entity), 'id')->will($this->returnCallback(function () use($entity) { $entity->reloaded = true; return $entity; })); $this->fixer->fixEntityAssociationFields($entity, 0); if ($fieldValue instanceof ArrayCollection) { $this->assertTrue($entity->field->getIterator()->offsetGet(0)->reloaded); } else { $this->assertTrue($entity->field->reloaded); } }
public function testGetTree() { $userRepo = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock(); $buRepo = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock(); $this->em->expects($this->any())->method('getRepository')->will($this->returnValueMap([['Oro\\Bundle\\UserBundle\\Entity\\User', $userRepo], ['Oro\\Bundle\\OrganizationBundle\\Entity\\BusinessUnit', $buRepo]])); list($users, $bUnits) = $this->getTestData(); $userRepo->expects($this->any())->method('findAll')->will($this->returnValue($users)); $qb = $this->getMockBuilder('\\Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock(); $query = $this->getMockBuilder('\\Doctrine\\ORM\\AbstractQuery')->setMethods(['setParameter', 'getArrayResult'])->disableOriginalConstructor()->getMockForAbstractClass(); $buRepo->expects($this->once())->method('createQueryBuilder')->will($this->returnValue($qb)); $qb->expects($this->once())->method('select')->will($this->returnValue($qb)); $qb->expects($this->once())->method('getQuery')->will($this->returnValue($query)); $query->expects($this->once())->method('getArrayResult')->will($this->returnValue($bUnits)); $metadata = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock(); $this->em->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(); $this->em->expects($this->any())->method('getConnection')->will($this->returnValue($connection)); $schemaManager = $this->getMockBuilder('Doctrine\\DBAL\\Schema\\MySqlSchemaManager')->disableOriginalConstructor()->getMock(); $connection->expects($this->any())->method('getSchemaManager')->will($this->returnValue($schemaManager)); $schemaManager->expects($this->any())->method('tablesExist')->with('test')->will($this->returnValue(true)); $this->treeProvider->warmUpCache(); /** @var OwnerTree $tree */ $tree = $this->treeProvider->getTree(); $this->assertEquals(1, $tree->getBusinessUnitOrganizationId(1)); $this->assertEquals([1], $tree->getUserOrganizationIds(1)); }
public function testProductShouldBeSuspendedAndFlushedWhenSuspendTheProduct() { $product = new Product('test'); $this->entityManager->expects(self::once())->method('persist')->with($product); $this->entityManager->expects(self::once())->method('flush'); $this->productService->suspend($product); }
public function testProcessGoodScenario() { $testWebsiteId = 1; $testStoreId = 2; $testStoresArray = new \ArrayIterator([['website_id' => $testWebsiteId, 'store_id' => $testStoreId]]); $settingBag = new ParameterBag(['website_id' => $testWebsiteId]); $testData = [['id' => 1, 'originId' => 11], ['id' => 2, 'originId' => 22], ['id' => 3, 'originId' => 33]]; $testExistedCarts = [(object) ['entity_id' => 22]]; $repo = $this->getMockBuilder('OroCRM\\Bundle\\MagentoBundle\\Entity\\Repository\\CartRepository')->disableOriginalConstructor()->getMock(); $this->em->expects($this->any())->method('getRepository')->with('OroCRMMagentoBundle:Cart')->will($this->returnValue($repo)); $transport = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport')->setMethods(['getSettingsBag'])->getMockForAbstractClass(); $transport->expects($this->any())->method('getSettingsBag')->will($this->returnValue($settingBag)); $realTransport = $this->getMock('OroCRM\\Bundle\\MagentoBundle\\Provider\\Transport\\MagentoTransportInterface'); $realTransport->expects($this->once())->method('isSupportedExtensionVersion')->will($this->returnValue(true)); $realTransport->expects($this->once())->method('getStores')->will($this->returnValue($testStoresArray)); $this->helper->expects($this->once())->method('getTransport')->will($this->returnValue($realTransport)); $channel = new Channel(); $channel->setTransport($transport); $realTransport->expects($this->at(3))->method('call')->with(SoapTransport::ACTION_ORO_CART_LIST, ['filters' => ['complex_filter' => [['key' => 'store_id', 'value' => ['key' => 'in', 'value' => $testStoreId]], ['key' => 'entity_id', 'value' => ['key' => 'in', 'value' => '11,22']]]], 'pager' => ['page' => 1, 'pageSize' => self::BATCH_SIZE]])->will($this->returnValue($testExistedCarts)); $realTransport->expects($this->at(4))->method('call')->with(SoapTransport::ACTION_ORO_CART_LIST, ['filters' => ['complex_filter' => [['key' => 'store_id', 'value' => ['key' => 'in', 'value' => $testStoreId]], ['key' => 'entity_id', 'value' => ['key' => 'in', 'value' => '33']]]], 'pager' => ['page' => 1, 'pageSize' => self::BATCH_SIZE]])->will($this->returnValue([])); $repo->expects($this->once())->method('getCartsByChannelIdsIterator')->with($channel)->will($this->returnValue($testData)); $repo->expects($this->at(1))->method('markExpired')->with([1]); $repo->expects($this->at(2))->method('markExpired')->with([3]); $this->processor->process($channel); }
/** * Sets up a PostMetaManager instance. */ protected function setUp() { $this->entityManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock(); $this->repository = $this->getMockBuilder('Ekino\\WordpressBundle\\Repository\\PostMetaRepository')->disableOriginalConstructor()->getMock(); $this->entityManager->expects($this->any())->method('getRepository')->will($this->returnValue($this->repository)); $this->manager = new PostMetaManager($this->entityManager, 'Ekino\\WordpressBundle\\Entity\\PostMeta'); }
/** * @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)); }
/** * Sets up a OptionManager instance. */ protected function setUp() { $this->entityManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock(); $this->repository = $this->getMockBuilder('Parenthesis\\WPBundle\\Repository\\OptionRepository')->disableOriginalConstructor()->getMock(); $this->entityManager->expects($this->any())->method('getRepository')->will($this->returnValue($this->repository)); $this->manager = new OptionManager($this->entityManager, 'Parenthesis\\WPBundle\\Entity\\Option'); }
public function testSchedule() { $testIntegrationType = 'testIntegrationType'; $testConnectorType = 'testConnectorType'; $testId = 22; $integration = new Integration(); $integration->setType($testIntegrationType); $integration->setEnabled(true); $ref = new \ReflectionProperty(get_class($integration), 'id'); $ref->setAccessible(true); $ref->setValue($integration, $testId); $this->typesRegistry->addChannelType($testIntegrationType, new TestIntegrationType()); $this->typesRegistry->addConnectorType($testConnectorType, $testIntegrationType, new TestTwoWayConnector()); $that = $this; $uow = $this->getMockBuilder('Doctrine\\ORM\\UnitOfWork')->disableOriginalConstructor()->getMock(); $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($uow)); $metadataFactory = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadataFactory')->disableOriginalConstructor()->getMock(); $metadataFactory->expects($this->once())->method('getMetadataFor')->will($this->returnValue(new ClassMetadata('testEntity'))); $this->em->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($metadataFactory)); $uow->expects($this->once())->method('persist')->with($this->isInstanceOf('JMS\\JobQueueBundle\\Entity\\Job'))->will($this->returnCallback(function (Job $job) use($that, $testId, $testConnectorType) { $expectedArgs = ['--integration=' . $testId, sprintf('--connector=testConnectorType', $testConnectorType), '--params=a:0:{}']; $that->assertEquals($expectedArgs, $job->getArgs()); })); $uow->expects($this->once())->method('computeChangeSet'); $this->scheduler->schedule($integration, $testConnectorType, [], false); }
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)); }
public function setUp() { $this->processor = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Model\\WebSocket\\WebSocketSendProcessor')->disableOriginalConstructor()->getMock(); $this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock(); $this->uow = $this->getMockBuilder('Doctrine\\ORM\\UnitOfWork')->disableOriginalConstructor()->getMock(); $this->em->expects($this->any())->method('getUnitOfWork')->willReturn($this->uow); $this->listener = new EmailUserListener($this->processor); }
/** * @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)); }
public function testFindItem() { $itemBuilder = $this->builder; $itemId = 1; $this->em->expects($this->once())->method('find')->with($this->equalTo('OroNavigationBundle:NavigationHistoryItem'), $this->equalTo($itemId))->will($this->returnValue(new NavigationHistoryItem())); $item = $itemBuilder->findItem($itemId); $this->assertInstanceOf('Oro\\Bundle\\NavigationBundle\\Entity\\NavigationHistoryItem', $item); }
/** * @inheritdoc */ protected function setUp() { $this->sourceProcessor = $this->getMockBuilder(DelegatingSourceProcessor::class)->disableOriginalConstructor()->getMock(); $this->queueManager = $this->getMockBuilder(QueueManager::class)->disableOriginalConstructor()->getMock(); $this->uow = $this->getMockBuilder(UnitOfWork::class)->disableOriginalConstructor()->setMethods(['getEntityChangeSet', 'getScheduledEntityInsertions', 'getScheduledEntityUpdates', 'getScheduledEntityDeletions'])->getMock(); $this->entityManager = $this->getMockBuilder(EntityManager::class)->disableOriginalConstructor()->setMethods(['getUnitOfWork'])->getMock(); $this->entityManager->expects($this->any())->method('getUnitOfWork')->will($this->returnValue($this->uow)); $this->listener = $this->getMockBuilder(SourceModificationListener::class)->disableOriginalConstructor()->setMethods(['isSourceModified', 'isSourceLinked', 'setSourceModificationDate', 'scheduleSourceProcess'])->getMock(); }
/** * {@inheritdoc} */ public function setUp() { $this->entityRepository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->setMethods(['find'])->getMock(); $this->entityRepository->expects($this->once())->method('find')->willReturn(null); $this->entityManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->setMethods(['getRepository'])->getMock(); $this->entityManager->expects($this->once())->method('getRepository')->willReturn($this->entityRepository); $this->elasticsearchRepository = $this->getMockBuilder('ONGR\\ElasticsearchBundle\\ORM\\Repository')->disableOriginalConstructor()->getMock(); $this->syncStorage = $this->getMockBuilder('ONGR\\ConnectionsBundle\\Sync\\SyncStorage\\SyncStorage')->disableOriginalConstructor()->setMethods(['getChunk'])->getMock(); }
public function testLogExecution() { $testExec = new Execution(); $testExec->setAlias('def1')->setEnv($this->container->getParameter('kernel.environment'))->setExecutionTime(1)->setFailed(false)->setExecutionDatetime(new \DateTime()); $this->entityManager->expects($this->once())->method('persist')->with($this->isInstanceOf(Execution::class))->willReturnCallback(function (Execution $execution) use($testExec) { $this->assertEquals($execution, $testExec); }); $this->report->logExecution($testExec->getAlias(), $testExec->getExecutionTime(), $testExec->getExecutionDatetime(), $testExec->isFailed()); }
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]])); }
protected function prepareEvent() { $this->entity->setEntities(['OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity1', 'OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity2']); $this->event->expects($this->atLeastOnce())->method('getChannel')->will($this->returnValue($this->entity)); $this->settingProvider->expects($this->at(0))->method('getIntegrationConnectorName')->with('OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity1')->will($this->returnValue('TestConnector1')); $this->settingProvider->expects($this->at(1))->method('getIntegrationConnectorName')->with('OroCRM\\Bundle\\AcmeBundle\\Entity\\TestEntity2')->will($this->returnValue('TestConnector2')); $this->registry->expects($this->any())->method('getManager')->will($this->returnValue($this->em)); $this->em->expects($this->once())->method('persist')->with($this->integration); $this->em->expects($this->once())->method('flush'); }
/** * @param array $inputData * @param array $expectedData * * @dataProvider getActionsProvider */ public function testGetActions(array $inputData, array $expectedData) { $this->record->expects($this->any())->method('getValue')->with('id')->willReturn($inputData['record']['id']); $this->doctrine->expects($this->any())->method('getManagerForClass')->with($expectedData['class'])->willReturn($this->manager); $this->manager->expects($this->any())->method('getReference')->with($expectedData['class'], $expectedData['id'])->willReturn($inputData['object']); $this->securityFacade->expects($this->any())->method('isGranted')->willReturnCallback(function ($permission) use($inputData) { return $inputData['isGranted'][$permission]; }); $this->assertEquals($expectedData['actions'], $this->actionPermissionProvider->getActions($this->record, $inputData['config'])); }
public function testSaveWithExtra() { $log = $this->subject->create(); $log->setExtra(['job_ticket']); $this->entityManager->expects($this->once())->method('persist')->with($this->callback(function (LogInterface $value) use($log) { $extra = $value->getExtra(); return $log === $value && !isset($extra['job_ticket']); })); $this->subject->save($log); }
public function testUpdateActivityDescription() { $activityList = $this->getMockBuilder('Oro\\Bundle\\ActivityListBundle\\Entity\\ActivityList')->getMock(); $event = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Event\\EmailBodyAdded')->disableOriginalConstructor()->getMock(); $email = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\Email')->disableOriginalConstructor()->getMock(); $event->expects($this->exactly(1))->method('getEmail')->will($this->returnValue($email)); $this->chainProvider->expects($this->exactly(1))->method('getUpdatedActivityList')->with($this->identicalTo($email), $this->identicalTo($this->entityManager))->will($this->returnValue($activityList)); $this->entityManager->expects($this->exactly(1))->method('persist')->with($activityList); $this->listener->updateActivityDescription($event); }
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); }
public function testFindDefaultScopes() { $unitOfWork = $this->getMock(UnitOfWork::class, [], [], '', false); $persister = $this->getMock(EntityPersister::class, [], [], '', false); $unitOfWork->expects($this->at(0))->method('getEntityPersister')->willReturn($persister); $this->em->expects($this->at(0))->method('getUnitOfWork')->willReturn($unitOfWork); $persister->expects($this->once())->method('loadAll')->willReturn([]); $returned = $this->repository->findDefaultScopes(); $this->assertEquals([], $returned); }
public function testProcessValidData() { $this->form->expects($this->once())->method('setData')->with($this->entity); $this->request->setMethod('POST'); $this->form->expects($this->once())->method('submit')->with($this->request); $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true)); $this->em->expects($this->once())->method('persist')->with($this->entity); $this->em->expects($this->once())->method('flush'); $this->assertTrue($this->handler->process($this->entity)); }
public function testFindAllByTicket() { $messageReference = $this->getMessageReference(); $ticket = $messageReference->getTicket(); $references = array($messageReference); $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->unitOfWork)); $this->unitOfWork->expects($this->once())->method('getEntityPersister')->with($this->equalTo(self::DUMMY_CLASS_NAME))->will($this->returnValue($this->entityPersister)); $this->entityPersister->expects($this->once())->method('loadAll')->with($this->equalTo(array('ticket' => $ticket)), null, null, null)->will($this->returnValue($references)); $result = $this->repository->findAllByTicket($ticket); $this->assertEquals($references, $result); }
/** * @test */ public function thatApiUserRetrievesByUsername() { $email = '*****@*****.**'; $apiUser = $this->getApiUser(); $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->unitOfWork)); $this->unitOfWork->expects($this->once())->method('getEntityPersister')->with($this->equalTo(self::DUMMY_CLASS_NAME))->will($this->returnValue($this->entityPersister)); $this->entityPersister->expects($this->once())->method('load')->with($this->equalTo(array('email' => $email)), $this->equalTo(null), $this->equalTo(null), array(), $this->equalTo(0), $this->equalTo(1), $this->equalTo(null))->will($this->returnValue($apiUser)); $retrievedApiUser = $this->repository->findOneBy(array('email' => $email)); $this->assertNotNull($retrievedApiUser); $this->assertEquals($apiUser, $retrievedApiUser); }
protected function setUp() { $this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock(); $this->uow = $this->getMockBuilder('Doctrine\\ORM\\UnitOfWork')->disableOriginalConstructor()->getMock(); $this->em->expects($this->any())->method('getUnitOfWork')->will($this->returnValue($this->uow)); $doctrine = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ManagerRegistry')->disableOriginalConstructor()->getMock(); $doctrine->expects($this->any())->method('getManagerForClass')->willReturnCallback(function ($class) { return in_array($class, [self::TEST_ENTITY_NAME, self::TEST_NEW_ENTITY_NAME], true) ? $this->em : null; }); $this->generator = new DoctrineTagGenerator($doctrine); }