コード例 #1
0
 /**
  * @return void
  */
 public function setUp()
 {
     $this->viewHelperVariableContainer = $this->createMock(\TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperVariableContainer::class);
     $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->createMock(TemplateVariableContainer::class);
     $this->uriBuilder = $this->createMock(\Neos\Flow\Mvc\Routing\UriBuilder::class);
     $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 = \Neos\Flow\Http\Request::create(new \Neos\Flow\Http\Uri('http://localhost/foo'));
     $this->request = $this->getMockBuilder(\Neos\Flow\Mvc\ActionRequest::class)->setConstructorArgs(array($httpRequest))->getMock();
     $this->request->expects($this->any())->method('isMainRequest')->will($this->returnValue(true));
     $this->controllerContext = $this->getMockBuilder(\Neos\Flow\Mvc\Controller\ControllerContext::class)->disableOriginalConstructor()->getMock();
     $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->createMock(TagBuilder::class);
     $this->arguments = array();
     $this->renderingContext = new \Neos\FluidAdaptor\Core\Rendering\RenderingContext(new StandaloneView(), []);
     $this->renderingContext->setVariableProvider($this->templateVariableContainer);
     $this->renderingContext->setViewHelperVariableContainer($this->viewHelperVariableContainer);
     $this->renderingContext->setControllerContext($this->controllerContext);
 }
コード例 #2
0
 /**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->subject = $this->getMock(RenderViewHelper::class, array('renderChildren'));
     $this->view = $this->getMock(TemplateView::class, array('renderPartial', 'renderSection'));
     $this->view->setRenderingContext($this->renderingContext);
     $container = new ViewHelperVariableContainer();
     $container->setView($this->view);
     $this->renderingContext->setViewHelperVariableContainer($container);
     $this->subject->setRenderingContext($this->renderingContext);
 }
コード例 #3
0
 /**
  * Helper function for the bound property
  *
  * @param $formObject
  */
 protected function stubVariableContainer($formObject)
 {
     $this->viewHelperVariableContainer->exists(Argument::cetera())->willReturn(true);
     $this->viewHelperVariableContainer->get(Argument::any(), 'formObjectName')->willReturn('objectName');
     $this->viewHelperVariableContainer->get(Argument::any(), 'fieldNamePrefix')->willReturn('fieldPrefix');
     $this->viewHelperVariableContainer->get(Argument::any(), 'formFieldNames')->willReturn([]);
     $this->viewHelperVariableContainer->get(Argument::any(), 'formObject')->willReturn($formObject);
     $this->viewHelperVariableContainer->get(Argument::any(), 'renderedHiddenFields')->willReturn([]);
     $this->viewHelperVariableContainer->addOrUpdate(Argument::cetera())->willReturn(null);
 }
コード例 #4
0
 /**
  * @test
  * @dataProvider getRenderTestValues
  * @param array $arguments
  * @param string|NULL $expectedViewMethod
  */
 public function testRender(array $arguments, $expectedViewMethod)
 {
     if ($expectedViewMethod) {
         $methods = array($expectedViewMethod);
     } else {
         $methods = array('renderPartial', 'renderSection');
     }
     $instance = $this->getMock('TYPO3Fluid\\Fluid\\ViewHelpers\\RenderViewHelper', array('renderChildren'));
     $instance->expects($this->any())->method('renderChildren')->willReturn(NULL);
     $renderingContext = new RenderingContext();
     $paths = $this->getMock('TYPO3Fluid\\Fluid\\View\\TemplatePaths', array('sanitizePath'));
     $paths->expects($this->any())->method('sanitizePath')->willReturnArgument(0);
     $viewHelperVariableContainer = new ViewHelperVariableContainer();
     $view = $this->getMock('TYPO3Fluid\\Fluid\\View\\TemplateView', $methods, array($paths, $renderingContext));
     $viewHelperVariableContainer->setView($view);
     $renderingContext->injectViewHelperVariableContainer($viewHelperVariableContainer);
     $instance->setArguments($arguments);
     $instance->setRenderingContext($renderingContext);
     $instance->render();
 }
コード例 #5
0
 /**
  * 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(TemplateView::class, array(), array(), '', false);
     $viewHelperVariableContainer = new 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'));
 }
コード例 #6
0
 /**
  * @test
  */
 public function testGetReturnsDefaultIfRequestedVariableDoesNotExist()
 {
     $subject = new ViewHelperVariableContainer();
     $this->assertEquals('test', $subject->get('foo', 'bar', 'test'));
 }
コード例 #7
0
ファイル: CycleViewHelper.php プロジェクト: typo3/fluid
 /**
  * @param string $as
  * @param ViewHelper\ViewHelperVariableContainer $viewHelperVariableContainer
  * @return integer
  */
 protected static function initializeIndex($as, ViewHelper\ViewHelperVariableContainer $viewHelperVariableContainer)
 {
     $index = 0;
     if ($viewHelperVariableContainer->exists(static::class, $as)) {
         $index = $viewHelperVariableContainer->get(static::class, $as);
     }
     return $index;
 }
コード例 #8
0
 /**
  * @test
  */
 public function viewIsPlacedInViewHelperVariableContainer()
 {
     $this->viewHelperVariableContainer->expects($this->once())->method('setView')->with($this->view);
     $this->view->setRenderingContext($this->renderingContext);
 }