public function renderMergesHttpResponseIfOutputIsHttpMessage()
{
$mockContext = $this->getMockBuilder(ContentContext::class)->disableOriginalConstructor()->getMock();
$mockNode = $this->getMockBuilder(NodeData::class)->disableOriginalConstructor()->getMock();
$mockContextualizedNode = $this->getMockBuilder(Node::class)->setMethods(array('getContext'))->setConstructorArgs(array($mockNode, $mockContext))->getMock();
$mockSiteNode = $this->createMock(NodeInterface::class);
$mockContext->expects($this->any())->method('getCurrentSiteNode')->will($this->returnValue($mockSiteNode));
$mockContext->expects($this->any())->method('getDimensions')->will($this->returnValue(array()));
$mockContextualizedNode->expects($this->any())->method('getContext')->will($this->returnValue($mockContext));
$mockResponse = $this->createMock(Response::class);
$mockControllerContext = $this->getMockBuilder(ControllerContext::class)->disableOriginalConstructor()->getMock();
$mockControllerContext->expects($this->any())->method('getResponse')->will($this->returnValue($mockResponse));
$mockRuntime = $this->getMockBuilder(Runtime::class)->disableOriginalConstructor()->getMock();
$mockRuntime->expects($this->any())->method('render')->will($this->returnValue("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\nMessage body"));
$mockRuntime->expects($this->any())->method('getControllerContext')->will($this->returnValue($mockControllerContext));
$mockTypoScriptService = $this->createMock(TypoScriptService::class);
$mockTypoScriptService->expects($this->any())->method('createRuntime')->will($this->returnValue($mockRuntime));
$mockSecurityContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
$view = $this->getAccessibleMock(TypoScriptView::class, array('getClosestDocumentNode'));
$view->expects($this->any())->method('getClosestDocumentNode')->will($this->returnValue($mockContextualizedNode));
$this->inject($view, 'securityContext', $mockSecurityContext);
$this->inject($view, 'controllerContext', $mockControllerContext);
$this->inject($view, 'typoScriptService', $mockTypoScriptService);
$view->_set('variables', array('value' => $mockContextualizedNode));
$mockResponse->expects($this->atLeastOnce())->method('setHeader')->with('Content-Type', 'application/json');
$output = $view->render();
$this->assertEquals('Message body', $output);
}