Completed
Push — master ( 26c14b...5d21ce )
by Aimeos
02:35
created
admin/jsonadm/src/Admin/JsonAdm/Base.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * @param array $templatePaths List of file system paths where the templates are stored
34 34
 	 * @param string $path Name of the client separated by slashes, e.g "product/property"
35 35
 	 */
36
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path )
36
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path)
37 37
 	{
38 38
 		$this->view = $view;
39 39
 		$this->context = $context;
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 	 * @param array $param List of method parameter
50 50
 	 * @throws \Aimeos\Admin\JsonAdm\Exception If method call failed
51 51
 	 */
52
-	public function __call( $name, array $param )
52
+	public function __call($name, array $param)
53 53
 	{
54
-		throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Unable to call method "%1$s"', $name ) );
54
+		throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Unable to call method "%1$s"', $name));
55 55
 	}
56 56
 
57 57
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @param array $include List of resource types that should be fetched
63 63
 	 * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface
64 64
 	 */
65
-	protected function getChildItems( array $items, array $include )
65
+	protected function getChildItems(array $items, array $include)
66 66
 	{
67 67
 		return [];
68 68
 	}
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	 * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter
86 86
 	 * @return array List of domain names
87 87
 	 */
88
-	protected function getDomains( \Aimeos\MW\View\Iface $view )
88
+	protected function getDomains(\Aimeos\MW\View\Iface $view)
89 89
 	{
90
-		if( ( $domains = $view->param( 'resource' ) ) == '' )
90
+		if (($domains = $view->param('resource')) == '')
91 91
 		{
92 92
 			/** admin/jsonadm/domains
93 93
 			 * A list of domain names whose clients are available for the JSON API
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 				'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', 'order',
111 111
 				'plugin', 'price', 'product', 'service', 'supplier', 'stock', 'tag', 'text'
112 112
 			);
113
-			$domains = $this->getContext()->getConfig()->get( 'admin/jsonadm/domains', $default );
113
+			$domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default);
114 114
 		}
115 115
 
116 116
 		return (array) $domains;
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
 	 * @param \stdClass $request Decoded request body
124 124
 	 * @return array List of item IDs
125 125
 	 */
126
-	protected function getIds( $request )
126
+	protected function getIds($request)
127 127
 	{
128 128
 		$ids = [];
129 129
 
130
-		if( isset( $request->data ) )
130
+		if (isset($request->data))
131 131
 		{
132
-			foreach( (array) $request->data as $entry )
132
+			foreach ((array) $request->data as $entry)
133 133
 			{
134
-				if( isset( $entry->id ) ) {
134
+				if (isset($entry->id)) {
135 135
 					$ids[] = $entry->id;
136 136
 				}
137 137
 			}
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 * @param array $include List of resource types that should be fetched
149 149
 	 * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface
150 150
 	 */
151
-	protected function getListItems( array $items, array $include )
151
+	protected function getListItems(array $items, array $include)
152 152
 	{
153 153
 		return [];
154 154
 	}
@@ -171,23 +171,23 @@  discard block
 block discarded – undo
171 171
 	 * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface
172 172
 	 * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface
173 173
 	 */
174
-	protected function getRefItems( array $listItems )
174
+	protected function getRefItems(array $listItems)
175 175
 	{
176 176
 		$list = $map = [];
177 177
 		$context = $this->getContext();
178 178
 
179
-		foreach( $listItems as $listItem ) {
179
+		foreach ($listItems as $listItem) {
180 180
 			$map[$listItem->getDomain()][] = $listItem->getRefId();
181 181
 		}
182 182
 
183
-		foreach( $map as $domain => $ids )
183
+		foreach ($map as $domain => $ids)
184 184
 		{
185
-			$manager = \Aimeos\MShop\Factory::createManager( $context, $domain );
185
+			$manager = \Aimeos\MShop\Factory::createManager($context, $domain);
186 186
 
187 187
 			$search = $manager->createSearch();
188
-			$search->setConditions( $search->compare( '==', $domain . '.id', $ids ) );
188
+			$search->setConditions($search->compare('==', $domain . '.id', $ids));
189 189
 
190
-			$list = array_merge( $list, $manager->searchItems( $search ) );
190
+			$list = array_merge($list, $manager->searchItems($search));
191 191
 		}
192 192
 
193 193
 		return $list;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter
201 201
 	 * @return array List of domain names
202 202
 	 */
203
-	protected function getResources( \Aimeos\MW\View\Iface $view )
203
+	protected function getResources(\Aimeos\MW\View\Iface $view)
204 204
 	{
205 205
 		/** admin/jsonadm/resources
206 206
 		 * A list of additional resources name whose clients are available for the JSON API
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		 * @category Developer
219 219
 		 * @see admin/jsonadm/domains
220 220
 		 */
221
-		return (array) $view->config( 'admin/jsonadm/resources', ['coupon/config'] );
221
+		return (array) $view->config('admin/jsonadm/resources', ['coupon/config']);
222 222
 	}
223 223
 
224 224
 
@@ -251,11 +251,11 @@  discard block
 block discarded – undo
251 251
 	 * @param array $params List of criteria data with condition, sorting and paging
252 252
 	 * @return \Aimeos\MW\Criteria\Iface Initialized criteria object
253 253
 	 */
254
-	protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params )
254
+	protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params)
255 255
 	{
256
-		$this->initCriteriaConditions( $criteria, $params );
257
-		$this->initCriteriaSortations( $criteria, $params );
258
-		$this->initCriteriaSlice( $criteria, $params );
256
+		$this->initCriteriaConditions($criteria, $params);
257
+		$this->initCriteriaSortations($criteria, $params);
258
+		$this->initCriteriaSlice($criteria, $params);
259 259
 
260 260
 		return $criteria;
261 261
 	}
@@ -267,17 +267,17 @@  discard block
 block discarded – undo
267 267
 	 * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object
268 268
 	 * @param array $params List of criteria data with condition, sorting and paging
269 269
 	 */
270
-	protected function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params )
270
+	protected function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params)
271 271
 	{
272
-		if( !isset( $params['filter'] ) ) {
272
+		if (!isset($params['filter'])) {
273 273
 			return;
274 274
 		}
275 275
 
276 276
 		$existing = $criteria->getConditions();
277
-		$criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) );
277
+		$criteria->setConditions($criteria->toConditions((array) $params['filter']));
278 278
 
279
-		$expr = array( $criteria->getConditions(), $existing );
280
-		$criteria->setConditions( $criteria->combine( '&&', $expr ) );
279
+		$expr = array($criteria->getConditions(), $existing);
280
+		$criteria->setConditions($criteria->combine('&&', $expr));
281 281
 	}
282 282
 
283 283
 
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
 	 * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object
288 288
 	 * @param array $params List of criteria data with condition, sorting and paging
289 289
 	 */
290
-	protected function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params )
290
+	protected function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params)
291 291
 	{
292
-		$start = ( isset( $params['page']['offset'] ) ? (int) $params['page']['offset'] : 0 );
293
-		$size = ( isset( $params['page']['limit'] ) ? (int) $params['page']['limit'] : 25 );
292
+		$start = (isset($params['page']['offset']) ? (int) $params['page']['offset'] : 0);
293
+		$size = (isset($params['page']['limit']) ? (int) $params['page']['limit'] : 25);
294 294
 
295
-		$criteria->setSlice( $start, $size );
295
+		$criteria->setSlice($start, $size);
296 296
 	}
297 297
 
298 298
 
@@ -302,24 +302,24 @@  discard block
 block discarded – undo
302 302
 	 * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object
303 303
 	 * @param array $params List of criteria data with condition, sorting and paging
304 304
 	 */
305
-	protected function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params )
305
+	protected function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params)
306 306
 	{
307
-		if( !isset( $params['sort'] ) ) {
307
+		if (!isset($params['sort'])) {
308 308
 			return;
309 309
 		}
310 310
 
311 311
 		$sortation = [];
312 312
 
313
-		foreach( explode( ',', $params['sort'] ) as $sort )
313
+		foreach (explode(',', $params['sort']) as $sort)
314 314
 		{
315
-			if( $sort[0] === '-' ) {
316
-				$sortation[] = $criteria->sort( '-', substr( $sort, 1 ) );
315
+			if ($sort[0] === '-') {
316
+				$sortation[] = $criteria->sort('-', substr($sort, 1));
317 317
 			} else {
318
-				$sortation[] = $criteria->sort( '+', $sort );
318
+				$sortation[] = $criteria->sort('+', $sort);
319 319
 			}
320 320
 		}
321 321
 
322
-		$criteria->setSortations( $sortation );
322
+		$criteria->setSortations($sortation);
323 323
 	}
324 324
 
325 325
 
@@ -330,14 +330,14 @@  discard block
 block discarded – undo
330 330
 	 * @param \stdClass $request Object with request body data
331 331
 	 * @return array List of items
332 332
 	 */
333
-	protected function saveData( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request )
333
+	protected function saveData(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request)
334 334
 	{
335 335
 		$data = [];
336 336
 
337
-		if( isset( $request->data ) )
337
+		if (isset($request->data))
338 338
 		{
339
-			foreach( (array) $request->data as $entry ) {
340
-				$data[] = $this->saveEntry( $manager, $entry );
339
+			foreach ((array) $request->data as $entry) {
340
+				$data[] = $this->saveEntry($manager, $entry);
341 341
 			}
342 342
 		}
343 343
 
@@ -352,22 +352,22 @@  discard block
 block discarded – undo
352 352
 	 * @param \stdClass $entry Object including "id" and "attributes" elements
353 353
 	 * @return \Aimeos\MShop\Common\Item\Iface New or updated item
354 354
 	 */
355
-	protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry )
355
+	protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry)
356 356
 	{
357
-		if( isset( $entry->id ) ) {
358
-			$item = $manager->getItem( $entry->id );
357
+		if (isset($entry->id)) {
358
+			$item = $manager->getItem($entry->id);
359 359
 		} else {
360 360
 			$item = $manager->createItem();
361 361
 		}
362 362
 
363
-		$item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() );
364
-		$item = $manager->saveItem( $item );
363
+		$item = $this->addItemData($manager, $item, $entry, $item->getResourceType());
364
+		$item = $manager->saveItem($item);
365 365
 
366
-		if( isset( $entry->relationships ) ) {
367
-			$this->saveRelationships( $manager, $item, $entry->relationships );
366
+		if (isset($entry->relationships)) {
367
+			$this->saveRelationships($manager, $item, $entry->relationships);
368 368
 		}
369 369
 
370
-		return $manager->getItem( $item->getId() );
370
+		return $manager->getItem($item->getId());
371 371
 	}
372 372
 
373 373
 
@@ -378,28 +378,28 @@  discard block
 block discarded – undo
378 378
 	 * @param \Aimeos\MShop\Common\Item\Iface $item Domain item with an unique ID set
379 379
 	 * @param \stdClass $relationships Object including the <domain>/data/attributes structure
380 380
 	 */
381
-	protected function saveRelationships( \Aimeos\MShop\Common\Manager\Iface $manager,
382
-		\Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships )
381
+	protected function saveRelationships(\Aimeos\MShop\Common\Manager\Iface $manager,
382
+		\Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships)
383 383
 	{
384 384
 		$id = $item->getId();
385
-		$listManager = $manager->getSubManager( 'lists' );
385
+		$listManager = $manager->getSubManager('lists');
386 386
 
387
-		foreach( (array) $relationships as $domain => $list )
387
+		foreach ((array) $relationships as $domain => $list)
388 388
 		{
389
-			if( isset( $list->data ) )
389
+			if (isset($list->data))
390 390
 			{
391
-				foreach( (array) $list->data as $data )
391
+				foreach ((array) $list->data as $data)
392 392
 				{
393
-					$listItem = $this->addItemData( $listManager, $listManager->createItem(), $data, $domain );
393
+					$listItem = $this->addItemData($listManager, $listManager->createItem(), $data, $domain);
394 394
 
395
-					if( isset( $data->id ) ) {
396
-						$listItem->setRefId( $data->id );
395
+					if (isset($data->id)) {
396
+						$listItem->setRefId($data->id);
397 397
 					}
398 398
 
399
-					$listItem->setParentId( $id );
400
-					$listItem->setDomain( $domain );
399
+					$listItem->setParentId($id);
400
+					$listItem->setDomain($domain);
401 401
 
402
-					$listManager->saveItem( $listItem, false );
402
+					$listManager->saveItem($listItem, false);
403 403
 				}
404 404
 			}
405 405
 		}
@@ -416,20 +416,20 @@  discard block
 block discarded – undo
416 416
 	 * @return \Aimeos\MShop\Common\Item\Iface Item including the data
417 417
 	 */
418 418
 	protected function addItemData(\Aimeos\MShop\Common\Manager\Iface $manager,
419
-		\Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain )
419
+		\Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain)
420 420
 	{
421
-		if( isset( $data->attributes ) )
421
+		if (isset($data->attributes))
422 422
 		{
423 423
 			$attr = (array) $data->attributes;
424
-			$key = str_replace( '/', '.', $item->getResourceType() );
424
+			$key = str_replace('/', '.', $item->getResourceType());
425 425
 
426
-			if( isset( $attr[$key.'.type'] ) )
426
+			if (isset($attr[$key . '.type']))
427 427
 			{
428
-				$typeItem = $manager->getSubManager( 'type' )->findItem( $attr[$key.'.type'], [], $domain );
429
-				$attr[$key.'.typeid'] = $typeItem->getId();
428
+				$typeItem = $manager->getSubManager('type')->findItem($attr[$key . '.type'], [], $domain);
429
+				$attr[$key . '.typeid'] = $typeItem->getId();
430 430
 			}
431 431
 
432
-			$item->fromArray( $attr );
432
+			$item->fromArray($attr);
433 433
 		}
434 434
 
435 435
 		return $item;
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Standard.php 1 patch
Spacing   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -31,38 +31,38 @@  discard block
 block discarded – undo
31 31
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
32 32
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
33 33
 	 */
34
-	public function delete( ServerRequestInterface $request, ResponseInterface $response )
34
+	public function delete(ServerRequestInterface $request, ResponseInterface $response)
35 35
 	{
36 36
 		$view = $this->getView();
37 37
 
38 38
 		try
39 39
 		{
40
-			$response = $this->deleteItems( $view, $request, $response );
40
+			$response = $this->deleteItems($view, $request, $response);
41 41
 			$status = 200;
42 42
 		}
43
-		catch( \Aimeos\Admin\JsonAdm\Exception $e )
43
+		catch (\Aimeos\Admin\JsonAdm\Exception $e)
44 44
 		{
45 45
 			$status = $e->getCode();
46
-			$view->errors = array( array(
47
-				'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ),
46
+			$view->errors = array(array(
47
+				'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()),
48 48
 				'detail' => $e->getTraceAsString(),
49
-			) );
49
+			));
50 50
 		}
51
-		catch( \Aimeos\MShop\Exception $e )
51
+		catch (\Aimeos\MShop\Exception $e)
52 52
 		{
53 53
 			$status = 404;
54
-			$view->errors = array( array(
55
-				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
54
+			$view->errors = array(array(
55
+				'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()),
56 56
 				'detail' => $e->getTraceAsString(),
57
-			) );
57
+			));
58 58
 		}
59
-		catch( \Exception $e )
59
+		catch (\Exception $e)
60 60
 		{
61 61
 			$status = 500;
62
-			$view->errors = array( array(
62
+			$view->errors = array(array(
63 63
 				'title' => $e->getMessage(),
64 64
 				'detail' => $e->getTraceAsString(),
65
-			) );
65
+			));
66 66
 		}
67 67
 
68 68
 		/** admin/jsonadm/standard/template-delete
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
 		$tplconf = 'admin/jsonadm/standard/template-delete';
94 94
 		$default = 'delete-default.php';
95 95
 
96
-		$body = $view->render( $view->config( $tplconf, $default ) );
96
+		$body = $view->render($view->config($tplconf, $default));
97 97
 
98
-		return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' )
99
-			->withBody( $view->response()->createStreamFromString( $body ) )
100
-			->withStatus( $status );
98
+		return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"')
99
+			->withBody($view->response()->createStreamFromString($body))
100
+			->withStatus($status);
101 101
 	}
102 102
 
103 103
 
@@ -108,33 +108,33 @@  discard block
 block discarded – undo
108 108
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
109 109
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
110 110
 	 */
111
-	public function get( ServerRequestInterface $request, ResponseInterface $response )
111
+	public function get(ServerRequestInterface $request, ResponseInterface $response)
112 112
 	{
113 113
 		$view = $this->getView();
114 114
 
115 115
 		try
116 116
 		{
117
-			$response = $this->getItems( $view, $request, $response );
117
+			$response = $this->getItems($view, $request, $response);
118 118
 			$status = 200;
119 119
 		}
120
-		catch( \Aimeos\MShop\Exception $e )
120
+		catch (\Aimeos\MShop\Exception $e)
121 121
 		{
122 122
 			$status = 404;
123
-			$view->errors = array( array(
124
-				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
123
+			$view->errors = array(array(
124
+				'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()),
125 125
 				'detail' => $e->getTraceAsString(),
126
-			) );
126
+			));
127 127
 		}
128
-		catch( \Exception $e )
128
+		catch (\Exception $e)
129 129
 		{
130 130
 			$status = 500;
131
-			$view->errors = array( array(
131
+			$view->errors = array(array(
132 132
 				'title' => $e->getMessage(),
133 133
 				'detail' => $e->getTraceAsString(),
134
-			) );
134
+			));
135 135
 		}
136 136
 
137
-		if( $view->param( 'aggregate' ) !== null )
137
+		if ($view->param('aggregate') !== null)
138 138
 		{
139 139
 			/** admin/jsonadm/standard/template-aggregate
140 140
 			 * Relative path to the JSON API template for GET aggregate requests
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 			$default = 'get-default.php';
196 196
 		}
197 197
 
198
-		$body = $view->render( $view->config( $tplconf, $default ) );
198
+		$body = $view->render($view->config($tplconf, $default));
199 199
 
200
-		return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' )
201
-			->withBody( $view->response()->createStreamFromString( $body ) )
202
-			->withStatus( $status );
200
+		return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"')
201
+			->withBody($view->response()->createStreamFromString($body))
202
+			->withStatus($status);
203 203
 	}
204 204
 
205 205
 
@@ -210,38 +210,38 @@  discard block
 block discarded – undo
210 210
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
211 211
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
212 212
 	 */
213
-	public function patch( ServerRequestInterface $request, ResponseInterface $response )
213
+	public function patch(ServerRequestInterface $request, ResponseInterface $response)
214 214
 	{
215 215
 		$view = $this->getView();
216 216
 
217 217
 		try
218 218
 		{
219
-			$response = $this->patchItems( $view, $request, $response );
219
+			$response = $this->patchItems($view, $request, $response);
220 220
 			$status = 200;
221 221
 		}
222
-		catch( \Aimeos\Admin\JsonAdm\Exception $e )
222
+		catch (\Aimeos\Admin\JsonAdm\Exception $e)
223 223
 		{
224 224
 			$status = $e->getCode();
225
-			$view->errors = array( array(
226
-				'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ),
225
+			$view->errors = array(array(
226
+				'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', $e->getMessage()),
227 227
 				'detail' => $e->getTraceAsString(),
228
-			) );
228
+			));
229 229
 		}
230
-		catch( \Aimeos\MShop\Exception $e )
230
+		catch (\Aimeos\MShop\Exception $e)
231 231
 		{
232 232
 			$status = 404;
233
-			$view->errors = array( array(
234
-				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
233
+			$view->errors = array(array(
234
+				'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()),
235 235
 				'detail' => $e->getTraceAsString(),
236
-			) );
236
+			));
237 237
 		}
238
-		catch( \Exception $e )
238
+		catch (\Exception $e)
239 239
 		{
240 240
 			$status = 500;
241
-			$view->errors = array( array(
241
+			$view->errors = array(array(
242 242
 				'title' => $e->getMessage(),
243 243
 				'detail' => $e->getTraceAsString(),
244
-			) );
244
+			));
245 245
 		}
246 246
 
247 247
 		/** admin/jsonadm/standard/template-patch
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 		$tplconf = 'admin/jsonadm/standard/template-patch';
273 273
 		$default = 'patch-default.php';
274 274
 
275
-		$body = $view->render( $view->config( $tplconf, $default ) );
275
+		$body = $view->render($view->config($tplconf, $default));
276 276
 
277
-		return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' )
278
-			->withBody( $view->response()->createStreamFromString( $body ) )
279
-			->withStatus( $status );
277
+		return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"')
278
+			->withBody($view->response()->createStreamFromString($body))
279
+			->withStatus($status);
280 280
 	}
281 281
 
282 282
 
@@ -287,38 +287,38 @@  discard block
 block discarded – undo
287 287
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
288 288
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
289 289
 	 */
290
-	public function post( ServerRequestInterface $request, ResponseInterface $response )
290
+	public function post(ServerRequestInterface $request, ResponseInterface $response)
291 291
 	{
292 292
 		$view = $this->getView();
293 293
 
294 294
 		try
295 295
 		{
296
-			$response = $this->postItems( $view, $request, $response );
296
+			$response = $this->postItems($view, $request, $response);
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,11 +349,11 @@  discard block
 block discarded – undo
349 349
 		$tplconf = 'admin/jsonadm/standard/template-post';
350 350
 		$default = 'post-default.php';
351 351
 
352
-		$body = $view->render( $view->config( $tplconf, $default ) );
352
+		$body = $view->render($view->config($tplconf, $default));
353 353
 
354
-		return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' )
355
-			->withBody( $view->response()->createStreamFromString( $body ) )
356
-			->withStatus( $status );
354
+		return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"')
355
+			->withBody($view->response()->createStreamFromString($body))
356
+			->withStatus($status);
357 357
 	}
358 358
 
359 359
 
@@ -364,14 +364,14 @@  discard block
 block discarded – undo
364 364
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
365 365
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
366 366
 	 */
367
-	public function put( ServerRequestInterface $request, ResponseInterface $response )
367
+	public function put(ServerRequestInterface $request, ResponseInterface $response)
368 368
 	{
369 369
 		$status = 501;
370 370
 		$view = $this->getView();
371 371
 
372
-		$view->errors = array( array(
373
-			'title' => $this->getContext()->getI18n()->dt( 'admin/jsonadm', 'Not implemented, use PATCH instead' ),
374
-		) );
372
+		$view->errors = array(array(
373
+			'title' => $this->getContext()->getI18n()->dt('admin/jsonadm', 'Not implemented, use PATCH instead'),
374
+		));
375 375
 
376 376
 		/** admin/jsonadm/standard/template-put
377 377
 		 * Relative path to the JSON API template for PUT requests
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
 		$tplconf = 'admin/jsonadm/standard/template-put';
402 402
 		$default = 'put-default.php';
403 403
 
404
-		$body = $view->render( $view->config( $tplconf, $default ) );
404
+		$body = $view->render($view->config($tplconf, $default));
405 405
 
406
-		return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' )
407
-			->withBody( $view->response()->createStreamFromString( $body ) )
408
-			->withStatus( $status );
406
+		return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"')
407
+			->withBody($view->response()->createStreamFromString($body))
408
+			->withStatus($status);
409 409
 	}
410 410
 
411 411
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 	 * @param string|null $prefix Form parameter prefix when nesting parameters is required
418 418
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
419 419
 	 */
420
-	public function options( ServerRequestInterface $request, ResponseInterface $response, $prefix = null )
420
+	public function options(ServerRequestInterface $request, ResponseInterface $response, $prefix = null)
421 421
 	{
422 422
 		$context = $this->getContext();
423 423
 		$view = $this->getView();
@@ -426,14 +426,14 @@  discard block
 block discarded – undo
426 426
 		{
427 427
 			$resources = $attributes = [];
428 428
 
429
-			foreach( $this->getDomains( $view ) as $domain )
429
+			foreach ($this->getDomains($view) as $domain)
430 430
 			{
431
-				$manager = \Aimeos\MShop\Factory::createManager( $context, $domain );
432
-				$resources = array_merge( $resources, $manager->getResourceType( true ) );
433
-				$attributes = array_merge( $attributes, $manager->getSearchAttributes( true ) );
431
+				$manager = \Aimeos\MShop\Factory::createManager($context, $domain);
432
+				$resources = array_merge($resources, $manager->getResourceType(true));
433
+				$attributes = array_merge($attributes, $manager->getSearchAttributes(true));
434 434
 			}
435 435
 
436
-			foreach( $this->getResources( $view ) as $resource ) {
436
+			foreach ($this->getResources($view) as $resource) {
437 437
 				$resources[] = $resource;
438 438
 			}
439 439
 
@@ -443,21 +443,21 @@  discard block
 block discarded – undo
443 443
 
444 444
 			$status = 200;
445 445
 		}
446
-		catch( \Aimeos\MShop\Exception $e )
446
+		catch (\Aimeos\MShop\Exception $e)
447 447
 		{
448 448
 			$status = 404;
449
-			$view->errors = array( array(
450
-				'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ),
449
+			$view->errors = array(array(
450
+				'title' => $context->getI18n()->dt('mshop', $e->getMessage()),
451 451
 				'detail' => $e->getTraceAsString(),
452
-			) );
452
+			));
453 453
 		}
454
-		catch( \Exception $e )
454
+		catch (\Exception $e)
455 455
 		{
456 456
 			$status = 500;
457
-			$view->errors = array( array(
457
+			$view->errors = array(array(
458 458
 				'title' => $e->getMessage(),
459 459
 				'detail' => $e->getTraceAsString(),
460
-			) );
460
+			));
461 461
 		}
462 462
 
463 463
 		/** admin/jsonadm/standard/template-options
@@ -488,12 +488,12 @@  discard block
 block discarded – undo
488 488
 		$tplconf = 'admin/jsonadm/standard/template-options';
489 489
 		$default = 'options-default.php';
490 490
 
491
-		$body = $view->render( $view->config( $tplconf, $default ) );
491
+		$body = $view->render($view->config($tplconf, $default));
492 492
 
493
-		return $response->withHeader( 'Allow', 'DELETE,GET,PATCH,POST,OPTIONS' )
494
-			->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' )
495
-			->withBody( $view->response()->createStreamFromString( $body ) )
496
-			->withStatus( $status );
493
+		return $response->withHeader('Allow', 'DELETE,GET,PATCH,POST,OPTIONS')
494
+			->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"')
495
+			->withBody($view->response()->createStreamFromString($body))
496
+			->withStatus($status);
497 497
 	}
498 498
 
499 499
 
@@ -506,25 +506,25 @@  discard block
 block discarded – undo
506 506
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
507 507
 	 * @throws \Aimeos\Admin\JsonAdm\Exception If the request body is invalid
508 508
 	 */
509
-	protected function deleteItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
509
+	protected function deleteItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
510 510
 	{
511
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() );
511
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath());
512 512
 
513
-		if( ( $id = $view->param( 'id' ) ) == null )
513
+		if (($id = $view->param('id')) == null)
514 514
 		{
515 515
 			$body = (string) $request->getBody();
516 516
 
517
-			if( ( $payload = json_decode( $body ) ) === null || !isset( $payload->data ) || !is_array( $payload->data ) ) {
518
-				throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 );
517
+			if (($payload = json_decode($body)) === null || !isset($payload->data) || !is_array($payload->data)) {
518
+				throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400);
519 519
 			}
520 520
 
521
-			$ids = $this->getIds( $payload );
522
-			$manager->deleteItems( $ids );
523
-			$view->total = count( $ids );
521
+			$ids = $this->getIds($payload);
522
+			$manager->deleteItems($ids);
523
+			$view->total = count($ids);
524 524
 		}
525 525
 		else
526 526
 		{
527
-			$manager->deleteItem( $id );
527
+			$manager->deleteItem($id);
528 528
 			$view->total = 1;
529 529
 		}
530 530
 
@@ -540,35 +540,35 @@  discard block
 block discarded – undo
540 540
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
541 541
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
542 542
 	 */
543
-	protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
543
+	protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
544 544
 	{
545
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() );
545
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath());
546 546
 
547
-		if( ( $key = $view->param( 'aggregate' ) ) !== null )
547
+		if (($key = $view->param('aggregate')) !== null)
548 548
 		{
549
-			$search = $this->initCriteria( $manager->createSearch(), $view->param() );
550
-			$view->data = $manager->aggregate( $search, $key );
549
+			$search = $this->initCriteria($manager->createSearch(), $view->param());
550
+			$view->data = $manager->aggregate($search, $key);
551 551
 			return $response;
552 552
 		}
553 553
 
554 554
 		$total = 1;
555
-		$include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : [] );
555
+		$include = (($include = $view->param('include')) !== null ? explode(',', $include) : []);
556 556
 
557
-		if( ( $id = $view->param( 'id' ) ) == null )
557
+		if (($id = $view->param('id')) == null)
558 558
 		{
559
-			$search = $this->initCriteria( $manager->createSearch(), $view->param() );
560
-			$view->data = $manager->searchItems( $search, [], $total );
561
-			$view->childItems = $this->getChildItems( $view->data, $include );
562
-			$view->listItems = $this->getListItems( $view->data, $include );
559
+			$search = $this->initCriteria($manager->createSearch(), $view->param());
560
+			$view->data = $manager->searchItems($search, [], $total);
561
+			$view->childItems = $this->getChildItems($view->data, $include);
562
+			$view->listItems = $this->getListItems($view->data, $include);
563 563
 		}
564 564
 		else
565 565
 		{
566
-			$view->data = $manager->getItem( $id, [] );
567
-			$view->childItems = $this->getChildItems( array( $id => $view->data ), $include );
568
-			$view->listItems = $this->getListItems( array( $id => $view->data ), $include );
566
+			$view->data = $manager->getItem($id, []);
567
+			$view->childItems = $this->getChildItems(array($id => $view->data), $include);
568
+			$view->listItems = $this->getListItems(array($id => $view->data), $include);
569 569
 		}
570 570
 
571
-		$view->refItems = $this->getRefItems( $view->listItems );
571
+		$view->refItems = $this->getRefItems($view->listItems);
572 572
 		$view->total = $total;
573 573
 
574 574
 		return $response;
@@ -584,35 +584,35 @@  discard block
 block discarded – undo
584 584
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
585 585
 	 * @throws \Aimeos\Admin\JsonAdm\Exception If "id" parameter isn't available or the body is invalid
586 586
 	 */
587
-	protected function patchItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
587
+	protected function patchItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
588 588
 	{
589 589
 		$body = (string) $request->getBody();
590 590
 
591
-		if( ( $payload = json_decode( $body ) ) === null || !isset( $payload->data ) ) {
592
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 );
591
+		if (($payload = json_decode($body)) === null || !isset($payload->data)) {
592
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400);
593 593
 		}
594 594
 
595
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() );
595
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath());
596 596
 
597
-		if( is_array( $payload->data ) )
597
+		if (is_array($payload->data))
598 598
 		{
599
-			$data = $this->saveData( $manager, $payload );
599
+			$data = $this->saveData($manager, $payload);
600 600
 
601 601
 			$view->data = $data;
602
-			$view->total = count( $data );
603
-			$response = $response->withHeader( 'Content-Type', 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"' );
602
+			$view->total = count($data);
603
+			$response = $response->withHeader('Content-Type', 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"');
604 604
 		}
605
-		elseif( ( $id = $view->param( 'id' ) ) != null )
605
+		elseif (($id = $view->param('id')) != null)
606 606
 		{
607 607
 			$payload->data->id = $id;
608
-			$data = $this->saveEntry( $manager, $payload->data );
608
+			$data = $this->saveEntry($manager, $payload->data);
609 609
 
610 610
 			$view->data = $data;
611 611
 			$view->total = 1;
612 612
 		}
613 613
 		else
614 614
 		{
615
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 );
615
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400);
616 616
 		}
617 617
 
618 618
 		return $response;
@@ -627,33 +627,33 @@  discard block
 block discarded – undo
627 627
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
628 628
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
629 629
 	 */
630
-	protected function postItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
630
+	protected function postItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
631 631
 	{
632 632
 		$body = (string) $request->getBody();
633 633
 
634
-		if( ( $payload = json_decode( $body ) ) === null || !isset( $payload->data ) ) {
635
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 );
634
+		if (($payload = json_decode($body)) === null || !isset($payload->data)) {
635
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400);
636 636
 		}
637 637
 
638
-		if( isset( $payload->data->id ) || $view->param( 'id' ) != null ) {
639
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Client generated IDs are not supported' ), 403 );
638
+		if (isset($payload->data->id) || $view->param('id') != null) {
639
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Client generated IDs are not supported'), 403);
640 640
 		}
641 641
 
642 642
 
643
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() );
643
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath());
644 644
 
645
-		if( is_array( $payload->data ) )
645
+		if (is_array($payload->data))
646 646
 		{
647
-			$data = $this->saveData( $manager, $payload );
647
+			$data = $this->saveData($manager, $payload);
648 648
 
649 649
 			$view->data = $data;
650
-			$view->total = count( $data );
651
-			$response = $response->withHeader( 'Content-Type', 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"' );
650
+			$view->total = count($data);
651
+			$response = $response->withHeader('Content-Type', 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"');
652 652
 		}
653 653
 		else
654 654
 		{
655 655
 			$payload->data->id = null;
656
-			$data = $this->saveEntry( $manager, $payload->data );
656
+			$data = $this->saveEntry($manager, $payload->data);
657 657
 
658 658
 			$view->data = $data;
659 659
 			$view->total = 1;
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/StandardTest.php 1 patch
Spacing   +387 added lines, -387 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,193 +34,193 @@  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
-		$response = $this->object->delete( $this->view->request(), $this->view->response() );
44
-		$result = json_decode( (string) $response->getBody(), true );
43
+		$response = $this->object->delete($this->view->request(), $this->view->response());
44
+		$result = json_decode((string) $response->getBody(), true);
45 45
 
46 46
 
47
-		$this->assertEquals( 200, $response->getStatusCode() );
48
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
47
+		$this->assertEquals(200, $response->getStatusCode());
48
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
49 49
 
50
-		$this->assertEquals( 1, $result['meta']['total'] );
50
+		$this->assertEquals(1, $result['meta']['total']);
51 51
 
52
-		$this->assertArrayNotHasKey( 'included', $result );
53
-		$this->assertArrayNotHasKey( 'data', $result );
54
-		$this->assertArrayNotHasKey( 'errors', $result );
52
+		$this->assertArrayNotHasKey('included', $result);
53
+		$this->assertArrayNotHasKey('data', $result);
54
+		$this->assertArrayNotHasKey('errors', $result);
55 55
 	}
56 56
 
57 57
 
58 58
 	public function testDeleteBulk()
59 59
 	{
60
-		$this->getProductMock( array( 'deleteItems' ) )->expects( $this->once() )->method( 'deleteItems' );
60
+		$this->getProductMock(array('deleteItems'))->expects($this->once())->method('deleteItems');
61 61
 
62 62
 		$body = '{"data":[{"type": "product", "id": "-1"},{"type": "product", "id": "-2"}]}';
63
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
63
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
64 64
 
65
-		$response = $this->object->delete( $request, $this->view->response() );
66
-		$result = json_decode( (string) $response->getBody(), true );
65
+		$response = $this->object->delete($request, $this->view->response());
66
+		$result = json_decode((string) $response->getBody(), true);
67 67
 
68 68
 
69
-		$this->assertEquals( 200, $response->getStatusCode() );
70
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
69
+		$this->assertEquals(200, $response->getStatusCode());
70
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
71 71
 
72
-		$this->assertEquals( 2, $result['meta']['total'] );
73
-		$this->assertArrayNotHasKey( 'included', $result );
74
-		$this->assertArrayNotHasKey( 'data', $result );
75
-		$this->assertArrayNotHasKey( 'errors', $result );
72
+		$this->assertEquals(2, $result['meta']['total']);
73
+		$this->assertArrayNotHasKey('included', $result);
74
+		$this->assertArrayNotHasKey('data', $result);
75
+		$this->assertArrayNotHasKey('errors', $result);
76 76
 	}
77 77
 
78 78
 
79 79
 	public function testDeleteInvalid()
80 80
 	{
81 81
 		$body = '{"data":null}';
82
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
82
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
83 83
 
84
-		$response = $this->object->delete( $request, $this->view->response() );
85
-		$result = json_decode( (string) $response->getBody(), true );
84
+		$response = $this->object->delete($request, $this->view->response());
85
+		$result = json_decode((string) $response->getBody(), true);
86 86
 
87 87
 
88
-		$this->assertEquals( 400, $response->getStatusCode() );
89
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
88
+		$this->assertEquals(400, $response->getStatusCode());
89
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
90 90
 
91
-		$this->assertEquals( 0, $result['meta']['total'] );
92
-		$this->assertArrayHasKey( 'errors', $result );
93
-		$this->assertArrayNotHasKey( 'included', $result );
94
-		$this->assertArrayNotHasKey( 'data', $result );
91
+		$this->assertEquals(0, $result['meta']['total']);
92
+		$this->assertArrayHasKey('errors', $result);
93
+		$this->assertArrayNotHasKey('included', $result);
94
+		$this->assertArrayNotHasKey('data', $result);
95 95
 	}
96 96
 
97 97
 
98 98
 	public function testDeleteException()
99 99
 	{
100
-		$this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' )
101
-			->will( $this->throwException( new \RuntimeException( 'test exception' ) ) );
100
+		$this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem')
101
+			->will($this->throwException(new \RuntimeException('test exception')));
102 102
 
103
-		$params = array( 'id' => $this->getProductItem()->getId() );
104
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
105
-		$this->view->addHelper( 'param', $helper );
103
+		$params = array('id' => $this->getProductItem()->getId());
104
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
105
+		$this->view->addHelper('param', $helper);
106 106
 
107
-		$response = $this->object->delete( $this->view->request(), $this->view->response() );
108
-		$result = json_decode( (string) $response->getBody(), true );
107
+		$response = $this->object->delete($this->view->request(), $this->view->response());
108
+		$result = json_decode((string) $response->getBody(), true);
109 109
 
110
-		$this->assertEquals( 500, $response->getStatusCode() );
111
-		$this->assertArrayHasKey( 'errors', $result );
110
+		$this->assertEquals(500, $response->getStatusCode());
111
+		$this->assertArrayHasKey('errors', $result);
112 112
 	}
113 113
 
114 114
 
115 115
 	public function testDeleteMShopException()
116 116
 	{
117
-		$this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' )
118
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
117
+		$this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem')
118
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
119 119
 
120
-		$params = array( 'id' => $this->getProductItem()->getId() );
121
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
122
-		$this->view->addHelper( 'param', $helper );
120
+		$params = array('id' => $this->getProductItem()->getId());
121
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
122
+		$this->view->addHelper('param', $helper);
123 123
 
124
-		$response = $this->object->delete( $this->view->request(), $this->view->response() );
125
-		$result = json_decode( (string) $response->getBody(), true );
124
+		$response = $this->object->delete($this->view->request(), $this->view->response());
125
+		$result = json_decode((string) $response->getBody(), true);
126 126
 
127
-		$this->assertEquals( 404, $response->getStatusCode() );
128
-		$this->assertArrayHasKey( 'errors', $result );
127
+		$this->assertEquals(404, $response->getStatusCode());
128
+		$this->assertArrayHasKey('errors', $result);
129 129
 	}
130 130
 
131 131
 
132 132
 	public function testGet()
133 133
 	{
134
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
135
-		$result = json_decode( (string) $response->getBody(), true );
134
+		$response = $this->object->get($this->view->request(), $this->view->response());
135
+		$result = json_decode((string) $response->getBody(), true);
136 136
 
137 137
 
138
-		$this->assertEquals( 200, $response->getStatusCode() );
139
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
138
+		$this->assertEquals(200, $response->getStatusCode());
139
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
140 140
 
141
-		$this->assertEquals( 28, $result['meta']['total'] );
142
-		$this->assertEquals( 25, count( $result['data'] ) );
143
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
144
-		$this->assertEquals( 0, count( $result['included'] ) );
145
-		$this->assertArrayHasKey( 'next', $result['links'] );
146
-		$this->assertArrayHasKey( 'last', $result['links'] );
147
-		$this->assertArrayHasKey( 'self', $result['links'] );
148
-		$this->assertArrayNotHasKey( 'errors', $result );
141
+		$this->assertEquals(28, $result['meta']['total']);
142
+		$this->assertEquals(25, count($result['data']));
143
+		$this->assertEquals('product', $result['data'][0]['type']);
144
+		$this->assertEquals(0, count($result['included']));
145
+		$this->assertArrayHasKey('next', $result['links']);
146
+		$this->assertArrayHasKey('last', $result['links']);
147
+		$this->assertArrayHasKey('self', $result['links']);
148
+		$this->assertArrayNotHasKey('errors', $result);
149 149
 	}
150 150
 
151 151
 
152 152
 	public function testGetType()
153 153
 	{
154 154
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
155
-		$object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'product/property/type' );
155
+		$object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'product/property/type');
156 156
 
157
-		$response = $object->get( $this->view->request(), $this->view->response() );
158
-		$result = json_decode( (string) $response->getBody(), true );
157
+		$response = $object->get($this->view->request(), $this->view->response());
158
+		$result = json_decode((string) $response->getBody(), true);
159 159
 
160 160
 
161
-		$this->assertEquals( 200, $response->getStatusCode() );
162
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
161
+		$this->assertEquals(200, $response->getStatusCode());
162
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
163 163
 
164
-		$this->assertEquals( 4, $result['meta']['total'] );
165
-		$this->assertEquals( 4, count( $result['data'] ) );
166
-		$this->assertEquals( 'product/property/type', $result['data'][0]['type'] );
167
-		$this->assertEquals( 0, count( $result['included'] ) );
164
+		$this->assertEquals(4, $result['meta']['total']);
165
+		$this->assertEquals(4, count($result['data']));
166
+		$this->assertEquals('product/property/type', $result['data'][0]['type']);
167
+		$this->assertEquals(0, count($result['included']));
168 168
 
169
-		$this->assertArrayNotHasKey( 'errors', $result );
169
+		$this->assertArrayNotHasKey('errors', $result);
170 170
 	}
171 171
 
172 172
 
173 173
 	public function testGetInvalid()
174 174
 	{
175 175
 		$templatePaths = \TestHelperJadm::getJsonadmPaths();
176
-		$object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'invalid' );
176
+		$object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'invalid');
177 177
 
178
-		$response = $object->get( $this->view->request(), $this->view->response() );
179
-		$result = json_decode( (string) $response->getBody(), true );
178
+		$response = $object->get($this->view->request(), $this->view->response());
179
+		$result = json_decode((string) $response->getBody(), true);
180 180
 
181 181
 
182
-		$this->assertEquals( 404, $response->getStatusCode() );
183
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
182
+		$this->assertEquals(404, $response->getStatusCode());
183
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
184 184
 
185
-		$this->assertEquals( 1, count( $result['errors'] ) );
186
-		$this->assertArrayHasKey( 'title', $result['errors'][0] );
187
-		$this->assertArrayHasKey( 'detail', $result['errors'][0] );
188
-		$this->assertArrayNotHasKey( 'data', $result );
189
-		$this->assertArrayNotHasKey( 'indluded', $result );
185
+		$this->assertEquals(1, count($result['errors']));
186
+		$this->assertArrayHasKey('title', $result['errors'][0]);
187
+		$this->assertArrayHasKey('detail', $result['errors'][0]);
188
+		$this->assertArrayNotHasKey('data', $result);
189
+		$this->assertArrayNotHasKey('indluded', $result);
190 190
 	}
191 191
 
192 192
 
193 193
 	public function testGetException()
194 194
 	{
195
-		$this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' )
196
-			->will( $this->throwException( new \RuntimeException( 'test exception' ) ) );
195
+		$this->getProductMock(array('getItem'))->expects($this->once())->method('getItem')
196
+			->will($this->throwException(new \RuntimeException('test exception')));
197 197
 
198
-		$params = array( 'id' => -1 );
199
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
200
-		$this->view->addHelper( 'param', $helper );
198
+		$params = array('id' => -1);
199
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
200
+		$this->view->addHelper('param', $helper);
201 201
 
202
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
203
-		$result = json_decode( (string) $response->getBody(), true );
202
+		$response = $this->object->get($this->view->request(), $this->view->response());
203
+		$result = json_decode((string) $response->getBody(), true);
204 204
 
205
-		$this->assertEquals( 500, $response->getStatusCode() );
206
-		$this->assertArrayHasKey( 'errors', $result );
205
+		$this->assertEquals(500, $response->getStatusCode());
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
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
220
-		$result = json_decode( (string) $response->getBody(), true );
219
+		$response = $this->object->get($this->view->request(), $this->view->response());
220
+		$result = json_decode((string) $response->getBody(), true);
221 221
 
222
-		$this->assertEquals( 404, $response->getStatusCode() );
223
-		$this->assertArrayHasKey( 'errors', $result );
222
+		$this->assertEquals(404, $response->getStatusCode());
223
+		$this->assertArrayHasKey('errors', $result);
224 224
 	}
225 225
 
226 226
 
@@ -228,25 +228,25 @@  discard block
 block discarded – undo
228 228
 	{
229 229
 		$params = array(
230 230
 			'filter' => array(
231
-				'==' => array( 'product.type.code' => 'select' )
231
+				'==' => array('product.type.code' => 'select')
232 232
 			)
233 233
 		);
234
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
235
-		$this->view->addHelper( 'param', $helper );
234
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
235
+		$this->view->addHelper('param', $helper);
236 236
 
237
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
238
-		$result = json_decode( (string) $response->getBody(), true );
237
+		$response = $this->object->get($this->view->request(), $this->view->response());
238
+		$result = json_decode((string) $response->getBody(), true);
239 239
 
240 240
 
241
-		$this->assertEquals( 200, $response->getStatusCode() );
242
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
241
+		$this->assertEquals(200, $response->getStatusCode());
242
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
243 243
 
244
-		$this->assertEquals( 3, $result['meta']['total'] );
245
-		$this->assertEquals( 3, count( $result['data'] ) );
246
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
247
-		$this->assertEquals( 0, count( $result['included'] ) );
244
+		$this->assertEquals(3, $result['meta']['total']);
245
+		$this->assertEquals(3, count($result['data']));
246
+		$this->assertEquals('product', $result['data'][0]['type']);
247
+		$this->assertEquals(0, count($result['included']));
248 248
 
249
-		$this->assertArrayNotHasKey( 'errors', $result );
249
+		$this->assertArrayNotHasKey('errors', $result);
250 250
 	}
251 251
 
252 252
 
@@ -255,27 +255,27 @@  discard block
 block discarded – undo
255 255
 		$params = array(
256 256
 			'filter' => array(
257 257
 				'&&' => array(
258
-					array( '=~' => array( 'product.label' => 'Unittest: Test' ) ),
259
-					array( '==' => array( 'product.type.code' => 'select' ) ),
258
+					array('=~' => array('product.label' => 'Unittest: Test')),
259
+					array('==' => array('product.type.code' => 'select')),
260 260
 				)
261 261
 			)
262 262
 		);
263
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
264
-		$this->view->addHelper( 'param', $helper );
263
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
264
+		$this->view->addHelper('param', $helper);
265 265
 
266
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
267
-		$result = json_decode( (string) $response->getBody(), true );
266
+		$response = $this->object->get($this->view->request(), $this->view->response());
267
+		$result = json_decode((string) $response->getBody(), true);
268 268
 
269 269
 
270
-		$this->assertEquals( 200, $response->getStatusCode() );
271
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
270
+		$this->assertEquals(200, $response->getStatusCode());
271
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
272 272
 
273
-		$this->assertEquals( 2, $result['meta']['total'] );
274
-		$this->assertEquals( 2, count( $result['data'] ) );
275
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
276
-		$this->assertEquals( 0, count( $result['included'] ) );
273
+		$this->assertEquals(2, $result['meta']['total']);
274
+		$this->assertEquals(2, count($result['data']));
275
+		$this->assertEquals('product', $result['data'][0]['type']);
276
+		$this->assertEquals(0, count($result['included']));
277 277
 
278
-		$this->assertArrayNotHasKey( 'errors', $result );
278
+		$this->assertArrayNotHasKey('errors', $result);
279 279
 	}
280 280
 
281 281
 
@@ -287,25 +287,25 @@  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
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
294
-		$result = json_decode( (string) $response->getBody(), true );
293
+		$response = $this->object->get($this->view->request(), $this->view->response());
294
+		$result = json_decode((string) $response->getBody(), true);
295 295
 
296 296
 
297
-		$this->assertEquals( 200, $response->getStatusCode() );
298
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
297
+		$this->assertEquals(200, $response->getStatusCode());
298
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
299 299
 
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'] );
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 307
 
308
-		$this->assertArrayNotHasKey( 'errors', $result );
308
+		$this->assertArrayNotHasKey('errors', $result);
309 309
 	}
310 310
 
311 311
 
@@ -314,24 +314,24 @@  discard block
 block discarded – undo
314 314
 		$params = array(
315 315
 			'sort' => 'product.label,-product.code'
316 316
 		);
317
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
318
-		$this->view->addHelper( 'param', $helper );
317
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
318
+		$this->view->addHelper('param', $helper);
319 319
 
320
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
321
-		$result = json_decode( (string) $response->getBody(), true );
320
+		$response = $this->object->get($this->view->request(), $this->view->response());
321
+		$result = json_decode((string) $response->getBody(), true);
322 322
 
323 323
 
324
-		$this->assertEquals( 200, $response->getStatusCode() );
325
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
324
+		$this->assertEquals(200, $response->getStatusCode());
325
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
326 326
 
327
-		$this->assertEquals( 28, $result['meta']['total'] );
328
-		$this->assertEquals( 25, count( $result['data'] ) );
329
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
330
-		$this->assertEquals( 'QRST', $result['data'][0]['attributes']['product.code'] );
331
-		$this->assertEquals( '16 discs', $result['data'][0]['attributes']['product.label'] );
332
-		$this->assertEquals( 0, count( $result['included'] ) );
327
+		$this->assertEquals(28, $result['meta']['total']);
328
+		$this->assertEquals(25, count($result['data']));
329
+		$this->assertEquals('product', $result['data'][0]['type']);
330
+		$this->assertEquals('QRST', $result['data'][0]['attributes']['product.code']);
331
+		$this->assertEquals('16 discs', $result['data'][0]['attributes']['product.label']);
332
+		$this->assertEquals(0, count($result['included']));
333 333
 
334
-		$this->assertArrayNotHasKey( 'errors', $result );
334
+		$this->assertArrayNotHasKey('errors', $result);
335 335
 	}
