本文整理汇总了PHP中eZ\Publish\API\Repository\Repository::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::expects方法的具体用法?PHP Repository::expects怎么用?PHP Repository::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\API\Repository\Repository
的用法示例。
在下文中一共展示了Repository::expects方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testVote
/**
* @dataProvider voteProvider
*/
public function testVote(Attribute $attribute, $repositoryCanUser, $expectedResult)
{
$voter = new ValueObjectVoter($this->repository);
$targets = isset($attribute->limitations['targets']) ? $attribute->limitations['targets'] : null;
$this->repository->expects($this->once())->method('canUser')->with($attribute->module, $attribute->function, $attribute->limitations['valueObject'], $targets)->will($this->returnValue($repositoryCanUser));
$this->assertSame($expectedResult, $voter->vote($this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface'), new \stdClass(), array($attribute)));
}
示例2: testVote
/**
* @dataProvider voteProvider
*/
public function testVote(Attribute $attribute, $repositoryCanUser, $expectedResult)
{
$voter = new CoreVoter($this->repository);
if ($repositoryCanUser !== null) {
$this->repository->expects($this->once())->method('hasAccess')->with($attribute->module, $attribute->function)->will($this->returnValue($repositoryCanUser));
} else {
$this->repository->expects($this->never())->method('hasAccess');
}
$this->assertSame($expectedResult, $voter->vote($this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface'), new \stdClass(), array($attribute)));
}
示例3: testAuthenticate
public function testAuthenticate()
{
$anonymousUserId = 10;
$this->configResolver->expects($this->once())->method('getParameter')->with('anonymous_user_id')->will($this->returnValue($anonymousUserId));
$this->repository->expects($this->once())->method('setCurrentUser')->with(new UserReference($anonymousUserId));
$key = 'some_key';
$authProvider = new AnonymousAuthenticationProvider($key);
$authProvider->setRepository($this->repository);
$authProvider->setConfigResolver($this->configResolver);
$anonymousToken = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\AnonymousToken')->setConstructorArgs(array($key, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface')))->getMockForAbstractClass();
$this->assertSame($anonymousToken, $authProvider->authenticate($anonymousToken));
}
示例4: testOnKernelBuilt
public function testOnKernelBuilt()
{
$kernelHandler = $this->getMock('ezpWebBasedKernelHandler');
$legacyKernel = $this->getMockBuilder('eZ\\Publish\\Core\\MVC\\Legacy\\Kernel')->setConstructorArgs(array($kernelHandler, 'foo', 'bar'))->getMock();
$event = new PostBuildKernelEvent($legacyKernel, $kernelHandler);
$this->configResolver->expects($this->once())->method('getParameter')->with('legacy_mode')->will($this->returnValue(false));
$this->securityContext->expects($this->once())->method('isGranted')->with('IS_AUTHENTICATED_REMEMBERED')->will($this->returnValue(true));
$userId = 123;
$user = $this->generateUser($userId);
$this->repository->expects($this->once())->method('getCurrentUser')->will($this->returnValue($user));
$legacyKernel->expects($this->once())->method('runCallback');
$listener = new Security($this->repository, $this->configResolver, $this->securityContext);
$listener->onKernelBuilt($event);
}
示例5: testCheckAuthentication
public function testCheckAuthentication()
{
$user = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\Security\\User');
$userName = 'my_username';
$password = 'foo';
$token = new UsernamePasswordToken($userName, $password, 'bar');
$apiUser = $this->getMockForAbstractClass('eZ\\Publish\\API\\Repository\\Values\\User\\User');
$userService = $this->getMock('eZ\\Publish\\API\\Repository\\UserService');
$userService->expects($this->once())->method('loadUserByCredentials')->with($userName, $password)->will($this->returnValue($apiUser));
$this->repository->expects($this->once())->method('getUserService')->will($this->returnValue($userService));
$this->repository->expects($this->once())->method('setCurrentUser')->with($apiUser);
$method = new \ReflectionMethod($this->authProvider, 'checkAuthentication');
$method->setAccessible(true);
$method->invoke($this->authProvider, $user, $token);
}
示例6: testRenderLocationWithClosure
public function testRenderLocationWithClosure()
{
$content = new Content(['versionInfo' => new VersionInfo(['contentInfo' => new ContentInfo()])]);
$location = new Location(['contentInfo' => new ContentInfo()]);
// Configuring view provider behaviour
$closure = function ($params) {
return serialize(array_keys($params));
};
$params = array('foo' => 'bar');
$this->viewConfigurator->expects($this->once())->method('configure')->will($this->returnCallback(function (View $view) use($closure) {
$view->setTemplateIdentifier($closure);
}));
$contentService = $this->getMockBuilder('eZ\\Publish\\Core\\Repository\\ContentService')->disableOriginalConstructor()->getMock();
$contentService->expects($this->any())->method('loadContentByContentInfo')->with($content->contentInfo)->will($this->returnValue($content));
$this->repositoryMock->expects($this->any())->method('getContentService')->will($this->returnValue($contentService));
// Configuring template engine behaviour
$params += array('location' => $location, 'content' => $content, 'viewbaseLayout' => $this->viewBaseLayout);
$this->templateEngineMock->expects($this->never())->method('render');
$expectedTemplateResult = array_keys($params);
$templateResult = unserialize($this->viewManager->renderLocation($location, 'full', $params));
sort($expectedTemplateResult);
sort($templateResult);
self::assertSame($expectedTemplateResult, $templateResult);
}