|
TYPO3 API
SVNRelease
|
00001 <?php 00002 00003 /* * 00004 * This script belongs to the FLOW3 package "Fluid". * 00005 * * 00006 * It is free software; you can redistribute it and/or modify it under * 00007 * the terms of the GNU Lesser General Public License as published by the * 00008 * Free Software Foundation, either version 3 of the License, or (at your * 00009 * option) any later version. * 00010 * * 00011 * This script is distributed in the hope that it will be useful, but * 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * 00013 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with the script. * 00018 * If not, see http://www.gnu.org/licenses/lgpl.html * 00019 * * 00020 * The TYPO3 project - inspiring people to share! * 00021 * */ 00022 00023 require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php'); 00024 00025 /** 00026 * Testcase for CycleViewHelper 00027 * 00028 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later 00029 */ 00030 class Tx_Fluid_Tests_Unit_ViewHelpers_RenderChildrenViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase { 00031 00032 /** 00033 * var Tx_Fluid_ViewHelpers_RenderChildrenViewHelper 00034 */ 00035 protected $viewHelper; 00036 00037 /** 00038 * @author Sebastian Kurfürst <sebastian@typo3.org> 00039 */ 00040 public function setUp() { 00041 $this->controllerContext = $this->getMock('Tx_Extbase_MVC_Controller_ControllerContext', array(), array(), '', FALSE); 00042 $this->viewHelper = $this->getMock('Tx_Fluid_ViewHelpers_RenderChildrenViewHelper', array('renderChildren')); 00043 } 00044 00045 /** 00046 * @test 00047 * @author Sebastian Kurfürst <sebastian@typo3.org> 00048 */ 00049 public function renderCallsEvaluateOnTheRootNodeAndRegistersTheArguments() { 00050 $this->request = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest'); 00051 $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request)); 00052 $this->viewHelper->setControllerContext($this->controllerContext); 00053 $this->viewHelper->initializeArguments(); 00054 00055 $templateVariableContainer = $this->getMock('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer'); 00056 $templateVariableContainer->expects($this->at(0))->method('add')->with('k1', 'v1'); 00057 $templateVariableContainer->expects($this->at(1))->method('add')->with('k2', 'v2'); 00058 $templateVariableContainer->expects($this->at(2))->method('remove')->with('k1'); 00059 $templateVariableContainer->expects($this->at(3))->method('remove')->with('k2'); 00060 00061 $renderingContext = $this->getMock('Tx_Fluid_Core_Rendering_RenderingContextInterface'); 00062 $renderingContext->expects($this->any())->method('getTemplateVariableContainer')->will($this->returnValue($templateVariableContainer)); 00063 00064 $rootNode = $this->getMock('Tx_Fluid_Core_Parser_SyntaxTree_RootNode'); 00065 00066 $widgetContext = $this->getMock('Tx_Fluid_Core_Widget_WidgetContext'); 00067 $this->request->expects($this->any())->method('getWidgetContext')->will($this->returnValue($widgetContext)); 00068 $widgetContext->expects($this->any())->method('getViewHelperChildNodeRenderingContext')->will($this->returnValue($renderingContext)); 00069 $widgetContext->expects($this->any())->method('getViewHelperChildNodes')->will($this->returnValue($rootNode)); 00070 00071 $rootNode->expects($this->any())->method('evaluate')->with($renderingContext)->will($this->returnValue('Rendered Results')); 00072 00073 $output = $this->viewHelper->render(array('k1' => 'v1', 'k2' => 'v2')); 00074 $this->assertEquals('Rendered Results', $output); 00075 } 00076 00077 /** 00078 * @test 00079 * @expectedException Tx_Fluid_Core_Widget_Exception_WidgetRequestNotFoundException 00080 * @author Sebastian Kurfürst <sebastian@typo3.org> 00081 */ 00082 public function renderThrowsExceptionIfTheRequestIsNotAWidgetRequest() { 00083 $this->request = $this->getMock('Tx_Fluid_MVC_Request'); 00084 $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request)); 00085 $this->viewHelper->setControllerContext($this->controllerContext); 00086 $this->viewHelper->initializeArguments(); 00087 00088 $output = $this->viewHelper->render(); 00089 } 00090 00091 /** 00092 * @test 00093 * @expectedException Tx_Fluid_Core_Widget_Exception_RenderingContextNotFoundException 00094 * @author Sebastian Kurfürst <sebastian@typo3.org> 00095 */ 00096 public function renderThrowsExceptionIfTheChildNodeRenderingContextIsNotThere() { 00097 $this->request = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest'); 00098 $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request)); 00099 $this->viewHelper->setControllerContext($this->controllerContext); 00100 $this->viewHelper->initializeArguments(); 00101 00102 $widgetContext = $this->getMock('Tx_Fluid_Core_Widget_WidgetContext'); 00103 $this->request->expects($this->any())->method('getWidgetContext')->will($this->returnValue($widgetContext)); 00104 $widgetContext->expects($this->any())->method('getViewHelperChildNodeRenderingContext')->will($this->returnValue(NULL)); 00105 $widgetContext->expects($this->any())->method('getViewHelperChildNodes')->will($this->returnValue(NULL)); 00106 00107 $output = $this->viewHelper->render(); 00108 } 00109 } 00110 ?>
1.8.0