336 336
 
337 337
 
@@ -344,262 +344,262 @@  discard block
 block discarded – undo
344 344
 			'sort' => 'product.id',
345 345
 			'include' => 'product'
346 346
 		);
347
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
348
-		$this->view->addHelper( 'param', $helper );
347
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
348
+		$this->view->addHelper('param', $helper);
349 349
 
350
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
351
-		$result = json_decode( (string) $response->getBody(), true );
350
+		$response = $this->object->get($this->view->request(), $this->view->response());
351
+		$result = json_decode((string) $response->getBody(), true);
352 352
 
353 353
 
354
-		$this->assertEquals( 200, $response->getStatusCode() );
355
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
354
+		$this->assertEquals(200, $response->getStatusCode());
355
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
356 356
 
357
-		$this->assertEquals( 28, $result['meta']['total'] );
358
-		$this->assertEquals( 25, count( $result['data'] ) );
359
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
360
-		$this->assertEquals( 2, count( $result['data'][0]['attributes'] ) );
357
+		$this->assertEquals(28, $result['meta']['total']);
358
+		$this->assertEquals(25, count($result['data']));
359
+		$this->assertEquals('product', $result['data'][0]['type']);
360
+		$this->assertEquals(2, count($result['data'][0]['attributes']));
361 361
 
