Completed
Push — master ( 74f0c0...5d0abf )
by Aimeos
02:39
created
admin/jsonadm/src/Admin/JsonAdm/Coupon/Config/Standard.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -110,30 +110,30 @@  discard block
 block discarded – undo
110 110
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
111 111
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
112 112
 	 */
113
-	public function get( ServerRequestInterface $request, ResponseInterface $response )
113
+	public function get(ServerRequestInterface $request, ResponseInterface $response)
114 114
 	{
115 115
 		$view = $this->getView();
116 116
 
117 117
 		try
118 118
 		{
119
-			$response = $this->getItems( $view, $request, $response );
119
+			$response = $this->getItems($view, $request, $response);
120 120
 			$status = 200;
121 121
 		}
122
-		catch( \Aimeos\MShop\Exception $e )
122
+		catch (\Aimeos\MShop\Exception $e)
123 123
 		{
124 124
 			$status = 404;
125
-			$view->errors = array( array(
126
-				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
125
+			$view->errors = array(array(
126
+				'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()),
127 127
 				'detail' => $e->getTraceAsString(),
128
-			) );
128
+			));
129 129
 		}
130
-		catch( \Exception $e )
130
+		catch (\Exception $e)
131 131
 		{
132 132
 			$status = 500;
133
-			$view->errors = array( array(
133
+			$view->errors = array(array(
134 134
 				'title' => $e->getMessage(),
135 135
 				'detail' => $e->getTraceAsString(),
136
-			) );
136
+			));
137 137
 		}
138 138
 
139 139
 		/** admin/jsonadm/coupon/config/template-get
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
 		$tplconf = 'admin/jsonadm/coupon/config/template-get';
159 159
 		$default = 'config-standard';
160 160
 
161
-		$body = $view->render( $view->config( $tplconf, $default ) );
161
+		$body = $view->render($view->config($tplconf, $default));
162 162
 
163
-		return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' )
164
-			->withBody( $view->response()->createStreamFromString( $body ) )
165
-			->withStatus( $status );
163
+		return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"')
164
+			->withBody($view->response()->createStreamFromString($body))
165
+			->withStatus($status);
166 166
 	}
167 167
 
168 168
 
@@ -174,18 +174,18 @@  discard block
 block discarded – undo
174 174
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
175 175
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
176 176
 	 */
177
-	protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
177
+	protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
178 178
 	{
179
-		if( ( $id = $view->param( 'id' ) ) == null ) {
180
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 );
179
+		if (($id = $view->param('id')) == null) {
180
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400);
181 181
 		}
182 182
 
183
-		$manager = \Aimeos\MShop::create( $this->getContext(), 'coupon' );
183
+		$manager = \Aimeos\MShop::create($this->getContext(), 'coupon');
184 184
 
185 185
 		$item = $manager->createItem();
186
-		$item->setProvider( $id );
186
+		$item->setProvider($id);
187 187
 
188
-		$view->configItems = $manager->getProvider( $item, null )->getConfigBE();
188
+		$view->configItems = $manager->getProvider($item, null)->getConfigBE();
189 189
 
190 190
 		return $response;
191 191
 	}
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Coupon/Standard.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -107,20 +107,20 @@
 block discarded – undo
107 107
 	 * @param array $include List of resource types that should be fetched
108 108
 	 * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface
109 109
 	 */
110
-	protected function getChildItems( array $items, array $include )
110
+	protected function getChildItems(array $items, array $include)
111 111
 	{
112 112
 		$list = [];
113
-		$ids = array_keys( $items );
114
-		$include = array_intersect( $include, array( 'coupon/code' ) );
113
+		$ids = array_keys($items);
114
+		$include = array_intersect($include, array('coupon/code'));
115 115
 
116
-		foreach( $include as $type )
116
+		foreach ($include as $type)
117 117
 		{
118
-			$manager = \Aimeos\MShop::create( $this->getContext(), $type );
118
+			$manager = \Aimeos\MShop::create($this->getContext(), $type);
119 119
 
120 120
 			$search = $manager->createSearch();
121
-			$search->setConditions( $search->compare( '==', str_replace( '/', '.', $type ) . '.parentid', $ids ) );
121
+			$search->setConditions($search->compare('==', str_replace('/', '.', $type) . '.parentid', $ids));
122 122
 
123
-			$list = array_merge( $list, $manager->searchItems( $search ) );
123
+			$list = array_merge($list, $manager->searchItems($search));
124 124
 		}
125 125
 
126 126
 		return $list;
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/Common/Factory/BaseTest.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -21,29 +21,29 @@  discard block
 block discarded – undo
21 21
 		$this->context = \TestHelperJadm::getContext();
22 22
 		$this->view = $this->context->getView();
23 23
 
24
-		$this->client = new \Aimeos\Admin\JsonAdm\Product\Standard( $this->context, $this->view, [], '' );
24
+		$this->client = new \Aimeos\Admin\JsonAdm\Product\Standard($this->context, $this->view, [], '');
25 25
 
26
-		$this->object = $this->getMockBuilder( \Aimeos\Admin\JsonAdm\Common\Factory\Base::class )
26
+		$this->object = $this->getMockBuilder(\Aimeos\Admin\JsonAdm\Common\Factory\Base::class)
27 27
 			->getMockForAbstractClass();
28 28
 	}
29 29
 
30 30
 
31 31
 	public function testinjectClient()
32 32
 	{
33
-		$this->object->injectClient( 'test', $this->client );
33
+		$this->object->injectClient('test', $this->client);
34 34
 	}
35 35
 
36 36
 
37 37
 	public function testAddClientDecorators()
38 38
 	{
39 39
 		$config = $this->context->getConfig();
40
-		$config->set( 'client/jsonapi/common/decorators/default', ['Test'] );
41
-		$config->set( 'client/jsonapi/product/decorators/excludes', ['Test'] );
40
+		$config->set('client/jsonapi/common/decorators/default', ['Test']);
41
+		$config->set('client/jsonapi/product/decorators/excludes', ['Test']);
42 42
 
43 43
 		$params = [$this->client, $this->context, $this->view, [], 'product'];
44
-		$result = $this->access( 'addClientDecorators' )->invokeArgs( $this->object, $params );
44
+		$result = $this->access('addClientDecorators')->invokeArgs($this->object, $params);
45 45
 
46
-		$this->assertInstanceOf( '\Aimeos\\Admin\\JsonAdm\\Iface', $result );
46
+		$this->assertInstanceOf('\Aimeos\\Admin\\JsonAdm\\Iface', $result);
47 47
 	}
48 48
 
49 49
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 		$prefix = '\Aimeos\\Admin\\JsonAdm\\Common\\Decorator\\';
53 53
 		$params = [$this->client, ['Example'], $prefix, $this->context, $this->view, [], ''];
54 54
 
55
-		$result = $this->access( 'addDecorators' )->invokeArgs( $this->object, $params );
55
+		$result = $this->access('addDecorators')->invokeArgs($this->object, $params);
56 56
 
57
-		$this->assertInstanceOf( '\Aimeos\\Admin\\JsonAdm\\Iface', $result );
57
+		$this->assertInstanceOf('\Aimeos\\Admin\\JsonAdm\\Iface', $result);
58 58
 	}
59 59
 
60 60
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 		$prefix = '\Aimeos\\Admin\\JsonAdm\\Common\\Decorator\\';
64 64
 		$params = [$this->client, ['Test'], $prefix, $this->context, $this->view, [], ''];
65 65
 
66
-		$this->setExpectedException( \Aimeos\Admin\JsonAdm\Exception::class );
67
-		$this->access( 'addDecorators' )->invokeArgs( $this->object, $params );
66
+		$this->setExpectedException(\Aimeos\Admin\JsonAdm\Exception::class);
67
+		$this->access('addDecorators')->invokeArgs($this->object, $params);
68 68
 	}
69 69
 
70 70
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 		$prefix = '\Aimeos\\Admin\\JsonAdm\\Common\\Decorator\\';
74 74
 		$params = [$this->client, [''], $prefix, $this->context, $this->view, [], ''];
75 75
 
76
-		$this->setExpectedException( \Aimeos\Admin\JsonAdm\Exception::class );
77
-		$this->access( 'addDecorators' )->invokeArgs( $this->object, $params );
76
+		$this->setExpectedException(\Aimeos\Admin\JsonAdm\Exception::class);
77
+		$this->access('addDecorators')->invokeArgs($this->object, $params);
78 78
 	}
79 79
 
80 80
 
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 		$class = '\Aimeos\\Admin\\JsonAdm\\Product\\Standard';
85 85
 		$params = [$class, $iface, $this->context, $this->view, [], ''];
86 86
 
87
-		$result = $this->access( 'createAdmin' )->invokeArgs( $this->object, $params );
87
+		$result = $this->access('createAdmin')->invokeArgs($this->object, $params);
88 88
 
89
-		$this->assertInstanceOf( '\Aimeos\\Admin\\JsonAdm\\Iface', $result );
89
+		$this->assertInstanceOf('\Aimeos\\Admin\\JsonAdm\\Iface', $result);
90 90
 	}
91 91
 
92 92
 
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
 		$iface = '\Aimeos\\Admin\\JsonAdm\\Iface';
96 96
 		$params = ['test', $iface, $this->context, $this->view, [], ''];
97 97
 
98
-		$this->object->injectClient( 'test', $this->client );
99
-		$result = $this->access( 'createAdmin' )->invokeArgs( $this->object, $params );
98
+		$this->object->injectClient('test', $this->client);
99
+		$result = $this->access('createAdmin')->invokeArgs($this->object, $params);
100 100
 
101
-		$this->assertSame( $this->client, $result );
101
+		$this->assertSame($this->client, $result);
102 102
 	}
103 103
 
104 104
 
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 		$iface = '\Aimeos\\Admin\\JsonAdm\\Iface';
108 108
 		$params = ['invalid', $iface, $this->context, $this->view, [], ''];
109 109
 
110
-		$this->setExpectedException( \Aimeos\Admin\JsonAdm\Exception::class );
111
-		$this->access( 'createAdmin' )->invokeArgs( $this->object, $params );
110
+		$this->setExpectedException(\Aimeos\Admin\JsonAdm\Exception::class);
111
+		$this->access('createAdmin')->invokeArgs($this->object, $params);
112 112
 	}
113 113
 
114 114
 
@@ -118,16 +118,16 @@  discard block
 block discarded – undo
118 118
 		$class = '\Aimeos\\Admin\\JsonAdm\\Product\\Standard';
119 119
 		$params = [$class, $iface, $this->context, $this->view, [], ''];
120 120
 
121
-		$this->setExpectedException( \Aimeos\MW\Common\Exception::class );
122
-		$this->access( 'createAdmin' )->invokeArgs( $this->object, $params );
121
+		$this->setExpectedException(\Aimeos\MW\Common\Exception::class);
122
+		$this->access('createAdmin')->invokeArgs($this->object, $params);
123 123
 	}
124 124
 
125 125
 
126
-	protected function access( $name )
126
+	protected function access($name)
127 127
 	{
128
-		$class = new \ReflectionClass( \Aimeos\Admin\JsonAdm\Common\Factory\Base::class );
129
-		$method = $class->getMethod( $name );
130
-		$method->setAccessible( true );
128
+		$class = new \ReflectionClass(\Aimeos\Admin\JsonAdm\Common\Factory\Base::class);
129
+		$method = $class->getMethod($name);
130
+		$method->setAccessible(true);
131 131
 
132 132
 		return $method;
133 133
 	}
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Common/Factory/Iface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,5 +28,5 @@
 block discarded – undo
28 28
 	 * @param string|null $name Name of the client implementation ("Standard" if null)
29 29
 	 * @return \Aimeos\Admin\JsonAdm\Iface Client Interface
30 30
 	 */
31
-	public static function create( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $path, $name = null );
31
+	public static function create(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $path, $name = null);
32 32
 }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
admin/jsonadm/src/Admin/JsonAdm/Common/Factory/Base.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param string $classname Full name of the class for which the object should be returned
32 32
 	 * @param \Aimeos\Admin\JsonAdm\Iface|null $client JSON API client object
