Completed
Push — master ( 1803e4...e36035 )
by Aimeos
06:43
created
admin/jsonadm/tests/Admin/JsonAdm/Order/StandardTest.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
23 23
 		$this->view = $this->context->getView();
24 24
 
25
-		$this->object = new \Aimeos\Admin\JsonAdm\Order\Standard( $this->context, $this->view, $templatePaths, 'order' );
25
+		$this->object = new \Aimeos\Admin\JsonAdm\Order\Standard($this->context, $this->view, $templatePaths, 'order');
26 26
 	}
27 27
 
28 28
 
@@ -30,25 +30,25 @@  discard block
 block discarded – undo
30 30
 	{
31 31
 		$params = array(
32 32
 			'filter' => array(
33
-				'==' => array( 'order.editor' => 'core:unittest' )
33
+				'==' => array('order.editor' => 'core:unittest')
34 34
 			),
35 35
 			'aggregate' => 'order.cdate',
36 36
 		);
37
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
38
-		$this->view->addHelper( 'param', $helper );
37
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
38
+		$this->view->addHelper('param', $helper);
39 39
 
40 40
 		$header = array();
41 41
 		$status = 500;
42 42
 
43
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
43
+		$result = json_decode($this->object->get('', $header, $status), true);
44 44
 
45
-		$this->assertEquals( 200, $status );
46
-		$this->assertEquals( 1, count( $header ) );
47
-		$this->assertEquals( 1, $result['meta']['total'] );
48
-		$this->assertEquals( 1, count( $result['data'] ) );
49
-		$this->assertEquals( 'aggregate', $result['data'][0]['type'] );
50
-		$this->assertGreaterThan( 0, count( $result['data'][0]['attributes'] ) );
51
-		$this->assertArrayNotHasKey( 'errors', $result );
45
+		$this->assertEquals(200, $status);
46
+		$this->assertEquals(1, count($header));
47
+		$this->assertEquals(1, $result['meta']['total']);
48
+		$this->assertEquals(1, count($result['data']));
49
+		$this->assertEquals('aggregate', $result['data'][0]['type']);
50
+		$this->assertGreaterThan(0, count($result['data'][0]['attributes']));
51
+		$this->assertArrayNotHasKey('errors', $result);
52 52
 	}
53 53
 
54 54
 
@@ -56,27 +56,27 @@  discard block
 block discarded – undo
56 56
 	{
57 57
 		$params = array(
58 58
 			'filter' => array(
59
-				'==' => array( 'order.datepayment' => '2008-02-15 12:34:56' )
59
+				'==' => array('order.datepayment' => '2008-02-15 12:34:56')
60 60
 			),
61 61
 			'include' => 'order/base,order/status'
62 62
 		);
63
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
64
-		$this->view->addHelper( 'param', $helper );
63
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
64
+		$this->view->addHelper('param', $helper);
65 65
 
66 66
 		$header = array();
67 67
 		$status = 500;
68 68
 
69
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
70
-
71
-		$this->assertEquals( 200, $status );
72
-		$this->assertEquals( 1, count( $header ) );
73
-		$this->assertEquals( 1, $result['meta']['total'] );
74
-		$this->assertEquals( 1, count( $result['data'] ) );
75
-		$this->assertEquals( 'order', $result['data'][0]['type'] );
76
-		$this->assertEquals( 3, count( $result['data'][0]['relationships']['order/status'] ) );
77
-		$this->assertEquals( 1, count( $result['data'][0]['relationships']['order/base'] ) );
78
-		$this->assertEquals( 4, count( $result['included'] ) );
79
-		$this->assertArrayNotHasKey( 'errors', $result );
69
+		$result = json_decode($this->object->get('', $header, $status), true);
70
+
71
+		$this->assertEquals(200, $status);
72
+		$this->assertEquals(1, count($header));
73
+		$this->assertEquals(1, $result['meta']['total']);
74
+		$this->assertEquals(1, count($result['data']));
75
+		$this->assertEquals('order', $result['data'][0]['type']);
76
+		$this->assertEquals(3, count($result['data'][0]['relationships']['order/status']));
77
+		$this->assertEquals(1, count($result['data'][0]['relationships']['order/base']));
78
+		$this->assertEquals(4, count($result['included']));
79
+		$this->assertArrayNotHasKey('errors', $result);
80 80
 	}
81 81
 
82 82
 
@@ -89,22 +89,22 @@  discard block
 block discarded – undo
89 89
 			'sort' => 'order.id',
90 90
 			'include' => 'order/status'
91 91
 		);
92
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
93
-		$this->view->addHelper( 'param', $helper );
92
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
93
+		$this->view->addHelper('param', $helper);
94 94
 
95 95
 		$header = array();
96 96
 		$status = 500;
97 97
 
98
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
99
-
100
-		$this->assertEquals( 200, $status );
101
-		$this->assertEquals( 1, count( $header ) );
102
-		$this->assertGreaterThanOrEqual( 4, $result['meta']['total'] );
103
-		$this->assertGreaterThanOrEqual( 4, count( $result['data'] ) );
104
-		$this->assertEquals( 'order', $result['data'][0]['type'] );
105
-		$this->assertEquals( 2, count( $result['data'][0]['attributes'] ) );
106
-		$this->assertGreaterThanOrEqual( 3, count( $result['data'][0]['relationships']['order/status'] ) );
107
-		$this->assertGreaterThanOrEqual( 11, count( $result['included'] ) );
108
-		$this->assertArrayNotHasKey( 'errors', $result );
98
+		$result = json_decode($this->object->get('', $header, $status), true);
99
+
100
+		$this->assertEquals(200, $status);
101
+		$this->assertEquals(1, count($header));
102
+		$this->assertGreaterThanOrEqual(4, $result['meta']['total']);
103
+		$this->assertGreaterThanOrEqual(4, count($result['data']));
104
+		$this->assertEquals('order', $result['data'][0]['type']);
105
+		$this->assertEquals(2, count($result['data'][0]['attributes']));
106
+		$this->assertGreaterThanOrEqual(3, count($result['data'][0]['relationships']['order/status']));
107
+		$this->assertGreaterThanOrEqual(11, count($result['included']));
108
+		$this->assertArrayNotHasKey('errors', $result);
109 109
 	}
110 110
 }
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Standard.php 1 patch
Spacing   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -29,39 +29,39 @@  discard block
 block discarded – undo
29 29
 	 * @param integer &$status Variable which contains the HTTP status afterwards
30 30
 	 * @return string Content for response body
31 31
 	 */