362
-		$this->assertArrayNotHasKey( 'errors', $result );
362
+		$this->assertArrayNotHasKey('errors', $result);
363 363
 	}
364 364
 
365 365
 
366 366
 	public function testPatch()
367 367
 	{
368
-		$productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) );
368
+		$productManagerStub = $this->getProductMock(array('getItem', 'saveItem'));
369 369
 
370 370
 		$item = $productManagerStub->createItem();
371
-		$item->setLabel( 'test' );
372
-		$item->setId( '-1' );
371
+		$item->setLabel('test');
372
+		$item->setId('-1');
373 373
 
374
-		$productManagerStub->expects( $this->once() )->method( 'saveItem' )
375
-			->will( $this->returnValue( $productManagerStub->createItem() ) );
376
-		$productManagerStub->expects( $this->atLeastOnce() )->method( 'getItem' )
377
-			->will( $this->returnValue( $item ) );
374
+		$productManagerStub->expects($this->once())->method('saveItem')
375
+			->will($this->returnValue($productManagerStub->createItem()));
376
+		$productManagerStub->expects($this->atLeastOnce())->method('getItem')
377
+			->will($this->returnValue($item));
378 378
 
379 379
 
380
-		$params = array( 'id' => '-1' );
381
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
382
-		$this->view->addHelper( 'param', $helper );
380
+		$params = array('id' => '-1');
381
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
382
+		$this->view->addHelper('param', $helper);
383 383
 
