本文整理汇总了PHP中Oro\Bundle\SecurityBundle\SecurityFacade::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP SecurityFacade::expects方法的具体用法?PHP SecurityFacade::expects怎么用?PHP SecurityFacade::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\SecurityBundle\SecurityFacade
的用法示例。
在下文中一共展示了SecurityFacade::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function setUp()
{
$this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
$this->doctrineHelper = $this->getMockBuilder('Oro\\Bundle\\EntityBundle\\ORM\\DoctrineHelper')->disableOriginalConstructor()->getMock();
$this->mailer = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Mailer\\DirectMailer')->disableOriginalConstructor()->getMock();
$this->mailerTransport = $this->getMockBuilder('\\Swift_Transport_EsmtpTransport')->disableOriginalConstructor()->getMock();
$this->mailer->expects($this->any())->method('getTransport')->will($this->returnValue($this->mailerTransport));
$this->emailEntityBuilder = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Builder\\EmailEntityBuilder')->disableOriginalConstructor()->getMock();
$this->emailOwnerProvider = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\Provider\\EmailOwnerProvider')->disableOriginalConstructor()->getMock();
$this->dispatcher = $this->getMockBuilder('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface')->disableOriginalConstructor()->getMock();
$this->emailActivityManager = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\Manager\\EmailActivityManager')->disableOriginalConstructor()->getMock();
$this->securityFacade = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\SecurityFacade')->setMethods(['getLoggedUser', 'getOrganization'])->disableOriginalConstructor()->getMock();
$this->emailOriginHelper = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Tools\\EmailOriginHelper')->setMethods(['setEmailModel', 'findEmailOrigin'])->disableOriginalConstructor()->getMock();
$this->userEmailOrigin = $this->getMockBuilder('Oro\\Bundle\\ImapBundle\\Entity\\UserEmailOrigin')->disableOriginalConstructor()->getMock();
$this->userEmailOrigin->expects($this->any())->method('getSmtpHost')->will($this->returnValue('abc'));
$this->userEmailOrigin->expects($this->any())->method('getSmtpPort')->will($this->returnValue(25));
$this->securityFacadeLink = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\DependencyInjection\\Utils\\ServiceLink')->setMethods(['getService'])->disableOriginalConstructor()->getMock();
$this->securityFacadeLink->expects($this->any())->method('getService')->will($this->returnValue($this->securityFacade));
$this->securityFacade->expects($this->any())->method('getOrganization')->will($this->returnValue($this->getTestOrganization()));
$this->doctrineHelper->expects($this->any())->method('getEntityManager')->with('OroEmailBundle:Email')->will($this->returnValue($this->em));
$folder = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\EmailFolder')->disableOriginalConstructor()->getMock();
$this->userEmailOrigin->expects($this->any())->method('getFolder')->with(FolderType::SENT)->will($this->returnValue($folder));
$emailOriginRepo = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
$emailOriginRepo->expects($this->any())->method('findOneBy')->with(['internalName' => InternalEmailOrigin::BAP])->will($this->returnValue($this->userEmailOrigin));
$this->em->expects($this->any())->method('getRepository')->with('OroEmailBundle:InternalEmailOrigin')->will($this->returnValue($emailOriginRepo));
$this->emailProcessor = new Processor($this->doctrineHelper, $this->mailer, new EmailAddressHelper(), $this->emailEntityBuilder, $this->emailOwnerProvider, $this->emailActivityManager, $this->securityFacadeLink, $this->dispatcher, new Mcrypt(), $this->emailOriginHelper);
}
示例2: testGetPrefix
/**
* @dataProvider getPrefixDataProvider
*
* @param UserInterface|string|null $loggedUser
* @param string|null $expectedPrefix
*/
public function testGetPrefix($loggedUser, $expectedPrefix = null)
{
$this->securityFacade->expects($this->once())->method('getLoggedUser')->willReturn($loggedUser);
if (!$expectedPrefix) {
$this->setExpectedException('\\RuntimeException', 'This method must be called only for logged User or AccountUser');
}
$this->assertEquals($expectedPrefix, $this->resolver->getPrefix());
}
示例3: testOnResultBeforeSkipForBackendUser
public function testOnResultBeforeSkipForBackendUser()
{
$this->securityfacade->expects($this->once())->method('getLoggedUser')->willReturn(new User());
$this->event->expects($this->never())->method('getQuery');
$this->event->expects($this->never())->method('getDatagrid');
$this->metadataProvider->expects($this->never())->method('getMetadata');
$this->listener->onResultBefore($this->event);
}
示例4: testProcessorIsAllowed
/**
* @param string $acl
* @param bool $isGranted
* @param bool $hasLoggedUser
* @param bool $expected
* @dataProvider processorIsAllowedProvider
*/
public function testProcessorIsAllowed($acl, $isGranted, $hasLoggedUser, $expected)
{
if (null !== $acl) {
$this->securityFacade->expects($this->any())->method('hasLoggedUser')->willReturn($hasLoggedUser);
$this->securityFacade->expects($this->any())->method('isGranted')->with($acl)->willReturn($isGranted);
}
$this->processor->setAcl($acl);
$this->assertEquals($expected, $this->processor->isAllowed());
}
示例5: testGetGridReturnsNullWhenDontHavePermissions
public function testGetGridReturnsNullWhenDontHavePermissions()
{
$gridName = 'test-grid';
$acl = 'test-acl';
$configuration = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Datagrid\\Common\\DatagridConfiguration')->disableOriginalConstructor()->getMock();
$configuration->expects($this->once())->method('getAclResource')->will($this->returnValue($acl));
$this->manager->expects($this->once())->method('getConfigurationForGrid')->with($gridName)->will($this->returnValue($configuration));
$this->securityFacade->expects($this->once())->method('isGranted')->with($acl)->will($this->returnValue(false));
$this->assertNull($this->twigExtension->getGrid($gridName));
}
示例6: 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']));
}
示例7: testProcessEvent
public function testProcessEvent()
{
$user = new User();
$user->setId(1);
$this->configManager->expects($this->once())->method('get')->with('diamante_desk.email_notification')->will($this->returnValue(true));
$this->securityFacade->expects($this->once())->method('getLoggedUser')->will($this->returnValue($user));
$event = $this->event();
$this->notificationDeliveryManager->expects($this->once())->method('add')->with($this->logicalAnd($this->isInstanceOf('\\Diamante\\DeskBundle\\Model\\Ticket\\Notifications\\TicketNotification'), $this->attributeEqualTo('ticketUniqueId', $event->getAggregateId()), $this->attributeEqualTo('author', $user), $this->attributeEqualTo('headerText', $event->getHeaderText()), $this->attributeEqualTo('subject', $event->getSubject()), $this->attributeEqualTo('attachments', $event->attachments()), $this->attribute($this->logicalAnd($this->isInstanceOf('\\ArrayIterator'), $this->arrayHasKey('Description'), $this->contains('New Description')), 'changeList')));
$this->subscriber->processEvent($event);
}
示例8: testGetAccountUserRolePermission
/**
* @param boolean $isRolePredefined
* @param boolean $isGranted
* @param array $expected
*
* @dataProvider getAccountUserRolePermissionProvider
*/
public function testGetAccountUserRolePermission($isRolePredefined, $isGranted, array $expected)
{
$this->record->expects($this->any())->method('getValue')->with($this->isType('string'))->willReturn($isRolePredefined);
$this->securityFacade->expects($isRolePredefined ? $this->once() : $this->never())->method('isGranted')->with($this->isType('string'))->willReturn($isGranted);
$result = $this->actionPermissionProvider->getAccountUserRolePermission($this->record);
$this->assertCount(count($this->accountUserRoleActionList), $result);
foreach ($this->accountUserRoleActionList as $action) {
$this->assertArrayHasKey($action, $result);
}
$this->assertEquals($expected, $result);
}
示例9: setUp
protected function setUp()
{
$this->encryptor = new Mcrypt('someKey');
$user = $this->getMockBuilder('Oro\\Bundle\\UserBundle\\Entity\\User')->setMethods(['getOrganization'])->getMock();
$organization = $this->getMock('Oro\\Bundle\\OrganizationBundle\\Entity\\Organization');
$user->expects($this->any())->method('getOrganization')->willReturn($organization);
$this->securityFacade = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\SecurityFacade')->disableOriginalConstructor()->getMock();
$this->securityFacade->expects($this->any())->method('getLoggerUser')->willReturn($user);
$this->securityFacade->expects($this->any())->method('getOrganization')->willReturn($organization);
parent::setUp();
}
示例10: testSubmit
/**
* @dataProvider submitProvider
*
* @param AccountUser $defaultData
* @param array $submittedData
* @param AccountUser $expectedData
* @param bool|true $rolesGranted
*/
public function testSubmit(AccountUser $defaultData, array $submittedData, AccountUser $expectedData, $rolesGranted = true)
{
if ($rolesGranted) {
$this->securityFacade->expects($this->once())->method('isGranted')->with('orob2b_account_account_user_role_view')->will($this->returnValue(true));
}
$form = $this->factory->create($this->formType, $defaultData, []);
$this->assertEquals($defaultData, $form->getData());
$form->submit($submittedData);
$this->assertTrue($form->isValid());
$this->assertEquals($expectedData, $form->getData());
}
示例11: configureSecurityMock
/**
* @param bool $isGranted
* @param bool $isFieldAclEnabled
* @param bool $isFieldGranted
*/
protected function configureSecurityMock($isGranted, $isFieldAclEnabled, $isFieldGranted)
{
$this->containerMock->expects($this->at(0))->method('get')->with('oro_security.security_facade')->willReturn($this->securityMock);
$this->securityMock->expects($this->at(0))->method('isGranted')->with('EDIT', 'entity:Test\\Entity')->willReturn($isGranted);
if ($isFieldAclEnabled) {
$this->containerMock->expects($this->at(3))->method('get')->with('oro_security.security_facade')->willReturn($this->securityMock);
$this->securityMock->expects($this->at(1))->method('isGranted')->with('EDIT', $this->isInstanceOf('Symfony\\Component\\Security\\Acl\\Voter\\FieldVote'))->willReturn($isFieldGranted);
$doctrineHelperMock = $this->getMockBuilder('Oro\\Bundle\\EntityBundle\\ORM\\DoctrineHelper')->disableOriginalConstructor()->getMock();
$doctrineHelperMock->expects($this->once())->method('createEntityInstance')->with('Test\\Entity')->willReturn(new \stdClass());
$this->containerMock->expects($this->at(4))->method('get')->with('oro_entity.doctrine_helper')->willReturn($doctrineHelperMock);
}
}
示例12: testFilterQueryByUserIdWhenNoMailboxesFound
public function testFilterQueryByUserIdWhenNoMailboxesFound()
{
$user = new User();
$organization = new Organization();
$em = $this->getTestEntityManager();
$qb = $em->createQueryBuilder();
$this->securityFacade->expects($this->once())->method('getLoggedUser')->will($this->returnValue($user));
$this->securityFacade->expects($this->once())->method('getOrganization')->will($this->returnValue($organization));
$this->mailboxRepository->expects($this->any())->method('findAvailableMailboxIds')->with($user, $organization)->will($this->returnValue([1, 3, 5]));
$qb->select('eu')->from('EmailUser', 'eu');
$this->factory->applyAcl($qb, 1);
$this->assertEquals("SELECT eu FROM EmailUser eu" . " WHERE (eu.owner = :owner AND eu.organization = :organization) OR eu.mailboxOwner IN(:mailboxIds)", $qb->getQuery()->getDQL());
}
示例13: setUp
protected function setUp()
{
$user = $this->getMockBuilder('Oro\\Bundle\\UserBundle\\Entity\\User')->setMethods(['getOrganization'])->getMock();
$organization = $this->getMock('Oro\\Bundle\\OrganizationBundle\\Entity\\Organization');
$user->expects($this->any())->method('getOrganization')->willReturn($organization);
$this->securityFacade = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\SecurityFacade')->disableOriginalConstructor()->getMock();
$this->securityFacade->expects($this->any())->method('getLoggerUser')->willReturn($user);
$this->securityFacade->expects($this->any())->method('getOrganization')->willReturn($organization);
$this->translator = $this->getMockBuilder('Oro\\Bundle\\TranslationBundle\\Translation\\Translator')->disableOriginalConstructor()->getMock();
$this->userConfigManager = $this->getMockBuilder('Oro\\Bundle\\ConfigBundle\\Config\\ConfigManager')->disableOriginalConstructor()->getMock();
$this->configProvider = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->setMethods(['hasConfig', 'getConfig', 'get'])->disableOriginalConstructor()->getMock();
parent::setUp();
}
示例14: testGetInvitationPermissions
/**
* @param array $params
* @param array $expected
*
* @dataProvider permissionsDataProvider
*/
public function testGetInvitationPermissions(array $params, array $expected)
{
$record = $this->getMock('Oro\\Bundle\\DataGridBundle\\Datasource\\ResultRecordInterface');
$user = new User();
$user->setId(self::ADMIN);
$this->securityFacade->expects($this->any())->method('getLoggedUser')->will($this->returnValue($user));
$record->expects($this->at(0))->method('getValue')->with('invitationStatus')->will($this->returnValue($params['invitationStatus']));
$record->expects($this->at(1))->method('getValue')->with('parentId')->will($this->returnValue($params['parentId']));
$record->expects($this->at(2))->method('getValue')->with('ownerId')->will($this->returnValue($params['ownerId']));
$record->expects($this->at(3))->method('getValue')->with('childrenCount')->will($this->returnValue($params['childrenCount']));
$result = $this->provider->getInvitationPermissions($record);
$this->assertEquals($expected, $result);
}
示例15: getExtensions
/**
* @return array
*/
protected function getExtensions()
{
$account = $this->getAccount(1);
$user = new AccountUser();
$user->setAccount($account);
$this->securityFacade->expects($this->any())->method('getLoggedUser')->willReturn($user);
$frontendUserRoleSelectType = new EntitySelectTypeStub($this->getRoles(), FrontendAccountUserRoleSelectType::NAME, new AccountUserRoleSelectType());
$addressEntityType = new EntityType($this->getAddresses(), 'test_address_entity');
$accountSelectType = new AccountSelectTypeStub($this->getAccounts(), 'orob2b_account_select');
$accountUserType = new AccountUserType($this->securityFacade);
$accountUserType->setDataClass(self::DATA_CLASS);
$accountUserType->setAddressClass(self::ADDRESS_CLASS);
return [new PreloadedExtension([OroDateType::NAME => new OroDateType(), AccountUserType::NAME => $accountUserType, FrontendAccountUserRoleSelectType::NAME => $frontendUserRoleSelectType, $accountSelectType->getName() => $accountSelectType, AddressCollectionTypeStub::NAME => new AddressCollectionTypeStub(), $addressEntityType->getName() => $addressEntityType], []), new ValidatorExtension(Validation::createValidator())];
}