32
-	public function delete( $body, array &$header, &$status )
32
+	public function delete($body, array &$header, &$status)
33 33
 	{
34
-		$header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' );
34
+		$header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"');
35 35
 		$view = $this->getView();
36 36
 
37 37
 		try
38 38
 		{
39
-			$view = $this->deleteItems( $view, $body );
39
+			$view = $this->deleteItems($view, $body);
40 40
 			$status = 200;
41 41
 		}
42
-		catch( \Aimeos\Admin\JsonAdm\Exception $e )
42
+		catch (\Aimeos\Admin\JsonAdm\Exception $e)
43 43
 		{
44 44
 			$status = $e->getCode();
45
-			$view->errors = array( array(
46
-				'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ),
45
+			$view->errors = array(array(
46
+				'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()),
47 47
 				'detail' => $e->getTraceAsString(),
48
-			) );
48
+			));
49 49
 		}
50
-		catch( \Aimeos\MShop\Exception $e )
50
+		catch (\Aimeos\MShop\Exception $e)
51 51
 		{
52 52
 			$status = 404;
53
-			$view->errors = array( array(
54
-				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
53
+			$view->errors = array(array(
54
+				'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()),
55 55
 				'detail' => $e->getTraceAsString(),
56
-			) );
56
+			));
57 57
 		}
58
-		catch( \Exception $e )
58
+		catch (\Exception $e)
59 59
 		{
60 60
 			$status = 500;
61
-			$view->errors = array( array(
61
+			$view->errors = array(array(
62 62
 				'title' => $e->getMessage(),
63 63
 				'detail' => $e->getTraceAsString(),
64
-			) );
64
+			));
65 65
 		}
66 66
 
67 67
 		/** admin/jsonadm/standard/template-delete
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		$tplconf = 'admin/jsonadm/standard/template-delete';
93 93
 		$default = 'delete-default.php';
94 94
 
95
-		return $view->render( $view->config( $tplconf, $default ) );
95
+		return $view->render($view->config($tplconf, $default));
96 96
 	}
97 97
 
98 98
 
@@ -104,41 +104,41 @@  discard block
 block discarded – undo
104 104
 	 * @param integer &$status Variable which contains the HTTP status afterwards
105 105
 	 * @return string Content for response body
106 106
 	 */
107
-	public function get( $body, array &$header, &$status )
107
+	public function get($body, array &$header, &$status)
108 108
 	{
109
-		$header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' );
109
+		$header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"');
110 110
 
111 111
 		$view = $this->getView();
112
-		$aggregate = $view->param( 'aggregate' );
112
+		$aggregate = $view->param('aggregate');
113 113
 
114 114
 		try
115 115
 		{
116
-			if( $aggregate !== null ) {
117
-				$view = $this->getAggregate( $view );
116
+			if ($aggregate !== null) {
117
+				$view = $this->getAggregate($view);
118 118
 			} else {
119
-				$view = $this->getItems( $view );
119
+				$view = $this->getItems($view);
120 120
 			}
121 121
 
122 122
 			$status = 200;
123 123
 		}
124
-		catch( \Aimeos\MShop\Exception $e )
124
+		catch (\Aimeos\MShop\Exception $e)
125 125
 		{
126 126
 			$status = 404;
127
-			$view->errors = array( array(
128
-				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
127
+			$view->errors = array(array(
128
+				'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()),
129 129
 				'detail' => $e->getTraceAsString(),
130
-			) );
130
+			));
131 131
 		}
132
-		catch( \Exception $e )
132
+		catch (\Exception $e)
133 133
 		{
134 134
 			$status = 500;
135
-			$view->errors = array( array(
135
+			$view->errors = array(array(
136 136
 				'title' => $e->getMessage(),
137 137
 				'detail' => $e->getTraceAsString(),
138
-			) );
138
+			));
139 139
 		}
140 140
 
141
-		if( $aggregate !== null )
141
+		if ($aggregate !== null)
142 142
 		{
143 143
 			/** admin/jsonadm/standard/template-aggregate
144 144
 			 * Relative path to the JSON API template for GET aggregate requests
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			$default = 'get-default.php';
200 200
 		}
201 201
 
202
-		return $view->render( $view->config( $tplconf, $default ) );
202
+		return $view->render($view->config($tplconf, $default));
203 203
 	}
204 204
 
205 205
 
@@ -211,39 +211,39 @@  discard block
 block discarded – undo
211 211
 	 * @param integer &$status Variable which contains the HTTP status afterwards
212 212
 	 * @return string Content for response body
213 213
 	 */
214
-	public function patch( $body, array &$header, &$status )
214
+	public function patch($body, array &$header, &$status)
215 215
 	{
216
-		$header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' );
216
+		$header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"');
217 217
 		$view = $this->getView();
218 218
 
219 219
 		try
220 220
 		{
221
-			$view = $this->patchItems( $view, $body, $header );
221
+			$view = $this->patchItems($view, $body, $header);
222 222
 			$status = 200;
223 223
 		}
224
-		catch( \Aimeos\Admin\JsonAdm\Exception $e )
224
+		catch (\Aimeos\Admin\JsonAdm\Exception $e)
225 225
 		{
226 226
 			$status = $e->getCode();
227
-			$view->errors = array( array(
228
-				'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ),
227
+			$view->errors = array(array(
228
+				'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()),
229 229
 				'detail' => $e->getTraceAsString(),
230
-			) );
230
+			));
231 231
 		}
232
-		catch( \Aimeos\MShop\Exception $e )
232
+		catch (\Aimeos\MShop\Exception $e)
233 233
 		{
234 234
 			$status = 404;
235
-			$view->errors = array( array(
236
-				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
235
+			$view->errors = array(array(
236
+				'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()),
237 237
 				'detail' => $e->getTraceAsString(),
238
-			) );
238
+			));
239 239
 		}
240
-		catch( \Exception $e )
240
+		catch (\Exception $e)
241 241
 		{
242 242
 			$status = 500;
243
-			$view->errors = array( array(
243
+			$view->errors = array(array(
244 244
 				'title' => $e->getMessage(),
245 245
 				'detail' => $e->getTraceAsString(),
246
-			) );
246
+			));
247 247
 		}
248 248
 
249 249
 		/** admin/jsonadm/standard/template-patch
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 		$tplconf = 'admin/jsonadm/standard/template-patch';
275 275
 		$default = 'patch-default.php';
276 276
 
277
-		return $view->render( $view->config( $tplconf, $default ) );
277
+		return $view->render($view->config($tplconf, $default));
278 278
 	}
279 279
 
280 280
 
@@ -286,39 +286,39 @@  discard block
 block discarded – undo
286 286
 	 * @param integer &$status Variable which contains the HTTP status afterwards
287 287
 	 * @return string Content for response body
288 288
 	 */
289
-	public function post( $body, array &$header, &$status )
289
+	public function post($body, array &$header, &$status)
290 290
 	{
291
-		$header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' );
291
+		$header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"');
292 292
 		$view = $this->getView();
293 293
 
294 294
 		try
295 295
 		{
296
-			$view = $this->postItems( $view, $body, $header );
296
+			$view = $this->postItems($view, $body, $header);
297 297
 			$status = 201;
298 298
 		}
299
-		catch( \Aimeos\Admin\JsonAdm\Exception $e )
299
+		catch (\Aimeos\Admin\JsonAdm\Exception $e)
300 300
 		{
301 301
 			$status = $e->getCode();
302
-			$view->errors = array( array(
303
-				'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ),
302
+			$view->errors = array(array(
303
+				'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()),
304 304
 				'detail' => $e->getTraceAsString(),
305
-			) );
305
+			));
306 306
 		}
307
-		catch( \Aimeos\MShop\Exception $e )
307
+		catch (\Aimeos\MShop\Exception $e)
308 308
 		{
309 309
 			$status = 404;
310
-			$view->errors = array( array(
311
-				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
310
+			$view->errors = array(array(
311
+				'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()),
312 312
 				'detail' => $e->getTraceAsString(),
313
-			) );
313
+			));
314 314
 		}
315
-		catch( \Exception $e )
315
+		catch (\Exception $e)
316 316
 		{
317 317
 			$status = 500;
318
-			$view->errors = array( array(
318
+			$view->errors = array(array(
319 319
 				'title' => $e->getMessage(),
320 320
 				'detail' => $e->getTraceAsString(),
321
-			) );
321
+			));
322 322
 		}
323 323
 
324 324
 		/** admin/jsonadm/standard/template-post
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 		$tplconf = 'admin/jsonadm/standard/template-post';
350 350
 		$default = 'post-default.php';
351 351
 
352
-		return $view->render( $view->config( $tplconf, $default ) );
352
+		return $view->render($view->config($tplconf, $default));
353 353
 	}
354 354
 
355 355
 
@@ -361,15 +361,15 @@  discard block
 block discarded – undo
361 361
 	 * @param integer &$status Variable which contains the HTTP status afterwards
362 362
 	 * @return string Content for response body
363 363
 	 */
364
-	public function put( $body, array &$header, &$status )
364
+	public function put($body, array &$header, &$status)
365 365
 	{
366 366
 		$status = 501;
367
-		$header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' );
367
+		$header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"');
368 368
 		$view = $this->getView();
369 369
 
370
-		$view->errors = array( array(
371
-			'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', 'Not implemented, use PATCH instead' ),
372
-		) );
370
+		$view->errors = array(array(
371
+			'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', 'Not implemented, use PATCH instead'),
372
+		));
373 373
 
374 374
 		/** admin/jsonadm/standard/template-put
375 375
 		 * Relative path to the JSON API template for PUT requests
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 		$tplconf = 'admin/jsonadm/standard/template-put';
400 400
 		$default = 'put-default.php';
401 401
 
402
-		return $view->render( $view->config( $tplconf, $default ) );
402
+		return $view->render($view->config($tplconf, $default));
403 403
 	}
404 404
 
405 405
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 	 * @param integer &$status Variable which contains the HTTP status afterwards
412 412
 	 * @return string Content for response body
413 413
 	 */
414
-	public function options( $body, array &$header, &$status )
414
+	public function options($body, array &$header, &$status)
415 415
 	{
416 416
 		$context = $this->getContext();
417 417
 		$view = $this->getView();
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
 		{
421 421
 			$resources = $attributes = array();
422 422
 
423
-			foreach( $this->getDomains( $view ) as $domain )
423
+			foreach ($this->getDomains($view) as $domain)
424 424
 			{
425
-				$manager = \Aimeos\MShop\Factory::createManager( $context, $domain );
426
-				$resources = array_merge( $resources, $manager->getResourceType( true ) );
427
-				$attributes = array_merge( $attributes, $manager->getSearchAttributes( true ) );
425
+				$manager = \Aimeos\MShop\Factory::createManager($context, $domain);
426
+				$resources = array_merge($resources, $manager->getResourceType(true));
427
+				$attributes = array_merge($attributes, $manager->getSearchAttributes(true));
428 428
 			}
429 429
 
430 430
 			$view->resources = $resources;
@@ -436,21 +436,21 @@  discard block
 block discarded – undo
436 436
 			);
437 437
 			$status = 200;
438 438
 		}
439
-		catch( \Aimeos\MShop\Exception $e )
439
+		catch (\Aimeos\MShop\Exception $e)
440 440
 		{
441 441
 			$status = 404;
442
-			$view->errors = array( array(
443
-				'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ),
442
+			$view->errors = array(array(
443
+				'title' => $context->getI18n()->dt('mshop', $e->getMessage()),
444 444
 				'detail' => $e->getTraceAsString(),
445
-			) );
445
+			));
446 446
 		}
447
-		catch( \Exception $e )
447
+		catch (\Exception $e)
448 448
 		{
449 449
 			$status = 500;
450
-			$view->errors = array( array(
450
+			$view->errors = array(array(
451 451
 				'title' => $e->getMessage(),
452 452
 				'detail' => $e->getTraceAsString(),
453
-			) );
453
+			));
454 454
 		}
455 455
 
456 456
 		/** admin/jsonadm/standard/template-options
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 		$tplconf = 'admin/jsonadm/standard/template-options';
482 482
 		$default = 'options-default.php';
483 483
 
484
-		return $view->render( $view->config( $tplconf, $default ) );
484
+		return $view->render($view->config($tplconf, $default));
485 485
 	}
486 486
 
487 487
 
@@ -493,23 +493,23 @@  discard block
 block discarded – undo
493 493
 	 * @return \Aimeos\MW\View\Iface $view View object that will contain the "total" property afterwards
494 494
 	 * @throws \Aimeos\Admin\JsonAdm\Exception If the request body is invalid
495 495
 	 */
496
-	protected function deleteItems( \Aimeos\MW\View\Iface $view, $body )
496
+	protected function deleteItems(\Aimeos\MW\View\Iface $view, $body)
497 497
 	{
498
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() );
498
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath());
499 499
 
500
-		if( ( $id = $view->param( 'id' ) ) == null )
500
+		if (($id = $view->param('id')) == null)
501 501
 		{
502
-			if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) || !is_array( $request->data ) ) {
503
-				throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 );
502
+			if (($request = json_decode($body)) === null || !isset($request->data) || !is_array($request->data)) {
503
+				throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400);
504 504
 			}
505 505
 
506
-			$ids = $this->getIds( $request );
507
-			$manager->deleteItems( $ids );
508
-			$view->total = count( $ids );
506
+			$ids = $this->getIds($request);
507
+			$manager->deleteItems($ids);
508
+			$view->total = count($ids);
509 509
 		}
510 510
 		else
511 511
 		{
512
-			$manager->deleteItem( $id );
512
+			$manager->deleteItem($id);
513 513
 			$view->total = 1;
514 514
 		}
515 515
 
@@ -523,14 +523,14 @@  discard block
 block discarded – undo
523 523
 	 * @param \Aimeos\MW\View\Iface $view View instance
524 524
 	 * @return \Aimeos\MW\View\Iface View instance with additional data assigned
525 525
 	 */
526
-	protected function getAggregate( \Aimeos\MW\View\Iface $view )
526
+	protected function getAggregate(\Aimeos\MW\View\Iface $view)
527 527
 	{
528
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() );
528
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath());
529 529
 