384 384
 		$body = '{"data": {"type": "product", "attributes": {"product.label": "test"}}}';
385
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
385
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
386 386
 
387
-		$response = $this->object->patch( $request, $this->view->response() );
388
-		$result = json_decode( (string) $response->getBody(), true );
387
+		$response = $this->object->patch($request, $this->view->response());
388
+		$result = json_decode((string) $response->getBody(), true);
389 389
 
390 390
 
391
-		$this->assertEquals( 200, $response->getStatusCode() );
392
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
391
+		$this->assertEquals(200, $response->getStatusCode());
392
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
393 393
 
394
-		$this->assertEquals( 1, $result['meta']['total'] );
395
-		$this->assertArrayHasKey( 'data', $result );
396
-		$this->assertEquals( '-1', $result['data']['id'] );
397
-		$this->assertEquals( 'product', $result['data']['type'] );
398
-		$this->assertEquals( 'test', $result['data']['attributes']['product.label'] );
394
+		$this->assertEquals(1, $result['meta']['total']);
395
+		$this->assertArrayHasKey('data', $result);
396
+		$this->assertEquals('-1', $result['data']['id']);
397
+		$this->assertEquals('product', $result['data']['type']);
398
+		$this->assertEquals('test', $result['data']['attributes']['product.label']);
399 399
 
