You are here

protected function CustomPageExceptionHtmlSubscriberTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\CustomPageExceptionHtmlSubscriberTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php, line 76
Contains \Drupal\Tests\Core\EventSubscriber\CustomPageExceptionHtmlSubscriberTest.

Class

CustomPageExceptionHtmlSubscriberTest
@coversDefaultClass \Drupal\Core\EventSubscriber\CustomPageExceptionHtmlSubscriber @group EventSubscriber

Namespace

Drupal\Tests\Core\EventSubscriber

Code

protected function setUp() {
  $this->configFactory = $this
    ->getConfigFactoryStub([
    'system.site' => [
      'page.403' => 'access-denied-page',
      'page.404' => 'not-found-page',
    ],
  ]);
  $this->aliasManager = $this
    ->getMock('Drupal\\Core\\Path\\AliasManagerInterface');
  $this->kernel = $this
    ->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
  $this->logger = $this
    ->getMock('Psr\\Log\\LoggerInterface');
  $this->redirectDestination = $this
    ->getMock('\\Drupal\\Core\\Routing\\RedirectDestinationInterface');
  $this->redirectDestination
    ->expects($this
    ->any())
    ->method('getAsArray')
    ->willReturn([
    'destination' => 'test',
  ]);
  $this->customPageSubscriber = new CustomPageExceptionHtmlSubscriber($this->configFactory, $this->aliasManager, $this->kernel, $this->logger, $this->redirectDestination);

  // You can't create an exception in PHP without throwing it. Store the
  // current error_log, and disable it temporarily.
  $this->errorLog = ini_set('error_log', file_exists('/dev/null') ? '/dev/null' : 'nul');
}