530
-		$key = $view->param( 'aggregate' );
530
+		$key = $view->param('aggregate');
531 531
 
532
-		$search = $this->initCriteria( $manager->createSearch(), $view->param() );
533
-		$view->data = $manager->aggregate( $search, $key );
532
+		$search = $this->initCriteria($manager->createSearch(), $view->param());
533
+		$view->data = $manager->aggregate($search, $key);
534 534
 
535 535
 		return $view;
536 536
 	}
@@ -542,27 +542,27 @@  discard block
 block discarded – undo
542 542
 	 * @param \Aimeos\MW\View\Iface $view View instance
543 543
 	 * @return \Aimeos\MW\View\Iface View instance with additional data assigned
544 544
 	 */
545
-	protected function getItems( \Aimeos\MW\View\Iface $view )
545
+	protected function getItems(\Aimeos\MW\View\Iface $view)
546 546
 	{
547 547
 		$total = 1;
548
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() );
549
-		$include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() );
548
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath());
549
+		$include = (($include = $view->param('include')) !== null ? explode(',', $include) : array());
550 550
 
551
-		if( ( $id = $view->param( 'id' ) ) == null )
551
+		if (($id = $view->param('id')) == null)
552 552
 		{
553
-			$search = $this->initCriteria( $manager->createSearch(), $view->param() );
554
-			$view->data = $manager->searchItems( $search, array(), $total );
555
-			$view->childItems = $this->getChildItems( $view->data, $include );
556
-			$view->listItems = $this->getListItems( $view->data, $include );
553
+			$search = $this->initCriteria($manager->createSearch(), $view->param());
554
+			$view->data = $manager->searchItems($search, array(), $total);
555
+			$view->childItems = $this->getChildItems($view->data, $include);
556
+			$view->listItems = $this->getListItems($view->data, $include);
557 557
 		}
558 558
 		else
559 559
 		{
560
-			$view->data = $manager->getItem( $id, array() );
561
-			$view->childItems = $this->getChildItems( array( $id => $view->data ), $include );
562
-			$view->listItems = $this->getListItems( array( $id => $view->data ), $include );
560
+			$view->data = $manager->getItem($id, array());
561
+			$view->childItems = $this->getChildItems(array($id => $view->data), $include);
562
+			$view->listItems = $this->getListItems(array($id => $view->data), $include);
563 563
 		}
564 564
 
565
-		$view->refItems = $this->getRefItems( $view->listItems );
565
+		$view->refItems = $this->getRefItems($view->listItems);
566 566
 		$view->total = $total;
567 567
 
568 568
 		return $view;
@@ -576,9 +576,9 @@  discard block
 block discarded – undo
576 576
 	 * @return \Aimeos\MW\View\Iface View instance with additional data assigned
577 577
 	 * @deprecated 2016.06 Use getItems() instead
578 578
 	 */
579
-	protected function getItem( \Aimeos\MW\View\Iface $view )
579
+	protected function getItem(\Aimeos\MW\View\Iface $view)
580 580
 	{
581
-		return $this->getItems( $view );
581
+		return $this->getItems($view);
582 582
 	}
583 583
 
584 584
 	/**
@@ -590,33 +590,33 @@  discard block
 block discarded – undo
590 590
 	 * @throws \Aimeos\Admin\JsonAdm\Exception If "id" parameter isn't available or the body is invalid
591 591
 	 * @return \Aimeos\MW\View\Iface Updated view instance
592 592
 	 */
593
-	protected function patchItems( \Aimeos\MW\View\Iface $view, $body, array &$header )
593
+	protected function patchItems(\Aimeos\MW\View\Iface $view, $body, array &$header)
594 594
 	{
595
-		if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) {
596
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 );
595
+		if (($request = json_decode($body)) === null || !isset($request->data)) {
596
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400);
597 597
 		}
598 598
 
599
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() );
599
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath());
600 600
 
601
-		if( is_array( $request->data ) )
601
+		if (is_array($request->data))
602 602
 		{
603
-			$data = $this->saveData( $manager, $request );
603
+			$data = $this->saveData($manager, $request);
604 604
 
605 605
 			$view->data = $data;
606
-			$view->total = count( $data );
606
+			$view->total = count($data);
607 607
 			$header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"';
608 608
 		}
609
-		elseif( ( $id = $view->param( 'id' ) ) != null )
609
+		elseif (($id = $view->param('id')) != null)
610 610
 		{
611 611
 			$request->data->id = $id;
612
-			$data = $this->saveEntry( $manager, $request->data );
612
+			$data = $this->saveEntry($manager, $request->data);
613 613
 
614 614
 			$view->data = $data;
615 615
 			$view->total = 1;
616 616
 		}
617 617
 		else
618 618
 		{
619
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 );
619
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400);
620 620
 		}
621 621
 
622 622
 		return $view;
@@ -631,31 +631,31 @@  discard block
 block discarded – undo
631 631
 	 * @param array &$header Associative list of HTTP headers as value/result parameter
632 632
 	 * @return \Aimeos\MW\View\Iface Updated view instance
633 633
 	 */
634
-	protected function postItems( \Aimeos\MW\View\Iface $view, $body, array &$header )
634
+	protected function postItems(\Aimeos\MW\View\Iface $view, $body, array &$header)
635 635
 	{
636
-		if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) {
637
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 );
636
+		if (($request = json_decode($body)) === null || !isset($request->data)) {
637
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400);
638 638
 		}
639 639
 
640
-		if( isset( $request->data->id ) || $view->param( 'id' ) != null ) {
641
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Client generated IDs are not supported' ), 403 );
640
+		if (isset($request->data->id) || $view->param('id') != null) {
641
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Client generated IDs are not supported'), 403);
642 642
 		}
643 643
 
644 644
 
645
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() );
645
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath());
646 646
 
647
-		if( is_array( $request->data ) )
647
+		if (is_array($request->data))
648 648
 		{
649
-			$data = $this->saveData( $manager, $request );
649
+			$data = $this->saveData($manager, $request);
650 650
 
651 651
 			$view->data = $data;
652
-			$view->total = count( $data );
652
+			$view->total = count($data);
653 653
 			$header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"';
654 654
 		}
655 655
 		else
656 656
 		{
657 657
 			$request->data->id = null;
658
-			$data = $this->saveEntry( $manager, $request->data );
658
+			$data = $this->saveEntry($manager, $request->data);
659 659
 
660 660
 			$view->data = $data;
661 661
 			$view->total = 1;
Please login to merge, or discard this patch.
admin/jsonadm/templates/aggregate-default.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-$data = $this->get( 'data', array() );
3
+$data = $this->get('data', array());
4 4
 $entries = array();
5 5
 
6
-foreach( $data as $key => $value ) {
7
-	$entries[] = array( 'id' => $key, 'type' => 'aggregate', 'attributes' => $value );
6
+foreach ($data as $key => $value) {
7
+	$entries[] = array('id' => $key, 'type' => 'aggregate', 'attributes' => $value);
8 8
 }
9 9
 
10 10
 ?>
11 11
 {
12 12
 	"meta": {
13
-		"total": <?php echo count( $data ); ?>
13
+		"total": <?php echo count($data); ?>
14 14
 
15 15
 	},
16
-<?php	if( isset( $this->errors ) ) : ?>
17
-	"errors": <?php echo $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>
18
-<?php	elseif( isset( $this->data ) ) : ?>
19
-	"data": <?php echo json_encode( $entries ); ?>
16
+<?php	if (isset($this->errors)) : ?>
17
+	"errors": <?php echo $this->partial($this->config($this->get('partial-errors', 'admin/jsonadm/partials/template-errors'), 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>
18
+<?php	elseif (isset($this->data)) : ?>
19
+	"data": <?php echo json_encode($entries); ?>
20 20
 <?php	endif; ?>
21 21
 }
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/StandardTest.php 1 patch
Spacing   +320 added lines, -320 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
23 23
 		$this->view = $this->context->getView();
24 24
 
25
-		$this->object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'product' );
25
+		$this->object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'product');
26 26
 	}
27 27
 
28 28
 
@@ -34,42 +34,42 @@  discard block
 block discarded – undo
34 34
 
35 35
 	public function testDelete()
36 36
 	{
37
-		$this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' );
37
+		$this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem');
38 38
 
39
-		$params = array( 'id' => $this->getProductItem()->getId() );
40
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
41
-		$this->view->addHelper( 'param', $helper );
39
+		$params = array('id' => $this->getProductItem()->getId());
40
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
41
+		$this->view->addHelper('param', $helper);
42 42
 
43 43
 		$header = array();
44 44
 		$status = 500;
45 45
 
46
-		$result = json_decode( $this->object->delete( '', $header, $status ), true );
46
+		$result = json_decode($this->object->delete('', $header, $status), true);
47 47
 
48
-		$this->assertEquals( 200, $status );
49
-		$this->assertEquals( 1, count( $header ) );
50
-		$this->assertEquals( 1, $result['meta']['total'] );
51
-		$this->assertArrayNotHasKey( 'included', $result );
52
-		$this->assertArrayNotHasKey( 'data', $result );
53
-		$this->assertArrayNotHasKey( 'errors', $result );
48
+		$this->assertEquals(200, $status);
49
+		$this->assertEquals(1, count($header));
50
+		$this->assertEquals(1, $result['meta']['total']);
51
+		$this->assertArrayNotHasKey('included', $result);
52
+		$this->assertArrayNotHasKey('data', $result);
53
+		$this->assertArrayNotHasKey('errors', $result);
54 54
 	}
55 55
 
56 56
 
57 57
 	public function testDeleteBulk()
58 58
 	{
59
-		$this->getProductMock( array( 'deleteItems' ) )->expects( $this->once() )->method( 'deleteItems' );
59
+		$this->getProductMock(array('deleteItems'))->expects($this->once())->method('deleteItems');
60 60
 
61 61
 		$body = '{"data":[{"type": "product", "id": "-1"},{"type": "product", "id": "-2"}]}';
62 62
 		$header = array();
63 63
 		$status = 500;
64 64
 
65
-		$result = json_decode( $this->object->delete( $body, $header, $status ), true );
65
+		$result = json_decode($this->object->delete($body, $header, $status), true);
66 66
 
67
-		$this->assertEquals( 200, $status );
68
-		$this->assertEquals( 1, count( $header ) );
69
-		$this->assertEquals( 2, $result['meta']['total'] );
70
-		$this->assertArrayNotHasKey( 'included', $result );
71
-		$this->assertArrayNotHasKey( 'data', $result );
72
-		$this->assertArrayNotHasKey( 'errors', $result );
67
+		$this->assertEquals(200, $status);
68
+		$this->assertEquals(1, count($header));
69
+		$this->assertEquals(2, $result['meta']['total']);
70
+		$this->assertArrayNotHasKey('included', $result);
71
+		$this->assertArrayNotHasKey('data', $result);
72
+		$this->assertArrayNotHasKey('errors', $result);
73 73
 	}
74 74
 
75 75
 
@@ -79,52 +79,52 @@  discard block
 block discarded – undo
79 79
 		$header = array();
80 80
 		$status = 500;
81 81
 
82
-		$result = json_decode( $this->object->delete( $body, $header, $status ), true );
82
+		$result = json_decode($this->object->delete($body, $header, $status), true);
83 83
 
84
-		$this->assertEquals( 400, $status );
85
-		$this->assertEquals( 1, count( $header ) );
86
-		$this->assertEquals( 0, $result['meta']['total'] );
87
-		$this->assertArrayHasKey( 'errors', $result );
88
-		$this->assertArrayNotHasKey( 'included', $result );
89
-		$this->assertArrayNotHasKey( 'data', $result );
84
+		$this->assertEquals(400, $status);
85
+		$this->assertEquals(1, count($header));
86
+		$this->assertEquals(0, $result['meta']['total']);
87
+		$this->assertArrayHasKey('errors', $result);
88
+		$this->assertArrayNotHasKey('included', $result);
89
+		$this->assertArrayNotHasKey('data', $result);
90 90
 	}