33 33
 	 */
34
-	public static function injectClient( $classname, \Aimeos\Admin\JsonAdm\Iface $client = null )
34
+	public static function injectClient($classname, \Aimeos\Admin\JsonAdm\Iface $client = null)
35 35
 	{
36 36
 		self::$objects[$classname] = $client;
37 37
 	}
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 	 * @param string $path Name of the client separated by slashes, e.g "product/property"
46 46
 	 * @return \Aimeos\Admin\JsonAdm\Common\Iface Client object
47 47
 	 */
48
-	protected static function addClientDecorators( \Aimeos\Admin\JsonAdm\Iface $client,
49
-		\Aimeos\MShop\Context\Item\Iface $context, $path )
48
+	protected static function addClientDecorators(\Aimeos\Admin\JsonAdm\Iface $client,
49
+		\Aimeos\MShop\Context\Item\Iface $context, $path)
50 50
 	{
51 51
 		$config = $context->getConfig();
52 52
 
@@ -72,38 +72,38 @@  discard block
 block discarded – undo
72 72
 		 * @since 2015.12
73 73
 		 * @category Developer
74 74
 		 */
75
-		$decorators = $config->get( 'admin/jsonadm/common/decorators/default', [] );
75
+		$decorators = $config->get('admin/jsonadm/common/decorators/default', []);
76 76
 
77
-		if( $path !== null && is_string( $path ) )
77
+		if ($path !== null && is_string($path))
78 78
 		{
79
-			$dpath = trim( $path, '/' );
80
-			$dpath = ( $dpath !== '' ? $dpath . '/' : $dpath );
79
+			$dpath = trim($path, '/');
80
+			$dpath = ($dpath !== '' ? $dpath . '/' : $dpath);
81 81
 
82
-			$excludes = $config->get( 'admin/jsonadm/' . $dpath . 'decorators/excludes', [] );
83
-			$localClass = str_replace( ' ', '\\', ucwords( str_replace( '/', ' ', $path ) ) );
82
+			$excludes = $config->get('admin/jsonadm/' . $dpath . 'decorators/excludes', []);
83
+			$localClass = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $path)));
84 84
 
85
-			foreach( $decorators as $key => $name )
85
+			foreach ($decorators as $key => $name)
86 86
 			{
87
-				if( in_array( $name, $excludes ) ) {
88
-					unset( $decorators[$key] );
87
+				if (in_array($name, $excludes)) {
88
+					unset($decorators[$key]);
89 89
 				}
90 90
 			}
91 91
 
92 92
 			$classprefix = '\\Aimeos\\Admin\\JsonAdm\\Common\\Decorator\\';
93
-			$decorators = $config->get( 'admin/jsonadm/' . $dpath . 'decorators/global', [] );
94
-			$client = self::addDecorators( $client, $decorators, $classprefix, $context, $path );
93
+			$decorators = $config->get('admin/jsonadm/' . $dpath . 'decorators/global', []);
94
+			$client = self::addDecorators($client, $decorators, $classprefix, $context, $path);
95 95
 
96
-			if( !empty( $path ) )
96
+			if (!empty($path))
97 97
 			{
98
-				$classprefix = '\\Aimeos\\Admin\\JsonAdm\\' . ucfirst( $localClass ) . '\\Decorator\\';
99
-				$decorators = $config->get( 'admin/jsonadm/' . $dpath . 'decorators/local', [] );
100
-				$client = self::addDecorators( $client, $decorators, $classprefix, $context, $path );
98
+				$classprefix = '\\Aimeos\\Admin\\JsonAdm\\' . ucfirst($localClass) . '\\Decorator\\';
99
+				$decorators = $config->get('admin/jsonadm/' . $dpath . 'decorators/local', []);
100
+				$client = self::addDecorators($client, $decorators, $classprefix, $context, $path);
101 101
 			}
102 102
 		}
103 103
 		else
104 104
 		{
105 105
 			$classprefix = '\\Aimeos\\Admin\\JsonAdm\\Common\\Decorator\\';
106
-			$client = self::addDecorators( $client, $decorators, $classprefix, $context, $path );
106
+			$client = self::addDecorators($client, $decorators, $classprefix, $context, $path);
107 107
 		}
108 108
 
109 109
 		return $client;
@@ -120,26 +120,26 @@  discard block
 block discarded – undo
120 120
 	 * @param string $path Name of the client separated by slashes, e.g "product/stock"
121 121
 	 * @return \Aimeos\Admin\JsonAdm\Common\Iface Client object
122 122
 	 */
123
-	protected static function addDecorators( \Aimeos\Admin\JsonAdm\Iface $client, array $decorators, $classprefix,
124
-			\Aimeos\MShop\Context\Item\Iface $context, $path )
123
+	protected static function addDecorators(\Aimeos\Admin\JsonAdm\Iface $client, array $decorators, $classprefix,
124
+			\Aimeos\MShop\Context\Item\Iface $context, $path)
125 125
 	{
126
-		foreach( $decorators as $name )
126
+		foreach ($decorators as $name)
127 127
 		{
128
-			if( ctype_alnum( $name ) === false )
128
+			if (ctype_alnum($name) === false)
129 129
 			{
130
-				$classname = is_string( $name ) ? $classprefix . $name : '<not a string>';
131
-				throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ), 404 );
130
+				$classname = is_string($name) ? $classprefix . $name : '<not a string>';
131
+				throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname), 404);
132 132
 			}
133 133
 
134 134
 			$classname = $classprefix . $name;
135 135
 
136
-			if( class_exists( $classname ) === false ) {
137
-				throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Class "%1$s" not found', $classname ), 404 );
136
+			if (class_exists($classname) === false) {
137
+				throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Class "%1$s" not found', $classname), 404);
138 138
 			}
139 139
 
140
-			$client = new $classname( $client, $context, $path );
140
+			$client = new $classname($client, $context, $path);
141 141
 
142
-			\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Admin\\JsonAdm\\Common\\Decorator\\Iface', $client );
142
+			\Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Admin\\JsonAdm\\Common\\Decorator\\Iface', $client);
143 143
 		}
144 144
 
145 145
 		return $client;
@@ -155,19 +155,19 @@  discard block
 block discarded – undo
155 155
 	 * @param string $path Name of the client separated by slashes, e.g "product/property"
156 156
 	 * @return \Aimeos\Admin\JsonAdm\Common\Iface Client object
157 157
 	 */
158
-	protected static function createAdmin( $classname, $interface, \Aimeos\MShop\Context\Item\Iface $context, $path )
158
+	protected static function createAdmin($classname, $interface, \Aimeos\MShop\Context\Item\Iface $context, $path)
159 159
 	{
160
-		if( isset( self::$objects[$classname] ) ) {
160
+		if (isset(self::$objects[$classname])) {
161 161
 			return self::$objects[$classname];
162 162
 		}
163 163
 
164
-		if( class_exists( $classname ) === false ) {
165
-			throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Class "%1$s" not found', $classname ), 404 );
164
+		if (class_exists($classname) === false) {
165
+			throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Class "%1$s" not found', $classname), 404);
166 166
 		}
167 167
 
168
-		$client = new $classname( $context, $path );
168
+		$client = new $classname($context, $path);
169 169
 
170
-		\Aimeos\MW\Common\Base::checkClass( $interface, $client );
170
+		\Aimeos\MW\Common\Base::checkClass($interface, $client);
171 171
 
172 172
 		return $client;
173 173
 	}
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/Product/StandardTest.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 		$this->context = \TestHelperJadm::getContext();
22 22
 		$this->view = $this->context->getView();
23 23
 
24
-		$this->object = new \Aimeos\Admin\JsonAdm\Product\Standard( $this->context, 'product' );
25
-		$this->object->setAimeos( \TestHelperJadm::getAimeos() );
26
-		$this->object->setView( $this->view );
24
+		$this->object = new \Aimeos\Admin\JsonAdm\Product\Standard($this->context, 'product');
25
+		$this->object->setAimeos(\TestHelperJadm::getAimeos());
26
+		$this->object->setView($this->view);
27 27
 	}
28 28
 
29 29
 
@@ -31,33 +31,33 @@  discard block
 block discarded – undo
31 31
 	{
32 32
 		$params = array(
33 33
 			'filter' => array(
34
-				'==' => array( 'product.code' => 'CNE' )
34
+				'==' => array('product.code' => 'CNE')
35 35
 			),
36 36
 			'include' => 'text,product,product/property'
37 37
 		);
38
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
39
-		$this->view->addHelper( 'param', $helper );
40
-
41
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
42
-		$result = json_decode( (string) $response->getBody(), true );
43
-
44
-		$this->assertEquals( 200, $response->getStatusCode() );
45
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
46
-
47
-		$this->assertEquals( 1, $result['meta']['total'] );
48
-		$this->assertEquals( 1, count( $result['data'] ) );
49
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
50
-		$this->assertEquals( 7, count( $result['data'][0]['relationships']['text'] ) );
51
-		$this->assertArrayHaskey( 'self', $result['data'][0]['relationships']['text'][0]['data']['links'] );
52
-		$this->assertEquals( 5, count( $result['data'][0]['relationships']['product'] ) );
53
-		$this->assertArrayHaskey( 'self', $result['data'][0]['relationships']['product'][0]['data']['links'] );
54
-		$this->assertEquals( 4, count( $result['data'][0]['relationships']['product/property'] ) );
55
-		$this->assertEquals( 15, count( $result['included'] ) );
56
-		$this->assertEquals( 'product/property', $result['included'][0]['type'] );
57
-		$this->assertArrayHaskey( 'self', $result['included'][0]['links'] );
58
-		$this->assertArrayHaskey( 'related', $result['included'][0]['links'] );
59
-
60
-		$this->assertArrayNotHasKey( 'errors', $result );
38
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
39
+		$this->view->addHelper('param', $helper);
40
+
41
+		$response = $this->object->get($this->view->request(), $this->view->response());
42
+		$result = json_decode((string) $response->getBody(), true);
43
+
44
+		$this->assertEquals(200, $response->getStatusCode());
45
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
46
+
47
+		$this->assertEquals(1, $result['meta']['total']);
48
+		$this->assertEquals(1, count($result['data']));
49
+		$this->assertEquals('product', $result['data'][0]['type']);
50
+		$this->assertEquals(7, count($result['data'][0]['relationships']['text']));
51
+		$this->assertArrayHaskey('self', $result['data'][0]['relationships']['text'][0]['data']['links']);
52
+		$this->assertEquals(5, count($result['data'][0]['relationships']['product']));
53
+		$this->assertArrayHaskey('self', $result['data'][0]['relationships']['product'][0]['data']['links']);
54
+		$this->assertEquals(4, count($result['data'][0]['relationships']['product/property']));
55
+		$this->assertEquals(15, count($result['included']));
56
+		$this->assertEquals('product/property', $result['included'][0]['type']);
57
+		$this->assertArrayHaskey('self', $result['included'][0]['links']);
58
+		$this->assertArrayHaskey('related', $result['included'][0]['links']);
59
+
60
+		$this->assertArrayNotHasKey('errors', $result);
61 61
 	}
62 62
 
63 63
 
@@ -70,22 +70,22 @@  discard block
 block discarded – undo
70 70
 			'sort' => 'product.label',
71 71
 			'include' => 'product,product/property'
72 72
 		);
73
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
74
-		$this->view->addHelper( 'param', $helper );
73
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
74
+		$this->view->addHelper('param', $helper);
75 75
 
76
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
77
-		$result = json_decode( (string) $response->getBody(), true );
76
+		$response = $this->object->get($this->view->request(), $this->view->response());
77
+		$result = json_decode((string) $response->getBody(), true);
78 78
 
79
-		$this->assertEquals( 200, $response->getStatusCode() );
80
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
79
+		$this->assertEquals(200, $response->getStatusCode());
80
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
81 81
 
