Completed
Push — master ( b5e3a0...88d9f1 )
by Aimeos
13:38
created
Tests/Controller/JsonapiControllerTest.php 1 patch
Spacing   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -10,74 +10,74 @@  discard block
 block discarded – undo
10 10
 	public function testOptionsAction()
11 11
 	{
12 12
 		$client = static::createClient();
13
-		$client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' );
13
+		$client->request('OPTIONS', '/unittest/de/EUR/jsonapi');
14 14
 		$response = $client->getResponse();
15 15
 
16
-		$json = json_decode( $response->getContent(), true );
16
+		$json = json_decode($response->getContent(), true);
17 17
 
18
-		$this->assertNotNull( $json );
19
-		$this->assertEquals( 200, $response->getStatusCode() );
20
-		$this->assertArrayHasKey( 'resources', $json['meta'] );
21
-		$this->assertGreaterThan( 1, count( $json['meta']['resources'] ) );
18
+		$this->assertNotNull($json);
19
+		$this->assertEquals(200, $response->getStatusCode());
20
+		$this->assertArrayHasKey('resources', $json['meta']);
21
+		$this->assertGreaterThan(1, count($json['meta']['resources']));
22 22
 	}
23 23
 
24 24
 
25 25
 	public function testPutAction()
26 26
 	{
27 27
 		$client = static::createClient();
28
-		$client->request( 'PUT', '/unittest/de/EUR/jsonapi/basket' );
28
+		$client->request('PUT', '/unittest/de/EUR/jsonapi/basket');
29 29
 		$response = $client->getResponse();
30 30
 
31
-		$json = json_decode( $response->getContent(), true );
31
+		$json = json_decode($response->getContent(), true);
32 32
 
33
-		$this->assertNotNull( $json );
34
-		$this->assertEquals( 403, $response->getStatusCode() );
35
-		$this->assertArrayHasKey( 'errors', $json );
33
+		$this->assertNotNull($json);
34
+		$this->assertEquals(403, $response->getStatusCode());
35
+		$this->assertArrayHasKey('errors', $json);
36 36
 	}
37 37
 
38 38
 
39 39
 	public function testGetAttributeAction()
40 40
 	{
41 41
 		$client = static::createClient();
42
-		$client->request( 'GET', '/unittest/de/EUR/jsonapi/attribute', [] );
42
+		$client->request('GET', '/unittest/de/EUR/jsonapi/attribute', []);
43 43
 		$response = $client->getResponse();
44 44
 
45
-		$json = json_decode( $response->getContent(), true );
45
+		$json = json_decode($response->getContent(), true);
46 46
 
47
-		$this->assertNotNull( $json );
48
-		$this->assertEquals( 200, $response->getStatusCode() );
49
-		$this->assertEquals( 25, $json['meta']['total'] );
50
-		$this->assertEquals( 25, count( $json['data'] ) );
47
+		$this->assertNotNull($json);
48
+		$this->assertEquals(200, $response->getStatusCode());
49
+		$this->assertEquals(25, $json['meta']['total']);
50
+		$this->assertEquals(25, count($json['data']));
51 51
 	}
52 52
 
53 53
 
54 54
 	public function testGetCatalogAction()
55 55
 	{
56 56
 		$client = static::createClient();
57
-		$client->request( 'GET', '/unittest/de/EUR/jsonapi/catalog', [] );
57
+		$client->request('GET', '/unittest/de/EUR/jsonapi/catalog', []);
58 58
 		$response = $client->getResponse();
59 59
 
60
-		$json = json_decode( $response->getContent(), true );
60
+		$json = json_decode($response->getContent(), true);
61 61
 
62
-		$this->assertNotNull( $json );
63
-		$this->assertEquals( 200, $response->getStatusCode() );
64
-		$this->assertEquals( 1, $json['meta']['total'] );
65
-		$this->assertEquals( 4, count( $json['data'] ) );
62
+		$this->assertNotNull($json);
63
+		$this->assertEquals(200, $response->getStatusCode());
64
+		$this->assertEquals(1, $json['meta']['total']);
65
+		$this->assertEquals(4, count($json['data']));
66 66
 	}
67 67
 
68 68
 
69 69
 	public function testGetLocaleAction()
70 70
 	{
71 71
 		$client = static::createClient();
72
-		$client->request( 'GET', '/unittest/de/EUR/jsonapi/locale', [] );
72
+		$client->request('GET', '/unittest/de/EUR/jsonapi/locale', []);
73 73
 		$response = $client->getResponse();
74 74
 
75
-		$json = json_decode( $response->getContent(), true );
75
+		$json = json_decode($response->getContent(), true);
76 76
 
77
-		$this->assertNotNull( $json );
78
-		$this->assertEquals( 200, $response->getStatusCode() );
79
-		$this->assertEquals( 1, $json['meta']['total'] );
80
-		$this->assertEquals( 1, count( $json['data'] ) );
77
+		$this->assertNotNull($json);
78
+		$this->assertEquals(200, $response->getStatusCode());
79
+		$this->assertEquals(1, $json['meta']['total']);
80
+		$this->assertEquals(1, count($json['data']));
81 81
 	}
82 82
 
83 83
 
@@ -86,60 +86,60 @@  discard block
 block discarded – undo
86 86
 		$client = static::createClient();
87 87
 
88 88
 		$params = ['filter' => ['f_search' => 'Cafe Noire Cap', 'f_listtype' => 'unittype19']];
