[BUGFIX] PHP 5.4 unit test warnings
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Unit / ViewHelpers / Link / EmailViewHelperTest.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Link;
3
4 /* *
5 * This script is part of the TYPO3 project - inspiring people to share! *
6 * *
7 * TYPO3 is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU General Public License version 2 as published by *
9 * the Free Software Foundation. *
10 * *
11 * This script is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
14 * Public License for more details. *
15 * */
16 require_once dirname(__FILE__) . '/../ViewHelperBaseTestcase.php';
17
18 /**
19
20 */
21 class EmailViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\ViewHelperBaseTestcase {
22
23 /**
24 * @var \TYPO3\CMS\Fluid\ViewHelpers\Link\EmailViewHelper
25 */
26 protected $viewHelper;
27
28 /**
29 * @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
30 */
31 protected $cObjBackup;
32
33 public function setUp() {
34 parent::setUp();
35 $GLOBALS['TSFE'] = new \stdClass();
36 $GLOBALS['TSFE']->cObj = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', array(), array(), '', FALSE);
37 $this->viewHelper = $this->getMock($this->buildAccessibleProxy('TYPO3\\CMS\\Fluid\\ViewHelpers\\Link\\EmailViewHelper'), array('renderChildren'));
38 $this->injectDependenciesIntoViewHelper($this->viewHelper);
39 $this->viewHelper->initializeArguments();
40 }
41
42 /**
43 * @test
44 */
45 public function renderCorrectlySetsTagNameAndAttributesAndContent() {
46 $mockTagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder', array('setTagName', 'addAttribute', 'setContent'));
47 $mockTagBuilder->expects($this->once())->method('setTagName')->with('a');
48 $mockTagBuilder->expects($this->once())->method('addAttribute')->with('href', 'mailto:some@email.tld');
49 $mockTagBuilder->expects($this->once())->method('setContent')->with('some content');
50 $this->viewHelper->_set('tag', $mockTagBuilder);
51 $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue('some content'));
52 $this->viewHelper->initialize();
53 $this->viewHelper->render('some@email.tld');
54 }
55
56 /**
57 * @test
58 */
59 public function renderSetsTagContentToEmailIfRenderChildrenReturnNull() {
60 $mockTagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder', array('setTagName', 'addAttribute', 'setContent'));
61 $mockTagBuilder->expects($this->once())->method('setContent')->with('some@email.tld');
62 $this->viewHelper->_set('tag', $mockTagBuilder);
63 $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue(NULL));
64 $this->viewHelper->initialize();
65 $this->viewHelper->render('some@email.tld');
66 }
67
68 }
69
70
71 ?>