/**
  * @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);
 }
Пример #2
0
 /**
  * @test
  */
 public function testGetLayoutName()
 {
     $context = new RenderingContext();
     $context->getVariableProvider()->add('layoutName', 'test');
     $result = $this->parsingState->getLayoutName($context);
     $this->assertEquals('test', $result);
 }
 /**
  * @return void
  */
 public function setUp()
 {
     $this->viewHelperVariableContainer = new ViewHelperVariableContainer();
     $this->templateVariableContainer = new StandardVariableProvider();
     $this->renderingContext = new RenderingContext();
     $this->renderingContext->setVariableProvider($this->templateVariableContainer);
     $this->renderingContext->injectViewHelperVariableContainer($this->viewHelperVariableContainer);
 }
 /**
  * Sets up this test case
  *
  * @return void
  */
 public function setUp()
 {
     $this->templateVariableContainer = $this->getMock('NamelessCoder\\Fluid\\Core\\Variables\\StandardVariableProvider', array('exists', 'remove', 'add'));
     $this->viewHelperVariableContainer = $this->getMock('NamelessCoder\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer', array('setView'));
     $this->renderingContext = $this->getMock('NamelessCoder\\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('NamelessCoder\\Fluid\\View\\AbstractTemplateView', array(new TemplatePaths()));
     $this->view->setRenderingContext($this->renderingContext);
 }
Пример #5
0
 /**
  * @test
  */
 public function testEvaluateCallsInvoker()
 {
     $resolver = $this->getMock('NamelessCoder\\Fluid\\Core\\ViewHelper\\ViewHelperResolver', array('resolveViewHelperInvoker'));
     $invoker = $this->getMock('NamelessCoder\\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);
 }
 /**
  * @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 = new RenderViewHelper();
     $renderingContext = new RenderingContext();
     $viewHelperVariableContainer = new ViewHelperVariableContainer();
     $view = $this->getMock('NamelessCoder\\Fluid\\View\\TemplateView', $methods, array(), '', FALSE);
     $viewHelperVariableContainer->setView($view);
     $renderingContext->injectViewHelperVariableContainer($viewHelperVariableContainer);
     $instance->setArguments($arguments);
     $instance->setRenderingContext($renderingContext);
     $instance->render();
 }
 /**
  * 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);
 }
 /**
  * @test
  */
 public function testAddCompiledNamespacesDoesNothing()
 {
     $instance = $this->getMockForAbstractClass('NamelessCoder\\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('NamelessCoder\\Fluid\\Core\\Variables\\StandardVariableProvider');
     $viewHelperVariableContainer = $this->getMock('NamelessCoder\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
     $renderingContext = new RenderingContext();
     $renderingContext->setVariableProvider($templateVariableContainer);
     $renderingContext->injectViewHelperVariableContainer($viewHelperVariableContainer);
     $viewHelper = $this->getAccessibleMock('NamelessCoder\\Fluid\\Core\\ViewHelper\\AbstractViewHelper', array('render', 'prepareArguments'), array(), '', FALSE);
     $viewHelper->setRenderingContext($renderingContext);
     $this->assertSame($viewHelper->_get('templateVariableContainer'), $templateVariableContainer);
     $this->assertSame($viewHelper->_get('viewHelperVariableContainer'), $viewHelperVariableContainer);
 }
Пример #10
0
 /**
  * @param array $variables
  * @return RenderingContext
  */
 protected function getDummyRenderingContextWithVariables(array $variables)
 {
     $context = new RenderingContext();
     $context->getVariableProvider()->setSource($variables);
     return $context;
 }