89
-		$client->request( 'GET', '/unittest/de/EUR/jsonapi/product', $params );
89
+		$client->request('GET', '/unittest/de/EUR/jsonapi/product', $params);
90 90
 		$response = $client->getResponse();
91 91
 
92
-		$json = json_decode( $response->getContent(), true );
92
+		$json = json_decode($response->getContent(), true);
93 93
 
94
-		$this->assertNotNull( $json );
95
-		$this->assertEquals( 200, $response->getStatusCode() );
96
-		$this->assertEquals( 1, $json['meta']['total'] );
97
-		$this->assertEquals( 1, count( $json['data'] ) );
98
-		$this->assertArrayHasKey( 'id', $json['data'][0] );
99
-		$this->assertEquals( 'CNC', $json['data'][0]['attributes']['product.code'] );
94
+		$this->assertNotNull($json);
95
+		$this->assertEquals(200, $response->getStatusCode());
96
+		$this->assertEquals(1, $json['meta']['total']);
97
+		$this->assertEquals(1, count($json['data']));
98
+		$this->assertArrayHasKey('id', $json['data'][0]);
99
+		$this->assertEquals('CNC', $json['data'][0]['attributes']['product.code']);
100 100
 
101 101
 		$id = $json['data'][0]['id'];
102 102
 
103
-		$client->request( 'GET', '/unittest/de/EUR/jsonapi/product/' . $id );
103
+		$client->request('GET', '/unittest/de/EUR/jsonapi/product/'.$id);
104 104
 		$response = $client->getResponse();
105 105
 
106
-		$json = json_decode( $response->getContent(), true );
106
+		$json = json_decode($response->getContent(), true);
107 107
 
108
-		$this->assertNotNull( $json );
109
-		$this->assertEquals( 200, $response->getStatusCode() );
110
-		$this->assertEquals( 1, $json['meta']['total'] );
111
-		$this->assertArrayHasKey( 'id', $json['data'] );
112
-		$this->assertEquals( 'CNC', $json['data']['attributes']['product.code'] );
108
+		$this->assertNotNull($json);
109
+		$this->assertEquals(200, $response->getStatusCode());
110
+		$this->assertEquals(1, $json['meta']['total']);
111
+		$this->assertArrayHasKey('id', $json['data']);
112
+		$this->assertEquals('CNC', $json['data']['attributes']['product.code']);
113 113
 	}
114 114
 
115 115
 
116 116
 	public function testGetServiceAction()
117 117
 	{
118 118
 		$client = static::createClient();
119
-		$client->request( 'GET', '/unittest/de/EUR/jsonapi/service', [] );
119
+		$client->request('GET', '/unittest/de/EUR/jsonapi/service', []);
120 120
 		$response = $client->getResponse();
121 121
 
122
-		$json = json_decode( $response->getContent(), true );
122
+		$json = json_decode($response->getContent(), true);
123 123
 
124
-		$this->assertNotNull( $json );
125
-		$this->assertEquals( 200, $response->getStatusCode() );
126
-		$this->assertEquals( 4, $json['meta']['total'] );
127
-		$this->assertEquals( 4, count( $json['data'] ) );
124
+		$this->assertNotNull($json);
125
+		$this->assertEquals(200, $response->getStatusCode());
126
+		$this->assertEquals(4, $json['meta']['total']);
127
+		$this->assertEquals(4, count($json['data']));
128 128
 	}
129 129
 
130 130
 
131 131
 	public function testGetStockAction()
132 132
 	{
133 133
 		$client = static::createClient();
134
-		$client->request( 'GET', '/unittest/de/EUR/jsonapi/stock', ['filter' => ['s_prodcode' => ['CNC', 'CNE']]] );
134
+		$client->request('GET', '/unittest/de/EUR/jsonapi/stock', ['filter' => ['s_prodcode' => ['CNC', 'CNE']]]);
135 135
 		$response = $client->getResponse();
136 136
 
137
-		$json = json_decode( $response->getContent(), true );
137
+		$json = json_decode($response->getContent(), true);
138 138
 
139
-		$this->assertNotNull( $json );
140
-		$this->assertEquals( 200, $response->getStatusCode() );
141
-		$this->assertEquals( 2, $json['meta']['total'] );
142
-		$this->assertEquals( 2, count( $json['data'] ) );
139
+		$this->assertNotNull($json);
140
+		$this->assertEquals(200, $response->getStatusCode());
141
+		$this->assertEquals(2, $json['meta']['total']);
142
+		$this->assertEquals(2, count($json['data']));
143 143
 	}
144 144
 
145 145
 
@@ -147,24 +147,24 @@  discard block
 block discarded – undo