91 91
 
92 92
 
93 93
 	public function testDeleteException()
94 94
 	{
95
-		$this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' )
96
-			->will( $this->throwException( new \Exception( 'test exception' ) ) );
95
+		$this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem')
96
+			->will($this->throwException(new \Exception('test exception')));
97 97
 
98
-		$params = array( 'id' => $this->getProductItem()->getId() );
99
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
100
-		$this->view->addHelper( 'param', $helper );
98
+		$params = array('id' => $this->getProductItem()->getId());
99
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
100
+		$this->view->addHelper('param', $helper);
101 101
 
102 102
 		$header = array();
103 103
 		$status = 500;
104 104
 
105
-		$result = json_decode( $this->object->delete( '', $header, $status ), true );
105
+		$result = json_decode($this->object->delete('', $header, $status), true);
106 106
 
107
-		$this->assertEquals( 500, $status );
108
-		$this->assertArrayHasKey( 'errors', $result );
107
+		$this->assertEquals(500, $status);
108
+		$this->assertArrayHasKey('errors', $result);
109 109
 	}
110 110
 
111 111
 
112 112
 	public function testDeleteMShopException()
113 113
 	{
114
-		$this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' )
115
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
114
+		$this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem')
115
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
116 116
 
117
-		$params = array( 'id' => $this->getProductItem()->getId() );
118
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
119
-		$this->view->addHelper( 'param', $helper );
117
+		$params = array('id' => $this->getProductItem()->getId());
118
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
119
+		$this->view->addHelper('param', $helper);
120 120
 
121 121
 		$header = array();
122 122
 		$status = 500;
123 123
 
124
-		$result = json_decode( $this->object->delete( '', $header, $status ), true );
124
+		$result = json_decode($this->object->delete('', $header, $status), true);
125 125
 
126
-		$this->assertEquals( 404, $status );
127
-		$this->assertArrayHasKey( 'errors', $result );
126
+		$this->assertEquals(404, $status);
127
+		$this->assertArrayHasKey('errors', $result);
128 128
 	}
129 129
 
130 130
 
@@ -133,18 +133,18 @@  discard block
 block discarded – undo
133 133
 		$header = array();
134 134
 		$status = 500;
135 135
 
136
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
136
+		$result = json_decode($this->object->get('', $header, $status), true);
137 137
 
138
-		$this->assertEquals( 200, $status );
139
-		$this->assertEquals( 1, count( $header ) );
140
-		$this->assertEquals( 28, $result['meta']['total'] );
141
-		$this->assertEquals( 25, count( $result['data'] ) );
142
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
143
-		$this->assertEquals( 0, count( $result['included'] ) );
144
-		$this->assertArrayHasKey( 'next', $result['links'] );
145
-		$this->assertArrayHasKey( 'last', $result['links'] );
146
-		$this->assertArrayHasKey( 'self', $result['links'] );
147
-		$this->assertArrayNotHasKey( 'errors', $result );
138
+		$this->assertEquals(200, $status);
139
+		$this->assertEquals(1, count($header));
140
+		$this->assertEquals(28, $result['meta']['total']);
141
+		$this->assertEquals(25, count($result['data']));
142
+		$this->assertEquals('product', $result['data'][0]['type']);
143
+		$this->assertEquals(0, count($result['included']));
144
+		$this->assertArrayHasKey('next', $result['links']);
145
+		$this->assertArrayHasKey('last', $result['links']);
146
+		$this->assertArrayHasKey('self', $result['links']);
147
+		$this->assertArrayNotHasKey('errors', $result);
148 148
 	}
149 149
 
150 150
 
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 		$status = 500;
155 155
 
156 156
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
157
-		$object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'product/stock/warehouse' );
157
+		$object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'product/stock/warehouse');
158 158
 
159
-		$result = json_decode( $object->get( '', $header, $status ), true );
159
+		$result = json_decode($object->get('', $header, $status), true);
160 160
 
161
-		$this->assertEquals( 200, $status );
162
-		$this->assertEquals( 1, count( $header ) );
163
-		$this->assertEquals( 6, $result['meta']['total'] );
164
-		$this->assertEquals( 6, count( $result['data'] ) );
165
-		$this->assertEquals( 'product/stock/warehouse', $result['data'][0]['type'] );
166
-		$this->assertEquals( 0, count( $result['included'] ) );
167
-		$this->assertArrayNotHasKey( 'errors', $result );
161
+		$this->assertEquals(200, $status);
162
+		$this->assertEquals(1, count($header));
163
+		$this->assertEquals(6, $result['meta']['total']);
164
+		$this->assertEquals(6, count($result['data']));
165
+		$this->assertEquals('product/stock/warehouse', $result['data'][0]['type']);
166
+		$this->assertEquals(0, count($result['included']));
167
+		$this->assertArrayNotHasKey('errors', $result);
168 168
 	}
169 169
 
170 170
 
@@ -174,55 +174,55 @@  discard block
 block discarded – undo
174 174
 		$status = 500;
175 175
 
176 176
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
177
-		$object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'invalid' );
177
+		$object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'invalid');
178 178
 
179
-		$result = json_decode( $object->get( '', $header, $status ), true );
179
+		$result = json_decode($object->get('', $header, $status), true);
180 180
 
181
-		$this->assertEquals( 404, $status );
182
-		$this->assertEquals( 1, count( $header ) );
183
-		$this->assertEquals( 1, count( $result['errors'] ) );
184
-		$this->assertArrayHasKey( 'title', $result['errors'][0] );
185
-		$this->assertArrayHasKey( 'detail', $result['errors'][0] );
186
-		$this->assertArrayNotHasKey( 'data', $result );
187
-		$this->assertArrayNotHasKey( 'indluded', $result );
181
+		$this->assertEquals(404, $status);
182
+		$this->assertEquals(1, count($header));
183
+		$this->assertEquals(1, count($result['errors']));
184
+		$this->assertArrayHasKey('title', $result['errors'][0]);
185
+		$this->assertArrayHasKey('detail', $result['errors'][0]);
186
+		$this->assertArrayNotHasKey('data', $result);
187
+		$this->assertArrayNotHasKey('indluded', $result);
188 188
 	}
189 189
 
190 190
 
191 191
 	public function testGetException()
192 192
 	{
193
-		$this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' )
194
-			->will( $this->throwException( new \Exception( 'test exception' ) ) );
193
+		$this->getProductMock(array('getItem'))->expects($this->once())->method('getItem')
194
+			->will($this->throwException(new \Exception('test exception')));
195 195
 
196
-		$params = array( 'id' => -1 );
197
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
198
-		$this->view->addHelper( 'param', $helper );
196
+		$params = array('id' => -1);
197
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
198
+		$this->view->addHelper('param', $helper);
199 199
 
200 200
 		$header = array();
201 201
 		$status = 500;
202 202
 
203
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
203
+		$result = json_decode($this->object->get('', $header, $status), true);
204 204
 
205
-		$this->assertEquals( 500, $status );
206
-		$this->assertArrayHasKey( 'errors', $result );
205
+		$this->assertEquals(500, $status);
206
+		$this->assertArrayHasKey('errors', $result);
207 207
 	}
208 208
 
209 209
 
210 210
 	public function testGetMShopException()
