本文整理匯總了PHP中Doctrine\Bundle\DoctrineBundle\Registry::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP Registry::expects方法的具體用法?PHP Registry::expects怎麽用?PHP Registry::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\Bundle\DoctrineBundle\Registry
的用法示例。
在下文中一共展示了Registry::expects方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGetValue
/**
* @param $entity
* @param FieldMetadata $metadata
* @param int $count
* @param $expectedValue
*
* @dataProvider getValueDataProvider
*/
public function testGetValue($entity, FieldMetadata $metadata, $count, $expectedValue)
{
$em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
$repository = $this->getMockBuilder('Oro\\Bundle\\ActivityListBundle\\Entity\\Repository\\ActivityListRepository')->disableOriginalConstructor()->getMock();
$repository->expects($this->once())->method('getRecordsCountForTargetClassAndId')->with(ClassUtils::getClass($entity), $entity->getId(), [$metadata->get('type')])->willReturn($count);
$em->expects($this->once())->method('getRepository')->willReturn($repository);
$this->registry->expects($this->once())->method('getManagerForClass')->willReturn($em);
$this->assertEquals($expectedValue, $this->accessor->getValue($entity, $metadata));
}
示例2: testValidate
public function testValidate()
{
$this->repository->expects($this->once())->method('findDuplicate')->with($this->lineItem)->will($this->returnValue(true));
$this->registry->expects($this->once())->method('getRepository')->with(self::LINE_ITEM_SHORTCUT)->will($this->returnValue($this->repository));
$this->context->expects($this->once())->method('addViolation')->with($this->constraint->message);
$validator = new LineItemValidator($this->registry);
$validator->initialize($this->context);
$validator->validate($this->lineItem, $this->constraint);
}
示例3: testProcess
/**
* @test
*/
public function testProcess()
{
$this->doctrineRegistry->expects($this->any())->method('getManager')->will($this->returnValue($this->manager));
$this->manager->expects($this->once())->method('createQueryBuilder')->will($this->returnValue($this->queryBuilder))->with($this->equalTo('a'));
$this->grid->expects($this->once())->method('getParameters')->will($this->returnValue($this->parameterBag));
$this->parameterBag->expects($this->once())->method('get')->will($this->returnValue(1));
$this->grid->expects($this->once())->method('setDatasource');
$this->combinedAuditDatasource->process($this->grid, []);
}
示例4: setUp
public function setUp()
{
$this->providerStorage = new EmailOwnerProviderStorage();
$this->entityNameResolver = $this->getMockBuilder('Oro\\Bundle\\EntityBundle\\Provider\\EntityNameResolver')->disableOriginalConstructor()->getMock();
$this->mailboxRepository = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\Repository\\MailboxRepository')->disableOriginalConstructor()->getMock();
$this->doctrine = $this->getMockBuilder('Doctrine\\Bundle\\DoctrineBundle\\Registry')->disableOriginalConstructor()->getMock();
$this->doctrine->expects($this->any())->method('getRepository')->with($this->equalTo('OroEmailBundle:Mailbox'))->will($this->returnValue($this->mailboxRepository));
$this->securityFacade = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\SecurityFacade')->disableOriginalConstructor()->getMock();
$this->factory = new EmailQueryFactory($this->providerStorage, $this->entityNameResolver, $this->doctrine, $this->securityFacade);
}
示例5: testGetActions
/**
* @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']));
}
示例6: setUp
public function setUp()
{
$this->contextAccessor = $this->getMock('Oro\\Bundle\\WorkflowBundle\\Model\\ContextAccessor');
$this->mailboxProcessStorage = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Mailbox\\MailboxProcessStorage')->disableOriginalConstructor()->getMock();
$demoProcess = $this->getMock('Oro\\Bundle\\EmailBundle\\Mailbox\\MailboxProcessProviderInterface');
$demoProcess->expects($this->any())->method('getSettingsEntityFQCN')->will($this->returnValue('DemoProcessSettings'));
$this->mailboxProcessStorage->expects($this->any())->method('getProcess')->with($this->equalTo('demo'))->will($this->returnValue($demoProcess));
$this->registry = $this->getMockBuilder('Doctrine\\Bundle\\DoctrineBundle\\Registry')->disableOriginalConstructor()->getMock();
$this->repository = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\Repository\\MailboxRepository')->disableOriginalConstructor()->getMock();
$this->registry->expects($this->any())->method('getRepository')->with($this->equalTo('OroEmailBundle:Mailbox'))->will($this->returnValue($this->repository));
$this->action = new RequestMailboxes($this->contextAccessor, $this->registry, $this->mailboxProcessStorage);
$this->action->setDispatcher($this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface'));
}
示例7: testProcessExistingShoppingList
public function testProcessExistingShoppingList()
{
$this->shoppingList->expects($this->once())->method('getId')->willReturn(1);
$this->request->expects($this->once())->method('getMethod')->will($this->returnValue('PUT'));
$this->form->expects($this->once())->method('submit')->with($this->request);
$this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
/** @var \PHPUnit_Framework_MockObject_MockObject|ObjectManager $manager */
$manager = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
$manager->expects($this->once())->method('persist');
$manager->expects($this->once())->method('flush');
$this->registry->expects($this->once())->method('getManagerForClass')->with(self::SHOPPING_LIST_SHORTCUT)->will($this->returnValue($manager));
$handler = new ShoppingListHandler($this->form, $this->request, $this->manager, $this->registry);
$this->assertTrue($handler->process($this->shoppingList));
}
示例8: initManager
protected function initManager()
{
$manager = $this->getMockBuilder('\\Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
$manager->expects($this->any())->method('persist');
$manager->expects($this->any())->method('flush');
$this->registry->expects($this->any())->method('getManager')->willReturn($manager);
}
示例9: setUp
protected function setUp()
{
MockAnnotations::init($this);
$this->doctrineRegistry->expects($this->any())->method('getRepository')->will($this->returnCallback([$this, 'getRepository']));
$this->ticketService = new TicketApiServiceImpl($this->doctrineRegistry, $this->ticketBuilder, $this->attachmentManager, $this->authorizationService, $this->dispatcher, $this->tagManager, $this->securityFacade);
$this->ticketService->setApiPagingService($this->apiPagingService);
}
示例10: updateBranchWithAllValues
/**
* @test
*/
public function updateBranchWithAllValues()
{
$this->fileMock = new UploadedFileStub(self::DUMMY_LOGO_PATH, self::DUMMY_LOGO_NAME);
$uploadedFile = $this->fileMock->move(self::DUMMY_LOGO_PATH, self::DUMMY_LOGO_NAME);
$this->branchRepository->expects($this->once())->method('get')->will($this->returnValue($this->branch));
$this->branch->expects($this->exactly(2))->method('getLogo')->will($this->returnValue($this->logo));
$this->branchLogoHandler->expects($this->once())->method('remove')->with($this->equalTo($this->logo));
$this->branchLogoHandler->expects($this->once())->method('upload')->with($this->equalTo($this->fileMock))->will($this->returnValue($uploadedFile));
$name = 'DUMMY_NAME_UPDT';
$description = 'DUMMY_DESC_UPDT';
$assigneeId = 1;
$assignee = new User($assigneeId, User::TYPE_ORO);
$defaultAssignee = new OroUser();
$tags = array('autocomplete' => array(), 'all' => array(), 'owner' => array());
$this->branch->expects($this->once())->method('update')->with($this->equalTo($name), $this->equalTo($description), $this->equalTo($defaultAssignee), $this->equalTo(new Logo($uploadedFile->getFilename(), $uploadedFile->getFilename())));
$this->branch->expects($this->once())->method('setTags')->with($this->equalTo($tags));
$this->registry->expects($this->exactly(2))->method('getManager')->will($this->returnValue($this->entityManager));
$this->entityManager->expects($this->once())->method('persist')->with($this->branch);
$this->entityManager->expects($this->once())->method('flush');
$this->tagManager->expects($this->once())->method('saveTagging')->with($this->equalTo($this->branch));
$this->authorizationService->expects($this->once())->method('isActionPermitted')->with($this->equalTo('EDIT'), $this->equalTo('Entity:DiamanteDeskBundle:Branch'))->will($this->returnValue(true));
$this->registry->expects($this->once())->method('getRepository')->with($this->equalTo('OroUserBundle:User'))->will($this->returnValue($this->userRepo));
$this->userRepo->expects($this->once())->method('find')->with($this->equalTo($assigneeId))->will($this->returnValue($defaultAssignee));
$command = new BranchCommand();
$command->name = $name;
$command->description = $description;
$command->defaultAssignee = $assigneeId;
$command->logoFile = $this->fileMock;
$command->tags = $tags;
$this->branchServiceImpl->updateBranch($command);
}
示例11: deleteAttachment
/**
* @test
*/
public function deleteAttachment()
{
$pathname = 'some/path/file.ext';
$filename = 'file.ext';
$attachment = new Attachment(new File($pathname));
$this->fileStorageService->expects($this->once())->method('remove')->with($this->equalTo($filename));
$this->registry->expects($this->once())->method('getManager')->will($this->returnValue($this->em));
$this->em->expects($this->once())->method('remove')->with($this->equalTo($attachment));
$this->manager->deleteAttachment($attachment);
}
示例12: testGetEntityIdentifier
/**
* @dataProvider getEntityIdentifier
*
* @param array $ids
*/
public function testGetEntityIdentifier(array $ids)
{
$entity = new Bar();
$meta = $this->getNoConstructorMock(ClassMetadata::class);
$meta->expects($this->once())->method('getIdentifierValues')->with($entity)->will($this->returnValue($ids));
$this->doctrine->expects($this->once())->method('getManager')->will($this->returnValue($this->em));
$this->em->expects($this->once())->method('getClassMetadata')->with(get_class($entity))->will($this->returnValue($meta));
$prefix = null;
if ($ids) {
$prefix = CacheKeyBuilder::IDENTIFIER_PREFIX . implode(CacheKeyBuilder::IDENTIFIER_SEPARATOR, $ids);
}
$this->assertEquals($prefix, $this->builder->getEntityIdentifier($entity));
}
示例13: testRenderTicket
public function testRenderTicket()
{
$tags = array(array('id' => 1, 'name' => 'Ticket Tag'));
$renderTagResult = '<span class="tag-inline">Ticket Tag</span>';
$this->registry->expects($this->once())->method('getRepository')->will($this->returnValue($this->sharedRepository));
$this->tagManager->expects($this->once())->method('loadTagging')->will($this->returnValue($this->tagManager));
$this->twig->expects($this->once())->method('render')->will($this->returnValue($renderTagResult));
$this->sharedRepository->expects($this->once())->method('get')->will($this->returnValue($this->ticket));
$this->ticket->expects($this->once())->method('getTags')->will($this->returnValue($this->commonCollection));
$this->commonCollection->expects($this->once())->method('getValues')->will($this->returnValue($tags));
$ticketResult = $this->renderTagExtensionExtension->renderTag($this->twig, 1, 'ticket');
$this->assertEquals($renderTagResult, $ticketResult);
}
示例14: 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();
}
示例15: testApplyInheritanceActivity
/**
* @param array $activity
* @param int $qbCalls
* @param int $hasModelCalls
* @param int $hasModelCalls
*
* @dataProvider getInheritanceDataProvider
*/
public function testApplyInheritanceActivity($activity, $qbCalls, $hasModelCalls, $getConfigCalls)
{
$config = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\Config')->disableOriginalConstructor()->getMock();
$config->expects($this->exactly($getConfigCalls))->method('getValues')->willReturn($activity);
$this->configManager->expects($this->exactly($hasModelCalls))->method('hasConfigEntityModel')->with('test')->willReturn(true);
$this->configManager->expects($this->exactly($getConfigCalls))->method('getEntityConfig')->with('activity', 'test')->willReturn($config);
$expr = new Expr();
$em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
$em->expects($this->any())->method('getExpressionBuilder')->willReturn($expr);
$qb = new QueryBuilder($em);
$qb->select('test')->from('test', 'ttt');
$em->expects($this->exactly($qbCalls))->method('createQueryBuilder')->willReturn($qb);
$this->registry->expects($this->exactly($qbCalls))->method('getManagerForClass')->willReturn($em);
$this->activityInheritanceTargetsHelper->applyInheritanceActivity($qb, 'test', 1);
}