400
-		$this->assertArrayNotHasKey( 'included', $result );
401
-		$this->assertArrayNotHasKey( 'errors', $result );
400
+		$this->assertArrayNotHasKey('included', $result);
401
+		$this->assertArrayNotHasKey('errors', $result);
402 402
 	}
403 403
 
404 404
 
405 405
 	public function testPatchBulk()
406 406
 	{
407
-		$productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) );
407
+		$productManagerStub = $this->getProductMock(array('getItem', 'saveItem'));
408 408
 
409 409
 		$item = $productManagerStub->createItem();
410
-		$item->setLabel( 'test' );
411
-		$item->setId( '-1' );
410
+		$item->setLabel('test');
411
+		$item->setId('-1');
412 412
 
413
-		$productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' )
414
-			->will( $this->returnValue( $productManagerStub->createItem() ) );
415
-		$productManagerStub->expects( $this->atLeastOnce() )->method( 'getItem' )
416
-			->will( $this->returnValue( $item ) );
413
+		$productManagerStub->expects($this->exactly(2))->method('saveItem')
414
+			->will($this->returnValue($productManagerStub->createItem()));
415
+		$productManagerStub->expects($this->atLeastOnce())->method('getItem')
416
+			->will($this->returnValue($item));
417 417
 
418 418
 
