public function NegotiationMiddlewareTest::testHandle in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php \Drupal\Tests\Core\StackMiddleware\NegotiationMiddlewareTest::testHandle()
Test that handle() correctly hands off to sub application.
@covers ::handle
File
- core/
tests/ Drupal/ Tests/ Core/ StackMiddleware/ NegotiationMiddlewareTest.php, line 94 - 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('html')
->shouldBeCalled();
// Some getContentType calls we don't really care about but have to mock.
$request
->get('ajax_iframe_upload', false)
->shouldBeCalled();
$request_mock = $request
->reveal();
$request_mock->query = new ParameterBag([]);
// Calling kernel app with default arguments.
$this->app
->handle($request_mock, HttpKernelInterface::MASTER_REQUEST, TRUE)
->shouldBeCalled();
$this->contentNegotiation
->handle($request_mock);
// Calling kernel app with specified arguments.
$this->app
->handle($request_mock, HttpKernelInterface::SUB_REQUEST, FALSE)
->shouldBeCalled();
$this->contentNegotiation
->handle($request_mock, HttpKernelInterface::SUB_REQUEST, FALSE);
}