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