1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Aimeos\Aimeos\Tests\Unit\Controller; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
class JsonadmControllerTest |
8
|
|
|
extends \TYPO3\CMS\Core\Tests\UnitTestCase |
|
|
|
|
9
|
|
|
{ |
10
|
|
|
private $object; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
public function setUp() |
14
|
|
|
{ |
15
|
|
|
\Aimeos\Aimeos\Base::aimeos(); // initialize autoloader |
16
|
|
|
|
17
|
|
|
$this->object = $this->getAccessibleMock('Aimeos\\Aimeos\\Controller\\JsonadmController', array('dummy')); |
18
|
|
|
|
19
|
|
|
$this->request = $this->getMockBuilder('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request') |
|
|
|
|
20
|
|
|
->setMethods(array('hasArgument', 'getArgument', 'getMethod')) |
21
|
|
|
->disableOriginalConstructor() |
22
|
|
|
->getMock(); |
23
|
|
|
|
24
|
|
|
$this->response = $this->getMockBuilder('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response') |
|
|
|
|
25
|
|
|
->setMethods(array('setStatus')) |
26
|
|
|
->disableOriginalConstructor() |
27
|
|
|
->getMock(); |
28
|
|
|
|
29
|
|
|
$objManager = new \TYPO3\CMS\Extbase\Object\ObjectManager(); |
|
|
|
|
30
|
|
|
$uriBuilder = $objManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder'); |
31
|
|
|
|
32
|
|
|
$uriBuilder->setRequest($this->request); |
33
|
|
|
|
34
|
|
|
if (method_exists($response, 'setRequest')) { |
|
|
|
|
35
|
|
|
$response->setRequest($this->request); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
$this->object->_set('uriBuilder', $uriBuilder); |
39
|
|
|
$this->object->_set('response', $this->response); |
40
|
|
|
$this->object->_set('request', $this->request); |
41
|
|
|
|
42
|
|
|
$this->object->_call('initializeAction'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
public function tearDown() |
47
|
|
|
{ |
48
|
|
|
unset($this->object, $this->request, $this->response); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @test |
54
|
|
|
*/ |
55
|
|
|
public function getAction() |
56
|
|
|
{ |
57
|
|
|
$this->request->expects($this->exactly(1))->method('getMethod') |
58
|
|
|
->will($this->returnValue('GET')); |
59
|
|
|
|
60
|
|
|
$this->request->expects($this->atLeastOnce())->method('hasArgument') |
61
|
|
|
->will($this->returnValue(true)); |
62
|
|
|
|
63
|
|
|
$this->request->expects($this->any())->method('getArgument') |
64
|
|
|
->will($this->onConsecutiveCalls('stock/type', null, 'unittest', null, null, 'unittest', null)); |
65
|
|
|
|
66
|
|
|
$this->response->expects($this->exactly(1))->method('setStatus') |
67
|
|
|
->with($this->equalTo(200)); |
68
|
|
|
|
69
|
|
|
$result = $this->object->indexAction(); |
70
|
|
|
$json = json_decode($result, true); |
71
|
|
|
|
72
|
|
|
$this->assertNotEquals(null, $json); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @test |
78
|
|
|
*/ |
79
|
|
|
public function optionsAction() |
80
|
|
|
{ |
81
|
|
|
$this->request->expects($this->exactly(1))->method('getMethod') |
82
|
|
|
->will($this->returnValue('OPTIONS')); |
83
|
|
|
|
84
|
|
|
$this->request->expects($this->atLeastOnce())->method('hasArgument') |
85
|
|
|
->will($this->returnValue(true)); |
86
|
|
|
|
87
|
|
|
$this->request->expects($this->any())->method('getArgument') |
88
|
|
|
->will($this->onConsecutiveCalls(null, null, 'unittest', null, null, 'unittest', null)); |
89
|
|
|
|
90
|
|
|
$this->response->expects($this->exactly(1))->method('setStatus') |
91
|
|
|
->with($this->equalTo(200)); |
92
|
|
|
|
93
|
|
|
$result = $this->object->indexAction(); |
94
|
|
|
$json = json_decode($result, true); |
95
|
|
|
|
96
|
|
|
$this->assertNotEquals(null, $json); |
97
|
|
|
$this->assertArrayHasKey('meta', $json); |
98
|
|
|
$this->assertArrayHasKey('resources', $json['meta']); |
99
|
|
|
$this->assertGreaterThan(1, count($json['meta']['resources'])); |
100
|
|
|
$this->assertArrayHasKey('stock/type', $json['meta']['resources']); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @test |
106
|
|
|
*/ |
107
|
|
|
public function deleteAction() |
108
|
|
|
{ |
109
|
|
|
$this->request->expects($this->exactly(1))->method('getMethod') |
110
|
|
|
->will($this->returnValue('DELETE')); |
111
|
|
|
|
112
|
|
|
$this->request->expects($this->atLeastOnce())->method('hasArgument') |
113
|
|
|
->will($this->returnValue(true)); |
114
|
|
|
|
115
|
|
|
$this->request->expects($this->any())->method('getArgument') |
116
|
|
|
->will($this->onConsecutiveCalls('stock/type', null, 'unittest', null, null, 'unittest', null)); |
117
|
|
|
|
118
|
|
|
$result = $this->object->indexAction(); |
119
|
|
|
$json = json_decode($result, true); |
120
|
|
|
|
121
|
|
|
$this->assertNotEquals(null, $json); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @test |
127
|
|
|
*/ |
128
|
|
|
public function patchAction() |
129
|
|
|
{ |
130
|
|
|
$this->request->expects($this->exactly(1))->method('getMethod') |
131
|
|
|
->will($this->returnValue('PATCH')); |
132
|
|
|
|
133
|
|
|
$this->request->expects($this->atLeastOnce())->method('hasArgument') |
134
|
|
|
->will($this->returnValue(true)); |
135
|
|
|
|
136
|
|
|
$this->request->expects($this->any())->method('getArgument') |
137
|
|
|
->will($this->onConsecutiveCalls('stock/type', null, 'unittest', null, null, 'unittest', null)); |
138
|
|
|
|
139
|
|
|
$result = $this->object->indexAction(); |
140
|
|
|
$json = json_decode($result, true); |
141
|
|
|
|
142
|
|
|
$this->assertNotEquals(null, $json); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @test |
148
|
|
|
*/ |
149
|
|
|
public function postAction() |
150
|
|
|
{ |
151
|
|
|
$this->request->expects($this->exactly(1))->method('getMethod') |
152
|
|
|
->will($this->returnValue('POST')); |
153
|
|
|
|
154
|
|
|
$this->request->expects($this->atLeastOnce())->method('hasArgument') |
155
|
|
|
->will($this->returnValue(true)); |
156
|
|
|
|
157
|
|
|
$this->request->expects($this->any())->method('getArgument') |
158
|
|
|
->will($this->onConsecutiveCalls('stock/type', null, 'unittest', null, null, 'unittest', null)); |
159
|
|
|
|
160
|
|
|
$result = $this->object->indexAction(); |
161
|
|
|
$json = json_decode($result, true); |
162
|
|
|
|
163
|
|
|
$this->assertNotEquals(null, $json); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @test |
169
|
|
|
*/ |
170
|
|
|
public function putAction() |
171
|
|
|
{ |
172
|
|
|
$this->request->expects($this->exactly(1))->method('getMethod') |
173
|
|
|
->will($this->returnValue('PUT')); |
174
|
|
|
|
175
|
|
|
$this->request->expects($this->atLeastOnce())->method('hasArgument') |
176
|
|
|
->will($this->returnValue(true)); |
177
|
|
|
|
178
|
|
|
$this->request->expects($this->any())->method('getArgument') |
179
|
|
|
->will($this->onConsecutiveCalls('stock/type', null, 'unittest', null, null, 'unittest', null)); |
180
|
|
|
|
181
|
|
|
$result = $this->object->indexAction(); |
182
|
|
|
$json = json_decode($result, true); |
183
|
|
|
|
184
|
|
|
$this->assertNotEquals(null, $json); |
185
|
|
|
} |
186
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths