public function testCheckAccess_WithInvalidRequest_WhenUserIsGuest() { $event = $this->prepareEvent(); $this->authServiceMock->expects($this->once())->method('getIdentity')->will($this->returnValue(null)); $this->namesResolverMock->expects($this->once())->method('resolve')->with($event)->will($this->returnValue(['module', 'controller', 'action'])); $this->aclMock->expects($this->once())->method('isAllowed')->with(UserEntityInterface::ROLE_GUEST, 'module', 'controller:action')->will($this->returnValue(false)); /** @var Response $result */ $result = $this->testedObject->checkAccess($event); $this->assertInstanceOf(ResponseInterface::class, $result); /** @var Location $location */ $location = $result->getHeaders()->get('Location'); $this->assertSame($location->getUri(), self::URL_LOGIN); }
public function onDispatch(MvcEvent $e) { $this->checkAclService->checkAccess($e); }