TYPO3  7.6
Link/EmailViewHelperTest.php
Go to the documentation of this file.
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 
21 {
25  protected $viewHelper;
26 
30  protected $cObjBackup;
31 
32  protected function setUp()
33  {
34  parent::setUp();
35  $GLOBALS['TSFE'] = new \stdClass();
36  $GLOBALS['TSFE']->cObj = $this->getMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class, array(), array(), '', false);
37  $this->viewHelper = $this->getMock($this->buildAccessibleProxy(\TYPO3\CMS\Fluid\ViewHelpers\Link\EmailViewHelper::class), array('renderChildren'));
38  $this->injectDependenciesIntoViewHelper($this->viewHelper);
39  $this->viewHelper->initializeArguments();
40  }
41 
46  {
47  $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, array('setTagName', 'addAttribute', 'setContent'));
48  $mockTagBuilder->expects($this->once())->method('setTagName')->with('a');
49  $mockTagBuilder->expects($this->once())->method('addAttribute')->with('href', 'mailto:some@email.tld');
50  $mockTagBuilder->expects($this->once())->method('setContent')->with('some content');
51  $this->viewHelper->_set('tag', $mockTagBuilder);
52  $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue('some content'));
53  $this->viewHelper->initialize();
54  $this->viewHelper->render('some@email.tld');
55  }
56 
61  {
62  $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, array('setTagName', 'addAttribute', 'setContent'));
63  $mockTagBuilder->expects($this->once())->method('setContent')->with('some@email.tld');
64  $this->viewHelper->_set('tag', $mockTagBuilder);
65  $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue(null));
66  $this->viewHelper->initialize();
67  $this->viewHelper->render('some@email.tld');
68  }
69 }