Exemplo n.º 1
0
 /**
  * @test
  */
 public function retrieveContentFromChildNodesReturnsBreaksOnBreak()
 {
     $instance = $this->getAccessibleMock(SwitchViewHelper::class, array('dummy'));
     $context = new RenderingContextFixture();
     $context->getViewHelperVariableContainer()->addOrUpdate(SwitchViewHelper::class, 'switchExpression', 'foo');
     $context->getViewHelperVariableContainer()->addOrUpdate(SwitchViewHelper::class, 'break', FALSE);
     $instance->_set('viewHelperVariableContainer', $context->getViewHelperVariableContainer());
     $instance->_set('renderingContext', $context);
     $matchingCaseViewHelper = new CaseViewHelper();
     $matchingCaseViewHelper->setRenderChildrenClosure(function () {
         return 'foo-childcontent';
     });
     $breakingMatchingCaseNode = $this->getAccessibleMock(ViewHelperNode::class, array('getViewHelperClassName', 'getUninitializedViewHelper'), array(), '', FALSE);
     $breakingMatchingCaseNode->_set('arguments', array('value' => 'foo'));
     $breakingMatchingCaseNode->_set('uninitializedViewHelper', $matchingCaseViewHelper);
     $breakingMatchingCaseNode->method('getViewHelperClassName')->willReturn(CaseViewHelper::class);
     $defaultCaseNode = $this->getMock(ViewHelperNode::class, array('getViewHelperClassName', 'evaluate'), array(), '', FALSE);
     $defaultCaseNode->method('getViewHelperClassName')->willReturn(DefaultCaseViewHelper::class);
     $defaultCaseNode->expects($this->never())->method('evaluate');
     $method = new \ReflectionMethod(SwitchViewHelper::class, 'retrieveContentFromChildNodes');
     $method->setAccessible(TRUE);
     $result = $method->invokeArgs($instance, array(array($breakingMatchingCaseNode, $defaultCaseNode)));
     $this->assertEquals('foo-childcontent', $result);
 }
Exemplo n.º 2
0
 /**
  * @test
  */
 public function renderReturnsAnEmptyStringIfTheSpecifiedValueIsNotEqualToTheSwitchExpression()
 {
     $this->viewHelperVariableContainer->addOrUpdate('TYPO3Fluid\\Fluid\\ViewHelpers\\SwitchViewHelper', 'switchExpression', 'someValue');
     $this->viewHelper->setArguments(array('value' => 'someOtherValue'));
     $this->assertSame('', $this->viewHelper->initializeArgumentsAndRender());
 }