211 211
 	{
212
-		$this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' )
213
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
212
+		$this->getProductMock(array('getItem'))->expects($this->once())->method('getItem')
213
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
214 214
 
215
-		$params = array( 'id' => -1 );
216
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
217
-		$this->view->addHelper( 'param', $helper );
215
+		$params = array('id' => -1);
216
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
217
+		$this->view->addHelper('param', $helper);
218 218
 
219 219
 		$header = array();
220 220
 		$status = 500;
221 221
 
222
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
222
+		$result = json_decode($this->object->get('', $header, $status), true);
223 223
 
224
-		$this->assertEquals( 404, $status );
225
-		$this->assertArrayHasKey( 'errors', $result );
224
+		$this->assertEquals(404, $status);
225
+		$this->assertArrayHasKey('errors', $result);
226 226
 	}
227 227
 
228 228
 
@@ -230,24 +230,24 @@  discard block
 block discarded – undo
230 230
 	{
231 231
 		$params = array(
232 232
 			'filter' => array(
233
-				'==' => array( 'product.type.code' => 'select' )
233
+				'==' => array('product.type.code' => 'select')
234 234
 			)
235 235
 		);
236
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
237
-		$this->view->addHelper( 'param', $helper );
236
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
237
+		$this->view->addHelper('param', $helper);
238 238
 
239 239
 		$header = array();
240 240
 		$status = 500;
241 241
 
242
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
242
+		$result = json_decode($this->object->get('', $header, $status), true);
243 243
 
244
-		$this->assertEquals( 200, $status );
245
-		$this->assertEquals( 1, count( $header ) );
246
-		$this->assertEquals( 3, $result['meta']['total'] );
247
-		$this->assertEquals( 3, count( $result['data'] ) );
248
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
249
-		$this->assertEquals( 0, count( $result['included'] ) );
250
-		$this->assertArrayNotHasKey( 'errors', $result );
244
+		$this->assertEquals(200, $status);
245
+		$this->assertEquals(1, count($header));
246
+		$this->assertEquals(3, $result['meta']['total']);
247
+		$this->assertEquals(3, count($result['data']));
248
+		$this->assertEquals('product', $result['data'][0]['type']);
249
+		$this->assertEquals(0, count($result['included']));
250
+		$this->assertArrayNotHasKey('errors', $result);
251 251
 	}
252 252
 
253 253
 
@@ -256,26 +256,26 @@  discard block
 block discarded – undo
256 256
 		$params = array(
257 257
 			'filter' => array(
258 258
 				'&&' => array(
259
-					array( '=~' => array( 'product.label' => 'Unittest: Test' ) ),
260
-					array( '==' => array( 'product.type.code' => 'select' ) ),
259
+					array('=~' => array('product.label' => 'Unittest: Test')),
260
+					array('==' => array('product.type.code' => 'select')),
261 261
 				)
262 262
 			)
263 263
 		);
264
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
265
-		$this->view->addHelper( 'param', $helper );
264
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
265
+		$this->view->addHelper('param', $helper);
266 266
 
267 267
 		$header = array();
268 268
 		$status = 500;
269 269
 
270
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
270
+		$result = json_decode($this->object->get('', $header, $status), true);
271 271
 
272
-		$this->assertEquals( 200, $status );
273
-		$this->assertEquals( 1, count( $header ) );
274
-		$this->assertEquals( 2, $result['meta']['total'] );
275
-		$this->assertEquals( 2, count( $result['data'] ) );
276
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
277
-		$this->assertEquals( 0, count( $result['included'] ) );
278
-		$this->assertArrayNotHasKey( 'errors', $result );
272
+		$this->assertEquals(200, $status);
273
+		$this->assertEquals(1, count($header));
274
+		$this->assertEquals(2, $result['meta']['total']);
275
+		$this->assertEquals(2, count($result['data']));
276
+		$this->assertEquals('product', $result['data'][0]['type']);
277
+		$this->assertEquals(0, count($result['included']));
278
+		$this->assertArrayNotHasKey('errors', $result);
279 279
 	}
280 280
 
281 281
 
@@ -287,24 +287,24 @@  discard block
 block discarded – undo
287 287
 				'limit' => 25
288 288
 			)
289 289
 		);
290
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
291
-		$this->view->addHelper( 'param', $helper );
290
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
291
+		$this->view->addHelper('param', $helper);
292 292
 
293 293
 		$header = array();
294 294
 		$status = 500;
295 295
 
296
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
296
+		$result = json_decode($this->object->get('', $header, $status), true);
297 297
 
298
-		$this->assertEquals( 200, $status );
299
-		$this->assertEquals( 1, count( $header ) );
300
-		$this->assertEquals( 28, $result['meta']['total'] );
301
-		$this->assertEquals( 3, count( $result['data'] ) );
302
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
303
-		$this->assertEquals( 0, count( $result['included'] ) );
304
-		$this->assertArrayHasKey( 'first', $result['links'] );
305
-		$this->assertArrayHasKey( 'prev', $result['links'] );
306
-		$this->assertArrayHasKey( 'self', $result['links'] );
307
-		$this->assertArrayNotHasKey( 'errors', $result );
298
+		$this->assertEquals(200, $status);
299
+		$this->assertEquals(1, count($header));
300
+		$this->assertEquals(28, $result['meta']['total']);
301
+		$this->assertEquals(3, count($result['data']));
302
+		$this->assertEquals('product', $result['data'][0]['type']);
303
+		$this->assertEquals(0, count($result['included']));
304
+		$this->assertArrayHasKey('first', $result['links']);
305
+		$this->assertArrayHasKey('prev', $result['links']);
306
+		$this->assertArrayHasKey('self', $result['links']);
307
+		$this->assertArrayNotHasKey('errors', $result);
308 308
 	}
309 309
 
310 310
 
@@ -313,23 +313,23 @@  discard block
 block discarded – undo
313 313
 		$params = array(
314 314
 			'sort' => 'product.label,-product.code'
315 315
 		);
316
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
317
-		$this->view->addHelper( 'param', $helper );
316
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
317
+		$this->view->addHelper('param', $helper);
318 318
 
319 319
 		$header = array();
320 320
 		$status = 500;
321 321
 
322
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
322
+		$result = json_decode($this->object->get('', $header, $status), true);
323 323
 
324
-		$this->assertEquals( 200, $status );
325
-		$this->assertEquals( 1, count( $header ) );
326
-		$this->assertEquals( 28, $result['meta']['total'] );
327
-		$this->assertEquals( 25, count( $result['data'] ) );
328
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
329
-		$this->assertEquals( 'QRST', $result['data'][0]['attributes']['product.code'] );
330
-		$this->assertEquals( '16 discs', $result['data'][0]['attributes']['product.label'] );
331
-		$this->assertEquals( 0, count( $result['included'] ) );
332
-		$this->assertArrayNotHasKey( 'errors', $result );
324
+		$this->assertEquals(200, $status);
325
+		$this->assertEquals(1, count($header));
326
+		$this->assertEquals(28, $result['meta']['total']);
327
+		$this->assertEquals(25, count($result['data']));
328
+		$this->assertEquals('product', $result['data'][0]['type']);
329
+		$this->assertEquals('QRST', $result['data'][0]['attributes']['product.code']);
330
+		$this->assertEquals('16 discs', $result['data'][0]['attributes']['product.label']);
331
+		$this->assertEquals(0, count($result['included']));
332
+		$this->assertArrayNotHasKey('errors', $result);
333 333
 	}
334 334
 
335 335
 
@@ -342,88 +342,88 @@  discard block
 block discarded – undo
342 342
 			'sort' => 'product.id',
343 343
 			'include' => 'product'
344 344
 		);
345
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
346
-		$this->view->addHelper( 'param', $helper );
345
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
346
+		$this->view->addHelper('param', $helper);
347 347
 
348 348
 		$header = array();
349 349
 		$status = 500;
350 350
 
351
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
351
+		$result = json_decode($this->object->get('', $header, $status), true);
352 352
 
353
-		$this->assertEquals( 200, $status );
354
-		$this->assertEquals( 1, count( $header ) );
355
-		$this->assertEquals( 28, $result['meta']['total'] );
356
-		$this->assertEquals( 25, count( $result['data'] ) );
357
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
358
-		$this->assertEquals( 2, count( $result['data'][0]['attributes'] ) );
359
-		$this->assertArrayNotHasKey( 'errors', $result );
353
+		$this->assertEquals(200, $status);
354
+		$this->assertEquals(1, count($header));
355
+		$this->assertEquals(28, $result['meta']['total']);
356
+		$this->assertEquals(25, count($result['data']));
357
+		$this->assertEquals('product', $result['data'][0]['type']);
358
+		$this->assertEquals(2, count($result['data'][0]['attributes']));
359
+		$this->assertArrayNotHasKey('errors', $result);
360 360
 	}
361 361
 
362 362
 
363 363
 	public function testPatch()
364 364
 	{
365
-		$productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) );
365
+		$productManagerStub = $this->getProductMock(array('getItem', 'saveItem'));
366 366
 
367 367
 		$item = $productManagerStub->createItem();
368
-		$item->setLabel( 'test' );
369
-		$item->setId( '-1' );
368
+		$item->setLabel('test');
369
+		$item->setId('-1');
370 370
 
371
-		$productManagerStub->expects( $this->once() )->method( 'saveItem' );
372
-		$productManagerStub->expects( $this->atLeastOnce() )->method( 'getItem' )
373
-			->will( $this->returnValue( $item ) );
371
+		$productManagerStub->expects($this->once())->method('saveItem');
372
+		$productManagerStub->expects($this->atLeastOnce())->method('getItem')
373
+			->will($this->returnValue($item));
374 374
 
375 375
 
376
-		$params = array( 'id' => '-1' );
377
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
378
-		$this->view->addHelper( 'param', $helper );
376
+		$params = array('id' => '-1');
377
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
378
+		$this->view->addHelper('param', $helper);
379 379
 