147 147
 	{
148 148
 		$client = static::createClient();
149 149
 
150
-		$client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' );
151
-		$optJson = json_decode( $client->getResponse()->getContent(), true );
152
-		$this->assertGreaterThan( 8, count( $optJson['meta']['resources'] ) );
150
+		$client->request('OPTIONS', '/unittest/de/EUR/jsonapi');
151
+		$optJson = json_decode($client->getResponse()->getContent(), true);
152
+		$this->assertGreaterThan(8, count($optJson['meta']['resources']));
153 153
 
154 154
 		// catalog root
155
-		$client->request( 'GET', $optJson['meta']['resources']['catalog'], ['include' => 'catalog'] );
156
-		$json = json_decode( $client->getResponse()->getContent(), true );
157
-		$this->assertEquals( 'categories', $json['included'][0]['attributes']['catalog.code'] );
155
+		$client->request('GET', $optJson['meta']['resources']['catalog'], ['include' => 'catalog']);
156
+		$json = json_decode($client->getResponse()->getContent(), true);
157
+		$this->assertEquals('categories', $json['included'][0]['attributes']['catalog.code']);
158 158
 
159 159
 		// "categories" category
160
-		$client->request( 'GET', $json['included'][0]['links']['self']['href'], ['include' => 'catalog'] );
161
-		$json = json_decode( $client->getResponse()->getContent(), true );
162
-		$this->assertEquals( 'cafe', $json['included'][0]['attributes']['catalog.code'] );
160
+		$client->request('GET', $json['included'][0]['links']['self']['href'], ['include' => 'catalog']);
161
+		$json = json_decode($client->getResponse()->getContent(), true);
162
+		$this->assertEquals('cafe', $json['included'][0]['attributes']['catalog.code']);
163 163
 
164 164
 		// product list for "cafe" category
165
-		$client->request( 'GET', $optJson['meta']['resources']['product'], ['f_catid' => $json['included'][0]['id']] );
166
-		$json = json_decode( $client->getResponse()->getContent(), true );
167
-		$this->assertEquals( 'CNE', $json['data'][0]['attributes']['product.code'] );
165
+		$client->request('GET', $optJson['meta']['resources']['product'], ['f_catid' => $json['included'][0]['id']]);
166
+		$json = json_decode($client->getResponse()->getContent(), true);
167
+		$this->assertEquals('CNE', $json['data'][0]['attributes']['product.code']);
168 168
 	}
169 169
 
170 170
 
@@ -172,26 +172,26 @@  discard block
 block discarded – undo
172 172
 	{
173 173
 		$client = static::createClient();
174 174
 
175
-		$client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' );
176
-		$options = json_decode( $client->getResponse()->getContent(), true );
177
-		$this->assertGreaterThan( 8, count( $options['meta']['resources'] ) );
175
+		$client->request('OPTIONS', '/unittest/de/EUR/jsonapi');
176
+		$options = json_decode($client->getResponse()->getContent(), true);
177
+		$this->assertGreaterThan(8, count($options['meta']['resources']));
178 178
 
179 179
 		// all available attrbutes
180
-		$client->request( 'GET', $options['meta']['resources']['attribute'] );
181
-		$json = json_decode( $client->getResponse()->getContent(), true );
180
+		$client->request('GET', $options['meta']['resources']['attribute']);
181
+		$json = json_decode($client->getResponse()->getContent(), true);
182 182
 
183
-		foreach( $json['data'] as $entry )
183
+		foreach ($json['data'] as $entry)
184 184
 		{
185
-			if( $entry['attributes']['attribute.code'] === 'xl' )
185
+			if ($entry['attributes']['attribute.code'] === 'xl')
186 186
 			{
187 187
 				// products with attrbute "xl"
188
-				$client->request( 'GET', $options['meta']['resources']['product'], ['filter' => ['f_attrid' => $entry['id']]] );
188
+				$client->request('GET', $options['meta']['resources']['product'], ['filter' => ['f_attrid' => $entry['id']]]);
189 189
 				break;
190 190
 			}
191 191
 		}
192 192
 
193
-		$json = json_decode( $client->getResponse()->getContent(), true );
194
-		$this->assertEquals( 2, $json['meta']['total'] );
193
+		$json = json_decode($client->getResponse()->getContent(), true);
194
+		$this->assertEquals(2, $json['meta']['total']);
195 195
 	}
196 196
 
