Revert "[CLEANUP] Rework/simplify copyright header and remove @package"
[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
17 /**
18
19 */
20 class EmailViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\ViewHelperBaseTestcase {
21
22 /**
23 * @var \TYPO3\CMS\Fluid\ViewHelpers\Link\EmailViewHelper
24 */
25 protected $viewHelper;
26
27 /**
28 * @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
29 */
30 protected $cObjBackup;
31
32 public function setUp() {
33 parent::setUp();
34 $GLOBALS['TSFE'] = new \stdClass();
35 $GLOBALS['TSFE']->cObj = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', array(), array(), '', FALSE);
36 $this->viewHelper = $this->getMock($this->buildAccessibleProxy('TYPO3\\CMS\\Fluid\\ViewHelpers\\Link\\EmailViewHelper'), array('renderChildren'));
37 $this->injectDependenciesIntoViewHelper($this->viewHelper);
38 $this->viewHelper->initializeArguments();
39 }
40
41 /**
42 * @test
43 */
44 public function renderCorrectlySetsTagNameAndAttributesAndContent() {
45 $mockTagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder', array('setTagName', 'addAttribute', 'setContent'));
46 $mockTagBuilder->expects($this->once())->method('setTagName')->with('a');
47 $mockTagBuilder->expects($this->once())->method('addAttribute')->with('href', 'mailto:some@email.tld');
48 $mockTagBuilder->expects($this->once())->method('setContent')->with('some content');
49 $this->viewHelper->_set('tag', $mockTagBuilder);
50 $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue('some content'));
51 $this->viewHelper->initialize();
52 $this->viewHelper->render('some@email.tld');
53 }
54
55 /**
56 * @test
57 */
58 public function renderSetsTagContentToEmailIfRenderChildrenReturnNull() {
59 $mockTagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder', array('setTagName', 'addAttribute', 'setContent'));
60 $mockTagBuilder->expects($this->once())->method('setContent')->with('some@email.tld');
61 $this->viewHelper->_set('tag', $mockTagBuilder);
62 $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue(NULL));
63 $this->viewHelper->initialize();
64 $this->viewHelper->render('some@email.tld');
65 }
66 }