function NegotiationMiddlewareTest::testHandle

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php \Drupal\Tests\Core\StackMiddleware\NegotiationMiddlewareTest::testHandle()
  2. 10 core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php \Drupal\Tests\Core\StackMiddleware\NegotiationMiddlewareTest::testHandle()
  3. 9 core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php \Drupal\Tests\Core\StackMiddleware\NegotiationMiddlewareTest::testHandle()
  4. 8.9.x core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php \Drupal\Tests\Core\StackMiddleware\NegotiationMiddlewareTest::testHandle()

Tests that handle() correctly hands off to sub application.

File

core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php, line 92

Class

NegotiationMiddlewareTest
Tests Drupal\Core\StackMiddleware\NegotiationMiddleware.

Namespace

Drupal\Tests\Core\StackMiddleware

Code

public function testHandle() : void {
  $request = new Request();
  // Calling kernel app with default arguments.
  $this->httpKernel
    ->handle($request, HttpKernelInterface::MAIN_REQUEST, TRUE)
    ->shouldBeCalled()
    ->willReturn($this->createStub(Response::class));
  $this->contentNegotiation
    ->handle($request);
  // No format was registered and none was requested, so the request format
  // should not have been set.
  $this->assertNull($request->getRequestFormat(NULL));
  // Calling kernel app with specified arguments.
  $this->httpKernel
    ->handle($request, HttpKernelInterface::SUB_REQUEST, FALSE)
    ->shouldBeCalled()
    ->willReturn($this->createStub(Response::class));
  $this->contentNegotiation
    ->handle($request, HttpKernelInterface::SUB_REQUEST, FALSE);
}

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