public function CurrentUserContextTest::testOnPageContext in Page Manager 8.4
Same name and namespace in other branches
- 8 tests/src/Unit/CurrentUserContextTest.php \Drupal\Tests\page_manager\Unit\CurrentUserContextTest::testOnPageContext()
@covers ::onPageContext
File
- tests/
src/ Unit/ CurrentUserContextTest.php, line 25
Class
- CurrentUserContextTest
- Tests the current user context.
Namespace
Drupal\Tests\page_manager\UnitCode
public function testOnPageContext() {
$currentUser = $this
->getMockBuilder(AccountProxyInterface::class)
->disableOriginalConstructor()
->getMock();
$contextRepository = $this
->getMockBuilder(LazyContextRepository::class)
->disableOriginalConstructor()
->getMock();
$currentUserContext = new EntityContext(new EntityContextDefinition('user', 'current_user_context'), $currentUser
->getAccount());
$contextRepository
->expects($this
->once())
->method('getRunTimeContexts')
->willReturn([
'@user.current_user_context:current_user' => $currentUserContext,
]);
$this->page
->addContext('@user.current_user_context:current_user', Argument::type(Context::class))
->shouldBeCalled()
->willReturn($this->page);
$this->page
->addContext('current_user', Argument::type(Context::class))
->shouldBeCalled()
->willReturn($this->page);
$route_param_context = new CurrentUserContext($contextRepository);
$route_param_context
->onPageContext($this->event);
}