82
-		$this->assertEquals( 28, $result['meta']['total'] );
83
-		$this->assertEquals( 25, count( $result['data'] ) );
84
-		$this->assertEquals( 'product', $result['data'][5]['type'] );
85
-		$this->assertEquals( 3, count( $result['data'][5]['attributes'] ) );
86
-		$this->assertEquals( 4, count( $result['data'][5]['relationships']['product/property'] ) );
87
-		$this->assertGreaterThanOrEqual( 20, count( $result['included'] ) );
82
+		$this->assertEquals(28, $result['meta']['total']);
83
+		$this->assertEquals(25, count($result['data']));
84
+		$this->assertEquals('product', $result['data'][5]['type']);
85
+		$this->assertEquals(3, count($result['data'][5]['attributes']));
86
+		$this->assertEquals(4, count($result['data'][5]['relationships']['product/property']));
87
+		$this->assertGreaterThanOrEqual(20, count($result['included']));
88 88
 
89
-		$this->assertArrayNotHasKey( 'errors', $result );
89
+		$this->assertArrayNotHasKey('errors', $result);
90 90
 	}
91 91
 }
92 92
\ No newline at end of file
Please login to merge, or discard this patch.
admin/jsonadm/tests/TestHelperJadm.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 	}
19 19
 
20 20
 
21
-	public static function getContext( $site = 'unittest' )
21
+	public static function getContext($site = 'unittest')
22 22
 	{
23
-		if( !isset( self::$context[$site] ) ) {
24
-			self::$context[$site] = self::createContext( $site );
23
+		if (!isset(self::$context[$site])) {
24
+			self::$context[$site] = self::createContext($site);
25 25
 		}
26 26
 
27 27
 		return clone self::$context[$site];
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 
31 31
 	public static function getAimeos()
32 32
 	{
33
-		if( !isset( self::$aimeos ) )
33
+		if (!isset(self::$aimeos))
34 34
 		{
35 35
 			require_once 'Bootstrap.php';
36
-			spl_autoload_register( 'Aimeos\\Bootstrap::autoload' );
36
+			spl_autoload_register('Aimeos\\Bootstrap::autoload');
37 37
 
38
-			$extdir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) );
39
-			self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), false );
38
+			$extdir = dirname(dirname(dirname(dirname(__FILE__))));
39
+			self::$aimeos = new \Aimeos\Bootstrap(array($extdir), false);
40 40
 		}
41 41
 
42 42
 		return self::$aimeos;
@@ -45,88 +45,88 @@  discard block
 block discarded – undo
45 45
 
46 46
 	public static function getJsonadmPaths()
47 47
 	{
48
-		return self::getAimeos()->getCustomPaths( 'admin/jsonadm/templates' );
48
+		return self::getAimeos()->getCustomPaths('admin/jsonadm/templates');
49 49
 	}
50 50
 
51 51
 
52
-	private static function createContext( $site )
52
+	private static function createContext($site)
53 53
 	{
54 54
 		$ctx = new \Aimeos\MShop\Context\Item\Standard();
55 55
 		$aimeos = self::getAimeos();
56 56
 
57 57
 
58
-		$paths = $aimeos->getConfigPaths( 'mysql' );
58
+		$paths = $aimeos->getConfigPaths('mysql');
59 59
 		$paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config';
60 60
 		$file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser';
61 61
 
62
-		$conf = new \Aimeos\MW\Config\PHPArray( [], $paths );
63
-		$conf = new \Aimeos\MW\Config\Decorator\Memory( $conf );
64
-		$conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file );
65
-		$ctx->setConfig( $conf );
62
+		$conf = new \Aimeos\MW\Config\PHPArray([], $paths);
63
+		$conf = new \Aimeos\MW\Config\Decorator\Memory($conf);
64
+		$conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file);
65
+		$ctx->setConfig($conf);
66 66
 
67 67
 
68
-		$dbm = new \Aimeos\MW\DB\Manager\PDO( $conf );
69
-		$ctx->setDatabaseManager( $dbm );
68
+		$dbm = new \Aimeos\MW\DB\Manager\PDO($conf);
69
+		$ctx->setDatabaseManager($dbm);
70 70
 
71 71
 
72
-		$logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG );
73
-		$ctx->setLogger( $logger );
72
+		$logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG);
73
+		$ctx->setLogger($logger);
74 74
 
75 75
 
76 76
 		$session = new \Aimeos\MW\Session\None();
77
-		$ctx->setSession( $session );
77
+		$ctx->setSession($session);
78 78
 
79 79
 
80
-		$i18n = new \Aimeos\MW\Translation\None( 'de' );
81
-		$ctx->setI18n( array( 'de' => $i18n ) );
80
+		$i18n = new \Aimeos\MW\Translation\None('de');
81
+		$ctx->setI18n(array('de' => $i18n));
82 82
 
83 83
 
84
-		$localeManager = \Aimeos\MShop::create( $ctx, 'locale' );
85
-		$locale = $localeManager->bootstrap( $site, 'de', '', false );
86
-		$ctx->setLocale( $locale );
84
+		$localeManager = \Aimeos\MShop::create($ctx, 'locale');
85
+		$locale = $localeManager->bootstrap($site, 'de', '', false);
86
+		$ctx->setLocale($locale);
87 87
 
88 88
 
89
-		$view = self::createView( $conf );
90
-		$ctx->setView( $view );
89
+		$view = self::createView($conf);
90
+		$ctx->setView($view);
91 91
 
92 92
 
93
-		$ctx->setEditor( 'core:admin/jsonadm' );
93
+		$ctx->setEditor('core:admin/jsonadm');
94 94
 
95 95
 		return $ctx;
96 96
 	}
97 97
 
98 98
 
99
-	protected static function createView( \Aimeos\MW\Config\Iface $config )
99
+	protected static function createView(\Aimeos\MW\Config\Iface $config)
100 100
 	{
101
-		$tmplpaths = self::getAimeos()->getCustomPaths( 'admin/jsonadm/templates' );
101
+		$tmplpaths = self::getAimeos()->getCustomPaths('admin/jsonadm/templates');
102 102
 
103
-		$view = new \Aimeos\MW\View\Standard( $tmplpaths );
103
+		$view = new \Aimeos\MW\View\Standard($tmplpaths);
104 104
 
105
-		$helper = new \Aimeos\MW\View\Helper\Access\All( $view );
106
-		$view->addHelper( 'access', $helper );
105
+		$helper = new \Aimeos\MW\View\Helper\Access\All($view);
106
+		$view->addHelper('access', $helper);
107 107
 
108
-		$trans = new \Aimeos\MW\Translation\None( 'de_DE' );
109
-		$helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $trans );
110
-		$view->addHelper( 'translate', $helper );
108
+		$trans = new \Aimeos\MW\Translation\None('de_DE');
109
+		$helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $trans);
110
+		$view->addHelper('translate', $helper);
111 111
 
112
-		$helper = new \Aimeos\MW\View\Helper\Url\Standard( $view, 'http://baseurl' );
113
-		$view->addHelper( 'url', $helper );
112
+		$helper = new \Aimeos\MW\View\Helper\Url\Standard($view, 'http://baseurl');
113
+		$view->addHelper('url', $helper);
114 114
 
115
-		$helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, '.', '' );
116
-		$view->addHelper( 'number', $helper );
115
+		$helper = new \Aimeos\MW\View\Helper\Number\Standard($view, '.', '');
116
+		$view->addHelper('number', $helper);
117 117
 
118
-		$helper = new \Aimeos\MW\View\Helper\Date\Standard( $view, 'Y-m-d' );
119
-		$view->addHelper( 'date', $helper );
118
+		$helper = new \Aimeos\MW\View\Helper\Date\Standard($view, 'Y-m-d');
119
+		$view->addHelper('date', $helper);
120 120
 
121
-		$config = new \Aimeos\MW\Config\Decorator\Protect( $config, array( 'admin/jsonadm' ) );
122
-		$helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config );
123
-		$view->addHelper( 'config', $helper );
121
+		$config = new \Aimeos\MW\Config\Decorator\Protect($config, array('admin/jsonadm'));
122
+		$helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config);
123
+		$view->addHelper('config', $helper);
124 124
 
125
-		$helper = new \Aimeos\MW\View\Helper\Request\Standard( $view, new \Zend\Diactoros\ServerRequest() );
126
-		$view->addHelper( 'request', $helper );
125
+		$helper = new \Aimeos\MW\View\Helper\Request\Standard($view, new \Zend\Diactoros\ServerRequest());
126
+		$view->addHelper('request', $helper);
127 127
 
128
-		$helper = new \Aimeos\MW\View\Helper\Response\Standard( $view, new \Zend\Diactoros\Response() );
129
-		$view->addHelper( 'response', $helper );
128
+		$helper = new \Aimeos\MW\View\Helper\Response\Standard($view, new \Zend\Diactoros\Response());
129
+		$view->addHelper('response', $helper);
130 130
 
131 131
 		return $view;
132 132
 	}
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/Catalog/StandardTest.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -18,20 +18,20 @@  discard block
 block discarded – undo
18 18
 
19 19
 	protected function setUp()
20 20
 	{
21
-		\Aimeos\MShop::cache( true );
21
+		\Aimeos\MShop::cache(true);
22 22
 
23 23
 		$this->context = \TestHelperJadm::getContext();
24 24
 		$this->view = $this->context->getView();
25 25
 
26
-		$this->object = new \Aimeos\Admin\JsonAdm\Catalog\Standard( $this->context, 'catalog' );
27
-		$this->object->setAimeos( \TestHelperJadm::getAimeos() );
28
-		$this->object->setView( $this->view );
26
+		$this->object = new \Aimeos\Admin\JsonAdm\Catalog\Standard($this->context, 'catalog');
27
+		$this->object->setAimeos(\TestHelperJadm::getAimeos());
28
+		$this->object->setView($this->view);
29 29
 	}
30 30
 
31 31
 
32 32
 	protected function tearDown()
33 33
 	{
34
-		\Aimeos\MShop::cache( false );
34
+		\Aimeos\MShop::cache(false);
35 35
 	}
36 36
 
37 37
 
@@ -39,142 +39,142 @@  discard block
 block discarded – undo
39 39
 	{
40 40
 		$params = array(
41 41
 			'filter' => array(
42
-				'==' => array( 'catalog.code' => 'cafe' )
42
+				'==' => array('catalog.code' => 'cafe')
43 43
 			),
44 44
 			'include' => 'text'
45 45
 		);
46
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
47
-		$this->view->addHelper( 'param', $helper );
46
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
47
+		$this->view->addHelper('param', $helper);
48 48
 
49
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
50
-		$result = json_decode( (string) $response->getBody(), true );
49
+		$response = $this->object->get($this->view->request(), $this->view->response());
50
+		$result = json_decode((string) $response->getBody(), true);
51 51
 
52 52
 
53
-		$this->assertEquals( 200, $response->getStatusCode() );
54
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
53
+		$this->assertEquals(200, $response->getStatusCode());
54
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
55 55
 
56
-		$this->assertEquals( 1, $result['meta']['total'] );
57
-		$this->assertEquals( 1, count( $result['data'] ) );
58
-		$this->assertEquals( 'catalog', $result['data'][0]['type'] );
59
-		$this->assertEquals( 6, count( $result['data'][0]['relationships']['text'] ) );
60
-		$this->assertEquals( 6, count( $result['included'] ) );
56
+		$this->assertEquals(1, $result['meta']['total']);
57
+		$this->assertEquals(1, count($result['data']));
58
+		$this->assertEquals('catalog', $result['data'][0]['type']);
59
+		$this->assertEquals(6, count($result['data'][0]['relationships']['text']));
60
+		$this->assertEquals(6, count($result['included']));
61 61
 
62
-		$this->assertArrayNotHasKey( 'errors', $result );
62
+		$this->assertArrayNotHasKey('errors', $result);
63 63
 	}
64 64
 
65 65
 
66 66
 	public function testGetTree()