419 419
 		$body = '{"data": [{"id": "-1", "type": "product", "attributes": {"product.label": "test"}}, {"id": "-1", "type": "product", "attributes": {"product.label": "test"}}]}';
420
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
420
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
421 421
 
422
-		$response = $this->object->patch( $request, $this->view->response() );
423
-		$result = json_decode( (string) $response->getBody(), true );
422
+		$response = $this->object->patch($request, $this->view->response());
423
+		$result = json_decode((string) $response->getBody(), true);
424 424
 
425 425
 
426
-		$this->assertEquals( 200, $response->getStatusCode() );
427
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
426
+		$this->assertEquals(200, $response->getStatusCode());
427
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
428 428
 
429
-		$this->assertEquals( 2, $result['meta']['total'] );
430
-		$this->assertArrayHasKey( 'data', $result );
431
-		$this->assertEquals( 2, count( $result['data'] ) );
432
-		$this->assertEquals( '-1', $result['data'][0]['id'] );
433
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
434
-		$this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] );
429
+		$this->assertEquals(2, $result['meta']['total']);
430
+		$this->assertArrayHasKey('data', $result);
431
+		$this->assertEquals(2, count($result['data']));
432
+		$this->assertEquals('-1', $result['data'][0]['id']);
433
+		$this->assertEquals('product', $result['data'][0]['type']);
434
+		$this->assertEquals('test', $result['data'][0]['attributes']['product.label']);
435 435
 
436
-		$this->assertArrayNotHasKey( 'included', $result );
437
-		$this->assertArrayNotHasKey( 'errors', $result );
436
+		$this->assertArrayNotHasKey('included', $result);
437
+		$this->assertArrayNotHasKey('errors', $result);
438 438
 	}
439 439
 
440 440
 
441 441
 	public function testPatchInvalid()
442 442
 	{
443 443
 		$body = '{"data":null}';
444
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
444
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
445 445
 
446
-		$response = $this->object->patch( $request, $this->view->response() );
447
-		$result = json_decode( (string) $response->getBody(), true );
446
+		$response = $this->object->patch($request, $this->view->response());
447
+		$result = json_decode((string) $response->getBody(), true);
448 448
 
449 449
 
450
-		$this->assertEquals( 400, $response->getStatusCode() );
451
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
450
+		$this->assertEquals(400, $response->getStatusCode());
451
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
452 452
 
453
-		$this->assertEquals( 0, $result['meta']['total'] );
454
-		$this->assertArrayHasKey( 'errors', $result );
455
-		$this->assertArrayNotHasKey( 'included', $result );
456
-		$this->assertArrayNotHasKey( 'data', $result );
453
+		$this->assertEquals(0, $result['meta']['total']);
454
+		$this->assertArrayHasKey('errors', $result);
455
+		$this->assertArrayNotHasKey('included', $result);
456
+		$this->assertArrayNotHasKey('data', $result);
457 457
 	}
458 458
 
459 459
 
460 460
 	public function testPatchInvalidId()
461 461
 	{
462 462
 		$body = '{"data":{"id":-1}}';
463
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
463
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
464 464
 
465
-		$response = $this->object->patch( $request, $this->view->response() );
466
-		$result = json_decode( (string) $response->getBody(), true );
465
+		$response = $this->object->patch($request, $this->view->response());
466
+		$result = json_decode((string) $response->getBody(), true);
467 467
 
468 468
 
469
-		$this->assertEquals( 400, $response->getStatusCode() );
470
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
469
+		$this->assertEquals(400, $response->getStatusCode());
470
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
471 471
 
472
-		$this->assertEquals( 0, $result['meta']['total'] );
473
-		$this->assertArrayHasKey( 'errors', $result );
472
+		$this->assertEquals(0, $result['meta']['total']);
473
+		$this->assertArrayHasKey('errors', $result);
474 474
 	}
475 475
 
476 476
 
477 477
 	public function testPatchException()
478 478
 	{
479
-		$this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' )
480
-			->will( $this->throwException( new \RuntimeException( 'test exception' ) ) );
479
+		$this->getProductMock(array('getItem'))->expects($this->once())->method('getItem')
480
+			->will($this->throwException(new \RuntimeException('test exception')));
481 481
 
482 482
 		$body = '{"data":[{"id":-1}]}';
483
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
483
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
484 484
 
485
-		$response = $this->object->patch( $request, $this->view->response() );
486
-		$result = json_decode( (string) $response->getBody(), true );
485
+		$response = $this->object->patch($request, $this->view->response());
486
+		$result = json_decode((string) $response->getBody(), true);
487 487
 
488 488
 
489
-		$this->assertEquals( 500, $response->getStatusCode() );
490
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
491
-		$this->assertArrayHasKey( 'errors', $result );
489
+		$this->assertEquals(500, $response->getStatusCode());
490
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
491
+		$this->assertArrayHasKey('errors', $result);
492 492
 	}
493 493
 
494 494
 
495 495
 	public function testPatchMShopException()
496 496
 	{
497
-		$this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' )
498
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
497
+		$this->getProductMock(array('getItem'))->expects($this->once())->method('getItem')
498
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
499 499
 
500 500
 		$body = '{"data":[{"id":-1}]}';
501
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
501
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
502 502
 
503
-		$response = $this->object->patch( $request, $this->view->response() );
504
-		$result = json_decode( (string) $response->getBody(), true );
503
+		$response = $this->object->patch($request, $this->view->response());
504
+		$result = json_decode((string) $response->getBody(), true);
505 505
 
506 506
 
507
-		$this->assertEquals( 404, $response->getStatusCode() );
508
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
509
-		$this->assertArrayHasKey( 'errors', $result );
507
+		$this->assertEquals(404, $response->getStatusCode());
508
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
509
+		$this->assertArrayHasKey('errors', $result);
510 510
 	}
