function NegotiationMiddlewareTest::testUnknownContentTypeButAjaxRequest

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

Tests the getContentType() method when no priority format is found but it's an AJAX request.

@covers ::getContentType

File

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

Class

NegotiationMiddlewareTest
@coversDefaultClass \Drupal\Core\StackMiddleware\NegotiationMiddleware[[api-linebreak]] @group NegotiationMiddleware

Namespace

Drupal\Tests\Core\StackMiddleware

Code

public function testUnknownContentTypeButAjaxRequest() {
  $request = new Request();
  $request->headers
    ->set('X-Requested-With', 'XMLHttpRequest');
  $this->assertNull($this->contentNegotiation
    ->getContentType($request));
}

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