67 67
 	{
68 68
 		$params = array(
69
-			'id' => $this->getCatalogItem( 'root' )->getId(),
69
+			'id' => $this->getCatalogItem('root')->getId(),
70 70
 			'include' => 'catalog,text'
71 71
 		);
72
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
73
-		$this->view->addHelper( 'param', $helper );
72
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
73
+		$this->view->addHelper('param', $helper);
74 74
 
75
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
76
-		$result = json_decode( (string) $response->getBody(), true );
75
+		$response = $this->object->get($this->view->request(), $this->view->response());
76
+		$result = json_decode((string) $response->getBody(), true);
77 77
 
78
-		$this->assertEquals( 200, $response->getStatusCode() );
79
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
78
+		$this->assertEquals(200, $response->getStatusCode());
79
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
80 80
 
81
-		$this->assertEquals( 1, $result['meta']['total'] );
82
-		$this->assertEquals( 'catalog', $result['data']['type'] );
83
-		$this->assertEquals( 2, count( $result['data']['relationships']['catalog'] ) );
84
-		$this->assertEquals( 2, count( $result['included'] ) );
81
+		$this->assertEquals(1, $result['meta']['total']);
82
+		$this->assertEquals('catalog', $result['data']['type']);
83
+		$this->assertEquals(2, count($result['data']['relationships']['catalog']));
84
+		$this->assertEquals(2, count($result['included']));
85 85
 
86
-		$this->assertArrayNotHasKey( 'errors', $result );
86
+		$this->assertArrayNotHasKey('errors', $result);
87 87
 	}
88 88
 
89 89
 
90 90
 	public function testPatch()
91 91
 	{
92
-		$stub = $this->getCatalogMock( array( 'getItem', 'moveItem', 'saveItem' ) );
92
+		$stub = $this->getCatalogMock(array('getItem', 'moveItem', 'saveItem'));
93 93
 
94
-		$stub->expects( $this->once() )->method( 'moveItem' );
95
-		$stub->expects( $this->once() )->method( 'saveItem' )
96
-			->will( $this->returnValue( $stub->createItem() ) );
97
-		$stub->expects( $this->exactly( 2 ) )->method( 'getItem' ) // 2x due to decorator
98
-			->will( $this->returnValue( $stub->createItem() ) );
94
+		$stub->expects($this->once())->method('moveItem');
95
+		$stub->expects($this->once())->method('saveItem')
96
+			->will($this->returnValue($stub->createItem()));
97
+		$stub->expects($this->exactly(2))->method('getItem') // 2x due to decorator
98
+			->will($this->returnValue($stub->createItem()));
99 99
 
100 100
 
101
-		$params = array( 'id' => '-1' );
102
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
103
-		$this->view->addHelper( 'param', $helper );
101
+		$params = array('id' => '-1');
102
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
103
+		$this->view->addHelper('param', $helper);
104 104
 
105 105
 		$body = '{"data": {"parentid": "1", "targetid": 2, "type": "catalog", "attributes": {"catalog.label": "test"}}}';
106
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
106
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
107 107
 
108
-		$response = $this->object->patch( $request, $this->view->response() );
109
-		$result = json_decode( (string) $response->getBody(), true );
108
+		$response = $this->object->patch($request, $this->view->response());
109
+		$result = json_decode((string) $response->getBody(), true);
110 110
 
111 111
 
112
-		$this->assertEquals( 200, $response->getStatusCode() );
113
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
112
+		$this->assertEquals(200, $response->getStatusCode());
113
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
114 114
 
115
-		$this->assertEquals( 1, $result['meta']['total'] );
116
-		$this->assertArrayHasKey( 'data', $result );
117
-		$this->assertEquals( 'catalog', $result['data']['type'] );
115
+		$this->assertEquals(1, $result['meta']['total']);
116
+		$this->assertArrayHasKey('data', $result);
117
+		$this->assertEquals('catalog', $result['data']['type']);
118 118
 
119
-		$this->assertArrayNotHasKey( 'included', $result );
120
-		$this->assertArrayNotHasKey( 'errors', $result );
119
+		$this->assertArrayNotHasKey('included', $result);
120
+		$this->assertArrayNotHasKey('errors', $result);
121 121
 	}
122 122
 
123 123
 
124 124
 	public function testPost()
125 125
 	{
126
-		$stub = $this->getCatalogMock( array( 'getItem', 'insertItem' ) );
126
+		$stub = $this->getCatalogMock(array('getItem', 'insertItem'));
127 127
 
128
-		$stub->expects( $this->any() )->method( 'getItem' )
129
-			->will( $this->returnValue( $stub->createItem() ) );
130
-		$stub->expects( $this->once() )->method( 'insertItem' );
128
+		$stub->expects($this->any())->method('getItem')
129
+			->will($this->returnValue($stub->createItem()));
130
+		$stub->expects($this->once())->method('insertItem');
131 131
 
132 132
 
133 133
 		$body = '{"data": {"type": "catalog", "attributes": {"catalog.code": "test", "catalog.label": "Test catalog"}}}';
134
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
134
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
135 135
 
136
-		$response = $this->object->post( $request, $this->view->response() );
137
-		$result = json_decode( (string) $response->getBody(), true );
136
+		$response = $this->object->post($request, $this->view->response());
137
+		$result = json_decode((string) $response->getBody(), true);
138 138
 
139 139
 
140
-		$this->assertEquals( 201, $response->getStatusCode() );
141
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
140
+		$this->assertEquals(201, $response->getStatusCode());
141
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
142 142
 
143
-		$this->assertEquals( 1, $result['meta']['total'] );
144
-		$this->assertArrayHasKey( 'data', $result );
145
-		$this->assertEquals( 'catalog', $result['data']['type'] );
143
+		$this->assertEquals(1, $result['meta']['total']);
144
+		$this->assertArrayHasKey('data', $result);
145
+		$this->assertEquals('catalog', $result['data']['type']);
146 146
 
147
-		$this->assertArrayNotHasKey( 'included', $result );
148
-		$this->assertArrayNotHasKey( 'errors', $result );
147
+		$this->assertArrayNotHasKey('included', $result);
148
+		$this->assertArrayNotHasKey('errors', $result);
149 149
 	}
150 150
 
151 151
 
152
-	protected function getCatalogItem( $code )
152
+	protected function getCatalogItem($code)
153 153
 	{
154
-		$manager = \Aimeos\MShop::create( $this->context, 'catalog' );
154
+		$manager = \Aimeos\MShop::create($this->context, 'catalog');
155 155
 		$search = $manager->createSearch();
156
-		$search->setConditions( $search->compare( '==', 'catalog.code', $code ) );
157
-		$items = $manager->searchItems( $search );
156
+		$search->setConditions($search->compare('==', 'catalog.code', $code));
157
+		$items = $manager->searchItems($search);
158 158
 
159
-		if( ( $item = reset( $items ) ) === false ) {
160
-			throw new \RuntimeException( sprintf( 'No catalog item with code "%1$s" found', $code ) );
159
+		if (($item = reset($items)) === false) {
160
+			throw new \RuntimeException(sprintf('No catalog item with code "%1$s" found', $code));
161 161
 		}
162 162
 
163 163
 		return $item;
164 164
 	}
165 165
 
166 166
 
167
-	protected function getCatalogMock( array $methods )
167
+	protected function getCatalogMock(array $methods)
168 168
 	{
169 169
 		$name = 'ClientJsonAdmStandard';
170
-		$this->context->getConfig()->set( 'mshop/catalog/manager/name', $name );
170
+		$this->context->getConfig()->set('mshop/catalog/manager/name', $name);
171 171
 
172
-		$stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Catalog\\Manager\\Standard' )
173
-			->setConstructorArgs( array( $this->context ) )
174
-			->setMethods( $methods )
172
+		$stub = $this->getMockBuilder('\\Aimeos\\MShop\\Catalog\\Manager\\Standard')
173
+			->setConstructorArgs(array($this->context))
174
+			->setMethods($methods)
175 175
 			->getMock();
176 176
 
177
-		\Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub );
177
+		\Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub);
178 178
 
179 179
 		return $stub;
180 180
 	}
Please login to merge, or discard this patch.
admin/jsonadm/tests/Admin/JsonAdm/StandardTest.php 1 patch
Spacing   +393 added lines, -393 removed lines patch added patch discarded remove patch
@@ -18,212 +18,212 @@  discard block
 block discarded – undo
18 18
 
19 19
 	protected function setUp()
20 20
 	{
21
-		\Aimeos\MShop::cache( true );
21
+		\Aimeos\MShop::cache(true);
22 22
 
23 23
 		$this->context = \TestHelperJadm::getContext();
24 24
 		$this->view = $this->context->getView();
25 25
 
26
-		$this->object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, 'product' );
27
-		$this->object->setAimeos( \TestHelperJadm::getAimeos() );
28
-		$this->object->setView( $this->view );
26
+		$this->object = new \Aimeos\Admin\JsonAdm\Standard($this->context, 'product');
27
+		$this->object->setAimeos(\TestHelperJadm::getAimeos());
28
+		$this->object->setView($this->view);
29 29
 	}
30 30
 
31 31
 
32 32
 	protected function tearDown()
33 33
 	{
34
-		\Aimeos\MShop::cache( false );
34
+		\Aimeos\MShop::cache(false);
35 35
 	}
36 36
 
37 37
 
38 38
 	public function testDelete()
39 39
 	{
40
-		$this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' );
40
+		$this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem');
41 41
 
42
-		$params = array( 'id' => $this->getProductItem()->getId() );
43
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
44
-		$this->view->addHelper( 'param', $helper );
42
+		$params = array('id' => $this->getProductItem()->getId());
43
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
44
+		$this->view->addHelper('param', $helper);
45 45
 
46
-		$response = $this->object->delete( $this->view->request(), $this->view->response() );
47
-		$result = json_decode( (string) $response->getBody(), true );
46
+		$response = $this->object->delete($this->view->request(), $this->view->response());
47
+		$result = json_decode((string) $response->getBody(), true);
48 48
 
49 49
 
50
-		$this->assertEquals( 200, $response->getStatusCode() );
51
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
50
+		$this->assertEquals(200, $response->getStatusCode());
51
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
52 52
 
53
-		$this->assertEquals( 1, $result['meta']['total'] );
53
+		$this->assertEquals(1, $result['meta']['total']);
54 54
 
55
-		$this->assertArrayNotHasKey( 'included', $result );
56
-		$this->assertArrayNotHasKey( 'data', $result );
57
-		$this->assertArrayNotHasKey( 'errors', $result );
55
+		$this->assertArrayNotHasKey('included', $result);
56
+		$this->assertArrayNotHasKey('data', $result);
57
+		$this->assertArrayNotHasKey('errors', $result);
58 58
 	}
59 59
 
60 60
 
61 61
 	public function testDeleteBulk()
62 62
 	{
63
-		$this->getProductMock( array( 'deleteItems' ) )->expects( $this->once() )->method( 'deleteItems' );
63
+		$this->getProductMock(array('deleteItems'))->expects($this->once())->method('deleteItems');
64 64
 
65 65
 		$body = '{"data":[{"type": "product", "id": "-1"},{"type": "product", "id": "-2"}]}';
66
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
66
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
67 67
 
68
-		$response = $this->object->delete( $request, $this->view->response() );
69
-		$result = json_decode( (string) $response->getBody(), true );
68
+		$response = $this->object->delete($request, $this->view->response());
69
+		$result = json_decode((string) $response->getBody(), true);
70 70
 
71 71
 
72
-		$this->assertEquals( 200, $response->getStatusCode() );
73
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
72
+		$this->assertEquals(200, $response->getStatusCode());
73
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
74 74
 
75
-		$this->assertEquals( 2, $result['meta']['total'] );
76
-		$this->assertArrayNotHasKey( 'included', $result );
77
-		$this->assertArrayNotHasKey( 'data', $result );
78
-		$this->assertArrayNotHasKey( 'errors', $result );
75
+		$this->assertEquals(2, $result['meta']['total']);
76
+		$this->assertArrayNotHasKey('included', $result);
77
+		$this->assertArrayNotHasKey('data', $result);
78
+		$this->assertArrayNotHasKey('errors', $result);
79 79
 	}
80 80
 
81 81
 
82 82
 	public function testDeleteInvalid()
