public function M4032404EventSubscriberTest::testAdminOnlyFailure in 403 to 404 8
Tests event handling for admin only routes when not admin route.
@covers ::onAccessDeniedException
File
- tests/
src/ Unit/ EventSubscriber/ M4032404EventSubscriberTest.php, line 122
Class
- M4032404EventSubscriberTest
- Tests for M4032404EventSubscriber.
Namespace
Drupal\Tests\m4032404\Unit\EventSubscriberCode
public function testAdminOnlyFailure() {
$this->configFactory = $this
->getConfigFactoryStub([
'm4032404.settings' => [
'admin_only' => TRUE,
],
]);
$this->adminContext
->method('isAdminRoute')
->willReturn(FALSE);
$subscriber = new M4032404EventSubscriber($this->configFactory, $this->adminContext, $this->currentUser);
$subscriber
->onAccessDeniedException($this->event);
$e = $this->event
->getException();
$this
->assertTrue($e instanceof AccessDeniedHttpException);
}