380 380
 		$body = '{"data": {"type": "product", "attributes": {"product.label": "test"}}}';
381 381
 		$header = array();
382 382
 		$status = 500;
383 383
 
384
-		$result = json_decode( $this->object->patch( $body, $header, $status ), true );
384
+		$result = json_decode($this->object->patch($body, $header, $status), true);
385 385
 
386
-		$this->assertEquals( 200, $status );
387
-		$this->assertEquals( 1, count( $header ) );
388
-		$this->assertEquals( 1, $result['meta']['total'] );
389
-		$this->assertArrayHasKey( 'data', $result );
390
-		$this->assertEquals( '-1', $result['data']['id'] );
391
-		$this->assertEquals( 'product', $result['data']['type'] );
392
-		$this->assertEquals( 'test', $result['data']['attributes']['product.label'] );
393
-		$this->assertArrayNotHasKey( 'included', $result );
394
-		$this->assertArrayNotHasKey( 'errors', $result );
386
+		$this->assertEquals(200, $status);
387
+		$this->assertEquals(1, count($header));
388
+		$this->assertEquals(1, $result['meta']['total']);
389
+		$this->assertArrayHasKey('data', $result);
390
+		$this->assertEquals('-1', $result['data']['id']);
391
+		$this->assertEquals('product', $result['data']['type']);
392
+		$this->assertEquals('test', $result['data']['attributes']['product.label']);
393
+		$this->assertArrayNotHasKey('included', $result);
394
+		$this->assertArrayNotHasKey('errors', $result);
395 395
 	}
396 396
 
397 397
 
398 398
 	public function testPatchBulk()
399 399
 	{
400
-		$productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) );
400
+		$productManagerStub = $this->getProductMock(array('getItem', 'saveItem'));
401 401
 
402 402
 		$item = $productManagerStub->createItem();
403
-		$item->setLabel( 'test' );
404
-		$item->setId( '-1' );
403
+		$item->setLabel('test');
404
+		$item->setId('-1');
405 405
 
406
-		$productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' );
407
-		$productManagerStub->expects( $this->atLeastOnce() )->method( 'getItem' )
408
-			->will( $this->returnValue( $item ) );
406
+		$productManagerStub->expects($this->exactly(2))->method('saveItem');
407
+		$productManagerStub->expects($this->atLeastOnce())->method('getItem')
408
+			->will($this->returnValue($item));
409 409
 
410 410
 
411 411
 		$body = '{"data": [{"id": "-1", "type": "product", "attributes": {"product.label": "test"}}, {"id": "-1", "type": "product", "attributes": {"product.label": "test"}}]}';
412 412
 		$header = array();
413 413
 		$status = 500;
414 414
 
415
-		$result = json_decode( $this->object->patch( $body, $header, $status ), true );
415
+		$result = json_decode($this->object->patch($body, $header, $status), true);
416 416
 
417
-		$this->assertEquals( 200, $status );
418
-		$this->assertEquals( 1, count( $header ) );
419
-		$this->assertEquals( 2, $result['meta']['total'] );
420
-		$this->assertArrayHasKey( 'data', $result );
421
-		$this->assertEquals( 2, count( $result['data'] ) );
422
-		$this->assertEquals( '-1', $result['data'][0]['id'] );
423
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
424
-		$this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] );
425
-		$this->assertArrayNotHasKey( 'included', $result );
426
-		$this->assertArrayNotHasKey( 'errors', $result );
417
+		$this->assertEquals(200, $status);
418
+		$this->assertEquals(1, count($header));
419
+		$this->assertEquals(2, $result['meta']['total']);
420
+		$this->assertArrayHasKey('data', $result);
421
+		$this->assertEquals(2, count($result['data']));
422
+		$this->assertEquals('-1', $result['data'][0]['id']);
423
+		$this->assertEquals('product', $result['data'][0]['type']);
424
+		$this->assertEquals('test', $result['data'][0]['attributes']['product.label']);
425
+		$this->assertArrayNotHasKey('included', $result);
426
+		$this->assertArrayNotHasKey('errors', $result);
427 427
 	}
428 428
 
429 429
 
@@ -433,14 +433,14 @@  discard block
 block discarded – undo
433 433
 		$header = array();
434 434
 		$status = 500;
435 435
 
436
-		$result = json_decode( $this->object->patch( $body, $header, $status ), true );
436
+		$result = json_decode($this->object->patch($body, $header, $status), true);
437 437
 
438
-		$this->assertEquals( 400, $status );
439
-		$this->assertEquals( 1, count( $header ) );
440
-		$this->assertEquals( 0, $result['meta']['total'] );
441
-		$this->assertArrayHasKey( 'errors', $result );
442
-		$this->assertArrayNotHasKey( 'included', $result );
443
-		$this->assertArrayNotHasKey( 'data', $result );
438
+		$this->assertEquals(400, $status);
439
+		$this->assertEquals(1, count($header));
440
+		$this->assertEquals(0, $result['meta']['total']);
441
+		$this->assertArrayHasKey('errors', $result);
442
+		$this->assertArrayNotHasKey('included', $result);
443
+		$this->assertArrayNotHasKey('data', $result);
444 444
 	}
445 445
 
446 446
 
@@ -450,127 +450,127 @@  discard block
 block discarded – undo
450 450
 		$header = array();
451 451
 		$status = 500;
452 452
 
453
-		$result = json_decode( $this->object->patch( $body, $header, $status ), true );
453
+		$result = json_decode($this->object->patch($body, $header, $status), true);
454 454
 
455
-		$this->assertEquals( 400, $status );
456
-		$this->assertEquals( 1, count( $header ) );
457
-		$this->assertEquals( 0, $result['meta']['total'] );
458
-		$this->assertArrayHasKey( 'errors', $result );
455
+		$this->assertEquals(400, $status);
456
+		$this->assertEquals(1, count($header));
457
+		$this->assertEquals(0, $result['meta']['total']);
458
+		$this->assertArrayHasKey('errors', $result);
459 459
 	}
460 460
 
461 461
 
462 462
 	public function testPatchException()
463 463
 	{
464
-		$this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' )
465
-			->will( $this->throwException( new \Exception( 'test exception' ) ) );
464
+		$this->getProductMock(array('getItem'))->expects($this->once())->method('getItem')
465
+			->will($this->throwException(new \Exception('test exception')));
466 466
 
467 467
 		$header = array();
468 468
 		$status = 500;
469 469
 
470
-		$result = json_decode( $this->object->patch( '{"data":[{"id":-1}]}', $header, $status ), true );
470
+		$result = json_decode($this->object->patch('{"data":[{"id":-1}]}', $header, $status), true);
471 471
 
472
-		$this->assertEquals( 500, $status );
473
-		$this->assertArrayHasKey( 'errors', $result );
472
+		$this->assertEquals(500, $status);
473
+		$this->assertArrayHasKey('errors', $result);
474 474
 	}
475 475
 
476 476
 
477 477
 	public function testPatchMShopException()
478 478
 	{
479
-		$this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' )
480
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
479
+		$this->getProductMock(array('getItem'))->expects($this->once())->method('getItem')
480
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
481 481
 
482 482
 		$header = array();
483 483
 		$status = 500;
484 484
 
485
-		$result = json_decode( $this->object->patch( '{"data":[{"id":-1}]}', $header, $status ), true );
485
+		$result = json_decode($this->object->patch('{"data":[{"id":-1}]}', $header, $status), true);
486 486
 
487
-		$this->assertEquals( 404, $status );
488
-		$this->assertArrayHasKey( 'errors', $result );
487
+		$this->assertEquals(404, $status);
488
+		$this->assertArrayHasKey('errors', $result);
489 489
 	}
490 490
 
491 491
 
492 492
 	public function testPost()
493 493
 	{
494
-		$productManagerStub = $this->getProductMock( array( 'createItem', 'getItem', 'saveItem' ) );
494
+		$productManagerStub = $this->getProductMock(array('createItem', 'getItem', 'saveItem'));
495 495
 
496 496
 		$item = new \Aimeos\MShop\Product\Item\Standard();
497
-		$item->setId( '-1' );
497
+		$item->setId('-1');
498 498
 
499
-		$productManagerStub->expects( $this->once() )->method( 'createItem' )
500
-			->will( $this->returnValue( $item ) );
501
-		$productManagerStub->expects( $this->any() )->method( 'getItem' )
502
-			->will( $this->returnValue( $item ) );
503
-		$productManagerStub->expects( $this->once() )->method( 'saveItem' );
499
+		$productManagerStub->expects($this->once())->method('createItem')
500
+			->will($this->returnValue($item));
501
+		$productManagerStub->expects($this->any())->method('getItem')
502
+			->will($this->returnValue($item));
503
+		$productManagerStub->expects($this->once())->method('saveItem');
504 504
 
505 505
 
506 506
 		$body = '{"data": {"type": "product", "attributes": {"product.type": "default", "product.label": "test"}}}';
507 507
 		$header = array();
508 508
 		$status = 500;
509 509
 
510
-		$result = json_decode( $this->object->post( $body, $header, $status ), true );
510
+		$result = json_decode($this->object->post($body, $header, $status), true);
511 511
 
512
-		$this->assertEquals( 201, $status );
513
-		$this->assertEquals( 1, count( $header ) );
514
-		$this->assertEquals( 1, $result['meta']['total'] );
515
-		$this->assertArrayHasKey( 'data', $result );
516
-		$this->assertEquals( '-1', $result['data']['id'] );
517
-		$this->assertEquals( 'product', $result['data']['type'] );
518
-		$this->assertGreaterThan( 0, $result['data']['attributes']['product.typeid'] );
519
-		$this->assertEquals( 'test', $result['data']['attributes']['product.label'] );
520
-		$this->assertArrayNotHasKey( 'included', $result );
521
-		$this->assertArrayNotHasKey( 'errors', $result );
512
+		$this->assertEquals(201, $status);
513
+		$this->assertEquals(1, count($header));
514
+		$this->assertEquals(1, $result['meta']['total']);
515
+		$this->assertArrayHasKey('data', $result);
516
+		$this->assertEquals('-1', $result['data']['id']);
517
+		$this->assertEquals('product', $result['data']['type']);
518
+		$this->assertGreaterThan(0, $result['data']['attributes']['product.typeid']);
519
+		$this->assertEquals('test', $result['data']['attributes']['product.label']);
520
+		$this->assertArrayNotHasKey('included', $result);
521
+		$this->assertArrayNotHasKey('errors', $result);
522 522
 	}