83 83
 	{
84 84
 		$body = '{"data":null}';
85
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
85
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
86 86
 
87
-		$response = $this->object->delete( $request, $this->view->response() );
88
-		$result = json_decode( (string) $response->getBody(), true );
87
+		$response = $this->object->delete($request, $this->view->response());
88
+		$result = json_decode((string) $response->getBody(), true);
89 89
 
90 90
 
91
-		$this->assertEquals( 400, $response->getStatusCode() );
92
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
91
+		$this->assertEquals(400, $response->getStatusCode());
92
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
93 93
 
94
-		$this->assertEquals( 0, $result['meta']['total'] );
95
-		$this->assertArrayHasKey( 'errors', $result );
96
-		$this->assertArrayNotHasKey( 'included', $result );
97
-		$this->assertArrayNotHasKey( 'data', $result );
94
+		$this->assertEquals(0, $result['meta']['total']);
95
+		$this->assertArrayHasKey('errors', $result);
96
+		$this->assertArrayNotHasKey('included', $result);
97
+		$this->assertArrayNotHasKey('data', $result);
98 98
 	}
99 99
 
100 100
 
101 101
 	public function testDeleteException()
102 102
 	{
103
-		$this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' )
104
-			->will( $this->throwException( new \RuntimeException( 'test exception' ) ) );
103
+		$this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem')
104
+			->will($this->throwException(new \RuntimeException('test exception')));
105 105
 
106
-		$params = array( 'id' => $this->getProductItem()->getId() );
107
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
108
-		$this->view->addHelper( 'param', $helper );
106
+		$params = array('id' => $this->getProductItem()->getId());
107
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
108
+		$this->view->addHelper('param', $helper);
109 109
 
110
-		$response = $this->object->delete( $this->view->request(), $this->view->response() );
111
-		$result = json_decode( (string) $response->getBody(), true );
110
+		$response = $this->object->delete($this->view->request(), $this->view->response());
111
+		$result = json_decode((string) $response->getBody(), true);
112 112
 
113
-		$this->assertEquals( 500, $response->getStatusCode() );
114
-		$this->assertArrayHasKey( 'errors', $result );
113
+		$this->assertEquals(500, $response->getStatusCode());
114
+		$this->assertArrayHasKey('errors', $result);
115 115
 	}
116 116
 
117 117
 
118 118
 	public function testDeleteMShopException()
119 119
 	{
120
-		$this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' )
121
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
120
+		$this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem')
121
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
122 122
 
123
-		$params = array( 'id' => $this->getProductItem()->getId() );
124
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
125
-		$this->view->addHelper( 'param', $helper );
123
+		$params = array('id' => $this->getProductItem()->getId());
124
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
125
+		$this->view->addHelper('param', $helper);
126 126
 
127
-		$response = $this->object->delete( $this->view->request(), $this->view->response() );
128
-		$result = json_decode( (string) $response->getBody(), true );
127
+		$response = $this->object->delete($this->view->request(), $this->view->response());
128
+		$result = json_decode((string) $response->getBody(), true);
129 129
 
130
-		$this->assertEquals( 404, $response->getStatusCode() );
131
-		$this->assertArrayHasKey( 'errors', $result );
130
+		$this->assertEquals(404, $response->getStatusCode());
131
+		$this->assertArrayHasKey('errors', $result);
132 132
 	}
133 133
 
134 134
 
135 135
 	public function testGet()
136 136
 	{
137
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
138
-		$result = json_decode( (string) $response->getBody(), true );
137
+		$response = $this->object->get($this->view->request(), $this->view->response());
138
+		$result = json_decode((string) $response->getBody(), true);
139 139
 
140 140
 
141
-		$this->assertEquals( 200, $response->getStatusCode() );
142
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
141
+		$this->assertEquals(200, $response->getStatusCode());
142
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
143 143
 
144
-		$this->assertEquals( 28, $result['meta']['total'] );
145
-		$this->assertEquals( 25, count( $result['data'] ) );
146
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
147
-		$this->assertEquals( 0, count( $result['included'] ) );
148
-		$this->assertArrayHasKey( 'next', $result['links'] );
149
-		$this->assertArrayHasKey( 'last', $result['links'] );
150
-		$this->assertArrayHasKey( 'self', $result['links'] );
151
-		$this->assertArrayNotHasKey( 'errors', $result );
144
+		$this->assertEquals(28, $result['meta']['total']);
145
+		$this->assertEquals(25, count($result['data']));
146
+		$this->assertEquals('product', $result['data'][0]['type']);
147
+		$this->assertEquals(0, count($result['included']));
148
+		$this->assertArrayHasKey('next', $result['links']);
149
+		$this->assertArrayHasKey('last', $result['links']);
150
+		$this->assertArrayHasKey('self', $result['links']);
151
+		$this->assertArrayNotHasKey('errors', $result);
152 152
 	}
153 153
 
154 154
 
155 155
 	public function testGetType()
156 156
 	{
157
-		$object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, 'product/property/type' );
158
-		$object->setView( $this->view );
157
+		$object = new \Aimeos\Admin\JsonAdm\Standard($this->context, 'product/property/type');
158
+		$object->setView($this->view);
159 159
 
160
-		$response = $object->get( $this->view->request(), $this->view->response() );
161
-		$result = json_decode( (string) $response->getBody(), true );
160
+		$response = $object->get($this->view->request(), $this->view->response());
161
+		$result = json_decode((string) $response->getBody(), true);
162 162
 
163 163
 
164
-		$this->assertEquals( 200, $response->getStatusCode() );
165
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
164
+		$this->assertEquals(200, $response->getStatusCode());
165
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
166 166
 
167
-		$this->assertEquals( 4, $result['meta']['total'] );
168
-		$this->assertEquals( 4, count( $result['data'] ) );
169
-		$this->assertEquals( 'product/property/type', $result['data'][0]['type'] );
170
-		$this->assertEquals( 0, count( $result['included'] ) );
167
+		$this->assertEquals(4, $result['meta']['total']);
168
+		$this->assertEquals(4, count($result['data']));
169
+		$this->assertEquals('product/property/type', $result['data'][0]['type']);
170
+		$this->assertEquals(0, count($result['included']));
171 171
 
172
-		$this->assertArrayNotHasKey( 'errors', $result );
172
+		$this->assertArrayNotHasKey('errors', $result);
173 173
 	}
174 174
 
175 175
 
176 176
 	public function testGetInvalid()
177 177
 	{
178
-		$object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, 'invalid' );
179
-		$object->setView( $this->view );
178
+		$object = new \Aimeos\Admin\JsonAdm\Standard($this->context, 'invalid');
179
+		$object->setView($this->view);
180 180
 
181
-		$response = $object->get( $this->view->request(), $this->view->response() );
182
-		$result = json_decode( (string) $response->getBody(), true );
181
+		$response = $object->get($this->view->request(), $this->view->response());
182
+		$result = json_decode((string) $response->getBody(), true);
183 183
 
184 184
 
185
-		$this->assertEquals( 404, $response->getStatusCode() );
186
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
185
+		$this->assertEquals(404, $response->getStatusCode());
186
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
187 187
 
188
-		$this->assertEquals( 1, count( $result['errors'] ) );
189
-		$this->assertArrayHasKey( 'title', $result['errors'][0] );
190
-		$this->assertArrayHasKey( 'detail', $result['errors'][0] );
191
-		$this->assertArrayNotHasKey( 'data', $result );
192
-		$this->assertArrayNotHasKey( 'indluded', $result );
188
+		$this->assertEquals(1, count($result['errors']));
189
+		$this->assertArrayHasKey('title', $result['errors'][0]);
190
+		$this->assertArrayHasKey('detail', $result['errors'][0]);
191
+		$this->assertArrayNotHasKey('data', $result);
192
+		$this->assertArrayNotHasKey('indluded', $result);
193 193
 	}
194 194
 
195 195
 
196 196
 	public function testGetException()
197 197
 	{
198
-		$this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' )
199
-			->will( $this->throwException( new \RuntimeException( 'test exception' ) ) );
198
+		$this->getProductMock(array('getItem'))->expects($this->once())->method('getItem')
199
+			->will($this->throwException(new \RuntimeException('test exception')));
200 200
 
201
-		$params = array( 'id' => -1 );
202
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
203
-		$this->view->addHelper( 'param', $helper );
201
+		$params = array('id' => -1);
202
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
203
+		$this->view->addHelper('param', $helper);
204 204
 
205
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
206
-		$result = json_decode( (string) $response->getBody(), true );
205
+		$response = $this->object->get($this->view->request(), $this->view->response());
206
+		$result = json_decode((string) $response->getBody(), true);
207 207
 
208
-		$this->assertEquals( 500, $response->getStatusCode() );
209
-		$this->assertArrayHasKey( 'errors', $result );
208
+		$this->assertEquals(500, $response->getStatusCode());
209
+		$this->assertArrayHasKey('errors', $result);
210 210
 	}
211 211
 
212 212
 
213 213
 	public function testGetMShopException()
214 214
 	{
215
-		$this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' )
216
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
215
+		$this->getProductMock(array('getItem'))->expects($this->once())->method('getItem')
216
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
217 217
 
218
-		$params = array( 'id' => -1 );
219
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
220
-		$this->view->addHelper( 'param', $helper );
218
+		$params = array('id' => -1);
219
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
220
+		$this->view->addHelper('param', $helper);
221 221
 
222
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
223
-		$result = json_decode( (string) $response->getBody(), true );
222
+		$response = $this->object->get($this->view->request(), $this->view->response());
223
+		$result = json_decode((string) $response->getBody(), true);
224 224
 
225
-		$this->assertEquals( 404, $response->getStatusCode() );
226
-		$this->assertArrayHasKey( 'errors', $result );
225
+		$this->assertEquals(404, $response->getStatusCode());
226
+		$this->assertArrayHasKey('errors', $result);
227 227
 	}
228 228
 
229 229
 
@@ -231,25 +231,25 @@  discard block
 block discarded – undo
231 231
 	{
232 232
 		$params = array(
233 233
 			'filter' => array(
234
-				'==' => array( 'product.type' => 'select' )
234
+				'==' => array('product.type' => 'select')
235 235
 			)
236 236
 		);
237
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
238
-		$this->view->addHelper( 'param', $helper );
237
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
238
+		$this->view->addHelper('param', $helper);
239 239
 
240
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
241
-		$result = json_decode( (string) $response->getBody(), true );
240
+		$response = $this->object->get($this->view->request(), $this->view->response());
241
+		$result = json_decode((string) $response->getBody(), true);
242 242
 
243 243
 
244
-		$this->assertEquals( 200, $response->getStatusCode() );
245
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
244
+		$this->assertEquals(200, $response->getStatusCode());
245
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
246 246
 
247
-		$this->assertEquals( 3, $result['meta']['total'] );
248
-		$this->assertEquals( 3, count( $result['data'] ) );
249
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
250
-		$this->assertEquals( 0, count( $result['included'] ) );
247
+		$this->assertEquals(3, $result['meta']['total']);
248
+		$this->assertEquals(3, count($result['data']));
249
+		$this->assertEquals('product', $result['data'][0]['type']);
250
+		$this->assertEquals(0, count($result['included']));
251 251
 
252
-		$this->assertArrayNotHasKey( 'errors', $result );
252
+		$this->assertArrayNotHasKey('errors', $result);
253 253
 	}
254 254
 
255 255
 
@@ -258,27 +258,27 @@  discard block
 block discarded – undo
258 258
 		$params = array(
259 259
 			'filter' => array(
260 260
 				'&&' => array(
261
-					array( '=~' => array( 'product.label' => 'Unittest: Test' ) ),
262
-					array( '==' => array( 'product.type' => 'select' ) ),
261
+					array('=~' => array('product.label' => 'Unittest: Test')),
262
+					array('==' => array('product.type' => 'select')),
263 263
 				)
264 264
 			)
265 265
 		);
266
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
267
-		$this->view->addHelper( 'param', $helper );
266
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
267
+		$this->view->addHelper('param', $helper);
268 268
 
269
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
270
-		$result = json_decode( (string) $response->getBody(), true );
269
+		$response = $this->object->get($this->view->request(), $this->view->response());
270
+		$result = json_decode((string) $response->getBody(), true);
271 271
 
272 272
 
273
-		$this->assertEquals( 200, $response->getStatusCode() );
274
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
273
+		$this->assertEquals(200, $response->getStatusCode());
274
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
275 275
 
