本文整理汇总了PHP中Doctrine\ORM\EntityRepository::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityRepository::expects方法的具体用法?PHP EntityRepository::expects怎么用?PHP EntityRepository::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\EntityRepository
的用法示例。
在下文中一共展示了EntityRepository::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例2: 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));
}
示例3: testSuccessChange
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]]));
}
示例4: setUp
/**
* {@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();
}
示例5: testGetChannelFromContext
public function testGetChannelFromContext()
{
$testID = 1;
$integration = new Integration();
$integration->setTransport($this->getMockForAbstractClass('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport'));
$context = $this->getMock('Oro\\Bundle\\ImportExportBundle\\Context\\ContextInterface');
$context->expects($this->once())->method('getOption')->with('channel')->will($this->returnValue($testID));
$this->repo->expects($this->once())->method('getOrLoadById')->with($testID)->will($this->returnValue($integration));
$result = $this->contextMediator->getChannel($context);
$this->assertEquals($integration, $result);
}
示例6: testGetSegmentTypeChoices
public function testGetSegmentTypeChoices()
{
$this->repository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
$this->em->expects($this->any())->method('getRepository')->with('OroSegmentBundle:SegmentType')->will($this->returnValue($this->repository));
$type = new SegmentType('test');
$type->setLabel('testLabel');
$types = [$type];
$this->repository->expects($this->once())->method('findAll')->will($this->returnValue($types));
$result = $this->manager->getSegmentTypeChoices();
$this->assertInternalType('array', $result);
$this->assertCount(1, $result);
$this->assertSame(['test' => 'testLabel'], $result);
}
示例7: getEntityRepository
/**
* @return EntityRepository
*/
public function getEntityRepository()
{
if (!$this->entityRepository) {
$this->entityRepository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
$this->entityRepository->expects($this->any())->method('createQueryBuilder')->with('e')->will($this->returnValue($this->getQueryBuilder()));
}
return $this->entityRepository;
}
示例8: testGetAllRoutes
public function testGetAllRoutes()
{
$this->objectRepositoryMock->expects($this->once())->method('findBy')->with(array(), null, 42)->will($this->returnValue(array($this->routeMock)));
$routeProvider = new RouteProvider($this->managerRegistryMock, $this->candidatesMock, 'Route');
$routeProvider->setManagerName('default');
$routeProvider->setRouteCollectionLimit(42);
$routes = $routeProvider->getRoutesByNames(null);
$this->assertCount(1, $routes);
}
示例9: setSearchExpects
protected function setSearchExpects()
{
$this->entityRepository->expects($this->once())->method('createQueryBuilder')->will($this->returnValue($this->queryBuilder));
$this->queryBuilder->expects($this->once())->method('where')->will($this->returnSelf());
$this->queryBuilder->expects($this->exactly(2))->method('andWhere')->will($this->returnSelf());
$this->queryBuilder->expects($this->exactly(3))->method('setParameter')->will($this->returnSelf());
$this->queryBuilder->expects($this->exactly(2))->method('addOrderBy')->will($this->returnSelf());
$this->queryBuilder->expects($this->any())->method('expr')->will($this->returnValue($this->expr));
$this->aclHelper->expects($this->once())->method('apply')->will($this->returnValue($this->queryBuilder));
}
示例10: testExecuteWrongNameSpecified
public function testExecuteWrongNameSpecified()
{
$this->expectContainerGetManagerRegistryAndProcessHandler();
$id = 1;
$this->input->expects($this->exactly(2))->method('getOption')->willReturnMap([['id', $id], ['name', 'wrong_name']]);
$processTrigger = $this->createProcessTrigger($id);
$this->repo->expects($this->once())->method('find')->with($id)->willReturn($processTrigger);
$this->processHandler->expects($this->never())->method($this->anything());
$this->command->execute($this->input, $this->output);
$this->assertAttributeEquals(['Trigger not found in process definition "wrong_name"'], 'messages', $this->output);
}
示例11: testShowResignedWithFilterAction
/**
* Test case to cover the showResignedAction with filter value as post
*
* @covers Skyrocket\LoginBundle\Controller\DefaultController::showResignedAction
*/
public function testShowResignedWithFilterAction()
{
$dummyResultArray = $this->getResignedDummyFilterArray();
$this->mockController->expects($this->once())->method('getRequest')->will($this->returnValue($this->mockRequest));
$this->mockRequest->expects($this->any())->method('getMethod')->will($this->returnValue('POST'));
$this->mockRequest->expects($this->at(1))->method('get')->with($this->equalTo('fromDate'))->will($this->returnValue('08/04/2015'));
$this->mockRequest->expects($this->at(2))->method('get')->with($this->equalTo('toDate'))->will($this->returnValue('08/06/2015'));
$this->mockController->expects($this->once())->method('getDoctrine')->will($this->returnValue($this->mockRegistry));
$this->mockRegistry->expects($this->once())->method('getManager')->will($this->returnValue($this->mockEntityManager));
$this->mockEntityManager->expects($this->once())->method('getRepository')->with($this->equalTo('SkyrocketLoginBundle:Employee'))->will($this->returnValue($this->mockRepository));
$this->mockRepository->expects($this->once())->method('getFilteredEmployeesResigned')->with($this->equalTo(1), $this->equalTo('2015-08-04 00:00:00'), $this->equalTo('2015-08-06 00:00:00'))->will($this->returnValue($dummyResultArray));
$this->mockController->showResignedAction();
}
示例12: __construct
/**
* @param null $name
* @param array $data
* @param string $dataName
*/
public function __construct($name = null, array $data = array(), $dataName = '')
{
parent::__construct($name, $data, $dataName);
$this->billingAddressType = new AddressType(AddressType::TYPE_BILLING);
$this->shippingAddressType = new AddressType(AddressType::TYPE_SHIPPING);
$this->em = $this->createEntityManagerMock();
$this->addressRepository = $this->createRepositoryMock([$this->billingAddressType, $this->shippingAddressType]);
$this->addressRepository->expects($this->any())->method('findBy')->will($this->returnCallback(function ($params) {
$result = [];
foreach ($params['name'] as $name) {
switch ($name) {
case AddressType::TYPE_BILLING:
$result[] = $this->billingAddressType;
break;
case AddressType::TYPE_SHIPPING:
$result[] = $this->shippingAddressType;
break;
}
}
return $result;
}));
}
示例13: testFindById
public function testFindById()
{
$accountId = 1;
$search = 'test';
$foundElement = $this->getResultStub($accountId, $search);
$expectedResultData = [['id' => $accountId, 'email' => $search]];
$queryString = sprintf('%s%s%d', $search, self::DELIMITER, $accountId);
$this->entityRepository->expects($this->once())->method('findOneBy')->will($this->returnValue($foundElement));
$searchResult = $this->searchHandler->search($queryString, 1, 10, true);
$this->assertInternalType('array', $searchResult);
$this->assertArrayHasKey('more', $searchResult);
$this->assertArrayHasKey('results', $searchResult);
$this->assertEquals($expectedResultData, $searchResult['results']);
}
示例14: assertSearchCall
/**
* @param string $search
* @param int $page
* @param int $perPage
* @param array $foundElements
* @param array $resultData
* @param array $expectedIds
* @return \PHPUnit_Framework_MockObject_MockObject
*/
protected function assertSearchCall($search, $page, $perPage, array $foundElements, array $resultData, array $expectedIds)
{
$searchResult = $this->getMockBuilder('Oro\\Bundle\\SearchBundle\\Query\\Result')->disableOriginalConstructor()->getMock();
$searchResult->expects($this->once())->method('getElements')->will($this->returnValue($foundElements));
$this->indexer->expects($this->once())->method('simpleSearch')->with($search, $page - 1, $perPage + 1, 'alias')->will($this->returnValue($searchResult));
$queryBuilder = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock();
$query = $this->getMockBuilder('Doctrine\\ORM\\AbstractQuery')->disableOriginalConstructor()->setMethods(['getResult'])->getMockForAbstractClass();
$query->expects($this->once())->method('getResult')->will($this->returnValue($resultData));
$expr = $this->getMockBuilder('Doctrine\\ORM\\Query\\Expr')->disableOriginalConstructor()->getMock();
$expr->expects($this->once())->method('in')->with('e.id', $expectedIds)->will($this->returnSelf());
$queryBuilder->expects($this->once())->method('expr')->will($this->returnValue($expr));
$queryBuilder->expects($this->once())->method('where')->with($expr)->will($this->returnSelf());
$this->aclHelper->expects($this->once())->method('apply')->with($queryBuilder, 'VIEW')->will($this->returnValue($query));
$this->entityRepository->expects($this->any())->method('createQueryBuilder')->will($this->returnValue($queryBuilder));
return $searchResult;
}
示例15: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->objectManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
$this->doctrineHelper = $this->getMockBuilder('Oro\\Bundle\\EntityBundle\\ORM\\DoctrineHelper')->disableOriginalConstructor()->getMock();
$this->eventDispatcher = $this->getMockBuilder('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface')->disableOriginalConstructor()->getMock();
$this->skuIncrementor = $this->getMockBuilder('OroB2B\\Bundle\\ProductBundle\\Duplicator\\SkuIncrementorInterface')->disableOriginalConstructor()->getMock();
$this->attachmentManager = $this->getMockBuilder('Oro\\Bundle\\AttachmentBundle\\Manager\\AttachmentManager')->disableOriginalConstructor()->getMock();
$this->attachmentProvider = $this->getMockBuilder('Oro\\Bundle\\AttachmentBundle\\Provider\\AttachmentProvider')->disableOriginalConstructor()->getMock();
$this->productStatusRepository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
$this->productStatusDisabled = $this->getMockBuilder('Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue')->disableOriginalConstructor()->getMockForAbstractClass();
$this->connection = $this->getMockBuilder('Doctrine\\DBAL\\Connection')->disableOriginalConstructor()->getMock();
$this->doctrineHelper->expects($this->once())->method('getEntityRepository')->with(ExtendHelper::buildEnumValueClassName('prod_status'))->will($this->returnValue($this->productStatusRepository));
$this->doctrineHelper->expects($this->any())->method('getEntityManager')->with($this->anything())->will($this->returnValue($this->objectManager));
$this->objectManager->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection));
$this->productStatusRepository->expects($this->once())->method('find')->with(Product::STATUS_DISABLED)->will($this->returnValue($this->productStatusDisabled));
$this->duplicator = new ProductDuplicator($this->doctrineHelper, $this->eventDispatcher, $this->attachmentManager, $this->attachmentProvider);
$this->duplicator->setSkuIncrementor($this->skuIncrementor);
}