You are here

public function RoutePreloaderTest::testOnRequestOnHtml in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php \Drupal\Tests\Core\Routing\RoutePreloaderTest::testOnRequestOnHtml()
  2. 9 core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php \Drupal\Tests\Core\Routing\RoutePreloaderTest::testOnRequestOnHtml()

Tests onRequest on a html request.

File

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

Class

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

Namespace

Drupal\Tests\Core\Routing

Code

public function testOnRequestOnHtml() {
  $event = $this
    ->getMockBuilder('\\Symfony\\Component\\HttpKernel\\Event\\KernelEvent')
    ->disableOriginalConstructor()
    ->getMock();
  $request = new Request();
  $request
    ->setRequestFormat('html');
  $event
    ->expects($this
    ->any())
    ->method('getRequest')
    ->will($this
    ->returnValue($request));
  $this->routeProvider
    ->expects($this
    ->once())
    ->method('preLoadRoutes')
    ->with([
    'test2',
  ]);
  $this->state
    ->expects($this
    ->once())
    ->method('get')
    ->with('routing.non_admin_routes')
    ->will($this
    ->returnValue([
    'test2',
  ]));
  $this->preloader
    ->onRequest($event);
}