276
-		$this->assertEquals( 2, $result['meta']['total'] );
277
-		$this->assertEquals( 2, count( $result['data'] ) );
278
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
279
-		$this->assertEquals( 0, count( $result['included'] ) );
276
+		$this->assertEquals(2, $result['meta']['total']);
277
+		$this->assertEquals(2, count($result['data']));
278
+		$this->assertEquals('product', $result['data'][0]['type']);
279
+		$this->assertEquals(0, count($result['included']));
280 280
 
281
-		$this->assertArrayNotHasKey( 'errors', $result );
281
+		$this->assertArrayNotHasKey('errors', $result);
282 282
 	}
283 283
 
284 284
 
@@ -290,25 +290,25 @@  discard block
 block discarded – undo
290 290
 				'limit' => 25
291 291
 			)
292 292
 		);
293
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
294
-		$this->view->addHelper( 'param', $helper );
293
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
294
+		$this->view->addHelper('param', $helper);
295 295
 
296
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
297
-		$result = json_decode( (string) $response->getBody(), true );
296
+		$response = $this->object->get($this->view->request(), $this->view->response());
297
+		$result = json_decode((string) $response->getBody(), true);
298 298
 
299 299
 
300
-		$this->assertEquals( 200, $response->getStatusCode() );
301
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
300
+		$this->assertEquals(200, $response->getStatusCode());
301
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
302 302
 
303
-		$this->assertEquals( 28, $result['meta']['total'] );
304
-		$this->assertEquals( 3, count( $result['data'] ) );
305
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
306
-		$this->assertEquals( 0, count( $result['included'] ) );
307
-		$this->assertArrayHasKey( 'first', $result['links'] );
308
-		$this->assertArrayHasKey( 'prev', $result['links'] );
309
-		$this->assertArrayHasKey( 'self', $result['links'] );
303
+		$this->assertEquals(28, $result['meta']['total']);
304
+		$this->assertEquals(3, count($result['data']));
305
+		$this->assertEquals('product', $result['data'][0]['type']);
306
+		$this->assertEquals(0, count($result['included']));
307
+		$this->assertArrayHasKey('first', $result['links']);
308
+		$this->assertArrayHasKey('prev', $result['links']);
309
+		$this->assertArrayHasKey('self', $result['links']);
310 310
 
311
-		$this->assertArrayNotHasKey( 'errors', $result );
311
+		$this->assertArrayNotHasKey('errors', $result);
312 312
 	}
313 313
 
314 314
 
@@ -317,24 +317,24 @@  discard block
 block discarded – undo
317 317
 		$params = array(
318 318
 			'sort' => 'product.label,-product.code'
319 319
 		);
320
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
321
-		$this->view->addHelper( 'param', $helper );
320
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
321
+		$this->view->addHelper('param', $helper);
322 322
 
323
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
324
-		$result = json_decode( (string) $response->getBody(), true );
323
+		$response = $this->object->get($this->view->request(), $this->view->response());
324
+		$result = json_decode((string) $response->getBody(), true);
325 325
 
326 326
 
327
-		$this->assertEquals( 200, $response->getStatusCode() );
328
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
327
+		$this->assertEquals(200, $response->getStatusCode());
328
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
329 329
 
330
-		$this->assertEquals( 28, $result['meta']['total'] );
331
-		$this->assertEquals( 25, count( $result['data'] ) );
332
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
333
-		$this->assertEquals( 'QRST', $result['data'][0]['attributes']['product.code'] );
334
-		$this->assertEquals( '16 discs', $result['data'][0]['attributes']['product.label'] );
335
-		$this->assertEquals( 0, count( $result['included'] ) );
330
+		$this->assertEquals(28, $result['meta']['total']);
331
+		$this->assertEquals(25, count($result['data']));
332
+		$this->assertEquals('product', $result['data'][0]['type']);
333
+		$this->assertEquals('QRST', $result['data'][0]['attributes']['product.code']);
334
+		$this->assertEquals('16 discs', $result['data'][0]['attributes']['product.label']);
335
+		$this->assertEquals(0, count($result['included']));
336 336
 
337
-		$this->assertArrayNotHasKey( 'errors', $result );
337
+		$this->assertArrayNotHasKey('errors', $result);
338 338
 	}
339 339
 
340 340
 
@@ -347,262 +347,262 @@  discard block
 block discarded – undo
347 347
 			'sort' => 'product.id',
348 348
 			'include' => 'product'
349 349
 		);
350
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
351
-		$this->view->addHelper( 'param', $helper );
350
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
351
+		$this->view->addHelper('param', $helper);
352 352
 
353
-		$response = $this->object->get( $this->view->request(), $this->view->response() );
354
-		$result = json_decode( (string) $response->getBody(), true );
353
+		$response = $this->object->get($this->view->request(), $this->view->response());
354
+		$result = json_decode((string) $response->getBody(), true);
355 355
 
356 356
 
357
-		$this->assertEquals( 200, $response->getStatusCode() );
358
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
357
+		$this->assertEquals(200, $response->getStatusCode());
358
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
359 359
 
360
-		$this->assertEquals( 28, $result['meta']['total'] );
361
-		$this->assertEquals( 25, count( $result['data'] ) );
362
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
363
-		$this->assertEquals( 2, count( $result['data'][0]['attributes'] ) );
360
+		$this->assertEquals(28, $result['meta']['total']);
361
+		$this->assertEquals(25, count($result['data']));
362
+		$this->assertEquals('product', $result['data'][0]['type']);
363
+		$this->assertEquals(2, count($result['data'][0]['attributes']));
364 364
 
365
-		$this->assertArrayNotHasKey( 'errors', $result );
365
+		$this->assertArrayNotHasKey('errors', $result);
366 366
 	}
367 367
 
368 368
 
369 369
 	public function testPatch()
370 370
 	{
371
-		$productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) );
371
+		$productManagerStub = $this->getProductMock(array('getItem', 'saveItem'));
372 372
 
373 373
 		$item = $productManagerStub->createItem();
374
-		$item->setLabel( 'test' );
375
-		$item->setId( '-1' );
374
+		$item->setLabel('test');
375
+		$item->setId('-1');
376 376
 
377
-		$productManagerStub->expects( $this->once() )->method( 'saveItem' )
378
-			->will( $this->returnValue( $productManagerStub->createItem() ) );
379
-		$productManagerStub->expects( $this->atLeastOnce() )->method( 'getItem' )
380
-			->will( $this->returnValue( $item ) );
377
+		$productManagerStub->expects($this->once())->method('saveItem')
378
+			->will($this->returnValue($productManagerStub->createItem()));
379
+		$productManagerStub->expects($this->atLeastOnce())->method('getItem')
380
+			->will($this->returnValue($item));
381 381
 
382 382
 
383
-		$params = array( 'id' => '-1' );
384
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
385
-		$this->view->addHelper( 'param', $helper );
383
+		$params = array('id' => '-1');
384
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params);
385
+		$this->view->addHelper('param', $helper);
386 386
 
387 387
 		$body = '{"data": {"type": "product", "attributes": {"product.label": "test"}}}';
388
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
388
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
389 389
 
390
-		$response = $this->object->patch( $request, $this->view->response() );
391
-		$result = json_decode( (string) $response->getBody(), true );
390
+		$response = $this->object->patch($request, $this->view->response());
391
+		$result = json_decode((string) $response->getBody(), true);
392 392
 
393 393
 
394
-		$this->assertEquals( 200, $response->getStatusCode() );
395
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
394
+		$this->assertEquals(200, $response->getStatusCode());
395
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
396 396
 
397
-		$this->assertEquals( 1, $result['meta']['total'] );
398
-		$this->assertArrayHasKey( 'data', $result );
399
-		$this->assertEquals( '-1', $result['data']['id'] );
400
-		$this->assertEquals( 'product', $result['data']['type'] );
401
-		$this->assertEquals( 'test', $result['data']['attributes']['product.label'] );
397
+		$this->assertEquals(1, $result['meta']['total']);
398
+		$this->assertArrayHasKey('data', $result);
399
+		$this->assertEquals('-1', $result['data']['id']);
400
+		$this->assertEquals('product', $result['data']['type']);
401
+		$this->assertEquals('test', $result['data']['attributes']['product.label']);
402 402
 
403
-		$this->assertArrayNotHasKey( 'included', $result );
404
-		$this->assertArrayNotHasKey( 'errors', $result );
403
+		$this->assertArrayNotHasKey('included', $result);
404
+		$this->assertArrayNotHasKey('errors', $result);
405 405
 	}
406 406
 
407 407
 
408 408
 	public function testPatchBulk()
409 409
 	{
410
-		$productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) );
410
+		$productManagerStub = $this->getProductMock(array('getItem', 'saveItem'));
411 411
 
412 412
 		$item = $productManagerStub->createItem();
413
-		$item->setLabel( 'test' );
414
-		$item->setId( '-1' );
413
+		$item->setLabel('test');
414
+		$item->setId('-1');
415 415
 
416
-		$productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' )
417
-			->will( $this->returnValue( $productManagerStub->createItem() ) );
418
-		$productManagerStub->expects( $this->atLeastOnce() )->method( 'getItem' )
419
-			->will( $this->returnValue( $item ) );
416
+		$productManagerStub->expects($this->exactly(2))->method('saveItem')
417
+			->will($this->returnValue($productManagerStub->createItem()));
418
+		$productManagerStub->expects($this->atLeastOnce())->method('getItem')
419
+			->will($this->returnValue($item));
420 420
 
421 421
 
422 422
 		$body = '{"data": [{"id": "-1", "type": "product", "attributes": {"product.label": "test"}}, {"id": "-1", "type": "product", "attributes": {"product.label": "test"}}]}';
423
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
423
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
424 424
 
425
-		$response = $this->object->patch( $request, $this->view->response() );
426
-		$result = json_decode( (string) $response->getBody(), true );
425
+		$response = $this->object->patch($request, $this->view->response());
426
+		$result = json_decode((string) $response->getBody(), true);
427 427
 
428 428
 
429
-		$this->assertEquals( 200, $response->getStatusCode() );
430
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
429
+		$this->assertEquals(200, $response->getStatusCode());
430
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
431 431
 
432
-		$this->assertEquals( 2, $result['meta']['total'] );
433
-		$this->assertArrayHasKey( 'data', $result );
434
-		$this->assertEquals( 2, count( $result['data'] ) );
435
-		$this->assertEquals( '-1', $result['data'][0]['id'] );
436
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
437
-		$this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] );
432
+		$this->assertEquals(2, $result['meta']['total']);
433
+		$this->assertArrayHasKey('data', $result);
434
+		$this->assertEquals(2, count($result['data']));
435
+		$this->assertEquals('-1', $result['data'][0]['id']);
436
+		$this->assertEquals('product', $result['data'][0]['type']);
437
+		$this->assertEquals('test', $result['data'][0]['attributes']['product.label']);
438 438
 
439
-		$this->assertArrayNotHasKey( 'included', $result );
440
-		$this->assertArrayNotHasKey( 'errors', $result );
439
+		$this->assertArrayNotHasKey('included', $result);
440
+		$this->assertArrayNotHasKey('errors', $result);
441 441
 	}
442 442
 
443 443
 
444 444
 	public function testPatchInvalid()
445 445
 	{
446 446
 		$body = '{"data":null}';
447
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
447
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
448 448
 
449
-		$response = $this->object->patch( $request, $this->view->response() );
450
-		$result = json_decode( (string) $response->getBody(), true );
449
+		$response = $this->object->patch($request, $this->view->response());
450
+		$result = json_decode((string) $response->getBody(), true);
451 451
 
452 452
 
453
-		$this->assertEquals( 400, $response->getStatusCode() );
454
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
453
+		$this->assertEquals(400, $response->getStatusCode());
454
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
455 455
 
456
-		$this->assertEquals( 0, $result['meta']['total'] );
457
-		$this->assertArrayHasKey( 'errors', $result );
458
-		$this->assertArrayNotHasKey( 'included', $result );
459
-		$this->assertArrayNotHasKey( 'data', $result );
456
+		$this->assertEquals(0, $result['meta']['total']);
457
+		$this->assertArrayHasKey('errors', $result);
458
+		$this->assertArrayNotHasKey('included', $result);
459
+		$this->assertArrayNotHasKey('data', $result);
460 460
 	}
