You are here

public function EdgeExceptionSubscriberTest::testOnExceptionErrorsOff in Apigee Edge 8

Test OnExceptionErrors method will not show errors.

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

File

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

Class

EdgeExceptionSubscriberTest
Test EdgeExceptionSubscriber.

Namespace

Drupal\Tests\apigee_edge\Unit\EventSubscriber

Code

public function testOnExceptionErrorsOff() {

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

  // Messenger should not be adding error since show debug messages is false.
  $this->messenger
    ->addError(Argument::type('string'))
    ->shouldNotBeCalled();
  $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());
}