Example #1
0
 /**
  * @test
  */
 public function testGetLayoutName()
 {
     $context = new RenderingContext();
     $context->getVariableProvider()->add('layoutName', 'test');
     $result = $this->parsingState->getLayoutName($context);
     $this->assertEquals('test', $result);
 }
Example #2
0
 /**
  * @test
  */
 public function testGetViewHelperResolverReturnsExpectedViewHelperResolver()
 {
     $viewHelperResolver = $this->getMock(ViewHelperResolver::class);
     $this->renderingContext->setViewHelperResolver($viewHelperResolver);
     $result = $this->view->getViewHelperResolver();
     $this->assertSame($viewHelperResolver, $result);
 }
 /**
  * @dataProvider getEvaluateExpressionTestValues
  * @param string $expression
  * @param array $variables
  * @param mixed $expected
  */
 public function testEvaluateExpression($expression, array $variables, $expected)
 {
     $renderingContext = new RenderingContext();
     $renderingContext->setVariableProvider(new StandardVariableProvider($variables));
     $result = CastingExpressionNode::evaluateExpression($renderingContext, $expression, array());
     $this->assertEquals($expected, $result);
 }
 /**
  * @return void
  */
 public function setUp()
 {
     $this->viewHelperVariableContainer = new ViewHelperVariableContainer();
     $this->templateVariableContainer = new StandardVariableProvider();
     $this->renderingContext = new RenderingContextFixture();
     $this->renderingContext->setVariableProvider($this->templateVariableContainer);
     $this->renderingContext->setViewHelperVariableContainer($this->viewHelperVariableContainer);
 }
Example #5
0
 /**
  * @dataProvider getEvaluateExpressionTestValues
  * @param string $expression
  * @param array $variables
  * @param mixed $expected
  */
 public function testEvaluateExpression($expression, array $variables, $expected)
 {
     $view = new TemplateView();
     $renderingContext = new RenderingContext($view);
     $renderingContext->setVariableProvider(new StandardVariableProvider($variables));
     $result = MathExpressionNode::evaluateExpression($renderingContext, $expression, []);
     $this->assertEquals($expected, $result);
 }
Example #6
0
 /**
  * Sets up the view
  */
 public function __construct()
 {
     $this->view = GeneralUtility::makeInstance(TemplateView::class);
     $context = new RenderingContext($this->view);
     $context->setControllerName('ErrorPage');
     $context->setTemplatePaths(new TemplatePaths(['templateRootPaths' => [ExtensionManagementUtility::extPath('core', 'Resources/Private/Templates/ErrorPage/')]]));
     $this->view->setRenderingContext($context);
 }
Example #7
0
 /**
  * @test
  */
 public function testEvaluateCallsInvoker()
 {
     $invoker = $this->getMock(ViewHelperInvoker::class, ['invoke']);
     $invoker->expects($this->once())->method('invoke')->willReturn('test');
     $this->renderingContext->setViewHelperInvoker($invoker);
     $node = new ViewHelperNode($this->renderingContext, 'f', 'vh', ['foo' => 'bar'], new ParsingState());
     $result = $node->evaluate($this->renderingContext);
     $this->assertEquals('test', $result);
 }
Example #8
0
 /**
  * Constructor
  *
  * @param null|RenderingContextInterface $context
  */
 public function __construct(RenderingContextInterface $context = NULL)
 {
     if (!$context) {
         $context = new RenderingContext($this);
         $context->setControllerName('Default');
         $context->setControllerAction('Default');
     }
     $this->setRenderingContext($context);
 }
 /**
  * Sets up this test case
  *
  * @return void
  */
 public function setUp()
 {
     $this->templateVariableContainer = $this->getMock('TYPO3Fluid\\Fluid\\Core\\Variables\\StandardVariableProvider', array('exists', 'remove', 'add'));
     $this->viewHelperVariableContainer = $this->getMock('TYPO3Fluid\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer', array('setView'));
     $this->renderingContext = $this->getMock('TYPO3Fluid\\Fluid\\Core\\Rendering\\RenderingContext', array('getViewHelperVariableContainer', 'getVariableProvider'));
     $this->renderingContext->expects($this->any())->method('getViewHelperVariableContainer')->will($this->returnValue($this->viewHelperVariableContainer));
     $this->renderingContext->expects($this->any())->method('getVariableProvider')->will($this->returnValue($this->templateVariableContainer));
     $this->view = $this->getMockForAbstractClass('TYPO3Fluid\\Fluid\\View\\AbstractTemplateView', array(new TemplatePaths()));
     $this->view->setRenderingContext($this->renderingContext);
 }