523 523
 
524 524
 
525 525
 	public function testPostBulk()
526 526
 	{
527
-		$productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) );
527
+		$productManagerStub = $this->getProductMock(array('getItem', 'saveItem'));
528 528
 
529 529
 		$item = $productManagerStub->createItem();
530
-		$item->setLabel( 'test' );
531
-		$item->setId( '-1' );
530
+		$item->setLabel('test');
531
+		$item->setId('-1');
532 532
 
533
-		$productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' );
534
-		$productManagerStub->expects( $this->exactly( 2 ) )->method( 'getItem' )
535
-			->will( $this->returnValue( $item ) );
533
+		$productManagerStub->expects($this->exactly(2))->method('saveItem');
534
+		$productManagerStub->expects($this->exactly(2))->method('getItem')
535
+			->will($this->returnValue($item));
536 536
 
537 537
 
538 538
 		$body = '{"data": [{"type": "product", "attributes": {"product.label": "test"}}, {"type": "product", "attributes": {"product.label": "test"}}]}';
539 539
 		$header = array();
540 540
 		$status = 500;
541 541
 
542
-		$result = json_decode( $this->object->post( $body, $header, $status ), true );
542
+		$result = json_decode($this->object->post($body, $header, $status), true);
543 543
 
544
-		$this->assertEquals( 201, $status );
545
-		$this->assertEquals( 1, count( $header ) );
546
-		$this->assertEquals( 2, $result['meta']['total'] );
547
-		$this->assertArrayHasKey( 'data', $result );
548
-		$this->assertEquals( 2, count( $result['data'] ) );
549
-		$this->assertEquals( '-1', $result['data'][0]['id'] );
550
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
551
-		$this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] );
552
-		$this->assertArrayNotHasKey( 'included', $result );
553
-		$this->assertArrayNotHasKey( 'errors', $result );
544
+		$this->assertEquals(201, $status);
545
+		$this->assertEquals(1, count($header));
546
+		$this->assertEquals(2, $result['meta']['total']);
547
+		$this->assertArrayHasKey('data', $result);
548
+		$this->assertEquals(2, count($result['data']));
549
+		$this->assertEquals('-1', $result['data'][0]['id']);
550
+		$this->assertEquals('product', $result['data'][0]['type']);
551
+		$this->assertEquals('test', $result['data'][0]['attributes']['product.label']);
552
+		$this->assertArrayNotHasKey('included', $result);
553
+		$this->assertArrayNotHasKey('errors', $result);
554 554
 	}
555 555
 
556 556
 
557 557
 	public function testPostRelationships()
558 558
 	{
559
-		$productManagerStub = $this->getProductMock( array( 'getSubManager', 'createItem', 'getItem', 'saveItem' ) );
560
-		$productManagerListsStub = $this->getProductListsMock( array( 'saveItem' ) );
559
+		$productManagerStub = $this->getProductMock(array('getSubManager', 'createItem', 'getItem', 'saveItem'));
560
+		$productManagerListsStub = $this->getProductListsMock(array('saveItem'));
561 561
 
562 562
 		$item = new \Aimeos\MShop\Product\Item\Standard();
563
-		$item->setId( '-1' );
563
+		$item->setId('-1');
564 564
 
565
-		$productManagerStub->expects( $this->once() )->method( 'createItem' )
566
-			->will( $this->returnValue( $item ) );
567
-		$productManagerStub->expects( $this->any() )->method( 'getItem' )
568
-			->will( $this->returnValue( $item ) );
569
-		$productManagerStub->expects( $this->once() )->method( 'getSubManager' )
570
-			->will( $this->returnValue( $productManagerListsStub ) );
571
-		$productManagerStub->expects( $this->once() )->method( 'saveItem' );
565
+		$productManagerStub->expects($this->once())->method('createItem')
566
+			->will($this->returnValue($item));
567
+		$productManagerStub->expects($this->any())->method('getItem')
568
+			->will($this->returnValue($item));
569
+		$productManagerStub->expects($this->once())->method('getSubManager')
570
+			->will($this->returnValue($productManagerListsStub));
571
+		$productManagerStub->expects($this->once())->method('saveItem');
572 572
 
573
-		$productManagerListsStub->expects( $this->once() )->method( 'saveItem' );
573
+		$productManagerListsStub->expects($this->once())->method('saveItem');
574 574
 
575 575
 		$body = '{"data": {"type": "product",
576 576
 			"attributes": {"product.label": "test"},
@@ -581,17 +581,17 @@  discard block
 block discarded – undo
581 581
 		$header = array();
582 582
 		$status = 500;
583 583
 
584
-		$result = json_decode( $this->object->post( $body, $header, $status ), true );
584
+		$result = json_decode($this->object->post($body, $header, $status), true);
585 585
 
586
-		$this->assertEquals( 201, $status );
587
-		$this->assertEquals( 1, count( $header ) );
588
-		$this->assertEquals( 1, $result['meta']['total'] );
589
-		$this->assertArrayHasKey( 'data', $result );
590
-		$this->assertEquals( '-1', $result['data']['id'] );
591
-		$this->assertEquals( 'product', $result['data']['type'] );
592
-		$this->assertEquals( 'test', $result['data']['attributes']['product.label'] );
593
-		$this->assertArrayNotHasKey( 'included', $result );
594
-		$this->assertArrayNotHasKey( 'errors', $result );
586
+		$this->assertEquals(201, $status);
587
+		$this->assertEquals(1, count($header));
588
+		$this->assertEquals(1, $result['meta']['total']);
589
+		$this->assertArrayHasKey('data', $result);
590
+		$this->assertEquals('-1', $result['data']['id']);
591
+		$this->assertEquals('product', $result['data']['type']);
592
+		$this->assertEquals('test', $result['data']['attributes']['product.label']);
593
+		$this->assertArrayNotHasKey('included', $result);
594
+		$this->assertArrayNotHasKey('errors', $result);
595 595
 	}
596 596
 
597 597
 
@@ -601,14 +601,14 @@  discard block
 block discarded – undo
601 601
 		$header = array();
602 602
 		$status = 500;
603 603
 
604
-		$result = json_decode( $this->object->post( $body, $header, $status ), true );
604
+		$result = json_decode($this->object->post($body, $header, $status), true);
605 605
 
606
-		$this->assertEquals( 400, $status );
607
-		$this->assertEquals( 1, count( $header ) );
608
-		$this->assertEquals( 0, $result['meta']['total'] );
609
-		$this->assertArrayHasKey( 'errors', $result );
610
-		$this->assertArrayNotHasKey( 'included', $result );
611
-		$this->assertArrayNotHasKey( 'data', $result );
606
+		$this->assertEquals(400, $status);
607
+		$this->assertEquals(1, count($header));
608
+		$this->assertEquals(0, $result['meta']['total']);
609
+		$this->assertArrayHasKey('errors', $result);
610
+		$this->assertArrayNotHasKey('included', $result);
611
+		$this->assertArrayNotHasKey('data', $result);
612 612
 	}
613 613
 
614 614
 
@@ -618,42 +618,42 @@  discard block
 block discarded – undo
618 618
 		$header = array();
619 619
 		$status = 500;
620 620
 
621
-		$result = json_decode( $this->object->post( $body, $header, $status ), true );
621
+		$result = json_decode($this->object->post($body, $header, $status), true);
622 622
 
623
-		$this->assertEquals( 403, $status );
624
-		$this->assertEquals( 1, count( $header ) );
625
-		$this->assertEquals( 0, $result['meta']['total'] );
626
-		$this->assertArrayHasKey( 'errors', $result );
623
+		$this->assertEquals(403, $status);
624
+		$this->assertEquals(1, count($header));
625
+		$this->assertEquals(0, $result['meta']['total']);
626
+		$this->assertArrayHasKey('errors', $result);
627 627
 	}
628 628
 
629 629
 
630 630
 	public function testPostException()
631 631
 	{
632
-		$this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' )
633
-			->will( $this->throwException( new \Exception( 'test exception' ) ) );
632
+		$this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem')
633
+			->will($this->throwException(new \Exception('test exception')));
634 634
 
635 635
 		$header = array();
636 636
 		$status = 500;
637 637
 
638
-		$result = json_decode( $this->object->post( '{"data":{}}', $header, $status ), true );
638
+		$result = json_decode($this->object->post('{"data":{}}', $header, $status), true);
639 639
 
640
-		$this->assertEquals( 500, $status );
641
-		$this->assertArrayHasKey( 'errors', $result );
640
+		$this->assertEquals(500, $status);
641
+		$this->assertArrayHasKey('errors', $result);
642 642
 	}
643 643
 
644 644
 
645 645
 	public function testPostMShopException()
646 646
 	{
647
-		$this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' )
648
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
647
+		$this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem')
648
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
649 649
 
650 650
 		$header = array();
651 651
 		$status = 500;
652 652
 
653
-		$result = json_decode( $this->object->post( '{"data":{}}', $header, $status ), true );
653
+		$result = json_decode($this->object->post('{"data":{}}', $header, $status), true);
654 654
 
655
-		$this->assertEquals( 404, $status );
656
-		$this->assertArrayHasKey( 'errors', $result );
655
+		$this->assertEquals(404, $status);
656
+		$this->assertArrayHasKey('errors', $result);
657 657
 	}
658 658
 
659 659
 
@@ -663,11 +663,11 @@  discard block
 block discarded – undo
663 663
 		$header = array();
664 664
 		$status = 500;
665 665
 