511 511
 
512 512
 
513 513
 	public function testPost()
514 514
 	{
515
-		$productManagerStub = $this->getProductMock( array( 'createItem', 'getItem', 'saveItem' ) );
515
+		$productManagerStub = $this->getProductMock(array('createItem', 'getItem', 'saveItem'));
516 516
 
517 517
 		$item = new \Aimeos\MShop\Product\Item\Standard();
518
-		$item->setId( '-1' );
518
+		$item->setId('-1');
519 519
 
520
-		$productManagerStub->expects( $this->exactly( 2 ) )->method( 'createItem' )
521
-			->will( $this->returnValue( $item ) );
522
-		$productManagerStub->expects( $this->any() )->method( 'getItem' )
523
-			->will( $this->returnValue( $item ) );
524
-		$productManagerStub->expects( $this->once() )->method( 'saveItem' )
525
-			->will( $this->returnValue( $productManagerStub->createItem() ) );
520
+		$productManagerStub->expects($this->exactly(2))->method('createItem')
521
+			->will($this->returnValue($item));
522
+		$productManagerStub->expects($this->any())->method('getItem')
523
+			->will($this->returnValue($item));
524
+		$productManagerStub->expects($this->once())->method('saveItem')
525
+			->will($this->returnValue($productManagerStub->createItem()));
526 526
 
527 527
 
528 528
 		$body = '{"data": {"type": "product", "attributes": {"product.type": "default", "product.label": "test"}}}';
529
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
529
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
530 530
 
531
-		$response = $this->object->post( $request, $this->view->response() );
532
-		$result = json_decode( (string) $response->getBody(), true );
531
+		$response = $this->object->post($request, $this->view->response());
532
+		$result = json_decode((string) $response->getBody(), true);
533 533
 
534
-		$this->assertEquals( 201, $response->getStatusCode() );
535
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
534
+		$this->assertEquals(201, $response->getStatusCode());
535
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
536 536
 
537
-		$this->assertEquals( 1, $result['meta']['total'] );
538
-		$this->assertArrayHasKey( 'data', $result );
539
-		$this->assertEquals( '-1', $result['data']['id'] );
540
-		$this->assertEquals( 'product', $result['data']['type'] );
541
-		$this->assertGreaterThan( 0, $result['data']['attributes']['product.typeid'] );
542
-		$this->assertEquals( 'test', $result['data']['attributes']['product.label'] );
537
+		$this->assertEquals(1, $result['meta']['total']);
538
+		$this->assertArrayHasKey('data', $result);
539
+		$this->assertEquals('-1', $result['data']['id']);
540
+		$this->assertEquals('product', $result['data']['type']);
541
+		$this->assertGreaterThan(0, $result['data']['attributes']['product.typeid']);
542
+		$this->assertEquals('test', $result['data']['attributes']['product.label']);
543 543
 
544
-		$this->assertArrayNotHasKey( 'included', $result );
545
-		$this->assertArrayNotHasKey( 'errors', $result );
544
+		$this->assertArrayNotHasKey('included', $result);
545
+		$this->assertArrayNotHasKey('errors', $result);
546 546
 	}
547 547
 
548 548
 
549 549
 	public function testPostBulk()
550 550
 	{
551
-		$productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) );
551
+		$productManagerStub = $this->getProductMock(array('getItem', 'saveItem'));
552 552
 
553 553
 		$item = $productManagerStub->createItem();
554
-		$item->setLabel( 'test' );
555
-		$item->setId( '-1' );
554
+		$item->setLabel('test');
555
+		$item->setId('-1');
556 556
 
557
-		$productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' )
558
-			->will( $this->returnValue( $productManagerStub->createItem() ) );
559
-		$productManagerStub->expects( $this->exactly( 2 ) )->method( 'getItem' )
560
-			->will( $this->returnValue( $item ) );
557
+		$productManagerStub->expects($this->exactly(2))->method('saveItem')
558
+			->will($this->returnValue($productManagerStub->createItem()));
559
+		$productManagerStub->expects($this->exactly(2))->method('getItem')
560
+			->will($this->returnValue($item));
561 561
 
562 562
 
563 563
 		$body = '{"data": [{"type": "product", "attributes": {"product.label": "test"}}, {"type": "product", "attributes": {"product.label": "test"}}]}';
564
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
564
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
565 565
 
566
-		$response = $this->object->post( $request, $this->view->response() );
567
-		$result = json_decode( (string) $response->getBody(), true );
566
+		$response = $this->object->post($request, $this->view->response());
567
+		$result = json_decode((string) $response->getBody(), true);
568 568
 
569 569
 
570
-		$this->assertEquals( 201, $response->getStatusCode() );
571
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
570
+		$this->assertEquals(201, $response->getStatusCode());
571
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
572 572
 
573
-		$this->assertEquals( 2, $result['meta']['total'] );
574
-		$this->assertArrayHasKey( 'data', $result );
575
-		$this->assertEquals( 2, count( $result['data'] ) );
576
-		$this->assertEquals( '-1', $result['data'][0]['id'] );
577
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
578
-		$this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] );
573
+		$this->assertEquals(2, $result['meta']['total']);
574
+		$this->assertArrayHasKey('data', $result);
575
+		$this->assertEquals(2, count($result['data']));
576
+		$this->assertEquals('-1', $result['data'][0]['id']);
577
+		$this->assertEquals('product', $result['data'][0]['type']);
578
+		$this->assertEquals('test', $result['data'][0]['attributes']['product.label']);
579 579
 
580
-		$this->assertArrayNotHasKey( 'included', $result );
581
-		$this->assertArrayNotHasKey( 'errors', $result );
580
+		$this->assertArrayNotHasKey('included', $result);
581
+		$this->assertArrayNotHasKey('errors', $result);
582 582
 	}
583 583
 
584 584
 
585 585
 	public function testPostRelationships()
586 586
 	{
587
-		$productManagerStub = $this->getProductMock( array( 'getSubManager', 'createItem', 'getItem', 'saveItem' ) );
588
-		$productManagerListsStub = $this->getProductListsMock( array( 'saveItem' ) );
587
+		$productManagerStub = $this->getProductMock(array('getSubManager', 'createItem', 'getItem', 'saveItem'));
588
+		$productManagerListsStub = $this->getProductListsMock(array('saveItem'));
589 589
 
590 590
 		$item = new \Aimeos\MShop\Product\Item\Standard();
591
-		$item->setId( '-1' );
591
+		$item->setId('-1');
592 592
 
593
-		$productManagerStub->expects( $this->exactly( 2 ) )->method( 'createItem' )
594
-			->will( $this->returnValue( $item ) );
595
-		$productManagerStub->expects( $this->any() )->method( 'getItem' )
596
-			->will( $this->returnValue( $item ) );
597
-		$productManagerStub->expects( $this->once() )->method( 'getSubManager' )
598
-			->will( $this->returnValue( $productManagerListsStub ) );
599
-		$productManagerStub->expects( $this->once() )->method( 'saveItem' )
600
-			->will( $this->returnValue( $productManagerStub->createItem() ) );
593
+		$productManagerStub->expects($this->exactly(2))->method('createItem')
594
+			->will($this->returnValue($item));
595
+		$productManagerStub->expects($this->any())->method('getItem')
596
+			->will($this->returnValue($item));
597
+		$productManagerStub->expects($this->once())->method('getSubManager')
598
+			->will($this->returnValue($productManagerListsStub));
599
+		$productManagerStub->expects($this->once())->method('saveItem')
600
+			->will($this->returnValue($productManagerStub->createItem()));
601 601
 
602
-		$productManagerListsStub->expects( $this->once() )->method( 'saveItem' );
602
+		$productManagerListsStub->expects($this->once())->method('saveItem');
603 603
 
604 604
 		$body = '{"data": {"type": "product",
605 605
 			"attributes": {"product.label": "test"},
@@ -607,212 +607,212 @@  discard block
 block discarded – undo
607 607
 				{"type": "text", "id": "-2", "attributes": {"product.lists.type": "default"}}
608 608
 			]}}
609 609
 		}}';
610
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
610
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
611 611
 
612
-		$response = $this->object->post( $request, $this->view->response() );
613
-		$result = json_decode( (string) $response->getBody(), true );
612
+		$response = $this->object->post($request, $this->view->response());
613
+		$result = json_decode((string) $response->getBody(), true);
614 614
 
615 615
 
616
-		$this->assertEquals( 201, $response->getStatusCode() );
617
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
616
+		$this->assertEquals(201, $response->getStatusCode());
617
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
618 618
 
619
-		$this->assertEquals( 1, $result['meta']['total'] );
620
-		$this->assertArrayHasKey( 'data', $result );
621
-		$this->assertEquals( '-1', $result['data']['id'] );
622
-		$this->assertEquals( 'product', $result['data']['type'] );
623
-		$this->assertEquals( 'test', $result['data']['attributes']['product.label'] );
619
+		$this->assertEquals(1, $result['meta']['total']);
620
+		$this->assertArrayHasKey('data', $result);
621
+		$this->assertEquals('-1', $result['data']['id']);
622
+		$this->assertEquals('product', $result['data']['type']);
623
+		$this->assertEquals('test', $result['data']['attributes']['product.label']);
624 624
 
625
-		$this->assertArrayNotHasKey( 'included', $result );
626
-		$this->assertArrayNotHasKey( 'errors', $result );
625
+		$this->assertArrayNotHasKey('included', $result);
626
+		$this->assertArrayNotHasKey('errors', $result);
627 627
 	}
628 628
 
629 629
 
630 630
 	public function testPostInvalid()
631 631
 	{
632 632
 		$body = '{"data":null}';
633
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
633
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
634 634
 
635
-		$response = $this->object->post( $request, $this->view->response() );
636
-		$result = json_decode( (string) $response->getBody(), true );
635
+		$response = $this->object->post($request, $this->view->response());
636
+		$result = json_decode((string) $response->getBody(), true);
637 637
 
638 638
 
639
-		$this->assertEquals( 400, $response->getStatusCode() );
640
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
639
+		$this->assertEquals(400, $response->getStatusCode());
640
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
641 641
 
642
-		$this->assertEquals( 0, $result['meta']['total'] );
643
-		$this->assertArrayHasKey( 'errors', $result );
644
-		$this->assertArrayNotHasKey( 'included', $result );
645
-		$this->assertArrayNotHasKey( 'data', $result );
642
+		$this->assertEquals(0, $result['meta']['total']);
643
+		$this->assertArrayHasKey('errors', $result);
644
+		$this->assertArrayNotHasKey('included', $result);
645
+		$this->assertArrayNotHasKey('data', $result);
646 646
 	}
