You are here

public function EdgeExceptionSubscriberTest::testOnExceptionErrorsOn in Apigee Edge 8

Test OnException method will show errors.

When error_page_debug_messages config is set, the exception message should be displayed.

File

tests/src/Unit/EventSubscriber/EdgeExceptionSubscriberTest.php, line 159

Class

EdgeExceptionSubscriberTest
Test EdgeExceptionSubscriber.

Namespace

Drupal\Tests\apigee_edge\Unit\EventSubscriber

Code

public function testOnExceptionErrorsOn() {

  // Config will return true when checked.
  $config_error_page = $this
    ->prophesize(Config::class);
  $config_error_page
    ->get(Argument::is('error_page_debug_messages'))
    ->shouldBeCalledTimes(1)
    ->willReturn(TRUE);
  $this->configFactory = $this
    ->prophesize(ConfigFactoryInterface::class);
  $this->configFactory
    ->get(Argument::is('apigee_edge.error_page'))
    ->willReturn($config_error_page
    ->reveal());

  // Error should be displayed since show debug messages config is on.
  $this->messenger
    ->addError(Argument::is($this->exception
    ->getMessage()))
    ->shouldBeCalledTimes(1);
  $edge_exception_subscriber = new EdgeExceptionSubscriber($this->logger
    ->reveal(), $this->configFactory
    ->reveal(), $this->messenger
    ->reveal(), $this->classResolver
    ->reveal(), $this->routeMatch
    ->reveal(), $this->mainContentRenderers);
  $edge_exception_subscriber
    ->onException($this->getResponseForExceptionEvent
    ->reveal());
}