Example #10
0
 /**
  * @test
  */
 public function testEvaluateCallsInvoker()
 {
     $resolver = $this->getMock('TYPO3Fluid\\Fluid\\Core\\ViewHelper\\ViewHelperResolver', array('resolveViewHelperInvoker'));
     $invoker = $this->getMock('TYPO3Fluid\\Fluid\\Core\\ViewHelper\\ViewHelperInvoker', array('invoke'), array($resolver));
     $resolver->expects($this->once())->method('resolveViewHelperInvoker')->willReturn($invoker);
     $invoker->expects($this->once())->method('invoke')->willReturn('test');
     $node = new ViewHelperNode($resolver, 'f', 'count', array(), new ParsingState());
     $context = new RenderingContext();
     $context->setViewHelperResolver($resolver);
     $result = $node->evaluate($context);
     $this->assertEquals('test', $result);
 }
Example #11
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();
 }
Example #12
0
 /**
  * Constructor
  *
  * @param TemplatePaths $paths
  * @param RenderingContext $context
  * @param FluidCacheInterface $cache
  */
 public function __construct(TemplatePaths $paths, RenderingContext $context = NULL, FluidCacheInterface $cache = NULL)
 {
     if (!$context) {
         $context = new RenderingContext();
         $context->setControllerName('Default');
         $context->setControllerAction('Default');
         $context->setVariableProvider(new StandardVariableProvider($this->variables));
         $context->injectViewHelperVariableContainer(new ViewHelperVariableContainer());
     }
     $this->templatePaths = $paths;
     $this->viewHelperResolver = new ViewHelperResolver();
     $this->setRenderingContext($context);
     $this->setTemplateCompiler(new TemplateCompiler($this->viewHelperResolver));
     $this->setTemplateParser(new TemplateParser($this->viewHelperResolver));
     $this->templateCompiler->setTemplateCache($cache);
 }
Example #13
0
 /**
  * @param array $variables
  * @return RenderingContext
  */
 protected function getDummyRenderingContextWithVariables(array $variables)
 {
     $context = new RenderingContext();
     $context->getVariableProvider()->setSource($variables);
     return $context;
 }
 /**
  * @test
  */
 public function setRenderingContextShouldSetInnerVariables()
 {
     $templateVariableContainer = $this->getMock(StandardVariableProvider::class);
     $viewHelperVariableContainer = $this->getMock(ViewHelperVariableContainer::class);
     $view = new TemplateView();
     $renderingContext = new RenderingContext($view);
     $renderingContext->setVariableProvider($templateVariableContainer);
     $renderingContext->setViewHelperVariableContainer($viewHelperVariableContainer);
     $viewHelper = $this->getAccessibleMock(AbstractViewHelper::class, array('prepareArguments'), array(), '', FALSE);
     $viewHelper->setRenderingContext($renderingContext);
     $this->assertSame($viewHelper->_get('templateVariableContainer'), $templateVariableContainer);
     $this->assertSame($viewHelper->_get('viewHelperVariableContainer'), $viewHelperVariableContainer);
 }
 /**
  * @test
  */
 public function testAddCompiledNamespacesDoesNothing()
 {
     $instance = $this->getMockForAbstractClass('TYPO3Fluid\\Fluid\\Core\\Compiler\\AbstractCompiledTemplate');
     $context = new RenderingContext();
     $before = $context->getViewHelperResolver()->getNamespaces();
     $instance->addCompiledNamespaces($context);
     $after = $context->getViewHelperResolver()->getNamespaces();
     $this->assertEquals($before, $after);
 }
 /**
  * @test
  */
 public function setRenderingContextShouldSetInnerVariables()
 {
     $templateVariableContainer = $this->getMock('TYPO3Fluid\\Fluid\\Core\\Variables\\StandardVariableProvider');
     $viewHelperVariableContainer = $this->getMock('TYPO3Fluid\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
     $renderingContext = new RenderingContext();
     $renderingContext->setVariableProvider($templateVariableContainer);
     $renderingContext->injectViewHelperVariableContainer($viewHelperVariableContainer);
     $viewHelper = $this->getAccessibleMock('TYPO3Fluid\\Fluid\\Core\\ViewHelper\\AbstractViewHelper', array('render', 'prepareArguments'), array(), '', FALSE);
     $viewHelper->setRenderingContext($renderingContext);
     $this->assertSame($viewHelper->_get('templateVariableContainer'), $templateVariableContainer);
     $this->assertSame($viewHelper->_get('viewHelperVariableContainer'), $viewHelperVariableContainer);
 }
 /**
  * @param string $controllerName
  * @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidControllerNameException
  */
 public function setControllerName($controllerName)
 {
     parent::setControllerName($controllerName);
     $this->controllerContext->getRequest()->setControllerName($controllerName);
 }
 /**
  * Build parser configuration
  *
  * @return Configuration
  */
 public function buildParserConfiguration()
 {
     $parserConfiguration = parent::buildParserConfiguration();
     $parserConfiguration->addInterceptor(new ResourceInterceptor());
     return $parserConfiguration;
 }
Example #19
0
 /**
  * @test
  */
 public function testIsCacheEnabled()
 {
     $subject = new RenderingContext($this->getMock(TemplateView::class));
     $this->assertFalse($subject->isCacheEnabled());
     $subject->setCache($this->getMock(SimpleFileCache::class));
     $this->assertTrue($subject->isCacheEnabled());
 }