197 197
 
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 	{
200 200
 		$client = static::createClient();
201 201
 
202
-		$client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' );
203
-		$json = json_decode( $client->getResponse()->getContent(), true );
204
-		$this->assertGreaterThan( 8, count( $json['meta']['resources'] ) );
202
+		$client->request('OPTIONS', '/unittest/de/EUR/jsonapi');
203
+		$json = json_decode($client->getResponse()->getContent(), true);
204
+		$this->assertGreaterThan(8, count($json['meta']['resources']));
205 205
 
206 206
 		// product list for full text search
207
-		$client->request( 'GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'selection']] );
208
-		$json = json_decode( $client->getResponse()->getContent(), true );
209
-		$this->assertEquals( 3, count( $json['data'] ) );
207
+		$client->request('GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'selection']]);
208
+		$json = json_decode($client->getResponse()->getContent(), true);
209
+		$this->assertEquals(3, count($json['data']));
210 210
 	}
211 211
 
212 212
 
@@ -214,23 +214,23 @@  discard block
 block discarded – undo
214 214
 	{
215 215
 		$client = static::createClient();
216 216
 
217
-		$client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' );
218
-		$json = json_decode( $client->getResponse()->getContent(), true );
219
-		$this->assertGreaterThan( 8, count( $json['meta']['resources'] ) );
217
+		$client->request('OPTIONS', '/unittest/de/EUR/jsonapi');
218
+		$json = json_decode($client->getResponse()->getContent(), true);
219
+		$this->assertGreaterThan(8, count($json['meta']['resources']));
220 220
 
221 221
 		// get empty basket
222
-		$client->request( 'GET', $json['meta']['resources']['basket'] );
223
-		$json = json_decode( $client->getResponse()->getContent(), true );
224
-		$this->assertEquals( 'basket', $json['data']['type'] );
222
+		$client->request('GET', $json['meta']['resources']['basket']);
223
+		$json = json_decode($client->getResponse()->getContent(), true);
224
+		$this->assertEquals('basket', $json['data']['type']);
225 225
 
226 226
 		$content = '{"data": {"id": "delivery", "attributes": {"order.base.address.firstname": "test"}}}';
227
-		$client->request( 'POST', $json['links']['basket/address']['href'], [], [], [], $content );
228
-		$json = json_decode( $client->getResponse()->getContent(), true );
229
-		$this->assertEquals( 'basket/address', $json['included'][0]['type'] );
227
+		$client->request('POST', $json['links']['basket/address']['href'], [], [], [], $content);
228
+		$json = json_decode($client->getResponse()->getContent(), true);
229
+		$this->assertEquals('basket/address', $json['included'][0]['type']);
230 230
 
231
-		$client->request( 'DELETE', $json['included'][0]['links']['self']['href'] );
232
-		$json = json_decode( $client->getResponse()->getContent(), true );
233
-		$this->assertEquals( 0, count( $json['included'] ) );
231
+		$client->request('DELETE', $json['included'][0]['links']['self']['href']);
232
+		$json = json_decode($client->getResponse()->getContent(), true);
233
+		$this->assertEquals(0, count($json['included']));
234 234
 	}
235 235
 
236 236
 
@@ -238,31 +238,31 @@  discard block
 block discarded – undo
238 238
 	{
239 239
 		$client = static::createClient();
240 240
 
241
-		$client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' );
242
-		$json = json_decode( $client->getResponse()->getContent(), true );
243
-		$this->assertGreaterThan( 8, count( $json['meta']['resources'] ) );
241
+		$client->request('OPTIONS', '/unittest/de/EUR/jsonapi');
242
+		$json = json_decode($client->getResponse()->getContent(), true);
243
+		$this->assertGreaterThan(8, count($json['meta']['resources']));
244 244
 
245 245
 		// product for code "CNC"
246
-		$client->request( 'GET', $json['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]] );
247
-		$json = json_decode( $client->getResponse()->getContent(), true );
248
-		$this->assertEquals( 1, count( $json['data'] ) );
246
+		$client->request('GET', $json['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]]);
247
+		$json = json_decode($client->getResponse()->getContent(), true);
248
+		$this->assertEquals(1, count($json['data']));
249 249
 
250 250
 		// add product "CNC" as prerequisite
251
-		$content = '{"data": {"attributes": {"product.id": ' . $json['data'][0]['id'] . '}}}';
252
-		$client->request( 'POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content );
253
-		$json = json_decode( $client->getResponse()->getContent(), true );
254
-		$this->assertEquals( 'basket/product', $json['included'][0]['type'] );
251
+		$content = '{"data": {"attributes": {"product.id": '.$json['data'][0]['id'].'}}}';
252
+		$client->request('POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content);
253
+		$json = json_decode($client->getResponse()->getContent(), true);
254
+		$this->assertEquals('basket/product', $json['included'][0]['type']);
255 255
 
256 256
 		// add coupon "GHIJ"
257 257
 		$content = '{"data": {"id": "GHIJ"}}';
258
-		$client->request( 'POST', $json['links']['basket/coupon']['href'], [], [], [], $content );
259
-		$json = json_decode( $client->getResponse()->getContent(), true );
260
-		$this->assertEquals( 'basket/coupon', $json['included'][2]['type'] );
258
+		$client->request('POST', $json['links']['basket/coupon']['href'], [], [], [], $content);
259
+		$json = json_decode($client->getResponse()->getContent(), true);
260
+		$this->assertEquals('basket/coupon', $json['included'][2]['type']);
261 261
 
262 262
 		// remove coupon "GHIJ" again
263
-		$client->request( 'DELETE', $json['included'][2]['links']['self']['href'] );
264
-		$json = json_decode( $client->getResponse()->getContent(), true );
265
-		$this->assertEquals( 1, count( $json['included'] ) );
263
+		$client->request('DELETE', $json['included'][2]['links']['self']['href']);
264
+		$json = json_decode($client->getResponse()->getContent(), true);
265
+		$this->assertEquals(1, count($json['included']));
266 266
 	}
267 267
 
268 268
 
@@ -270,28 +270,28 @@  discard block
 block discarded – undo
270 270
 	{
271 271
 		$client = static::createClient();
272 272
 
273
-		$client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' );
274
-		$json = json_decode( $client->getResponse()->getContent(), true );
275
-		$this->assertGreaterThan( 8, count( $json['meta']['resources'] ) );
273
+		$client->request('OPTIONS', '/unittest/de/EUR/jsonapi');
274
+		$json = json_decode($client->getResponse()->getContent(), true);
275
+		$this->assertGreaterThan(8, count($json['meta']['resources']));
276 276
 
277 277
 		// product for code "CNC"
278
-		$client->request( 'GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'ABCD']] );
279
-		$json = json_decode( $client->getResponse()->getContent(), true );
280
-		$this->assertEquals( 1, count( $json['data'] ) );
278
+		$client->request('GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'ABCD']]);
279
+		$json = json_decode($client->getResponse()->getContent(), true);
280
+		$this->assertEquals(1, count($json['data']));
281 281
 
282
-		$content = '{"data": {"attributes": {"product.id": ' . $json['data'][0]['id'] . '}}}';
283
-		$client->request( 'POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content );
284
-		$json = json_decode( $client->getResponse()->getContent(), true );
285
-		$this->assertEquals( 'basket/product', $json['included'][0]['type'] );
282
+		$content = '{"data": {"attributes": {"product.id": '.$json['data'][0]['id'].'}}}';
283
+		$client->request('POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content);
284
+		$json = json_decode($client->getResponse()->getContent(), true);
285
+		$this->assertEquals('basket/product', $json['included'][0]['type']);
286 286
 
287 287
 		$content = '{"data": {"attributes": {"quantity": 2}}}';
288
-		$client->request( 'PATCH', $json['included'][0]['links']['self']['href'], [], [], [], $content );
289
-		$json = json_decode( $client->getResponse()->getContent(), true );
290
-		$this->assertEquals( 2, $json['included'][0]['attributes']['order.base.product.quantity'] );
288
+		$client->request('PATCH', $json['included'][0]['links']['self']['href'], [], [], [], $content);
289
+		$json = json_decode($client->getResponse()->getContent(), true);
290
+		$this->assertEquals(2, $json['included'][0]['attributes']['order.base.product.quantity']);
291 291
 
292
-		$client->request( 'DELETE', $json['included'][0]['links']['self']['href'] );
293
-		$json = json_decode( $client->getResponse()->getContent(), true );
294
-		$this->assertEquals( 0, count( $json['included'] ) );
292
+		$client->request('DELETE', $json['included'][0]['links']['self']['href']);
293
+		$json = json_decode($client->getResponse()->getContent(), true);
294
+		$this->assertEquals(0, count($json['included']));
295 295
 	}
296 296
 
297 297
 
@@ -299,14 +299,14 @@  discard block
 block discarded – undo
299 299
 	{
300 300
 		$client = static::createClient();
301 301
 
302
-		$client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' );
303
-		$json = json_decode( $client->getResponse()->getContent(), true );
304
-		$this->assertGreaterThan( 8, count( $json['meta']['resources'] ) );
302
+		$client->request('OPTIONS', '/unittest/de/EUR/jsonapi');
303
+		$json = json_decode($client->getResponse()->getContent(), true);
304
+		$this->assertGreaterThan(8, count($json['meta']['resources']));
305 305
 
306 306
 		// payment services
307
-		$client->request( 'GET', $json['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']] );
308
-		$json = json_decode( $client->getResponse()->getContent(), true );
309
-		$this->assertEquals( 3, count( $json['data'] ) );
307
+		$client->request('GET', $json['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']]);
308
+		$json = json_decode($client->getResponse()->getContent(), true);
309
+		$this->assertEquals(3, count($json['data']));
310 310
 
311 311
 		$content = ['data' => ['id' => 'payment', 'attributes' => [
312 312
 			'service.id' => $json['data'][1]['id'],
@@ -315,15 +315,15 @@  discard block
 block discarded – undo
315 315
 			'directdebit.bankcode' => 'ABCDEFGH',
316 316
 			'directdebit.bankname' => 'test bank',
317 317
 		]]];
318
-		$client->request( 'POST', $json['data'][1]['links']['basket/service']['href'], [], [], [], json_encode( $content ) );
319
-		$json = json_decode( $client->getResponse()->getContent(), true );
320
-		$this->assertEquals( 'basket/service', $json['included'][0]['type'] );
321
-		$this->assertEquals( 'directdebit-test', $json['included'][0]['attributes']['order.base.service.code'] );
322
-		$this->assertEquals( 5, count( $json['included'][0]['attributes']['attribute'] ) );
323
-
324
-		$client->request( 'DELETE', $json['included'][0]['links']['self']['href'] );
325
-		$json = json_decode( $client->getResponse()->getContent(), true );
326
-		$this->assertEquals( 0, count( $json['included'] ) );
318
+		$client->request('POST', $json['data'][1]['links']['basket/service']['href'], [], [], [], json_encode($content));
319
+		$json = json_decode($client->getResponse()->getContent(), true);
320
+		$this->assertEquals('basket/service', $json['included'][0]['type']);
321
+		$this->assertEquals('directdebit-test', $json['included'][0]['attributes']['order.base.service.code']);
322
+		$this->assertEquals(5, count($json['included'][0]['attributes']['attribute']));
323
+
324
+		$client->request('DELETE', $json['included'][0]['links']['self']['href']);
325
+		$json = json_decode($client->getResponse()->getContent(), true);
326
+		$this->assertEquals(0, count($json['included']));
327 327
 	}
328 328
 
329 329
 
@@ -332,17 +332,17 @@  discard block
 block discarded – undo
332 332
 		$client = static::createClient(array(), array(
333 333
 			'PHP_AUTH_USER' => 'UTC001',
334 334
 			'PHP_AUTH_PW'   => 'unittest',
335
-		) );
335
+		));
336 336
 
337
-		$client->request( 'GET', '/unittest/de/EUR/jsonapi/customer', [] );
337
+		$client->request('GET', '/unittest/de/EUR/jsonapi/customer', []);
338 338
 		$response = $client->getResponse();
339 339
 
340
-		$json = json_decode( $response->getContent(), true );
340
+		$json = json_decode($response->getContent(), true);
341 341
 
342
-		$this->assertNotNull( $json );
343
-		$this->assertEquals( 200, $response->getStatusCode() );
344
-		$this->assertEquals( 1, $json['meta']['total'] );
345
-		$this->assertEquals( 4, count( $json['data'] ) );
342
+		$this->assertNotNull($json);
343
+		$this->assertEquals(200, $response->getStatusCode());
344
+		$this->assertEquals(1, $json['meta']['total']);
345
+		$this->assertEquals(4, count($json['data']));
346 346
 	}
347 347
 
348 348
 
@@ -351,22 +351,22 @@  discard block
 block discarded – undo
351 351
 		$client = static::createClient(array(), array(
352 352
 			'PHP_AUTH_USER' => 'UTC001',
353 353
 			'PHP_AUTH_PW'   => 'unittest',
354
-		) );
354
+		));
355 355
 
356
-		$client->request( 'GET', '/unittest/de/EUR/jsonapi/customer', [] );
356
+		$client->request('GET', '/unittest/de/EUR/jsonapi/customer', []);
357 357
 		$response = $client->getResponse();
358 358
 
359
-		$json = json_decode( $response->getContent(), true );
359
+		$json = json_decode($response->getContent(), true);
360 360
 
361
-		$client->request( 'GET', $json['links']['customer/address']['href'], [] );
361
+		$client->request('GET', $json['links']['customer/address']['href'], []);
362 362
 		$response = $client->getResponse();
363 363
 
364
-		$json = json_decode( $response->getContent(), true );
364
+		$json = json_decode($response->getContent(), true);
365 365
 
366
-		$this->assertNotNull( $json );
367
-		$this->assertEquals( 200, $response->getStatusCode() );
368
-		$this->assertEquals( 1, $json['meta']['total'] );
369
-		$this->assertEquals( 1, count( $json['data'] ) );
366
+		$this->assertNotNull($json);
367
+		$this->assertEquals(200, $response->getStatusCode());
368
+		$this->assertEquals(1, $json['meta']['total']);
369
+		$this->assertEquals(1, count($json['data']));
370 370
 	}
371 371
 
372 372
 
@@ -375,17 +375,17 @@  discard block
 block discarded – undo
375 375
 		$client = static::createClient(array(), array(
376 376
 			'PHP_AUTH_USER' => 'UTC001',
377 377
 			'PHP_AUTH_PW'   => 'unittest',
378
-		) );
378
+		));
379 379
 
380
-		$client->request( 'GET', '/unittest/de/EUR/jsonapi/order', [] );
380
+		$client->request('GET', '/unittest/de/EUR/jsonapi/order', []);
381 381
 		$response = $client->getResponse();
382 382
 
383
-		$json = json_decode( $response->getContent(), true );
383
+		$json = json_decode($response->getContent(), true);
384 384
 
385
-		$this->assertNotNull( $json );
386
-		$this->assertEquals( 200, $response->getStatusCode() );
387
-		$this->assertEquals( 5, $json['meta']['total'] );
388
-		$this->assertEquals( 5, count( $json['data'] ) );
385
+		$this->assertNotNull($json);
386
+		$this->assertEquals(200, $response->getStatusCode());
387
+		$this->assertEquals(5, $json['meta']['total']);
388
+		$this->assertEquals(5, count($json['data']));
389 389
 	}
390 390
 
391 391
 
@@ -393,63 +393,63 @@  discard block
 block discarded – undo
393 393
 	{
394 394
 		$client = static::createClient();
395 395
 
396
-		$client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' );
397
-		$optJson = json_decode( $client->getResponse()->getContent(), true );
398
-		$this->assertGreaterThan( 8, count( $optJson['meta']['resources'] ) );
396
+		$client->request('OPTIONS', '/unittest/de/EUR/jsonapi');
397
+		$optJson = json_decode($client->getResponse()->getContent(), true);
398
+		$this->assertGreaterThan(8, count($optJson['meta']['resources']));
399 399
 
400 400
 		// product for code "CNC"
401
-		$client->request( 'GET', $optJson['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]] );
402
-		$json = json_decode( $client->getResponse()->getContent(), true );
403
-		$this->assertEquals( 1, count( $json['data'] ) );
401
+		$client->request('GET', $optJson['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]]);
402
+		$json = json_decode($client->getResponse()->getContent(), true);
403
+		$this->assertEquals(1, count($json['data']));
404 404
 
405 405
 		// add product "CNC"
406
-		$content = '{"data": {"attributes": {"product.id": ' . $json['data'][0]['id'] . '}}}';
407
-		$client->request( 'POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content );
408
-		$json = json_decode( $client->getResponse()->getContent(), true );
409
-		$this->assertEquals( 'basket/product', $json['included'][0]['type'] );
406
+		$content = '{"data": {"attributes": {"product.id": '.$json['data'][0]['id'].'}}}';
407
+		$client->request('POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content);
408
+		$json = json_decode($client->getResponse()->getContent(), true);
409
+		$this->assertEquals('basket/product', $json['included'][0]['type']);
410 410
 
411 411
 		// delivery services
412
-		$client->request( 'GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'delivery']] );
413
-		$json = json_decode( $client->getResponse()->getContent(), true );
414
-		$this->assertEquals( 1, count( $json['data'] ) );
412
+		$client->request('GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'delivery']]);
413
+		$json = json_decode($client->getResponse()->getContent(), true);
414
+		$this->assertEquals(1, count($json['data']));
415 415
 
416 416
 		// add delivery service
417
-		$content = '{"data": {"id": "delivery", "attributes": {"service.id": ' . $json['data'][0]['id'] . '}}}';
418
-		$client->request( 'POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content );
419
-		$json = json_decode( $client->getResponse()->getContent(), true );
420
-		$this->assertEquals( 'basket/service', $json['included'][1]['type'] );
417
+		$content = '{"data": {"id": "delivery", "attributes": {"service.id": '.$json['data'][0]['id'].'}}}';
418
+		$client->request('POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content);
419
+		$json = json_decode($client->getResponse()->getContent(), true);
420
+		$this->assertEquals('basket/service', $json['included'][1]['type']);
421 421
 
422 422
 		// payment services
423
-		$client->request( 'GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']] );
424
-		$json = json_decode( $client->getResponse()->getContent(), true );
425
-		$this->assertEquals( 3, count( $json['data'] ) );
423
+		$client->request('GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']]);
424
+		$json = json_decode($client->getResponse()->getContent(), true);
425
+		$this->assertEquals(3, count($json['data']));
426 426
 
427 427
 		// add payment service
428
-		$content = '{"data": {"id": "payment", "attributes": {"service.id": ' . $json['data'][0]['id'] . '}}}';
429
-		$client->request( 'POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content );
430
-		$json = json_decode( $client->getResponse()->getContent(), true );
431
-		$this->assertEquals( 'basket/service', $json['included'][2]['type'] );
428
+		$content = '{"data": {"id": "payment", "attributes": {"service.id": '.$json['data'][0]['id'].'}}}';
429
+		$client->request('POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content);
430
+		$json = json_decode($client->getResponse()->getContent(), true);
431
+		$this->assertEquals('basket/service', $json['included'][2]['type']);
432 432
 
433 433
 		// add address
434 434
 		$content = '{"data": {"id": "payment", "attributes": {"order.base.address.firstname": "test"}}}';
435
-		$client->request( 'POST', $json['links']['basket/address']['href'], [], [], [], $content );
436
-		$json = json_decode( $client->getResponse()->getContent(), true );
437
-		$this->assertEquals( 'basket/address', $json['included'][3]['type'] );
435
+		$client->request('POST', $json['links']['basket/address']['href'], [], [], [], $content);
436
+		$json = json_decode($client->getResponse()->getContent(), true);
437
+		$this->assertEquals('basket/address', $json['included'][3]['type']);
438 438
 
439 439
 		// store basket
440
-		$client->request( 'POST', $json['data']['links']['self']['href'] );
441
-		$basketJson = json_decode( $client->getResponse()->getContent(), true );
442
-		$this->assertEquals( true, ctype_digit( $basketJson['data']['id'] ) );
440
+		$client->request('POST', $json['data']['links']['self']['href']);
441
+		$basketJson = json_decode($client->getResponse()->getContent(), true);
442
+		$this->assertEquals(true, ctype_digit($basketJson['data']['id']));
443 443
 
444 444
 		// add order
445
-		$content = '{"data": {"attributes": {"order.baseid": ' . $basketJson['data']['id'] . '}}}';
446
-		$client->request( 'POST', $basketJson['links']['order']['href'], [], [], [], $content );
447
-		$json = json_decode( $client->getResponse()->getContent(), true );
448
-		$this->assertEquals( true, ctype_digit( $json['data']['id'] ) );
445
+		$content = '{"data": {"attributes": {"order.baseid": '.$basketJson['data']['id'].'}}}';
446
+		$client->request('POST', $basketJson['links']['order']['href'], [], [], [], $content);
447
+		$json = json_decode($client->getResponse()->getContent(), true);
448
+		$this->assertEquals(true, ctype_digit($json['data']['id']));
449 449
 
450 450
 
451 451
 		// delete created order
452
-		$context = static::$kernel->getContainer()->get( 'aimeos_context' )->get();
453
-		\Aimeos\MShop\Factory::createManager( $context, 'order/base' )->deleteItem( $basketJson['data']['id'] );
452
+		$context = static::$kernel->getContainer()->get('aimeos_context')->get();
453
+		\Aimeos\MShop\Factory::createManager($context, 'order/base')->deleteItem($basketJson['data']['id']);
454 454
 	}
455 455
 }
Please login to merge, or discard this patch.
Tests/Controller/JqadmControllerTest.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 		$client = static::createClient(array(), array(
13 13
 			'PHP_AUTH_USER' => 'admin',
14 14
 			'PHP_AUTH_PW'   => 'adminpass',
15
-		) );
15
+		));
16 16
 
17
-		$client->request( 'GET', '/unittest/jqadm/file/css' );
17
+		$client->request('GET', '/unittest/jqadm/file/css');
18 18
 
19
-		$this->assertEquals( 200, $client->getResponse()->getStatusCode() );
20
-		$this->assertContains( '.aimeos', $client->getResponse()->getContent() );
19
+		$this->assertEquals(200, $client->getResponse()->getStatusCode());
20
+		$this->assertContains('.aimeos', $client->getResponse()->getContent());
21 21
 	}
22 22
 
23 23
 
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 		$client = static::createClient(array(), array(
27 27
 			'PHP_AUTH_USER' => 'admin',
28 28
 			'PHP_AUTH_PW'   => 'adminpass',
29
-		) );
29
+		));
30 30
 
31
-		$client->request( 'GET', '/unittest/jqadm/file/js' );
31
+		$client->request('GET', '/unittest/jqadm/file/js');
32 32
 
33
-		$this->assertEquals( 200, $client->getResponse()->getStatusCode() );
34
-		$this->assertContains( 'Aimeos = {', $client->getResponse()->getContent() );
33
+		$this->assertEquals(200, $client->getResponse()->getStatusCode());
34
+		$this->assertContains('Aimeos = {', $client->getResponse()->getContent());
35 35
 	}
36 36
 
37 37
 
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
 		$client = static::createClient(array(), array(
41 41
 			'PHP_AUTH_USER' => 'admin',
42 42
 			'PHP_AUTH_PW'   => 'adminpass',
43
-		) );
43
+		));
44 44
 
