@@ -112,6 +112,7 @@ |
||
112 | 112 | * |
113 | 113 | * @param string Resource location, e.g. "customer" |
114 | 114 | * @param string Related resource location, e.g. "address" |
115 | + * @param string $related |
|
115 | 116 | * @return \Aimeos\Client\JsonApi\Iface JSON API client |
116 | 117 | */ |
117 | 118 | protected function createClient( $resource, $related ) |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | * @param string Related resource location, e.g. "address" |
32 | 32 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
33 | 33 | */ |
34 | - public function deleteAction( ServerRequestInterface $request, $resource, $related = '' ) |
|
34 | + public function deleteAction(ServerRequestInterface $request, $resource, $related = '') |
|
35 | 35 | { |
36 | - return $this->createClient( $resource, $related )->delete( $request, new Response() ); |
|
36 | + return $this->createClient($resource, $related)->delete($request, new Response()); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @param string Related resource location, e.g. "address" |
46 | 46 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
47 | 47 | */ |
48 | - public function getAction( ServerRequestInterface $request, $resource, $related = '' ) |
|
48 | + public function getAction(ServerRequestInterface $request, $resource, $related = '') |
|
49 | 49 | { |
50 | - return $this->createClient( $resource, $related )->get( $request, new Response() ); |
|
50 | + return $this->createClient($resource, $related)->get($request, new Response()); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | * @param string Related resource location, e.g. "address" |
60 | 60 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
61 | 61 | */ |
62 | - public function patchAction( ServerRequestInterface $request, $resource, $related = '' ) |
|
62 | + public function patchAction(ServerRequestInterface $request, $resource, $related = '') |
|
63 | 63 | { |
64 | - return $this->createClient( $resource, $related )->patch( $request, new Response() ); |
|
64 | + return $this->createClient($resource, $related)->patch($request, new Response()); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | * @param string Related resource location, e.g. "address" |
74 | 74 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
75 | 75 | */ |
76 | - public function postAction( ServerRequestInterface $request, $resource, $related = '' ) |
|
76 | + public function postAction(ServerRequestInterface $request, $resource, $related = '') |
|
77 | 77 | { |
78 | - return $this->createClient( $resource, $related )->post( $request, new Response() ); |
|
78 | + return $this->createClient($resource, $related)->post($request, new Response()); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @param string Related resource location, e.g. "address" |
88 | 88 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
89 | 89 | */ |
90 | - public function putAction( ServerRequestInterface $request, $resource, $related = '' ) |
|
90 | + public function putAction(ServerRequestInterface $request, $resource, $related = '') |
|
91 | 91 | { |
92 | - return $this->createClient( $resource, $related )->put( $request, new Response() ); |
|
92 | + return $this->createClient($resource, $related)->put($request, new Response()); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * @param string Related resource location, e.g. "address" |
102 | 102 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
103 | 103 | */ |
104 | - public function optionsAction( ServerRequestInterface $request, $resource = '', $related = '' ) |
|
104 | + public function optionsAction(ServerRequestInterface $request, $resource = '', $related = '') |
|
105 | 105 | { |
106 | - return $this->createClient( $resource, $related )->options( $request, new Response() ); |
|
106 | + return $this->createClient($resource, $related)->options($request, new Response()); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | * @param string Related resource location, e.g. "address" |
115 | 115 | * @return \Aimeos\Client\JsonApi\Iface JSON API client |
116 | 116 | */ |
117 | - protected function createClient( $resource, $related ) |
|
117 | + protected function createClient($resource, $related) |
|
118 | 118 | { |
119 | - $tmplPaths = $this->container->get( 'aimeos' )->get()->getCustomPaths( 'client/jsonapi/templates' ); |
|
120 | - $context = $this->container->get( 'aimeos_context' )->get(); |
|
119 | + $tmplPaths = $this->container->get('aimeos')->get()->getCustomPaths('client/jsonapi/templates'); |
|
120 | + $context = $this->container->get('aimeos_context')->get(); |
|
121 | 121 | $langid = $context->getLocale()->getLanguageId(); |
122 | 122 | |
123 | - $view = $this->container->get( 'aimeos_view' )->create( $context, $tmplPaths, $langid ); |
|
124 | - $context->setView( $view ); |
|
123 | + $view = $this->container->get('aimeos_view')->create($context, $tmplPaths, $langid); |
|
124 | + $context->setView($view); |
|
125 | 125 | |
126 | - return \Aimeos\Client\JsonApi\Factory::createClient( $context, $tmplPaths, $resource . '/' . $related ); |
|
126 | + return \Aimeos\Client\JsonApi\Factory::createClient($context, $tmplPaths, $resource.'/'.$related); |
|
127 | 127 | } |
128 | 128 | } |
@@ -10,60 +10,60 @@ 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 testGetAttributeAction() |
26 | 26 | { |
27 | 27 | $client = static::createClient(); |
28 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/attribute', [] ); |
|
28 | + $client->request('GET', '/unittest/de/EUR/jsonapi/attribute', []); |
|
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( 200, $response->getStatusCode() ); |
|
35 | - $this->assertEquals( 24, $json['meta']['total'] ); |
|
36 | - $this->assertEquals( 24, count( $json['data'] ) ); |
|
33 | + $this->assertNotNull($json); |
|
34 | + $this->assertEquals(200, $response->getStatusCode()); |
|
35 | + $this->assertEquals(24, $json['meta']['total']); |
|
36 | + $this->assertEquals(24, count($json['data'])); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
40 | 40 | public function testGetCatalogAction() |
41 | 41 | { |
42 | 42 | $client = static::createClient(); |
43 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/catalog', [] ); |
|
43 | + $client->request('GET', '/unittest/de/EUR/jsonapi/catalog', []); |
|
44 | 44 | $response = $client->getResponse(); |
45 | 45 | |
46 | - $json = json_decode( $response->getContent(), true ); |
|
46 | + $json = json_decode($response->getContent(), true); |
|
47 | 47 | |
48 | - $this->assertNotNull( $json ); |
|
49 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
50 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
51 | - $this->assertEquals( 4, count( $json['data'] ) ); |
|
48 | + $this->assertNotNull($json); |
|
49 | + $this->assertEquals(200, $response->getStatusCode()); |
|
50 | + $this->assertEquals(1, $json['meta']['total']); |
|
51 | + $this->assertEquals(4, count($json['data'])); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | public function testGetLocaleAction() |
56 | 56 | { |
57 | 57 | $client = static::createClient(); |
58 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/locale', [] ); |
|
58 | + $client->request('GET', '/unittest/de/EUR/jsonapi/locale', []); |
|
59 | 59 | $response = $client->getResponse(); |
60 | 60 | |
61 | - $json = json_decode( $response->getContent(), true ); |
|
61 | + $json = json_decode($response->getContent(), true); |
|
62 | 62 | |
63 | - $this->assertNotNull( $json ); |
|
64 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
65 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
66 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
63 | + $this->assertNotNull($json); |
|
64 | + $this->assertEquals(200, $response->getStatusCode()); |
|
65 | + $this->assertEquals(1, $json['meta']['total']); |
|
66 | + $this->assertEquals(1, count($json['data'])); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -72,60 +72,60 @@ discard block |
||
72 | 72 | $client = static::createClient(); |
73 | 73 | |
74 | 74 | $params = ['filter' => ['f_search' => 'Cafe Noire Cap', 'f_listtype' => 'unittype19']]; |
75 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/product', $params ); |
|
75 | + $client->request('GET', '/unittest/de/EUR/jsonapi/product', $params); |
|
76 | 76 | $response = $client->getResponse(); |
77 | 77 | |
78 | - $json = json_decode( $response->getContent(), true ); |
|
78 | + $json = json_decode($response->getContent(), true); |
|
79 | 79 | |
80 | - $this->assertNotNull( $json ); |
|
81 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
82 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
83 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
84 | - $this->assertArrayHasKey( 'id', $json['data'][0] ); |
|
85 | - $this->assertEquals( 'CNC', $json['data'][0]['attributes']['product.code'] ); |
|
80 | + $this->assertNotNull($json); |
|
81 | + $this->assertEquals(200, $response->getStatusCode()); |
|
82 | + $this->assertEquals(1, $json['meta']['total']); |
|
83 | + $this->assertEquals(1, count($json['data'])); |
|
84 | + $this->assertArrayHasKey('id', $json['data'][0]); |
|
85 | + $this->assertEquals('CNC', $json['data'][0]['attributes']['product.code']); |
|
86 | 86 | |
87 | 87 | $id = $json['data'][0]['id']; |
88 | 88 | |
89 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/product/' . $id ); |
|
89 | + $client->request('GET', '/unittest/de/EUR/jsonapi/product/'.$id); |
|
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->assertArrayHasKey( 'id', $json['data'] ); |
|
98 | - $this->assertEquals( 'CNC', $json['data']['attributes']['product.code'] ); |
|
94 | + $this->assertNotNull($json); |
|
95 | + $this->assertEquals(200, $response->getStatusCode()); |
|
96 | + $this->assertEquals(1, $json['meta']['total']); |
|
97 | + $this->assertArrayHasKey('id', $json['data']); |
|
98 | + $this->assertEquals('CNC', $json['data']['attributes']['product.code']); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | 102 | public function testGetServiceAction() |
103 | 103 | { |
104 | 104 | $client = static::createClient(); |
105 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/service', [] ); |
|
105 | + $client->request('GET', '/unittest/de/EUR/jsonapi/service', []); |
|
106 | 106 | $response = $client->getResponse(); |
107 | 107 | |
108 | - $json = json_decode( $response->getContent(), true ); |
|
108 | + $json = json_decode($response->getContent(), true); |
|
109 | 109 | |
110 | - $this->assertNotNull( $json ); |
|
111 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
112 | - $this->assertEquals( 4, $json['meta']['total'] ); |
|
113 | - $this->assertEquals( 4, count( $json['data'] ) ); |
|
110 | + $this->assertNotNull($json); |
|
111 | + $this->assertEquals(200, $response->getStatusCode()); |
|
112 | + $this->assertEquals(4, $json['meta']['total']); |
|
113 | + $this->assertEquals(4, count($json['data'])); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
117 | 117 | public function testGetStockAction() |
118 | 118 | { |
119 | 119 | $client = static::createClient(); |
120 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/stock', ['filter' => ['s_prodcode' => ['CNC', 'CNE']]] ); |
|
120 | + $client->request('GET', '/unittest/de/EUR/jsonapi/stock', ['filter' => ['s_prodcode' => ['CNC', 'CNE']]]); |
|
121 | 121 | $response = $client->getResponse(); |
122 | 122 | |
123 | - $json = json_decode( $response->getContent(), true ); |
|
123 | + $json = json_decode($response->getContent(), true); |
|
124 | 124 | |
125 | - $this->assertNotNull( $json ); |
|
126 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
127 | - $this->assertEquals( 2, $json['meta']['total'] ); |
|
128 | - $this->assertEquals( 2, count( $json['data'] ) ); |
|
125 | + $this->assertNotNull($json); |
|
126 | + $this->assertEquals(200, $response->getStatusCode()); |
|
127 | + $this->assertEquals(2, $json['meta']['total']); |
|
128 | + $this->assertEquals(2, count($json['data'])); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -133,24 +133,24 @@ discard block |
||
133 | 133 | { |
134 | 134 | $client = static::createClient(); |
135 | 135 | |
136 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
137 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
138 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
136 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
137 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
138 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
139 | 139 | |
140 | 140 | // catalog root |
141 | - $client->request( 'GET', $json['meta']['resources']['catalog'], ['include' => 'catalog'] ); |
|
142 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
143 | - $this->assertEquals( 'categories', $json['included'][0]['attributes']['catalog.code'] ); |
|
141 | + $client->request('GET', $json['meta']['resources']['catalog'], ['include' => 'catalog']); |
|
142 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
143 | + $this->assertEquals('categories', $json['included'][0]['attributes']['catalog.code']); |
|
144 | 144 | |
145 | 145 | // "categories" category |
146 | - $client->request( 'GET', $json['included'][0]['links']['self']['href'], ['include' => 'catalog'] ); |
|
147 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
148 | - $this->assertEquals( 'cafe', $json['included'][0]['attributes']['catalog.code'] ); |
|
146 | + $client->request('GET', $json['included'][0]['links']['self']['href'], ['include' => 'catalog']); |
|
147 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
148 | + $this->assertEquals('cafe', $json['included'][0]['attributes']['catalog.code']); |
|
149 | 149 | |
150 | 150 | // product list for "cafe" category |
151 | - $client->request( 'GET', $json['included'][0]['links']['product']['href'] ); |
|
152 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
153 | - $this->assertEquals( 'CNE', $json['data'][0]['attributes']['product.code'] ); |
|
151 | + $client->request('GET', $json['included'][0]['links']['product']['href']); |
|
152 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
153 | + $this->assertEquals('CNE', $json['data'][0]['attributes']['product.code']); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -158,26 +158,26 @@ discard block |
||
158 | 158 | { |
159 | 159 | $client = static::createClient(); |
160 | 160 | |
161 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
162 | - $options = json_decode( $client->getResponse()->getContent(), true ); |
|
163 | - $this->assertGreaterThan( 8, count( $options['meta']['resources'] ) ); |
|
161 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
162 | + $options = json_decode($client->getResponse()->getContent(), true); |
|
163 | + $this->assertGreaterThan(8, count($options['meta']['resources'])); |
|
164 | 164 | |
165 | 165 | // all available attrbutes |
166 | - $client->request( 'GET', $options['meta']['resources']['attribute'] ); |
|
167 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
166 | + $client->request('GET', $options['meta']['resources']['attribute']); |
|
167 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
168 | 168 | |
169 | - foreach( $json['data'] as $entry ) |
|
169 | + foreach ($json['data'] as $entry) |
|
170 | 170 | { |
171 | - if( $entry['attributes']['attribute.code'] === 'xl' ) |
|
171 | + if ($entry['attributes']['attribute.code'] === 'xl') |
|
172 | 172 | { |
173 | 173 | // products with attrbute "xl" |
174 | - $client->request( 'GET', $options['meta']['resources']['product'], ['filter' => ['f_attrid' => $entry['id']]] ); |
|
174 | + $client->request('GET', $options['meta']['resources']['product'], ['filter' => ['f_attrid' => $entry['id']]]); |
|
175 | 175 | break; |
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
180 | - $this->assertEquals( 2, $json['meta']['total'] ); |
|
179 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
180 | + $this->assertEquals(2, $json['meta']['total']); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | |
@@ -185,14 +185,14 @@ discard block |
||
185 | 185 | { |
186 | 186 | $client = static::createClient(); |
187 | 187 | |
188 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
189 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
190 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
188 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
189 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
190 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
191 | 191 | |
192 | 192 | // product list for full text search |
193 | - $client->request( 'GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'selection']] ); |
|
194 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
195 | - $this->assertEquals( 3, count( $json['data'] ) ); |
|
193 | + $client->request('GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'selection']]); |
|
194 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
195 | + $this->assertEquals(3, count($json['data'])); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -200,23 +200,23 @@ discard block |
||
200 | 200 | { |
201 | 201 | $client = static::createClient(); |
202 | 202 | |
203 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
204 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
205 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
203 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
204 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
205 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
206 | 206 | |
207 | 207 | // get empty basket |
208 | - $client->request( 'GET', $json['meta']['resources']['basket'] ); |
|
209 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
210 | - $this->assertEquals( 'basket', $json['data']['type'] ); |
|
208 | + $client->request('GET', $json['meta']['resources']['basket']); |
|
209 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
210 | + $this->assertEquals('basket', $json['data']['type']); |
|
211 | 211 | |
212 | 212 | $content = '{"data": {"id": "delivery", "attributes": {"order.base.address.firstname": "test"}}}'; |
213 | - $client->request( 'POST', $json['links']['basket/address']['href'], [], [], [], $content ); |
|
214 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
215 | - $this->assertEquals( 'basket/address', $json['included'][0]['type'] ); |
|
213 | + $client->request('POST', $json['links']['basket/address']['href'], [], [], [], $content); |
|
214 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
215 | + $this->assertEquals('basket/address', $json['included'][0]['type']); |
|
216 | 216 | |
217 | - $client->request( 'DELETE', $json['included'][0]['links']['self']['href'] ); |
|
218 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
219 | - $this->assertEquals( 0, count( $json['included'] ) ); |
|
217 | + $client->request('DELETE', $json['included'][0]['links']['self']['href']); |
|
218 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
219 | + $this->assertEquals(0, count($json['included'])); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | |
@@ -224,31 +224,31 @@ discard block |
||
224 | 224 | { |
225 | 225 | $client = static::createClient(); |
226 | 226 | |
227 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
228 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
229 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
227 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
228 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
229 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
230 | 230 | |
231 | 231 | // product for code "CNC" |
232 | - $client->request( 'GET', $json['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]] ); |
|
233 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
234 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
232 | + $client->request('GET', $json['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]]); |
|
233 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
234 | + $this->assertEquals(1, count($json['data'])); |
|
235 | 235 | |
236 | 236 | // add product "CNC" as prerequisite |
237 | - $content = '{"data": {"attributes": {"product.id": ' . $json['data'][0]['id'] . '}}}'; |
|
238 | - $client->request( 'POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content ); |
|
239 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
240 | - $this->assertEquals( 'basket/product', $json['included'][0]['type'] ); |
|
237 | + $content = '{"data": {"attributes": {"product.id": '.$json['data'][0]['id'].'}}}'; |
|
238 | + $client->request('POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content); |
|
239 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
240 | + $this->assertEquals('basket/product', $json['included'][0]['type']); |
|
241 | 241 | |
242 | 242 | // add coupon "GHIJ" |
243 | 243 | $content = '{"data": {"id": "GHIJ"}}'; |
244 | - $client->request( 'POST', $json['links']['basket/coupon']['href'], [], [], [], $content ); |
|
245 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
246 | - $this->assertEquals( 'basket/coupon', $json['included'][2]['type'] ); |
|
244 | + $client->request('POST', $json['links']['basket/coupon']['href'], [], [], [], $content); |
|
245 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
246 | + $this->assertEquals('basket/coupon', $json['included'][2]['type']); |
|
247 | 247 | |
248 | 248 | // remove coupon "GHIJ" again |
249 | - $client->request( 'DELETE', $json['included'][2]['links']['self']['href'] ); |
|
250 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
251 | - $this->assertEquals( 1, count( $json['included'] ) ); |
|
249 | + $client->request('DELETE', $json['included'][2]['links']['self']['href']); |
|
250 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
251 | + $this->assertEquals(1, count($json['included'])); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | |
@@ -256,28 +256,28 @@ discard block |
||
256 | 256 | { |
257 | 257 | $client = static::createClient(); |
258 | 258 | |
259 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
260 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
261 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
259 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
260 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
261 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
262 | 262 | |
263 | 263 | // product for code "CNC" |
264 | - $client->request( 'GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'ABCD']] ); |
|
265 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
266 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
264 | + $client->request('GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'ABCD']]); |
|
265 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
266 | + $this->assertEquals(1, count($json['data'])); |
|
267 | 267 | |
268 | - $content = '{"data": {"attributes": {"product.id": ' . $json['data'][0]['id'] . '}}}'; |
|
269 | - $client->request( 'POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content ); |
|
270 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
271 | - $this->assertEquals( 'basket/product', $json['included'][0]['type'] ); |
|
268 | + $content = '{"data": {"attributes": {"product.id": '.$json['data'][0]['id'].'}}}'; |
|
269 | + $client->request('POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content); |
|
270 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
271 | + $this->assertEquals('basket/product', $json['included'][0]['type']); |
|
272 | 272 | |
273 | 273 | $content = '{"data": {"attributes": {"quantity": 2}}}'; |
274 | - $client->request( 'PATCH', $json['included'][0]['links']['self']['href'], [], [], [], $content ); |
|
275 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
276 | - $this->assertEquals( 2, $json['included'][0]['attributes']['order.base.product.quantity'] ); |
|
274 | + $client->request('PATCH', $json['included'][0]['links']['self']['href'], [], [], [], $content); |
|
275 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
276 | + $this->assertEquals(2, $json['included'][0]['attributes']['order.base.product.quantity']); |
|
277 | 277 | |
278 | - $client->request( 'DELETE', $json['included'][0]['links']['self']['href'] ); |
|
279 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
280 | - $this->assertEquals( 0, count( $json['included'] ) ); |
|
278 | + $client->request('DELETE', $json['included'][0]['links']['self']['href']); |
|
279 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
280 | + $this->assertEquals(0, count($json['included'])); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -285,14 +285,14 @@ discard block |
||
285 | 285 | { |
286 | 286 | $client = static::createClient(); |
287 | 287 | |
288 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
289 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
290 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
288 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
289 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
290 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
291 | 291 | |
292 | 292 | // payment services |
293 | - $client->request( 'GET', $json['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']] ); |
|
294 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
295 | - $this->assertEquals( 3, count( $json['data'] ) ); |
|
293 | + $client->request('GET', $json['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']]); |
|
294 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
295 | + $this->assertEquals(3, count($json['data'])); |
|
296 | 296 | |
297 | 297 | $content = ['data' => ['id' => 'payment', 'attributes' => [ |
298 | 298 | 'service.id' => $json['data'][1]['id'], |
@@ -301,15 +301,15 @@ discard block |
||
301 | 301 | 'directdebit.bankcode' => 'ABCDEFGH', |
302 | 302 | 'directdebit.bankname' => 'test bank', |
303 | 303 | ]]]; |
304 | - $client->request( 'POST', $json['data'][1]['links']['basket/service']['href'], [], [], [], json_encode( $content ) ); |
|
305 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
306 | - $this->assertEquals( 'basket/service', $json['included'][0]['type'] ); |
|
307 | - $this->assertEquals( 'directdebit-test', $json['included'][0]['attributes']['order.base.service.code'] ); |
|
308 | - $this->assertEquals( 5, count( $json['included'][0]['attributes']['attribute'] ) ); |
|
309 | - |
|
310 | - $client->request( 'DELETE', $json['included'][0]['links']['self']['href'] ); |
|
311 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
312 | - $this->assertEquals( 0, count( $json['included'] ) ); |
|
304 | + $client->request('POST', $json['data'][1]['links']['basket/service']['href'], [], [], [], json_encode($content)); |
|
305 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
306 | + $this->assertEquals('basket/service', $json['included'][0]['type']); |
|
307 | + $this->assertEquals('directdebit-test', $json['included'][0]['attributes']['order.base.service.code']); |
|
308 | + $this->assertEquals(5, count($json['included'][0]['attributes']['attribute'])); |
|
309 | + |
|
310 | + $client->request('DELETE', $json['included'][0]['links']['self']['href']); |
|
311 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
312 | + $this->assertEquals(0, count($json['included'])); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -318,17 +318,17 @@ discard block |
||
318 | 318 | $client = static::createClient(array(), array( |
319 | 319 | 'PHP_AUTH_USER' => 'UTC001', |
320 | 320 | 'PHP_AUTH_PW' => 'unittest', |
321 | - ) ); |
|
321 | + )); |
|
322 | 322 | |
323 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/customer', [] ); |
|
323 | + $client->request('GET', '/unittest/de/EUR/jsonapi/customer', []); |
|
324 | 324 | $response = $client->getResponse(); |
325 | 325 | |
326 | - $json = json_decode( $response->getContent(), true ); |
|
326 | + $json = json_decode($response->getContent(), true); |
|
327 | 327 | |
328 | - $this->assertNotNull( $json ); |
|
329 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
330 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
331 | - $this->assertEquals( 4, count( $json['data'] ) ); |
|
328 | + $this->assertNotNull($json); |
|
329 | + $this->assertEquals(200, $response->getStatusCode()); |
|
330 | + $this->assertEquals(1, $json['meta']['total']); |
|
331 | + $this->assertEquals(4, count($json['data'])); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -337,22 +337,22 @@ 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 | - $client->request( 'GET', $json['links']['customer/address']['href'], [] ); |
|
347 | + $client->request('GET', $json['links']['customer/address']['href'], []); |
|
348 | 348 | $response = $client->getResponse(); |
349 | 349 | |
350 | - $json = json_decode( $response->getContent(), true ); |
|
350 | + $json = json_decode($response->getContent(), true); |
|
351 | 351 | |
352 | - $this->assertNotNull( $json ); |
|
353 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
354 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
355 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
352 | + $this->assertNotNull($json); |
|
353 | + $this->assertEquals(200, $response->getStatusCode()); |
|
354 | + $this->assertEquals(1, $json['meta']['total']); |
|
355 | + $this->assertEquals(1, count($json['data'])); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | |
@@ -361,17 +361,17 @@ discard block |
||
361 | 361 | $client = static::createClient(array(), array( |
362 | 362 | 'PHP_AUTH_USER' => 'UTC001', |
363 | 363 | 'PHP_AUTH_PW' => 'unittest', |
364 | - ) ); |
|
364 | + )); |
|
365 | 365 | |
366 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/order', [] ); |
|
366 | + $client->request('GET', '/unittest/de/EUR/jsonapi/order', []); |
|
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( 4, $json['meta']['total'] ); |
|
374 | - $this->assertEquals( 4, count( $json['data'] ) ); |
|
371 | + $this->assertNotNull($json); |
|
372 | + $this->assertEquals(200, $response->getStatusCode()); |
|
373 | + $this->assertEquals(4, $json['meta']['total']); |
|
374 | + $this->assertEquals(4, count($json['data'])); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | |
@@ -379,63 +379,63 @@ discard block |
||
379 | 379 | { |
380 | 380 | $client = static::createClient(); |
381 | 381 | |
382 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
383 | - $optJson = json_decode( $client->getResponse()->getContent(), true ); |
|
384 | - $this->assertGreaterThan( 8, count( $optJson['meta']['resources'] ) ); |
|
382 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
383 | + $optJson = json_decode($client->getResponse()->getContent(), true); |
|
384 | + $this->assertGreaterThan(8, count($optJson['meta']['resources'])); |
|
385 | 385 | |
386 | 386 | // product for code "CNC" |
387 | - $client->request( 'GET', $optJson['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]] ); |
|
388 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
389 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
387 | + $client->request('GET', $optJson['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]]); |
|
388 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
389 | + $this->assertEquals(1, count($json['data'])); |
|
390 | 390 | |
391 | 391 | // add product "CNC" |
392 | - $content = '{"data": {"attributes": {"product.id": ' . $json['data'][0]['id'] . '}}}'; |
|
393 | - $client->request( 'POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content ); |
|
394 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
395 | - $this->assertEquals( 'basket/product', $json['included'][0]['type'] ); |
|
392 | + $content = '{"data": {"attributes": {"product.id": '.$json['data'][0]['id'].'}}}'; |
|
393 | + $client->request('POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content); |
|
394 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
395 | + $this->assertEquals('basket/product', $json['included'][0]['type']); |
|
396 | 396 | |
397 | 397 | // delivery services |
398 | - $client->request( 'GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'delivery']] ); |
|
399 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
400 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
398 | + $client->request('GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'delivery']]); |
|
399 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
400 | + $this->assertEquals(1, count($json['data'])); |
|
401 | 401 | |
402 | 402 | // add delivery service |
403 | - $content = '{"data": {"id": "delivery", "attributes": {"service.id": ' . $json['data'][0]['id'] . '}}}'; |
|
404 | - $client->request( 'POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content ); |
|
405 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
406 | - $this->assertEquals( 'basket/service', $json['included'][1]['type'] ); |
|
403 | + $content = '{"data": {"id": "delivery", "attributes": {"service.id": '.$json['data'][0]['id'].'}}}'; |
|
404 | + $client->request('POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content); |
|
405 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
406 | + $this->assertEquals('basket/service', $json['included'][1]['type']); |
|
407 | 407 | |
408 | 408 | // payment services |
409 | - $client->request( 'GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']] ); |
|
410 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
411 | - $this->assertEquals( 3, count( $json['data'] ) ); |
|
409 | + $client->request('GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']]); |
|
410 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
411 | + $this->assertEquals(3, count($json['data'])); |
|
412 | 412 | |
413 | 413 | // add payment service |
414 | - $content = '{"data": {"id": "payment", "attributes": {"service.id": ' . $json['data'][0]['id'] . '}}}'; |
|
415 | - $client->request( 'POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content ); |
|
416 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
417 | - $this->assertEquals( 'basket/service', $json['included'][2]['type'] ); |
|
414 | + $content = '{"data": {"id": "payment", "attributes": {"service.id": '.$json['data'][0]['id'].'}}}'; |
|
415 | + $client->request('POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content); |
|
416 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
417 | + $this->assertEquals('basket/service', $json['included'][2]['type']); |
|
418 | 418 | |
419 | 419 | // add address |
420 | 420 | $content = '{"data": {"id": "payment", "attributes": {"order.base.address.firstname": "test"}}}'; |
421 | - $client->request( 'POST', $json['links']['basket/address']['href'], [], [], [], $content ); |
|
422 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
423 | - $this->assertEquals( 'basket/address', $json['included'][3]['type'] ); |
|
421 | + $client->request('POST', $json['links']['basket/address']['href'], [], [], [], $content); |
|
422 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
423 | + $this->assertEquals('basket/address', $json['included'][3]['type']); |
|
424 | 424 | |
425 | 425 | // store basket |
426 | - $client->request( 'POST', $json['links']['self']['href'] ); |
|
427 | - $basketJson = json_decode( $client->getResponse()->getContent(), true ); |
|
428 | - $this->assertEquals( true, ctype_digit( $basketJson['data']['id'] ) ); |
|
426 | + $client->request('POST', $json['links']['self']['href']); |
|
427 | + $basketJson = json_decode($client->getResponse()->getContent(), true); |
|
428 | + $this->assertEquals(true, ctype_digit($basketJson['data']['id'])); |
|
429 | 429 | |
430 | 430 | // add order |
431 | - $content = '{"data": {"attributes": {"order.baseid": ' . $basketJson['data']['id'] . '}}}'; |
|
432 | - $client->request( 'POST', $basketJson['links']['order']['href'], [], [], [], $content ); |
|
433 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
434 | - $this->assertEquals( true, ctype_digit( $json['data']['id'] ) ); |
|
431 | + $content = '{"data": {"attributes": {"order.baseid": '.$basketJson['data']['id'].'}}}'; |
|
432 | + $client->request('POST', $basketJson['links']['order']['href'], [], [], [], $content); |
|
433 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
434 | + $this->assertEquals(true, ctype_digit($json['data']['id'])); |
|
435 | 435 | |
436 | 436 | |
437 | 437 | // delete created order |
438 | - $context = static::$kernel->getContainer()->get( 'aimeos_context' )->get(); |
|
439 | - \Aimeos\MShop\Factory::createManager( $context, 'order/base' )->deleteItem( $basketJson['data']['id'] ); |
|
438 | + $context = static::$kernel->getContainer()->get('aimeos_context')->get(); |
|
439 | + \Aimeos\MShop\Factory::createManager($context, 'order/base')->deleteItem($basketJson['data']['id']); |
|
440 | 440 | } |
441 | 441 | } |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * {@inheritdoc} |
30 | 30 | */ |
31 | - public function registerContainerConfiguration( LoaderInterface $loader ) |
|
31 | + public function registerContainerConfiguration(LoaderInterface $loader) |
|
32 | 32 | { |
33 | - $loader->load( __DIR__ . '/config/config.yml' ); |
|
33 | + $loader->load(__DIR__.'/config/config.yml'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function getCacheDir() |
41 | 41 | { |
42 | - return sys_get_temp_dir() . '/aimeos-symfony/cache'; |
|
42 | + return sys_get_temp_dir().'/aimeos-symfony/cache'; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -48,6 +48,6 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function getLogDir() |
50 | 50 | { |
51 | - return sys_get_temp_dir() . '/aimeos-symfony/logs'; |
|
51 | + return sys_get_temp_dir().'/aimeos-symfony/logs'; |
|
52 | 52 | } |
53 | 53 | } |