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