45
-		$client->request( 'GET', '/unittest/jqadm/copy/product/0' );
45
+		$client->request('GET', '/unittest/jqadm/copy/product/0');
46 46
 		$response = $client->getResponse();
47 47
 
48
-		$this->assertEquals( 200, $response->getStatusCode() );
49
-		$this->assertContains( 'item-product', $response->getContent() );
48
+		$this->assertEquals(200, $response->getStatusCode());
49
+		$this->assertContains('item-product', $response->getContent());
50 50
 	}
51 51
 
52 52
 
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
 		$client = static::createClient(array(), array(
56 56
 			'PHP_AUTH_USER' => 'admin',
57 57
 			'PHP_AUTH_PW'   => 'adminpass',
58
-		) );
58
+		));
59 59
 
60
-		$client->request( 'GET', '/unittest/jqadm/create/product' );
60
+		$client->request('GET', '/unittest/jqadm/create/product');
61 61
 		$response = $client->getResponse();
62 62
 
63
-		$this->assertEquals( 200, $response->getStatusCode() );
64
-		$this->assertContains( 'item-product', $response->getContent() );
63
+		$this->assertEquals(200, $response->getStatusCode());
64
+		$this->assertContains('item-product', $response->getContent());
65 65
 	}
66 66
 
67 67
 
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
 		$client = static::createClient(array(), array(
71 71
 			'PHP_AUTH_USER' => 'admin',
72 72
 			'PHP_AUTH_PW'   => 'adminpass',
73
-		) );
73
+		));
74 74
 
