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