TYPO3 CMS  TYPO3_6-2
All Classes Namespaces Files Functions Variables Pages
ExternalViewHelperTest.php
Go to the documentation of this file.
1 <?php
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  public function setUp() {
25  parent::setUp();
26  $this->viewHelper = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\Link\\ExternalViewHelper', array('renderChildren'));
27  $this->injectDependenciesIntoViewHelper($this->viewHelper);
28  $this->viewHelper->initializeArguments();
29  }
30 
35  $mockTagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder', array('setTagName', 'addAttribute', 'setContent'));
36  $mockTagBuilder->expects($this->once())->method('setTagName')->with('a');
37  $mockTagBuilder->expects($this->once())->method('addAttribute')->with('href', 'http://www.some-domain.tld');
38  $mockTagBuilder->expects($this->once())->method('setContent')->with('some content');
39  $this->viewHelper->_set('tag', $mockTagBuilder);
40 
41  $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue('some content'));
42 
43  $this->viewHelper->initialize();
44  $this->viewHelper->render('http://www.some-domain.tld');
45  }
46 
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', 'http://www.some-domain.tld');
54  $mockTagBuilder->expects($this->once())->method('setContent')->with('some content');
55  $this->viewHelper->_set('tag', $mockTagBuilder);
56 
57  $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue('some content'));
58 
59  $this->viewHelper->initialize();
60  $this->viewHelper->render('www.some-domain.tld');
61  }
62 
67  $mockTagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder', array('setTagName', 'addAttribute', 'setContent'));
68  $mockTagBuilder->expects($this->once())->method('setTagName')->with('a');
69  $mockTagBuilder->expects($this->once())->method('addAttribute')->with('href', 'ftp://some-domain.tld');
70  $mockTagBuilder->expects($this->once())->method('setContent')->with('some content');
71  $this->viewHelper->_set('tag', $mockTagBuilder);
72 
73  $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue('some content'));
74 
75  $this->viewHelper->initialize();
76  $this->viewHelper->render('some-domain.tld', 'ftp');
77  }
78 
82  public function renderDoesNotAddEmptyScheme() {
83  $mockTagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder', array('setTagName', 'addAttribute', 'setContent'));
84  $mockTagBuilder->expects($this->once())->method('setTagName')->with('a');
85  $mockTagBuilder->expects($this->once())->method('addAttribute')->with('href', 'some-domain.tld');
86  $mockTagBuilder->expects($this->once())->method('setContent')->with('some content');
87  $this->viewHelper->_set('tag', $mockTagBuilder);
88 
89  $this->viewHelper->expects($this->any())->method('renderChildren')->will($this->returnValue('some content'));
90 
91  $this->viewHelper->initialize();
92  $this->viewHelper->render('some-domain.tld', '');
93  }
94 }
injectDependenciesIntoViewHelper(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper)
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)