75
-		$client->request( 'GET', '/unittest/jqadm/delete/product/0' );
75
+		$client->request('GET', '/unittest/jqadm/delete/product/0');
76 76
 		$response = $client->getResponse();
77 77
 
78
-		$this->assertEquals( 200, $response->getStatusCode() );
79
-		$this->assertContains( 'list-items', $response->getContent() );
78
+		$this->assertEquals(200, $response->getStatusCode());
79
+		$this->assertContains('list-items', $response->getContent());
80 80
 	}
81 81
 
82 82
 
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 		$client = static::createClient(array(), array(
86 86
 			'PHP_AUTH_USER' => 'admin',
87 87
 			'PHP_AUTH_PW'   => 'adminpass',
88
-		) );
88
+		));
89 89
 
90
-		$client->request( 'GET', '/unittest/jqadm/get/product/0' );
90
+		$client->request('GET', '/unittest/jqadm/get/product/0');
91 91
 		$response = $client->getResponse();
92 92
 
93
-		$this->assertEquals( 200, $response->getStatusCode() );
94
-		$this->assertContains( 'item-product', $response->getContent() );
93
+		$this->assertEquals(200, $response->getStatusCode());
94
+		$this->assertContains('item-product', $response->getContent());
95 95
 	}
96 96
 
