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