TYPO3 CMS  TYPO3_7-6
TypolinkViewHelperTest.php
Go to the documentation of this file.
1 <?php
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, ['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, [], [], '', 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 [
62  'empty input' => [
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' => [
71  19,
72  '',
73  '',
74  '',
75  '',
76  '19',
77  ],
78  'external url with target' => [
79  'www.web.de _blank',
80  '',
81  '',
82  '',
83  '',
84  'www.web.de _blank',
85  ],
86  'page with extended class' => [
87  '42 - css-class',
88  '',
89  'fluid_class',
90  '',
91  '',
92  '42 - "css-class fluid_class"',
93  ],
94  'classes are unique' => [
95  '42 - css-class',
96  '',
97  'css-class',
98  '',
99  '',
100  '42 - css-class',
101  ],
102  'page with overridden title' => [
103  '42 - - "a link title"',
104  '',
105  '',
106  'another link title',
107  '',
108  '42 - - "another link title"',
109  ],
110  'page with title and extended parameters' => [
111  '42 - - "a link title" &x=y',
112  '',
113  '',
114  '',
115  '&a=b',
116  '42 - - "a link title" &x=y&a=b',
117  ],
118  'page with complex title and extended parameters' => [
119  '42 - - "a \\"link\\" title with \\\\" &x=y',
120  '',
121  '',
122  '',
123  '&a=b',
124  '42 - - "a \\"link\\" title with \\\\" &x=y&a=b',
125  ],
126  'full parameter usage' => [
127  '19 _blank css-class "testtitle with whitespace" &X=y',
128  '-',
129  'fluid_class',
130  'a new title',
131  '&a=b',
132  '19 - "css-class fluid_class" "a new title" &X=y&a=b',
133  ],
134  'only page id and overwrite' => [
135  '42',
136  '',
137  '',
138  '',
139  '&a=b',
140  '42 - - - &a=b',
141  ],
142  ];
143  }
144 
155  public function createTypolinkParameterArrayFromArgumentsReturnsExpectedArray($input, $targetFromFluid, $classFromFluid, $titleFromFluid, $additionalParametersFromFluid, $expected)
156  {
157  $result = $this->subject->_call('createTypolinkParameterArrayFromArguments', $input, $targetFromFluid, $classFromFluid, $titleFromFluid, $additionalParametersFromFluid);
158  $this->assertSame($expected, $result);
159  }
160 }
static addInstance($className, $instance)
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)