97 97
 
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 		$client = static::createClient(array(), array(
101 101
 			'PHP_AUTH_USER' => 'admin',
102 102
 			'PHP_AUTH_PW'   => 'adminpass',
103
-		) );
103
+		));
104 104
 
105
-		$client->request( 'POST', '/unittest/jqadm/save/product/0' );
105
+		$client->request('POST', '/unittest/jqadm/save/product/0');
106 106
 		$response = $client->getResponse();
107 107
 
108
-		$this->assertEquals( 200, $response->getStatusCode() );
109
-		$this->assertContains( 'item-product', $response->getContent() );
108
+		$this->assertEquals(200, $response->getStatusCode());
109
+		$this->assertContains('item-product', $response->getContent());
110 110
 	}
111 111
 
112 112
 
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 		$client = static::createClient(array(), array(
116 116
 			'PHP_AUTH_USER' => 'admin',
117 117
 			'PHP_AUTH_PW'   => 'adminpass',
118
-		) );
118
+		));
119 119
 
120
-		$client->request( 'GET', '/unittest/jqadm/search/product' );
120
+		$client->request('GET', '/unittest/jqadm/search/product');
121 121
 		$response = $client->getResponse();
122 122
 
123
-		$this->assertEquals( 200, $response->getStatusCode() );
124
-		$this->assertContains( 'list-items', $response->getContent() );
123
+		$this->assertEquals(200, $response->getStatusCode());
124
+		$this->assertContains('list-items', $response->getContent());
125 125
 	}
126 126
 
127 127
 
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
 		$client = static::createClient(array(), array(
131 131
 			'PHP_AUTH_USER' => 'admin',
132 132
 			'PHP_AUTH_PW'   => 'adminpass',
133
-		) );
133
+		));
134 134
 
135
-		$client->request( 'GET', '/invalid/jqadm/search/product' );
135
+		$client->request('GET', '/invalid/jqadm/search/product');
136 136
 		$response = $client->getResponse();
137 137
 
138
-		$this->assertEquals( 500, $response->getStatusCode() );
138
+		$this->assertEquals(500, $response->getStatusCode());
139 139
 	}
140 140
 }
Please login to merge, or discard this patch.