function NegotiationMiddlewareTest::testSetFormat

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

Tests set format.

@legacy-covers ::registerFormat

File

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

Class

NegotiationMiddlewareTest
Tests Drupal\Core\StackMiddleware\NegotiationMiddleware.

Namespace

Drupal\Tests\Core\StackMiddleware

Code

public function testSetFormat() : void {
  $httpKernel = $this->createMock(HttpKernelInterface::class);
  $httpKernel->expects($this->once())
    ->method('handle')
    ->willReturn($this->createStub(Response::class));
  $content_negotiation = new StubNegotiationMiddleware($httpKernel);
  $request = new Request();
  // Trigger handle.
  $content_negotiation->registerFormat('david', 'geeky/david');
  $content_negotiation->handle($request);
  $this->assertSame('geeky/david', $request->getMimeType('david'));
}

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