647 647
 
648 648
 
649 649
 	public function testPostInvalidId()
650 650
 	{
651 651
 		$body = '{"data":{"id":-1}}';
652
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
652
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
653 653
 
654
-		$response = $this->object->post( $request, $this->view->response() );
655
-		$result = json_decode( (string) $response->getBody(), true );
654
+		$response = $this->object->post($request, $this->view->response());
655
+		$result = json_decode((string) $response->getBody(), true);
656 656
 
657 657
 
658
-		$this->assertEquals( 403, $response->getStatusCode() );
659
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
658
+		$this->assertEquals(403, $response->getStatusCode());
659
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
660 660
 
661
-		$this->assertEquals( 0, $result['meta']['total'] );
662
-		$this->assertArrayHasKey( 'errors', $result );
661
+		$this->assertEquals(0, $result['meta']['total']);
662
+		$this->assertArrayHasKey('errors', $result);
663 663
 	}
664 664
 
665 665
 
666 666
 	public function testPostException()
667 667
 	{
668
-		$this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' )
669
-			->will( $this->throwException( new \RuntimeException( 'test exception' ) ) );
668
+		$this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem')
669
+			->will($this->throwException(new \RuntimeException('test exception')));
670 670
 
671 671
 		$body = '{"data":{}}';
672
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
672
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
673 673
 
674
-		$response = $this->object->post( $request, $this->view->response() );
675
-		$result = json_decode( (string) $response->getBody(), true );
674
+		$response = $this->object->post($request, $this->view->response());
675
+		$result = json_decode((string) $response->getBody(), true);
676 676
 
677 677
 
678
-		$this->assertEquals( 500, $response->getStatusCode() );
679
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
680
-		$this->assertArrayHasKey( 'errors', $result );
678
+		$this->assertEquals(500, $response->getStatusCode());
679
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
680
+		$this->assertArrayHasKey('errors', $result);
681 681
 	}
682 682
 
683 683
 
684 684
 	public function testPostMShopException()
685 685
 	{
686
-		$this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' )
687
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
686
+		$this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem')
687
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
688 688
 
689 689
 		$body = '{"data":{}}';
690
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
690
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
691 691
 
692
-		$response = $this->object->post( $request, $this->view->response() );
693
-		$result = json_decode( (string) $response->getBody(), true );
692
+		$response = $this->object->post($request, $this->view->response());
693
+		$result = json_decode((string) $response->getBody(), true);
694 694
 
695 695
 
696
-		$this->assertEquals( 404, $response->getStatusCode() );
697
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
698
-		$this->assertArrayHasKey( 'errors', $result );
696
+		$this->assertEquals(404, $response->getStatusCode());
697
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
698
+		$this->assertArrayHasKey('errors', $result);
699 699
 	}
700 700
 
701 701
 
702 702
 	public function testPut()
703 703
 	{
704
-		$response = $this->object->put( $this->view->request(), $this->view->response() );
705
-		$result = json_decode( (string) $response->getBody(), true );
704
+		$response = $this->object->put($this->view->request(), $this->view->response());
705
+		$result = json_decode((string) $response->getBody(), true);
706 706
 
707
-		$this->assertEquals( 501, $response->getStatusCode() );
708
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
709
-		$this->assertArrayHasKey( 'errors', $result );
707
+		$this->assertEquals(501, $response->getStatusCode());
708
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
709
+		$this->assertArrayHasKey('errors', $result);
710 710
 	}
711 711
 
712 712
 
713 713
 	public function testOptions()
714 714
 	{
715
-		$response = $this->object->options( $this->view->request(), $this->view->response() );
716
-		$result = json_decode( (string) $response->getBody(), true );
715
+		$response = $this->object->options($this->view->request(), $this->view->response());
716
+		$result = json_decode((string) $response->getBody(), true);
717 717
 
718 718
 
719
-		$this->assertEquals( 200, $response->getStatusCode() );
720
-		$this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) );
721
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
719
+		$this->assertEquals(200, $response->getStatusCode());
720
+		$this->assertEquals(1, count($response->getHeader('Allow')));
721
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
722 722
 
723
-		$this->assertNull( $result['meta']['prefix'] );
724
-		$this->assertGreaterThan( 59, count( $result['meta']['resources'] ) );
725
-		$this->assertGreaterThan( 0, count( $result['meta']['attributes'] ) );
723
+		$this->assertNull($result['meta']['prefix']);
724
+		$this->assertGreaterThan(59, count($result['meta']['resources']));
725
+		$this->assertGreaterThan(0, count($result['meta']['attributes']));
726 726
 
727
-		$this->assertArrayNotHasKey( 'errors', $result );
727
+		$this->assertArrayNotHasKey('errors', $result);
728 728
 	}
729 729
 
730 730
 
731 731
 	public function testOptionsWithPrefix()
732 732
 	{
733
-		$response = $this->object->options( $this->view->request(), $this->view->response(), 'prefix' );
734
-		$result = json_decode( (string) $response->getBody(), true );
733
+		$response = $this->object->options($this->view->request(), $this->view->response(), 'prefix');
734
+		$result = json_decode((string) $response->getBody(), true);
735 735
 
736 736
 
737
-		$this->assertEquals( 200, $response->getStatusCode() );
738
-		$this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) );
739
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
737
+		$this->assertEquals(200, $response->getStatusCode());
738
+		$this->assertEquals(1, count($response->getHeader('Allow')));
739
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
740 740
 
741
-		$this->assertEquals( 'prefix', $result['meta']['prefix'] );
742
-		$this->assertGreaterThan( 59, count( $result['meta']['resources'] ) );
743
-		$this->assertGreaterThan( 0, count( $result['meta']['attributes'] ) );
741
+		$this->assertEquals('prefix', $result['meta']['prefix']);
742
+		$this->assertGreaterThan(59, count($result['meta']['resources']));
743
+		$this->assertGreaterThan(0, count($result['meta']['attributes']));
744 744
 
745
-		$this->assertArrayNotHasKey( 'errors', $result );
745
+		$this->assertArrayNotHasKey('errors', $result);
746 746
 	}
747 747
 
748 748
 
749 749
 	public function testOptionsException()
750 750
 	{
751
-		$this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' )
752
-			->will( $this->throwException( new \RuntimeException( 'test exception' ) ) );
751
+		$this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType')
752
+			->will($this->throwException(new \RuntimeException('test exception')));
753 753
 
754
-		$response = $this->object->options( $this->view->request(), $this->view->response() );
755
-		$result = json_decode( (string) $response->getBody(), true );
754
+		$response = $this->object->options($this->view->request(), $this->view->response());
755
+		$result = json_decode((string) $response->getBody(), true);
756 756
 
757
-		$this->assertEquals( 500, $response->getStatusCode() );
758
-		$this->assertArrayHasKey( 'errors', $result );
757
+		$this->assertEquals(500, $response->getStatusCode());
758
+		$this->assertArrayHasKey('errors', $result);
759 759
 	}
760 760
 
761 761
 
762 762
 	public function testOptionsMShopException()
763 763
 	{
764
-		$this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' )
765
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
764
+		$this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType')
765
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
766 766
 
767
-		$response = $this->object->options( $this->view->request(), $this->view->response() );
768
-		$result = json_decode( (string) $response->getBody(), true );
767
+		$response = $this->object->options($this->view->request(), $this->view->response());
768
+		$result = json_decode((string) $response->getBody(), true);
769 769
 
770
-		$this->assertEquals( 404, $response->getStatusCode() );
771
-		$this->assertArrayHasKey( 'errors', $result );
770
+		$this->assertEquals(404, $response->getStatusCode());
771
+		$this->assertArrayHasKey('errors', $result);
772 772
 	}
773 773
 
774 774
 
775
-	protected function getProductMock( array $methods )
775
+	protected function getProductMock(array $methods)
776 776
 	{
777 777
 		$name = 'ClientJsonAdmStandard';
778
-		$this->context->getConfig()->set( 'mshop/product/manager/name', $name );
778
+		$this->context->getConfig()->set('mshop/product/manager/name', $name);
779 779
 
780
-		$stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Standard' )
781
-			->setConstructorArgs( array( $this->context ) )
782
-			->setMethods( $methods )
780
+		$stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Standard')
781
+			->setConstructorArgs(array($this->context))
782
+			->setMethods($methods)
783 783
 			->getMock();
784 784
 
785
-		\Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub );
785
+		\Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub);
786 786
 
787 787
 		return $stub;
788 788
 	}
789 789
 
790 790
 
791
-	protected function getProductListsMock( array $methods )
791
+	protected function getProductListsMock(array $methods)
792 792
 	{
793 793
 		$name = 'ClientJsonAdmStandard';
794
-		$this->context->getConfig()->set( 'mshop/product/manager/lists/name', $name );
794
+		$this->context->getConfig()->set('mshop/product/manager/lists/name', $name);
795 795
 
796
-		$stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard' )
797
-			->setConstructorArgs( array( $this->context ) )
798
-			->setMethods( $methods )
796
+		$stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard')
797
+			->setConstructorArgs(array($this->context))
798
+			->setMethods($methods)
799 799
 			->getMock();
800 800
 
801
-		\Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub );
801
+		\Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub);
802 802
 
803 803
 		return $stub;
804 804
 	}
805 805
 
806 806
 
807
-	protected function getProductItem( $code = 'CNC' )
807
+	protected function getProductItem($code = 'CNC')
808 808
 	{
809
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
809
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
810 810
 		$search = $manager->createSearch();
811
-		$search->setConditions( $search->compare( '==', 'product.code', $code ) );
812
-		$items = $manager->searchItems( $search );
811
+		$search->setConditions($search->compare('==', 'product.code', $code));
812
+		$items = $manager->searchItems($search);
813 813
 
814
-		if( ( $item = reset( $items ) ) === false ) {
815
-			throw new \RuntimeException( sprintf( 'No product item with code "%1$s" found', $code ) );
814
+		if (($item = reset($items)) === false) {
815
+			throw new \RuntimeException(sprintf('No product item with code "%1$s" found', $code));
816 816
 		}
817 817
 
818 818
 		return $item;
Please login to merge, or discard this patch.