/**
  * @return void
  */
 public function setUp()
 {
     $this->viewHelperVariableContainer = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
     $this->viewHelperVariableContainer->expects($this->any())->method('exists')->will($this->returnCallback(array($this, 'viewHelperVariableContainerExistsCallback')));
     $this->viewHelperVariableContainer->expects($this->any())->method('get')->will($this->returnCallback(array($this, 'viewHelperVariableContainerGetCallback')));
     $this->templateVariableContainer = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer');
     $this->uriBuilder = $this->getMock('TYPO3\\Flow\\Mvc\\Routing\\UriBuilder');
     $this->uriBuilder->expects($this->any())->method('reset')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setArguments')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setSection')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setFormat')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setCreateAbsoluteUri')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setAddQueryString')->will($this->returnValue($this->uriBuilder));
     $this->uriBuilder->expects($this->any())->method('setArgumentsToBeExcludedFromQueryString')->will($this->returnValue($this->uriBuilder));
     // BACKPORTER TOKEN #1
     $httpRequest = \TYPO3\Flow\Http\Request::create(new \TYPO3\Flow\Http\Uri('http://localhost/foo'));
     $this->request = $this->getMock('TYPO3\\Flow\\Mvc\\ActionRequest', array(), array($httpRequest));
     $this->request->expects($this->any())->method('isMainRequest')->will($this->returnValue(TRUE));
     $this->controllerContext = $this->getMock('TYPO3\\Flow\\Mvc\\Controller\\ControllerContext', array(), array(), '', FALSE);
     $this->controllerContext->expects($this->any())->method('getUriBuilder')->will($this->returnValue($this->uriBuilder));
     $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
     $this->tagBuilder = $this->getMock('TYPO3\\Fluid\\Core\\ViewHelper\\TagBuilder');
     $this->arguments = array();
     $this->renderingContext = new \TYPO3\Fluid\Core\Rendering\RenderingContext();
     $this->renderingContext->injectTemplateVariableContainer($this->templateVariableContainer);
     $this->renderingContext->injectViewHelperVariableContainer($this->viewHelperVariableContainer);
     $this->renderingContext->setControllerContext($this->controllerContext);
 }
Пример #2
0
 public function addWrapper($name, $callback)
 {
     $wrap = array();
     if ($this->viewHelperVariableContainer->exists('Flowpack\\Expose\\ViewHelpers\\WrapViewHelper', $name)) {
         $wrap = $this->viewHelperVariableContainer->get('Flowpack\\Expose\\ViewHelpers\\WrapViewHelper', $name);
     }
     $wrap[] = $callback;
     $this->viewHelperVariableContainer->addOrUpdate('Flowpack\\Expose\\ViewHelpers\\WrapViewHelper', $name, $wrap);
 }
 /**
  * @test
  */
 public function viewCanBeReadOutAgain()
 {
     $view = $this->getMock(\TYPO3\Fluid\View\AbstractTemplateView::class, array('getTemplateSource', 'getLayoutSource', 'getPartialSource', 'hasTemplate', 'canRender', 'getTemplateIdentifier', 'getLayoutIdentifier', 'getPartialIdentifier'));
     $this->viewHelperVariableContainer->setView($view);
     $this->assertSame($view, $this->viewHelperVariableContainer->getView());
 }
 public function setUp()
 {
     parent::setUp();
     $this->nodeDataRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository');
     $domainRepository = $this->objectManager->get('TYPO3\\Neos\\Domain\\Repository\\DomainRepository');
     $siteRepository = $this->objectManager->get('TYPO3\\Neos\\Domain\\Repository\\SiteRepository');
     $this->contextFactory = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactoryInterface');
     $contextProperties = array('workspaceName' => 'live');
     $contentContext = $this->contextFactory->create($contextProperties);
     $siteImportService = $this->objectManager->get('TYPO3\\Neos\\Domain\\Service\\SiteImportService');
     $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('TYPO3\\Flow\\Property\\PropertyMapper');
     $this->viewHelper = new \TYPO3\Neos\ViewHelpers\Link\NodeViewHelper();
     /** @var $requestHandler \TYPO3\Flow\Tests\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('\\TYPO3\\TypoScript\\TypoScriptObjects\\TemplateImplementation', 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('TYPO3\\TypoScript\\TypoScriptObjects\\Helpers\\FluidView', 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();
 }
 /**
  * We empty the TemplateVariableContainer for this test, as it shouldn't be needed for rendering a link to a node
  * identified by ContextNodePath
  *
  * @test
  */
 public function viewHelperRendersUriViaContextNodePathString()
 {
     $this->assertSame('<a href="/en/home.html">Home</a>', $this->viewHelper->render('/sites/example/home@live'));
     $this->assertSame('<a href="/en/home/about-us.html">About Us Test</a>', $this->viewHelper->render('/sites/example/home/about-us@live'));
     $this->assertSame('<a href="/en/home/about-us/our-mission.html">Our mission</a>', $this->viewHelper->render('/sites/example/home/about-us/mission@live'));
     // The tests should also work in a regular fluid view, so we set that and repeat the tests
     $mockView = $this->getAccessibleMock('TYPO3\\Fluid\\View\\TemplateView', array(), array(), '', false);
     $viewHelperVariableContainer = new \TYPO3\Fluid\Core\ViewHelper\ViewHelperVariableContainer();
     $viewHelperVariableContainer->setView($mockView);
     $this->inject($this->viewHelper, 'viewHelperVariableContainer', $viewHelperVariableContainer);
     $this->assertSame('<a href="/en/home.html">Home</a>', $this->viewHelper->render('/sites/example/home@live'));
     $this->assertSame('<a href="/en/home/about-us.html">About Us Test</a>', $this->viewHelper->render('/sites/example/home/about-us@live'));
     $this->assertSame('<a href="/en/home/about-us/our-mission.html">Our mission</a>', $this->viewHelper->render('/sites/example/home/about-us/mission@live'));
 }
 /**
  * We empty the TemplateVariableContainer for this test, as it shouldn't be needed for rendering a link to a node
  * identified by ContextNodePath
  *
  * @test
  */
 public function viewHelperRendersUriViaContextNodePathString()
 {
     $this->assertOutputLinkValid('en/home.html', $this->viewHelper->render('/sites/example/home@live'));
     $this->assertOutputLinkValid('en/home/about-us.html', $this->viewHelper->render('/sites/example/home/about-us@live'));
     $this->assertOutputLinkValid('en/home/about-us/our-mission.html', $this->viewHelper->render('/sites/example/home/about-us/mission@live'));
     // The tests should also work in a regular fluid view, so we set that and repeat the tests
     $mockView = $this->getAccessibleMock(TemplateView::class, array(), array(), '', false);
     $viewHelperVariableContainer = new ViewHelperVariableContainer();
     $viewHelperVariableContainer->setView($mockView);
     $this->inject($this->viewHelper, 'viewHelperVariableContainer', $viewHelperVariableContainer);
     $this->assertOutputLinkValid('en/home.html', $this->viewHelper->render('/sites/example/home@live'));
     $this->assertOutputLinkValid('en/home/about-us.html', $this->viewHelper->render('/sites/example/home/about-us@live'));
     $this->assertOutputLinkValid('en/home/about-us/our-mission.html', $this->viewHelper->render('/sites/example/home/about-us/mission@live'));
 }
 /**
  * @test
  */
 public function viewIsPlacedInViewHelperVariableContainer()
 {
     $this->viewHelperVariableContainer->expects($this->once())->method('setView')->with($this->view);
     $this->view->setRenderingContext($this->renderingContext);
 }