function RoutePreloaderTest::testOnRequestNonHtml

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php \Drupal\Tests\Core\Routing\RoutePreloaderTest::testOnRequestNonHtml()
  2. 8.9.x core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php \Drupal\Tests\Core\Routing\RoutePreloaderTest::testOnRequestNonHtml()
  3. 11.x core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php \Drupal\Tests\Core\Routing\RoutePreloaderTest::testOnRequestNonHtml()

Tests onRequest on a non html request.

File

core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php, line 137

Class

RoutePreloaderTest
@coversDefaultClass \Drupal\Core\Routing\RoutePreloader @group Routing

Namespace

Drupal\Tests\Core\Routing

Code

public function testOnRequestNonHtml() : void {
    $event = $this->getMockBuilder('\\Symfony\\Component\\HttpKernel\\Event\\KernelEvent')
        ->disableOriginalConstructor()
        ->getMock();
    $request = new Request();
    $request->setRequestFormat('non-html');
    $event->expects($this->any())
        ->method('getRequest')
        ->willReturn($request);
    $this->routeProvider
        ->expects($this->never())
        ->method('getRoutesByNames');
    $this->state
        ->expects($this->never())
        ->method('get');
    $this->preloader
        ->onRequest($event);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.