You are here

public function M4032404EventSubscriberTest::testHandleAll in 403 to 404 8

Tests event handling for all routes.

@covers ::onAccessDeniedException

File

tests/src/Unit/EventSubscriber/M4032404EventSubscriberTest.php, line 74

Class

M4032404EventSubscriberTest
Tests for M4032404EventSubscriber.

Namespace

Drupal\Tests\m4032404\Unit\EventSubscriber

Code

public function testHandleAll() {
  $this->configFactory = $this
    ->getConfigFactoryStub([
    'm4032404.settings' => [
      'admin_only' => FALSE,
    ],
  ]);
  $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 NotFoundHttpException);
}