461 461
 
462 462
 
463 463
 	public function testPatchInvalidId()
464 464
 	{
465 465
 		$body = '{"data":{"id":-1}}';
466
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
466
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
467 467
 
468
-		$response = $this->object->patch( $request, $this->view->response() );
469
-		$result = json_decode( (string) $response->getBody(), true );
468
+		$response = $this->object->patch($request, $this->view->response());
469
+		$result = json_decode((string) $response->getBody(), true);
470 470
 
471 471
 
472
-		$this->assertEquals( 400, $response->getStatusCode() );
473
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
472
+		$this->assertEquals(400, $response->getStatusCode());
473
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
474 474
 
475
-		$this->assertEquals( 0, $result['meta']['total'] );
476
-		$this->assertArrayHasKey( 'errors', $result );
475
+		$this->assertEquals(0, $result['meta']['total']);
476
+		$this->assertArrayHasKey('errors', $result);
477 477
 	}
478 478
 
479 479
 
480 480
 	public function testPatchException()
481 481
 	{
482
-		$this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' )
483
-			->will( $this->throwException( new \RuntimeException( 'test exception' ) ) );
482
+		$this->getProductMock(array('getItem'))->expects($this->once())->method('getItem')
483
+			->will($this->throwException(new \RuntimeException('test exception')));
484 484
 
485 485
 		$body = '{"data":[{"id":-1}]}';
486
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
486
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
487 487
 
488
-		$response = $this->object->patch( $request, $this->view->response() );
489
-		$result = json_decode( (string) $response->getBody(), true );
488
+		$response = $this->object->patch($request, $this->view->response());
489
+		$result = json_decode((string) $response->getBody(), true);
490 490
 
491 491
 
492
-		$this->assertEquals( 500, $response->getStatusCode() );
493
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
494
-		$this->assertArrayHasKey( 'errors', $result );
492
+		$this->assertEquals(500, $response->getStatusCode());
493
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
494
+		$this->assertArrayHasKey('errors', $result);
495 495
 	}
496 496
 
497 497
 
498 498
 	public function testPatchMShopException()
499 499
 	{
500
-		$this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' )
501
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
500
+		$this->getProductMock(array('getItem'))->expects($this->once())->method('getItem')
501
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
502 502
 
503 503
 		$body = '{"data":[{"id":-1}]}';
504
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
504
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
505 505
 
506
-		$response = $this->object->patch( $request, $this->view->response() );
507
-		$result = json_decode( (string) $response->getBody(), true );
506
+		$response = $this->object->patch($request, $this->view->response());
507
+		$result = json_decode((string) $response->getBody(), true);
508 508
 
509 509
 
510
-		$this->assertEquals( 404, $response->getStatusCode() );
511
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
512
-		$this->assertArrayHasKey( 'errors', $result );
510
+		$this->assertEquals(404, $response->getStatusCode());
511
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
512
+		$this->assertArrayHasKey('errors', $result);
513 513
 	}
514 514
 
515 515
 
516 516
 	public function testPost()
517 517
 	{
518
-		$productManagerStub = $this->getProductMock( array( 'createItem', 'getItem', 'saveItem' ) );
518
+		$productManagerStub = $this->getProductMock(array('createItem', 'getItem', 'saveItem'));
519 519
 
520 520
 		$item = new \Aimeos\MShop\Product\Item\Standard();
521
-		$item->setId( '-1' );
521
+		$item->setId('-1');
522 522
 
523
-		$productManagerStub->expects( $this->exactly( 2 ) )->method( 'createItem' )
524
-			->will( $this->returnValue( $item ) );
525
-		$productManagerStub->expects( $this->any() )->method( 'getItem' )
526
-			->will( $this->returnValue( $item ) );
527
-		$productManagerStub->expects( $this->once() )->method( 'saveItem' )
528
-			->will( $this->returnValue( $productManagerStub->createItem() ) );
523
+		$productManagerStub->expects($this->exactly(2))->method('createItem')
524
+			->will($this->returnValue($item));
525
+		$productManagerStub->expects($this->any())->method('getItem')
526
+			->will($this->returnValue($item));
527
+		$productManagerStub->expects($this->once())->method('saveItem')
528
+			->will($this->returnValue($productManagerStub->createItem()));
529 529
 
530 530
 
531 531
 		$body = '{"data": {"type": "product", "attributes": {"product.type": "default", "product.label": "test"}}}';
532
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
532
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
533 533
 
534
-		$response = $this->object->post( $request, $this->view->response() );
535
-		$result = json_decode( (string) $response->getBody(), true );
534
+		$response = $this->object->post($request, $this->view->response());
535
+		$result = json_decode((string) $response->getBody(), true);
536 536
 
537
-		$this->assertEquals( 201, $response->getStatusCode() );
538
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
537
+		$this->assertEquals(201, $response->getStatusCode());
538
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
539 539
 
540
-		$this->assertEquals( 1, $result['meta']['total'] );
541
-		$this->assertArrayHasKey( 'data', $result );
542
-		$this->assertEquals( '-1', $result['data']['id'] );
543
-		$this->assertEquals( 'product', $result['data']['type'] );
544
-		$this->assertEquals( 'default', $result['data']['attributes']['product.type'] );
545
-		$this->assertEquals( 'test', $result['data']['attributes']['product.label'] );
540
+		$this->assertEquals(1, $result['meta']['total']);
541
+		$this->assertArrayHasKey('data', $result);
542
+		$this->assertEquals('-1', $result['data']['id']);
543
+		$this->assertEquals('product', $result['data']['type']);
544
+		$this->assertEquals('default', $result['data']['attributes']['product.type']);
545
+		$this->assertEquals('test', $result['data']['attributes']['product.label']);
546 546
 
547
-		$this->assertArrayNotHasKey( 'included', $result );
548
-		$this->assertArrayNotHasKey( 'errors', $result );
547
+		$this->assertArrayNotHasKey('included', $result);
548
+		$this->assertArrayNotHasKey('errors', $result);
549 549
 	}
550 550
 
551 551
 
552 552
 	public function testPostBulk()
553 553
 	{
554
-		$productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) );
554
+		$productManagerStub = $this->getProductMock(array('getItem', 'saveItem'));
555 555
 
556 556
 		$item = $productManagerStub->createItem();
557
-		$item->setLabel( 'test' );
558
-		$item->setId( '-1' );
557
+		$item->setLabel('test');
558
+		$item->setId('-1');
559 559
 
560
-		$productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' )
561
-			->will( $this->returnValue( $productManagerStub->createItem() ) );
562
-		$productManagerStub->expects( $this->exactly( 2 ) )->method( 'getItem' )
563
-			->will( $this->returnValue( $item ) );
560
+		$productManagerStub->expects($this->exactly(2))->method('saveItem')
561
+			->will($this->returnValue($productManagerStub->createItem()));
562
+		$productManagerStub->expects($this->exactly(2))->method('getItem')
563
+			->will($this->returnValue($item));
564 564
 
565 565
 
566 566
 		$body = '{"data": [{"type": "product", "attributes": {"product.label": "test"}}, {"type": "product", "attributes": {"product.label": "test"}}]}';
567
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
567
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
568 568
 
569
-		$response = $this->object->post( $request, $this->view->response() );
570
-		$result = json_decode( (string) $response->getBody(), true );
569
+		$response = $this->object->post($request, $this->view->response());
570
+		$result = json_decode((string) $response->getBody(), true);
571 571
 
572 572
 
573
-		$this->assertEquals( 201, $response->getStatusCode() );
574
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
573
+		$this->assertEquals(201, $response->getStatusCode());
574
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
575 575
 
576
-		$this->assertEquals( 2, $result['meta']['total'] );
577
-		$this->assertArrayHasKey( 'data', $result );
578
-		$this->assertEquals( 2, count( $result['data'] ) );
579
-		$this->assertEquals( '-1', $result['data'][0]['id'] );
580
-		$this->assertEquals( 'product', $result['data'][0]['type'] );
581
-		$this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] );
576
+		$this->assertEquals(2, $result['meta']['total']);
577
+		$this->assertArrayHasKey('data', $result);
578
+		$this->assertEquals(2, count($result['data']));
579
+		$this->assertEquals('-1', $result['data'][0]['id']);
580
+		$this->assertEquals('product', $result['data'][0]['type']);
581
+		$this->assertEquals('test', $result['data'][0]['attributes']['product.label']);
582 582
 
583
-		$this->assertArrayNotHasKey( 'included', $result );
584
-		$this->assertArrayNotHasKey( 'errors', $result );
583
+		$this->assertArrayNotHasKey('included', $result);
584
+		$this->assertArrayNotHasKey('errors', $result);
585 585
 	}
586 586
 
587 587
 
588 588
 	public function testPostRelationships()
589 589
 	{
590
-		$productManagerStub = $this->getProductMock( array( 'getSubManager', 'createItem', 'getItem', 'saveItem' ) );
591
-		$productManagerListsStub = $this->getProductListsMock( array( 'saveItem' ) );
590
+		$productManagerStub = $this->getProductMock(array('getSubManager', 'createItem', 'getItem', 'saveItem'));
591
+		$productManagerListsStub = $this->getProductListsMock(array('saveItem'));
592 592
 
593 593
 		$item = new \Aimeos\MShop\Product\Item\Standard();
594
-		$item->setId( '-1' );
594
+		$item->setId('-1');
595 595
 
596
-		$productManagerStub->expects( $this->exactly( 2 ) )->method( 'createItem' )
597
-			->will( $this->returnValue( $item ) );
598
-		$productManagerStub->expects( $this->any() )->method( 'getItem' )
599
-			->will( $this->returnValue( $item ) );
600
-		$productManagerStub->expects( $this->once() )->method( 'getSubManager' )
601
-			->will( $this->returnValue( $productManagerListsStub ) );
602
-		$productManagerStub->expects( $this->once() )->method( 'saveItem' )
603
-			->will( $this->returnValue( $productManagerStub->createItem() ) );
596
+		$productManagerStub->expects($this->exactly(2))->method('createItem')
597
+			->will($this->returnValue($item));
598
+		$productManagerStub->expects($this->any())->method('getItem')
599
+			->will($this->returnValue($item));
600
+		$productManagerStub->expects($this->once())->method('getSubManager')
601
+			->will($this->returnValue($productManagerListsStub));
602
+		$productManagerStub->expects($this->once())->method('saveItem')
603
+			->will($this->returnValue($productManagerStub->createItem()));
604 604
 
605
-		$productManagerListsStub->expects( $this->once() )->method( 'saveItem' );
605
+		$productManagerListsStub->expects($this->once())->method('saveItem');
606 606
 
607 607
 		$body = '{"data": {"type": "product",
608 608
 			"attributes": {"product.label": "test"},
@@ -610,213 +610,213 @@  discard block
 block discarded – undo
610 610
 				{"type": "text", "id": "-2", "attributes": {"product.lists.type": "default"}}
611 611
 			]}}
612 612
 		}}';
613
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
613
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
614 614
 
615
-		$response = $this->object->post( $request, $this->view->response() );
616
-		$result = json_decode( (string) $response->getBody(), true );
615
+		$response = $this->object->post($request, $this->view->response());
616
+		$result = json_decode((string) $response->getBody(), true);
617 617
 
618 618
 
619
-		$this->assertEquals( 201, $response->getStatusCode() );
620
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
619
+		$this->assertEquals(201, $response->getStatusCode());
620
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
621 621
 
622
-		$this->assertEquals( 1, $result['meta']['total'] );
623
-		$this->assertArrayHasKey( 'data', $result );
624
-		$this->assertEquals( '-1', $result['data']['id'] );
625
-		$this->assertEquals( 'product', $result['data']['type'] );
626
-		$this->assertEquals( 'test', $result['data']['attributes']['product.label'] );
622
+		$this->assertEquals(1, $result['meta']['total']);
623
+		$this->assertArrayHasKey('data', $result);
624
+		$this->assertEquals('-1', $result['data']['id']);
625
+		$this->assertEquals('product', $result['data']['type']);
626
+		$this->assertEquals('test', $result['data']['attributes']['product.label']);
627 627
 
