TYPO3  7.6
Link/ExternalViewHelperTest.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 backported from the TYPO3 Flow package "TYPO3.Fluid". *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * The TYPO3 project - inspiring people to share! *
12  * */
13 
18 {
22  protected $viewHelper;
23 
24  protected function setUp()
25  {
26  parent::setUp();
27  $this->viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Link\ExternalViewHelper::class, array('renderChildren'));
28  $this->injectDependenciesIntoViewHelper($this->viewHelper);
29  $this->viewHelper->initializeArguments();
30  }
31 
36  {
37  $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, array('setTagName', 'addAttribute', 'setContent'));
38  $mockTagBuilder->expects($this->once())->method('setTagName')->with('a');
39  $mockTagBuilder->expects($this->once())->method('addAttribute')->with('href', 'http://www.some-domain.tld');
40  $mockTagBuilder->expects($this->once())->method('setContent')->with('some content');
41  $this->viewHelper->_set('tag', $mockTagBuilder);
42 
43  $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue('some content'));
44 
45  $this->viewHelper->initialize();
46  $this->viewHelper->render('http://www.some-domain.tld');
47  }
48 
53  {
54  $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, array('setTagName', 'addAttribute', 'setContent'));
55  $mockTagBuilder->expects($this->once())->method('setTagName')->with('a');
56  $mockTagBuilder->expects($this->once())->method('addAttribute')->with('href', 'http://www.some-domain.tld');
57  $mockTagBuilder->expects($this->once())->method('setContent')->with('some content');
58  $this->viewHelper->_set('tag', $mockTagBuilder);
59 
60  $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue('some content'));
61 
62  $this->viewHelper->initialize();
63  $this->viewHelper->render('www.some-domain.tld');
64  }
65 
70  {
71  $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, array('setTagName', 'addAttribute', 'setContent'));
72  $mockTagBuilder->expects($this->once())->method('setTagName')->with('a');
73  $mockTagBuilder->expects($this->once())->method('addAttribute')->with('href', 'ftp://some-domain.tld');
74  $mockTagBuilder->expects($this->once())->method('setContent')->with('some content');
75  $this->viewHelper->_set('tag', $mockTagBuilder);
76 
77  $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue('some content'));
78 
79  $this->viewHelper->initialize();
80  $this->viewHelper->render('some-domain.tld', 'ftp');
81  }
82 
86  public function renderDoesNotAddEmptyScheme()
87  {
88  $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, array('setTagName', 'addAttribute', 'setContent'));
89  $mockTagBuilder->expects($this->once())->method('setTagName')->with('a');
90  $mockTagBuilder->expects($this->once())->method('addAttribute')->with('href', 'some-domain.tld');
91  $mockTagBuilder->expects($this->once())->method('setContent')->with('some content');
92  $this->viewHelper->_set('tag', $mockTagBuilder);
93 
94  $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue('some content'));
95 
96  $this->viewHelper->initialize();
97  $this->viewHelper->render('some-domain.tld', '');
98  }
99 }