Neos\Neos\Tests\Functional\ViewHelpers\Link\NodeViewHelperTest::setUp PHP Метод

setUp() публичный Метод

public setUp ( )
    public function setUp()
    {
        parent::setUp();
        $this->router->setRoutesConfiguration(null);
        $this->nodeDataRepository = $this->objectManager->get(NodeDataRepository::class);
        $domainRepository = $this->objectManager->get(DomainRepository::class);
        $siteRepository = $this->objectManager->get(SiteRepository::class);
        $this->contextFactory = $this->objectManager->get(ContextFactoryInterface::class);
        $contextProperties = array('workspaceName' => 'live');
        $contentContext = $this->contextFactory->create($contextProperties);
        $siteImportService = $this->objectManager->get(SiteImportService::class);
        $siteImportService->importFromFile(__DIR__ . '/../../Fixtures/NodeStructure.xml', $contentContext);
        $this->persistenceManager->persistAll();
        /** @var Domain $currentDomain */
        $currentDomain = $domainRepository->findOneByActiveRequest();
        if ($currentDomain !== null) {
            $contextProperties['currentSite'] = $currentDomain->getSite();
            $contextProperties['currentDomain'] = $currentDomain;
        } else {
            $contextProperties['currentSite'] = $siteRepository->findFirst();
        }
        $contentContext = $this->contextFactory->create($contextProperties);
        $this->contentContext = $contentContext;
        $this->propertyMapper = $this->objectManager->get(PropertyMapper::class);
        $this->viewHelper = new NodeViewHelper();
        /** @var $requestHandler FunctionalTestRequestHandler */
        $requestHandler = self::$bootstrap->getActiveRequestHandler();
        $httpRequest = $requestHandler->getHttpRequest();
        $httpRequest->setBaseUri(new Uri('http://neos.test/'));
        $controllerContext = new ControllerContext(new ActionRequest($httpRequest), $requestHandler->getHttpResponse(), new Arguments(array()), new UriBuilder());
        $this->inject($this->viewHelper, 'controllerContext', $controllerContext);
        $typoScriptObject = $this->getAccessibleMock(TemplateImplementation::class, array('dummy'), array(), '', false);
        $this->tsRuntime = new Runtime(array(), $controllerContext);
        $this->tsRuntime->pushContextArray(array('documentNode' => $this->contentContext->getCurrentSiteNode()->getNode('home'), 'alternativeDocumentNode' => $this->contentContext->getCurrentSiteNode()->getNode('home/about-us/mission')));
        $this->inject($typoScriptObject, 'tsRuntime', $this->tsRuntime);
        /** @var AbstractTemplateView|\PHPUnit_Framework_MockObject_MockObject $mockView */
        $mockView = $this->getAccessibleMock(FluidView::class, array(), array(), '', false);
        $mockView->expects($this->any())->method('getTypoScriptObject')->will($this->returnValue($typoScriptObject));
        $viewHelperVariableContainer = new ViewHelperVariableContainer();
        $viewHelperVariableContainer->setView($mockView);
        $this->inject($this->viewHelper, 'viewHelperVariableContainer', $viewHelperVariableContainer);
        $templateVariableContainer = new TemplateVariableContainer(array());
        $this->inject($this->viewHelper, 'templateVariableContainer', $templateVariableContainer);
        $this->viewHelper->setRenderChildrenClosure(function () use($templateVariableContainer) {
            $linkedNode = $templateVariableContainer->get('linkedNode');
            return $linkedNode !== null ? $linkedNode->getLabel() : '';
        });
        $this->viewHelper->initialize();
    }