1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2011 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2021 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\MW\View\Helper\Url; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
require_once __DIR__ . DIRECTORY_SEPARATOR . 'UriBuilder'; |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
class Typo3Test extends \PHPUnit\Framework\TestCase |
17
|
|
|
{ |
18
|
|
|
private $view; |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
protected function setUp() : void |
22
|
|
|
{ |
23
|
|
|
$this->view = new \Aimeos\MW\View\Standard(); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
protected function tearDown() : void |
28
|
|
|
{ |
29
|
|
|
unset( $this->view ); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
public function testTransform() |
34
|
|
|
{ |
35
|
|
|
$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' ) |
36
|
|
|
->setMethods( array( 'buildFrontendUri' ) )->getMock(); |
37
|
|
|
|
38
|
|
|
$mock->expects( $this->once() )->method( 'buildFrontendUri' ); |
39
|
|
|
|
40
|
|
|
$fixed = array( 'site' => 'unittest' ); |
41
|
|
|
$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, $fixed ); |
42
|
|
|
|
43
|
|
|
$this->assertEquals( '', $object->transform() ); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
public function testTransformAbsolute() |
48
|
|
|
{ |
49
|
|
|
$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' ) |
50
|
|
|
->setMethods( array( 'setCreateAbsoluteUri' ) )->getMock(); |
51
|
|
|
|
52
|
|
|
$mock->expects( $this->once() )->method( 'setCreateAbsoluteUri' ) |
53
|
|
|
->with( $this->equalTo( true ) )->will( $this->returnValue( $mock ) ); |
54
|
|
|
|
55
|
|
|
$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, [] ); |
56
|
|
|
|
57
|
|
|
$config = array( 'absoluteUri' => 1 ); |
58
|
|
|
$this->assertEquals( '', $object->transform( null, null, null, [], [], $config ) ); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
public function testTransformNocache() |
63
|
|
|
{ |
64
|
|
|
$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' ) |
65
|
|
|
->setMethods( array( 'setNoCache' ) )->getMock(); |
66
|
|
|
|
67
|
|
|
$mock->expects( $this->once() )->method( 'setNoCache' ) |
68
|
|
|
->with( $this->equalTo( true ) )->will( $this->returnValue( $mock ) ); |
69
|
|
|
|
70
|
|
|
$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, [] ); |
71
|
|
|
|
72
|
|
|
$config = array( 'nocache' => 1 ); |
73
|
|
|
$this->assertEquals( '', $object->transform( null, null, null, [], [], $config ) ); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
public function testTransformType() |
78
|
|
|
{ |
79
|
|
|
$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' ) |
80
|
|
|
->setMethods( array( 'setTargetPageType' ) )->getMock(); |
81
|
|
|
|
82
|
|
|
$mock->expects( $this->once() )->method( 'setTargetPageType' ) |
83
|
|
|
->with( $this->equalTo( 123 ) )->will( $this->returnValue( $mock ) ); |
84
|
|
|
|
85
|
|
|
$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, [] ); |
86
|
|
|
|
87
|
|
|
$config = array( 'type' => 123 ); |
88
|
|
|
$this->assertEquals( '', $object->transform( null, null, null, [], [], $config ) ); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
public function testTransformFormat() |
93
|
|
|
{ |
94
|
|
|
$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' ) |
95
|
|
|
->setMethods( array( 'setFormat' ) )->getMock(); |
96
|
|
|
|
97
|
|
|
$mock->expects( $this->once() )->method( 'setFormat' ) |
98
|
|
|
->with( $this->equalTo( 'xml' ) )->will( $this->returnValue( $mock ) ); |
99
|
|
|
|
100
|
|
|
$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, [] ); |
101
|
|
|
|
102
|
|
|
$config = array( 'format' => 'xml' ); |
103
|
|
|
$this->assertEquals( '', $object->transform( null, null, null, [], [], $config ) ); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
|
107
|
|
|
public function testTransformEID() |
108
|
|
|
{ |
109
|
|
|
$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' ) |
110
|
|
|
->setMethods( array( 'setArguments' ) )->getMock(); |
111
|
|
|
|
112
|
|
|
$param = array( 'eID' => 123, 'ai' => array( 'controller' => '', 'action' => null ) ); |
113
|
|
|
|
114
|
|
|
$mock->expects( $this->once() )->method( 'setArguments' ) |
115
|
|
|
->with( $this->equalTo( $param ) )->will( $this->returnValue( $mock ) ); |
116
|
|
|
|
117
|
|
|
$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, [] ); |
118
|
|
|
|
119
|
|
|
$config = array( 'eID' => 123 ); |
120
|
|
|
$this->assertEquals( '', $object->transform( null, null, null, [], [], $config ) ); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
|
124
|
|
|
public function testTransformLocale() |
125
|
|
|
{ |
126
|
|
|
$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' ) |
127
|
|
|
->setMethods( array( 'setArguments' ) )->getMock(); |
128
|
|
|
|
129
|
|
|
$param = array( 'L' => 'de', 'ai' => ['controller' => '', 'action' => null, 'locale' => 'de'] ); |
130
|
|
|
|
131
|
|
|
$mock->expects( $this->once() )->method( 'setArguments' ) |
132
|
|
|
->with( $this->equalTo( $param ) )->will( $this->returnValue( $mock ) ); |
133
|
|
|
|
134
|
|
|
$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, [] ); |
135
|
|
|
|
136
|
|
|
$params = array( 'locale' => 'de' ); |
137
|
|
|
$this->assertEquals( '', $object->transform( null, null, null, $params ) ); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
|
141
|
|
|
public function testTransformBackend() |
142
|
|
|
{ |
143
|
|
|
$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' ) |
144
|
|
|
->setMethods( array( 'buildBackendUri' ) )->getMock(); |
145
|
|
|
|
146
|
|
|
$mock->expects( $this->once() )->method( 'buildBackendUri' ); |
147
|
|
|
|
148
|
|
|
$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, array( 'site' => 'unittest' ) ); |
149
|
|
|
|
150
|
|
|
$params = array( 'test' => 'my/value' ); |
151
|
|
|
$this->assertEquals( '', $object->transform( null, null, null, $params, [], array( 'BE' => 1 ) ) ); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
|
155
|
|
|
public function testTransformParams() |
156
|
|
|
{ |
157
|
|
|
$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' ) |
158
|
|
|
->setMethods( array( 'buildFrontendUri' ) )->getMock(); |
159
|
|
|
|
160
|
|
|
$mock->expects( $this->once() )->method( 'buildFrontendUri' ); |
161
|
|
|
|
162
|
|
|
$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, array( 'site' => 'unittest' ) ); |
163
|
|
|
|
164
|
|
|
$params = array( 'test' => 'my/value' ); |
165
|
|
|
$this->assertEquals( '', $object->transform( null, null, null, $params ) ); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
|
169
|
|
|
public function testTransformNoNamespace() |
170
|
|
|
{ |
171
|
|
|
$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' ) |
172
|
|
|
->setMethods( array( 'buildFrontendUri', 'getArgumentPrefix' ) )->getMock(); |
173
|
|
|
|
174
|
|
|
$mock->expects( $this->once() )->method( 'buildFrontendUri' ); |
175
|
|
|
$mock->expects( $this->once() )->method( 'getArgumentPrefix' )->will( $this->returnValue( 'ai' ) ); |
176
|
|
|
|
177
|
|
|
$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, array( 'site' => 'unittest' ) ); |
178
|
|
|
|
179
|
|
|
$params = array( 'test' => 'my/value' ); |
180
|
|
|
$config = array( 'namespace' => false ); |
181
|
|
|
$this->assertEquals( '', $object->transform( null, null, null, $params, [], $config ) ); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
|
185
|
|
|
public function testTransformUnchangedOriginalUriBuilder() |
186
|
|
|
{ |
187
|
|
|
$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' ) |
188
|
|
|
->setMethods( array( 'reset' ) )->getMock(); |
189
|
|
|
|
190
|
|
|
$mock->expects( $this->once() )->method( 'reset' )->will( $this->returnValue( $mock ) ); |
191
|
|
|
|
192
|
|
|
$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, [] ); |
193
|
|
|
|
194
|
|
|
$mock->expects( $this->never() )->method( 'reset' ); |
195
|
|
|
$this->assertEquals( '', $object->transform( null, null, null, [], [], [] ) ); |
196
|
|
|
} |
197
|
|
|
} |
198
|
|
|
|