666
-		$result = json_decode( $this->object->put( $body, $header, $status ), true );
666
+		$result = json_decode($this->object->put($body, $header, $status), true);
667 667
 
668
-		$this->assertEquals( 501, $status );
669
-		$this->assertEquals( 1, count( $header ) );
670
-		$this->assertArrayHasKey( 'errors', $result );
668
+		$this->assertEquals(501, $status);
669
+		$this->assertEquals(1, count($header));
670
+		$this->assertArrayHasKey('errors', $result);
671 671
 	}
672 672
 
673 673
 
@@ -676,87 +676,87 @@  discard block
 block discarded – undo
676 676
 		$header = array();
677 677
 		$status = 500;
678 678
 
679
-		$result = json_decode( $this->object->options( '', $header, $status ), true );
679
+		$result = json_decode($this->object->options('', $header, $status), true);
680 680
 
681
-		$this->assertEquals( 200, $status );
682
-		$this->assertEquals( 2, count( $header ) );
683
-		$this->assertEquals( 59, count( $result['meta']['resources'] ) );
684
-		$this->assertGreaterThan( 0, count( $result['meta']['attributes'] ) );
685
-		$this->assertArrayNotHasKey( 'errors', $result );
681
+		$this->assertEquals(200, $status);
682
+		$this->assertEquals(2, count($header));
683
+		$this->assertEquals(59, count($result['meta']['resources']));
684
+		$this->assertGreaterThan(0, count($result['meta']['attributes']));
685
+		$this->assertArrayNotHasKey('errors', $result);
686 686
 	}
687 687
 
688 688
 
689 689
 	public function testOptionsException()
690 690
 	{
691
-		$this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' )
692
-			->will( $this->throwException( new \Exception( 'test exception' ) ) );
691
+		$this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType')
692
+			->will($this->throwException(new \Exception('test exception')));
693 693
 
694 694
 		$header = array();
695 695
 		$status = 500;
696 696
 
697
-		$result = json_decode( $this->object->options( '', $header, $status ), true );
697
+		$result = json_decode($this->object->options('', $header, $status), true);
698 698
 
699
-		$this->assertEquals( 500, $status );
700
-		$this->assertArrayHasKey( 'errors', $result );
699
+		$this->assertEquals(500, $status);
700
+		$this->assertArrayHasKey('errors', $result);
701 701
 	}
702 702
 
703 703
 
704 704
 	public function testOptionsMShopException()
705 705
 	{
706
-		$this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' )
707
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
706
+		$this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType')
707
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
708 708
 
709 709
 		$header = array();
710 710
 		$status = 500;
711 711
 
712
-		$result = json_decode( $this->object->options( '', $header, $status ), true );
712
+		$result = json_decode($this->object->options('', $header, $status), true);
713 713
 
714
-		$this->assertEquals( 404, $status );
715
-		$this->assertArrayHasKey( 'errors', $result );
714
+		$this->assertEquals(404, $status);
715
+		$this->assertArrayHasKey('errors', $result);
716 716
 	}
717 717
 
718 718
 
719
-	protected function getProductMock( array $methods )
719
+	protected function getProductMock(array $methods)
720 720
 	{
721 721
 		$name = 'ClientJsonAdmStandard';
722
-		$this->context->getConfig()->set( 'mshop/product/manager/name', $name );
722
+		$this->context->getConfig()->set('mshop/product/manager/name', $name);
723 723
 
724
-		$stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Standard' )
725
-			->setConstructorArgs( array( $this->context ) )
726
-			->setMethods( $methods )
724
+		$stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Standard')
725
+			->setConstructorArgs(array($this->context))
726
+			->setMethods($methods)
727 727
 			->getMock();
728 728
 
729
-		\Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub );
729
+		\Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub);
730 730
 
731 731
 		return $stub;
732 732
 	}
733 733
 
734 734
 
735
-	protected function getProductListsMock( array $methods )
735
+	protected function getProductListsMock(array $methods)
736 736
 	{
737 737
 		$name = 'ClientJsonAdmStandard';
738
-		$this->context->getConfig()->set( 'mshop/product/manager/lists/name', $name );
738
+		$this->context->getConfig()->set('mshop/product/manager/lists/name', $name);
739 739
 
740
-		$stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard' )
741
-			->setConstructorArgs( array( $this->context ) )
742
-			->setMethods( $methods )
740
+		$stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard')
741
+			->setConstructorArgs(array($this->context))
742
+			->setMethods($methods)
743 743
 			->getMock();
744 744
 
745
-		\Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub );
745
+		\Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub);
746 746
 
747 747
 		return $stub;
748 748
 	}
749 749
 
750 750
 
751
-	protected function getProductItem( $code = 'CNC' )
751
+	protected function getProductItem($code = 'CNC')
752 752
 	{
753
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
753
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
754 754
 		$search = $manager->createSearch();
755
-		$search->setConditions( $search->compare( '==', 'product.code', $code ) );
756
-		$items = $manager->searchItems( $search );
755
+		$search->setConditions($search->compare('==', 'product.code', $code));
756
+		$items = $manager->searchItems($search);
757 757
 
758
-		if( ( $item = reset( $items ) ) === false ) {
759
-			throw new \Exception( sprintf( 'No product item with code "%1$s" found', $code ) );
758
+		if (($item = reset($items)) === false) {
759
+			throw new \Exception(sprintf('No product item with code "%1$s" found', $code));
760 760
 		}
761 761
 
762 762
 		return $item;
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/Customer/StandardTest.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
23 23
 		$this->view = $this->context->getView();
24 24
 
25
-		$this->object = new \Aimeos\Admin\JsonAdm\Customer\Standard( $this->context, $this->view, $templatePaths, 'customer' );
25
+		$this->object = new \Aimeos\Admin\JsonAdm\Customer\Standard($this->context, $this->view, $templatePaths, 'customer');
26 26
 	}
27 27
 
28 28
 
@@ -30,27 +30,27 @@  discard block
 block discarded – undo
30 30
 	{
31 31
 		$params = array(
32 32
 			'filter' => array(
33
-				'==' => array( 'customer.code' => 'UTC001' )
33
+				'==' => array('customer.code' => 'UTC001')
34 34
 			),
35 35
 			'include' => 'text,customer/address'
36 36
 		);
37
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
38
-		$this->view->addHelper( 'param', $helper );
37
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
38
+		$this->view->addHelper('param', $helper);
39 39
 
40 40
 		$header = array();
41 41
 		$status = 500;
42 42
 
43
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
44
-
45
-		$this->assertEquals( 200, $status );
46
-		$this->assertEquals( 1, count( $header ) );
47
-		$this->assertEquals( 1, $result['meta']['total'] );
48
-		$this->assertEquals( 1, count( $result['data'] ) );
49
-		$this->assertEquals( 'customer', $result['data'][0]['type'] );
50
-		$this->assertEquals( 1, count( $result['data'][0]['relationships']['text'] ) );
51
-		$this->assertEquals( 1, count( $result['data'][0]['relationships']['customer/address'] ) );
52
-		$this->assertEquals( 2, count( $result['included'] ) );
53
-		$this->assertArrayNotHasKey( 'errors', $result );
43
+		$result = json_decode($this->object->get('', $header, $status), true);
44
+
45
+		$this->assertEquals(200, $status);
46
+		$this->assertEquals(1, count($header));
47
+		$this->assertEquals(1, $result['meta']['total']);
48
+		$this->assertEquals(1, count($result['data']));
49
+		$this->assertEquals('customer', $result['data'][0]['type']);
50
+		$this->assertEquals(1, count($result['data'][0]['relationships']['text']));
51
+		$this->assertEquals(1, count($result['data'][0]['relationships']['customer/address']));
52
+		$this->assertEquals(2, count($result['included']));
53
+		$this->assertArrayNotHasKey('errors', $result);
54 54
 	}
55 55
 
56 56
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	{
59 59
 		$params = array(
60 60
 			'filter' => array(
61
-				'=~' => array( 'customer.code' => 'UTC' )
61
+				'=~' => array('customer.code' => 'UTC')
62 62
 			),
63 63
 			'fields' => array(
64 64
 				'customer' => 'customer.id,customer.label'
@@ -66,22 +66,22 @@  discard block
 block discarded – undo
66 66
 			'sort' => 'customer.id',
67 67
 			'include' => 'customer/address'
68 68
 		);
69
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
70
-		$this->view->addHelper( 'param', $helper );
69
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
70
+		$this->view->addHelper('param', $helper);
71 71
 
72 72
 		$header = array();
73 73
 		$status = 500;
74 74
 
75
-		$result = json_decode( $this->object->get( '', $header, $status ), true );
76
-
77
-		$this->assertEquals( 200, $status );
78
-		$this->assertEquals( 1, count( $header ) );
79
-		$this->assertEquals( 3, $result['meta']['total'] );
80
-		$this->assertEquals( 3, count( $result['data'] ) );
81
-		$this->assertEquals( 'customer', $result['data'][0]['type'] );
82
-		$this->assertEquals( 2, count( $result['data'][0]['attributes'] ) );
83
-		$this->assertEquals( 1, count( $result['data'][0]['relationships']['customer/address'] ) );
84
-		$this->assertEquals( 4, count( $result['included'] ) );
85
-		$this->assertArrayNotHasKey( 'errors', $result );
75
+		$result = json_decode($this->object->get('', $header, $status), true);
76
+
77
+		$this->assertEquals(200, $status);
78
+		$this->assertEquals(1, count($header));
79
+		$this->assertEquals(3, $result['meta']['total']);
80
+		$this->assertEquals(3, count($result['data']));
81
+		$this->assertEquals('customer', $result['data'][0]['type']);
82
+		$this->assertEquals(2, count($result['data'][0]['attributes']));
83
+		$this->assertEquals(1, count($result['data'][0]['relationships']['customer/address']));
84
+		$this->assertEquals(4, count($result['included']));
85
+		$this->assertArrayNotHasKey('errors', $result);
86 86
 	}
87 87
 }
88 88
\ No newline at end of file
Please login to merge, or discard this patch.