628
-		$this->assertArrayNotHasKey( 'included', $result );
629
-		$this->assertArrayNotHasKey( 'errors', $result );
628
+		$this->assertArrayNotHasKey('included', $result);
629
+		$this->assertArrayNotHasKey('errors', $result);
630 630
 	}
631 631
 
632 632
 
633 633
 	public function testPostInvalid()
634 634
 	{
635 635
 		$body = '{"data":null}';
636
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
636
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
637 637
 
638
-		$response = $this->object->post( $request, $this->view->response() );
639
-		$result = json_decode( (string) $response->getBody(), true );
638
+		$response = $this->object->post($request, $this->view->response());
639
+		$result = json_decode((string) $response->getBody(), true);
640 640
 
641 641
 
642
-		$this->assertEquals( 400, $response->getStatusCode() );
643
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
642
+		$this->assertEquals(400, $response->getStatusCode());
643
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
644 644
 
645
-		$this->assertEquals( 0, $result['meta']['total'] );
646
-		$this->assertArrayHasKey( 'errors', $result );
647
-		$this->assertArrayNotHasKey( 'included', $result );
648
-		$this->assertArrayNotHasKey( 'data', $result );
645
+		$this->assertEquals(0, $result['meta']['total']);
646
+		$this->assertArrayHasKey('errors', $result);
647
+		$this->assertArrayNotHasKey('included', $result);
648
+		$this->assertArrayNotHasKey('data', $result);
649 649
 	}
650 650
 
651 651
 
652 652
 	public function testPostInvalidId()
653 653
 	{
654 654
 		$body = '{"data":{"id":-1}}';
655
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
655
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
656 656
 
657
-		$response = $this->object->post( $request, $this->view->response() );
658
-		$result = json_decode( (string) $response->getBody(), true );
657
+		$response = $this->object->post($request, $this->view->response());
658
+		$result = json_decode((string) $response->getBody(), true);
659 659
 
660 660
 
661
-		$this->assertEquals( 403, $response->getStatusCode() );
662
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
661
+		$this->assertEquals(403, $response->getStatusCode());
662
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
663 663
 
664
-		$this->assertEquals( 0, $result['meta']['total'] );
665
-		$this->assertArrayHasKey( 'errors', $result );
664
+		$this->assertEquals(0, $result['meta']['total']);
665
+		$this->assertArrayHasKey('errors', $result);
666 666
 	}
667 667
 
668 668
 
669 669
 	public function testPostException()
670 670
 	{
671
-		$this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' )
672
-			->will( $this->throwException( new \RuntimeException( 'test exception' ) ) );
671
+		$this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem')
672
+			->will($this->throwException(new \RuntimeException('test exception')));
673 673
 
674 674
 		$body = '{"data":{}}';
675
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
675
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
676 676
 
677
-		$response = $this->object->post( $request, $this->view->response() );
678
-		$result = json_decode( (string) $response->getBody(), true );
677
+		$response = $this->object->post($request, $this->view->response());
678
+		$result = json_decode((string) $response->getBody(), true);
679 679
 
680 680
 
681
-		$this->assertEquals( 500, $response->getStatusCode() );
682
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
683
-		$this->assertArrayHasKey( 'errors', $result );
681
+		$this->assertEquals(500, $response->getStatusCode());
682
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
683
+		$this->assertArrayHasKey('errors', $result);
684 684
 	}
685 685
 
686 686
 
687 687
 	public function testPostMShopException()
688 688
 	{
689
-		$this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' )
690
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
689
+		$this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem')
690
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
691 691
 
692 692
 		$body = '{"data":{}}';
693
-		$request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) );
693
+		$request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body));
694 694
 
695
-		$response = $this->object->post( $request, $this->view->response() );
696
-		$result = json_decode( (string) $response->getBody(), true );
695
+		$response = $this->object->post($request, $this->view->response());
696
+		$result = json_decode((string) $response->getBody(), true);
697 697
 
698 698
 
699
-		$this->assertEquals( 404, $response->getStatusCode() );
700
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
701
-		$this->assertArrayHasKey( 'errors', $result );
699
+		$this->assertEquals(404, $response->getStatusCode());
700
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
701
+		$this->assertArrayHasKey('errors', $result);
702 702
 	}
703 703
 
704 704
 
705 705
 	public function testPut()
706 706
 	{
707
-		$response = $this->object->put( $this->view->request(), $this->view->response() );
708
-		$result = json_decode( (string) $response->getBody(), true );
707
+		$response = $this->object->put($this->view->request(), $this->view->response());
708
+		$result = json_decode((string) $response->getBody(), true);
709 709
 
710
-		$this->assertEquals( 501, $response->getStatusCode() );
711
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
712
-		$this->assertArrayHasKey( 'errors', $result );
710
+		$this->assertEquals(501, $response->getStatusCode());
711
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
712
+		$this->assertArrayHasKey('errors', $result);
713 713
 	}
714 714
 
715 715
 
716 716
 	public function testOptions()
717 717
 	{
718
-		$response = $this->object->options( $this->view->request(), $this->view->response() );
719
-		$result = json_decode( (string) $response->getBody(), true );
718
+		$response = $this->object->options($this->view->request(), $this->view->response());
719
+		$result = json_decode((string) $response->getBody(), true);
720 720
 
721 721
 
722
-		$this->assertEquals( 200, $response->getStatusCode() );
723
-		$this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) );
724
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
722
+		$this->assertEquals(200, $response->getStatusCode());
723
+		$this->assertEquals(1, count($response->getHeader('Allow')));
724
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
725 725
 
726
-		$this->assertNull( $result['meta']['prefix'] );
727
-		$this->assertGreaterThan( 65, count( $result['meta']['resources'] ) );
728
-		$this->assertGreaterThan( 0, count( $result['meta']['attributes'] ) );
726
+		$this->assertNull($result['meta']['prefix']);
727
+		$this->assertGreaterThan(65, count($result['meta']['resources']));
728
+		$this->assertGreaterThan(0, count($result['meta']['attributes']));
729 729
 
730
-		$this->assertArrayNotHasKey( 'errors', $result );
730
+		$this->assertArrayNotHasKey('errors', $result);
731 731
 	}
732 732
 
733 733
 
734 734
 	public function testOptionsWithPrefix()
735 735
 	{
736 736
 		$this->view->prefix = 'prefix';
737
-		$response = $this->object->options( $this->view->request(), $this->view->response() );
738
-		$result = json_decode( (string) $response->getBody(), true );
737
+		$response = $this->object->options($this->view->request(), $this->view->response());
738
+		$result = json_decode((string) $response->getBody(), true);
739 739
 
740 740
 
741
-		$this->assertEquals( 200, $response->getStatusCode() );
742
-		$this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) );
743
-		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
741
+		$this->assertEquals(200, $response->getStatusCode());
742
+		$this->assertEquals(1, count($response->getHeader('Allow')));
743
+		$this->assertEquals(1, count($response->getHeader('Content-Type')));
744 744
 
745
-		$this->assertEquals( 'prefix', $result['meta']['prefix'] );
746
-		$this->assertGreaterThan( 65, count( $result['meta']['resources'] ) );
747
-		$this->assertGreaterThan( 0, count( $result['meta']['attributes'] ) );
745
+		$this->assertEquals('prefix', $result['meta']['prefix']);
746
+		$this->assertGreaterThan(65, count($result['meta']['resources']));
747
+		$this->assertGreaterThan(0, count($result['meta']['attributes']));
748 748
 
749
-		$this->assertArrayNotHasKey( 'errors', $result );
749
+		$this->assertArrayNotHasKey('errors', $result);
750 750
 	}
751 751
 
752 752
 
753 753
 	public function testOptionsException()
754 754
 	{
755
-		$this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' )
756
-			->will( $this->throwException( new \RuntimeException( 'test exception' ) ) );
755
+		$this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType')
756
+			->will($this->throwException(new \RuntimeException('test exception')));
757 757
 
758
-		$response = $this->object->options( $this->view->request(), $this->view->response() );
759
-		$result = json_decode( (string) $response->getBody(), true );
758
+		$response = $this->object->options($this->view->request(), $this->view->response());
759
+		$result = json_decode((string) $response->getBody(), true);
760 760
 
761
-		$this->assertEquals( 500, $response->getStatusCode() );
762
-		$this->assertArrayHasKey( 'errors', $result );
761
+		$this->assertEquals(500, $response->getStatusCode());
762
+		$this->assertArrayHasKey('errors', $result);
763 763
 	}
764 764
 
765 765
 
766 766
 	public function testOptionsMShopException()
767 767
 	{
768
-		$this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' )
769
-			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
768
+		$this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType')
769
+			->will($this->throwException(new \Aimeos\MShop\Exception('test exception')));
770 770
 
771
-		$response = $this->object->options( $this->view->request(), $this->view->response() );
772
-		$result = json_decode( (string) $response->getBody(), true );
771
+		$response = $this->object->options($this->view->request(), $this->view->response());
772
+		$result = json_decode((string) $response->getBody(), true);
773 773
 
774
-		$this->assertEquals( 404, $response->getStatusCode() );
775
-		$this->assertArrayHasKey( 'errors', $result );
774
+		$this->assertEquals(404, $response->getStatusCode());
775
+		$this->assertArrayHasKey('errors', $result);
776 776
 	}
777 777
 
778 778
 
779
-	protected function getProductMock( array $methods )
779
+	protected function getProductMock(array $methods)
780 780
 	{
781 781
 		$name = 'ClientJsonAdmStandard';
782
-		$this->context->getConfig()->set( 'mshop/product/manager/name', $name );
782
+		$this->context->getConfig()->set('mshop/product/manager/name', $name);
783 783
 
784
-		$stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Standard' )
785
-			->setConstructorArgs( array( $this->context ) )
786
-			->setMethods( $methods )
784
+		$stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Standard')
785
+			->setConstructorArgs(array($this->context))
786
+			->setMethods($methods)
787 787
 			->getMock();
788 788
 
789
-		\Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub );
789
+		\Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub);
790 790
 
791 791
 		return $stub;
792 792
 	}
793 793
 
794 794
 
795
-	protected function getProductListsMock( array $methods )
795
+	protected function getProductListsMock(array $methods)
796 796
 	{
797 797
 		$name = 'ClientJsonAdmStandard';
798
-		$this->context->getConfig()->set( 'mshop/product/manager/lists/name', $name );
798
+		$this->context->getConfig()->set('mshop/product/manager/lists/name', $name);
799 799
 
800
-		$stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard' )
801
-			->setConstructorArgs( array( $this->context ) )
802
-			->setMethods( $methods )
800
+		$stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard')
801
+			->setConstructorArgs(array($this->context))
802
+			->setMethods($methods)
803 803
 			->getMock();
804 804
 
805
-		\Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub );
805
+		\Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub);
806 806
 
807 807
 		return $stub;
808 808
 	}
809 809
 
810 810
 
811
-	protected function getProductItem( $code = 'CNC' )
811
+	protected function getProductItem($code = 'CNC')
812 812
 	{
813
-		$manager = \Aimeos\MShop::create( $this->context, 'product' );
813
+		$manager = \Aimeos\MShop::create($this->context, 'product');
814 814
 		$search = $manager->createSearch();
815
-		$search->setConditions( $search->compare( '==', 'product.code', $code ) );
816
-		$items = $manager->searchItems( $search );
815
+		$search->setConditions($search->compare('==', 'product.code', $code));
816
+		$items = $manager->searchItems($search);
817 817
 
818
-		if( ( $item = reset( $items ) ) === false ) {
819
-			throw new \RuntimeException( sprintf( 'No product item with code "%1$s" found', $code ) );
818
+		if (($item = reset($items)) === false) {
819
+			throw new \RuntimeException(sprintf('No product item with code "%1$s" found', $code));
820 820
 		}
821 821
 
822 822
 		return $item;
Please login to merge, or discard this patch.