TYPO3  7.6
Link/TypolinkViewHelperTest.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 
22 
27 {
31  protected $subject;
32 
36  protected function setUp()
37  {
38  $this->subject = $this->getAccessibleMock(TypolinkViewHelper::class, array('renderChildren'));
40  $renderingContext = $this->getMock(RenderingContext::class);
41  $this->subject->setRenderingContext($renderingContext);
42  }
43 
48  {
49  $this->subject->expects($this->any())->method('renderChildren')->will($this->returnValue('innerContent'));
50  $contentObjectRendererMock = $this->getMock(ContentObjectRenderer::class, array(), array(), '', false);
51  $contentObjectRendererMock->expects($this->once())->method('stdWrap')->will($this->returnValue('foo'));
52  GeneralUtility::addInstance(ContentObjectRenderer::class, $contentObjectRendererMock);
53  $this->assertEquals('foo', $this->subject->render('42'));
54  }
55 
59  public function typoScriptConfigurationData()
60  {
61  return array(
62  'empty input' => array(
63  '', // input from link field
64  '', // target from fluid
65  '', // class from fluid
66  '', // title from fluid
67  '', // additional parameters from fluid
68  '',
69  ),
70  'simple id input' => array(
71  19,
72  '',
73  '',
74  '',
75  '',
76  '19',
77  ),
78  'external url with target' => array(
79  'www.web.de _blank',
80  '',
81  '',
82  '',
83  '',
84  'www.web.de _blank',
85  ),
86  'page with extended class' => array(
87  '42 - css-class',
88  '',
89  'fluid_class',
90  '',
91  '',
92  '42 - "css-class fluid_class"',
93  ),
94  'page with overridden title' => array(
95  '42 - - "a link title"',
96  '',
97  '',
98  'another link title',
99  '',
100  '42 - - "another link title"',
101  ),
102  'page with title and extended parameters' => array(
103  '42 - - "a link title" &x=y',
104  '',
105  '',
106  '',
107  '&a=b',
108  '42 - - "a link title" &x=y&a=b',
109  ),
110  'page with complex title and extended parameters' => array(
111  '42 - - "a \\"link\\" title with \\\\" &x=y',
112  '',
113  '',
114  '',
115  '&a=b',
116  '42 - - "a \\"link\\" title with \\\\" &x=y&a=b',
117  ),
118  'full parameter usage' => array(
119  '19 _blank css-class "testtitle with whitespace" &X=y',
120  '-',
121  'fluid_class',
122  'a new title',
123  '&a=b',
124  '19 - "css-class fluid_class" "a new title" &X=y&a=b',
125  ),
126  'only page id and overwrite' => array(
127  '42',
128  '',
129  '',
130  '',
131  '&a=b',
132  '42 - - - &a=b',
133  ),
134  );
135  }
136 
147  public function createTypolinkParameterArrayFromArgumentsReturnsExpectedArray($input, $targetFromFluid, $classFromFluid, $titleFromFluid, $additionalParametersFromFluid, $expected)
148  {
149  $result = $this->subject->_call('createTypolinkParameterArrayFromArguments', $input, $targetFromFluid, $classFromFluid, $titleFromFluid, $additionalParametersFromFluid);
150  $this->assertSame($expected, $result);
151  }
152 }