/** * Sets up a view with context for testing * * @return void */ public function setUpMockView() { $this->mockContext = $this->getMockBuilder(ContentContext::class)->disableOriginalConstructor()->getMock(); $mockNode = $this->getMockBuilder(NodeData::class)->disableOriginalConstructor()->getMock(); $this->mockContextualizedNode = $this->getMockBuilder(Node::class)->setMethods(array('getContext'))->setConstructorArgs(array($mockNode, $this->mockContext))->getMock(); $mockSiteNode = $this->createMock(NodeInterface::class); $this->mockContext->expects($this->any())->method('getCurrentSiteNode')->will($this->returnValue($mockSiteNode)); $this->mockContext->expects($this->any())->method('getDimensions')->will($this->returnValue(array())); $this->mockContextualizedNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContext)); $this->mockRuntime = $this->getMockBuilder(Runtime::class)->disableOriginalConstructor()->getMock(); $mockControllerContext = $this->getMockBuilder(ControllerContext::class)->disableOriginalConstructor()->getMock(); $this->mockSecurityContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); $mockTypoScriptService = $this->createMock(TypoScriptService::class); $mockTypoScriptService->expects($this->any())->method('createRuntime')->will($this->returnValue($this->mockRuntime)); $this->mockView = $this->getAccessibleMock(TypoScriptView::class, array('getClosestDocumentNode')); $this->mockView->expects($this->any())->method('getClosestDocumentNode')->will($this->returnValue($this->mockContextualizedNode)); $this->inject($this->mockView, 'controllerContext', $mockControllerContext); $this->inject($this->mockView, 'securityContext', $this->mockSecurityContext); $this->inject($this->mockView, 'typoScriptService', $mockTypoScriptService); $this->mockView->_set('variables', array('value' => $this->mockContextualizedNode)); }