[TASK] Make fluid tests run again
[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 $this->cObjBackup = $GLOBALS['TSFE']->cObj;
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 public function tearDown() {
43 $GLOBALS['TSFE']->cObj = $this->cObjBackup;
44 }
45
46 /**
47 * @test
48 */
49 public function renderCorrectlySetsTagNameAndAttributesAndContent() {
50 //$GLOBALS['TSFE']->cObj->expects($this->once())->method('getMailTo')->with('some@email.tld', 'some@email.tld')->will($this->returnValue(array('mailto:some@email.tld', 'some@email.tld')));
51 $mockTagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder', array('setTagName', 'addAttribute', 'setContent'));
52 $mockTagBuilder->expects($this->once())->method('setTagName')->with('a');
53 $mockTagBuilder->expects($this->once())->method('addAttribute')->with('href', 'mailto:some@email.tld');
54 $mockTagBuilder->expects($this->once())->method('setContent')->with('some content');
55 $this->viewHelper->_set('tag', $mockTagBuilder);
56 $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue('some content'));
57 $this->viewHelper->initialize();
58 $this->viewHelper->render('some@email.tld');
59 }
60
61 /**
62 * @test
63 */
64 public function renderSetsTagContentToEmailIfRenderChildrenReturnNull() {
65 //$GLOBALS['TSFE']->cObj->expects($this->once())->method('getMailTo')->with('some@email.tld', 'some@email.tld')->will($this->returnValue(array('mailto:some@email.tld', 'some@email.tld')));
66 $mockTagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder', array('setTagName', 'addAttribute', 'setContent'));
67 $mockTagBuilder->expects($this->once())->method('setContent')->with('some@email.tld');
68 $this->viewHelper->_set('tag', $mockTagBuilder);
69 $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue(NULL));
70 $this->viewHelper->initialize();
71 $this->viewHelper->render('some@email.tld');
72 }
73
74 }
75
76
77 ?>