public function NegotiationMiddlewareTest::testHandle in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php \Drupal\Tests\Core\StackMiddleware\NegotiationMiddlewareTest::testHandle()
- 9 core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php \Drupal\Tests\Core\StackMiddleware\NegotiationMiddlewareTest::testHandle()
Tests that handle() correctly hands off to sub application.
@covers ::handle
File
- core/
tests/ Drupal/ Tests/ Core/ StackMiddleware/ NegotiationMiddlewareTest.php, line 95 - Contains \Drupal\Tests\Core\StackMiddleware\NegotiationMiddlewareTest.
Class
- NegotiationMiddlewareTest
- @coversDefaultClass \Drupal\Core\StackMiddleware\NegotiationMiddleware @group NegotiationMiddleware
Namespace
Drupal\Tests\Core\StackMiddlewareCode
public function testHandle() {
$request = $this
->prophesize(Request::class);
// Default empty format list should not set any formats.
$request
->setFormat()
->shouldNotBeCalled();
// Request format will be set with default format.
$request
->setRequestFormat()
->shouldNotBeCalled();
// Some getContentType calls we don't really care about but have to mock.
$request_data = $this
->prophesize(ParameterBag::class);
$request_data
->get('ajax_iframe_upload', FALSE)
->willReturn(FALSE)
->shouldBeCalled();
$request_mock = $request
->reveal();
$request_mock->query = new ParameterBag([]);
$request_mock->request = $request_data
->reveal();
// Calling kernel app with default arguments.
$this->app
->handle($request_mock, HttpKernelInterface::MAIN_REQUEST, TRUE)
->shouldBeCalled()
->willReturn($this
->createMock(Response::class));
$this->contentNegotiation
->handle($request_mock);
// Calling kernel app with specified arguments.
$this->app
->handle($request_mock, HttpKernelInterface::SUB_REQUEST, FALSE)
->shouldBeCalled()
->willReturn($this
->createMock(Response::class));
$this->contentNegotiation
->handle($request_mock, HttpKernelInterface::SUB_REQUEST, FALSE);
}