TYPO3 API  SVNRelease
AbstractTagBasedViewHelperTest.php
Go to the documentation of this file.
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 /**
00024  * Testcase for AbstractTagBasedViewHelper
00025  *
00026  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
00027  */
00028 class Tx_Fluid_Tests_Unit_Core_ViewHelper_AbstractTagBasedViewHelperTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
00029 
00030     public function setUp() {
00031         $this->viewHelper = $this->getAccessibleMock('Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper', array('dummy'), array(), '', FALSE);
00032     }
00033 
00034     /**
00035      * @test
00036      * @author Bastian Waidelich <bastian@typo3.org>
00037      */
00038     public function initializeResetsUnderlyingTagBuilder() {
00039         $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('reset'), array(), '', FALSE);
00040         $mockTagBuilder->expects($this->once())->method('reset');
00041         $this->viewHelper->_set('tag', $mockTagBuilder);
00042 
00043         $this->viewHelper->initialize();
00044     }
00045 
00046     /**
00047      * @test
00048      * @author Sebastian Kurfürst <sebastian@typo3.org>
00049      * @author Bastian Waidelich <bastian@typo3.org>
00050      */
00051     public function oneTagAttributeIsRenderedCorrectly() {
00052         $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('addAttribute'), array(), '', FALSE);
00053         $mockTagBuilder->expects($this->once())->method('addAttribute')->with('foo', 'bar');
00054         $this->viewHelper->_set('tag', $mockTagBuilder);
00055 
00056         $this->viewHelper->_call('registerTagAttribute', 'foo', 'string', 'Description', FALSE);
00057         $arguments = new Tx_Fluid_Core_ViewHelper_Arguments(array('foo' => 'bar'));
00058         $this->viewHelper->setArguments($arguments);
00059         $this->viewHelper->initialize();
00060     }
00061 
00062     /**
00063      * @test
00064      * @author Sebastian Kurfürst <sebastian@typo3.org>
00065      * @author Bastian Waidelich <bastian@typo3.org>
00066      */
00067     public function additionalTagAttributesAreRenderedCorrectly() {
00068         $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('addAttribute'), array(), '', FALSE);
00069         $mockTagBuilder->expects($this->once())->method('addAttribute')->with('foo', 'bar');
00070         $this->viewHelper->_set('tag', $mockTagBuilder);
00071 
00072         $this->viewHelper->_call('registerTagAttribute', 'foo', 'string', 'Description', FALSE);
00073         $arguments = new Tx_Fluid_Core_ViewHelper_Arguments(array('additionalAttributes' => array('foo' => 'bar')));
00074         $this->viewHelper->setArguments($arguments);
00075         $this->viewHelper->initialize();
00076     }
00077 
00078     /**
00079      * @test
00080      * @author Bastian Waidelich <bastian@typo3.org>
00081      */
00082     public function standardTagAttributesAreRegistered() {
00083         $mockTagBuilder = $this->getMock('Tx_Fluid_Core_ViewHelper_TagBuilder', array('addAttribute'), array(), '', FALSE);
00084         $mockTagBuilder->expects($this->at(0))->method('addAttribute')->with('class', 'classAttribute');
00085         $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('dir', 'dirAttribute');
00086         $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('id', 'idAttribute');
00087         $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('lang', 'langAttribute');
00088         $mockTagBuilder->expects($this->at(4))->method('addAttribute')->with('style', 'styleAttribute');
00089         $mockTagBuilder->expects($this->at(5))->method('addAttribute')->with('title', 'titleAttribute');
00090         $mockTagBuilder->expects($this->at(6))->method('addAttribute')->with('accesskey', 'accesskeyAttribute');
00091         $mockTagBuilder->expects($this->at(7))->method('addAttribute')->with('tabindex', 'tabindexAttribute');
00092         $this->viewHelper->_set('tag', $mockTagBuilder);
00093 
00094         $arguments = new Tx_Fluid_Core_ViewHelper_Arguments(
00095             array(
00096                 'class' => 'classAttribute',
00097                 'dir' => 'dirAttribute',
00098                 'id' => 'idAttribute',
00099                 'lang' => 'langAttribute',
00100                 'style' => 'styleAttribute',
00101                 'title' => 'titleAttribute',
00102                 'accesskey' => 'accesskeyAttribute',
00103                 'tabindex' => 'tabindexAttribute'
00104             )
00105         );
00106         $this->viewHelper->_call('registerUniversalTagAttributes');
00107         $this->viewHelper->setArguments($arguments);
00108         $this->viewHelper->initializeArguments();
00109         $this->viewHelper->initialize();
00110     }
00111 }
00112 ?>