@@ -115,7 +115,6 @@ |
||
115 | 115 | * |
116 | 116 | * @param \Psr\Http\Message\ServerRequestInterface $request Request object |
117 | 117 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
118 | - * @param string|null $prefix Form parameter prefix when nesting parameters is required |
|
119 | 118 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
120 | 119 | */ |
121 | 120 | public function put( ServerRequestInterface $request, ResponseInterface $response ) |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param array $templatePaths List of file system paths where the templates are stored |
37 | 37 | * @param string $path Name of the client separated by slashes, e.g "catalog/lists" |
38 | 38 | */ |
39 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
|
39 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path) |
|
40 | 40 | { |
41 | 41 | $this->view = $view; |
42 | 42 | $this->context = $context; |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @param array $param List of method parameter |
53 | 53 | * @throws \Aimeos\Client\JsonApi\Exception If method call failed |
54 | 54 | */ |
55 | - public function __call( $name, array $param ) |
|
55 | + public function __call($name, array $param) |
|
56 | 56 | { |
57 | - throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Unable to call method "%1$s"', $name ) ); |
|
57 | + throw new \Aimeos\Client\JsonApi\Exception(sprintf('Unable to call method "%1$s"', $name)); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
66 | 66 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
67 | 67 | */ |
68 | - public function delete( ServerRequestInterface $request, ResponseInterface $response ) |
|
68 | + public function delete(ServerRequestInterface $request, ResponseInterface $response) |
|
69 | 69 | { |
70 | - return $this->defaultAction( $request, $response ); |
|
70 | + return $this->defaultAction($request, $response); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
79 | 79 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
80 | 80 | */ |
81 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
81 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
82 | 82 | { |
83 | - return $this->defaultAction( $request, $response ); |
|
83 | + return $this->defaultAction($request, $response); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
92 | 92 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
93 | 93 | */ |
94 | - public function patch( ServerRequestInterface $request, ResponseInterface $response ) |
|
94 | + public function patch(ServerRequestInterface $request, ResponseInterface $response) |
|
95 | 95 | { |
96 | - return $this->defaultAction( $request, $response ); |
|
96 | + return $this->defaultAction($request, $response); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
105 | 105 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
106 | 106 | */ |
107 | - public function post( ServerRequestInterface $request, ResponseInterface $response ) |
|
107 | + public function post(ServerRequestInterface $request, ResponseInterface $response) |
|
108 | 108 | { |
109 | - return $this->defaultAction( $request, $response ); |
|
109 | + return $this->defaultAction($request, $response); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | * @param string|null $prefix Form parameter prefix when nesting parameters is required |
119 | 119 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
120 | 120 | */ |
121 | - public function put( ServerRequestInterface $request, ResponseInterface $response ) |
|
121 | + public function put(ServerRequestInterface $request, ResponseInterface $response) |
|
122 | 122 | { |
123 | - return $this->defaultAction( $request, $response ); |
|
123 | + return $this->defaultAction($request, $response); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
132 | 132 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
133 | 133 | */ |
134 | - public function options( ServerRequestInterface $request, ResponseInterface $response, $prefix = null ) |
|
134 | + public function options(ServerRequestInterface $request, ResponseInterface $response, $prefix = null) |
|
135 | 135 | { |
136 | - return $this->defaultAction( $request, $response ); |
|
136 | + return $this->defaultAction($request, $response); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
145 | 145 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
146 | 146 | */ |
147 | - protected function defaultAction( ServerRequestInterface $request, ResponseInterface $response ) |
|
147 | + protected function defaultAction(ServerRequestInterface $request, ResponseInterface $response) |
|
148 | 148 | { |
149 | 149 | $status = 403; |
150 | 150 | $view = $this->getView(); |
151 | 151 | |
152 | - $view->errors = array( array( |
|
153 | - 'title' => $this->getContext()->getI18n()->dt( 'client/jsonapi', 'Not allowed for this resource' ), |
|
154 | - ) ); |
|
152 | + $view->errors = array(array( |
|
153 | + 'title' => $this->getContext()->getI18n()->dt('client/jsonapi', 'Not allowed for this resource'), |
|
154 | + )); |
|
155 | 155 | |
156 | 156 | /** client/jsonapi/standard/template-error |
157 | 157 | * Relative path to the default JSON API template |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | $tplconf = 'client/jsonapi/standard/template-error'; |
181 | 181 | $default = 'error-default.php'; |
182 | 182 | |
183 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
183 | + $body = $view->render($view->config($tplconf, $default)); |
|
184 | 184 | |
185 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json' ) |
|
186 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
187 | - ->withStatus( $status ); |
|
185 | + return $response->withHeader('Content-Type', 'application/vnd.api+json') |
|
186 | + ->withBody($view->response()->createStreamFromString($body)) |
|
187 | + ->withStatus($status); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | * @param array $params List of criteria data with condition, sorting and paging |
240 | 240 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
241 | 241 | */ |
242 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
242 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
243 | 243 | { |
244 | - $this->initCriteriaConditions( $criteria, $params ); |
|
245 | - $this->initCriteriaSortations( $criteria, $params ); |
|
246 | - $this->initCriteriaSlice( $criteria, $params ); |
|
244 | + $this->initCriteriaConditions($criteria, $params); |
|
245 | + $this->initCriteriaSortations($criteria, $params); |
|
246 | + $this->initCriteriaSlice($criteria, $params); |
|
247 | 247 | |
248 | 248 | return $criteria; |
249 | 249 | } |
@@ -256,17 +256,17 @@ discard block |
||
256 | 256 | * @param array $params List of criteria data with condition, sorting and paging |
257 | 257 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
258 | 258 | */ |
259 | - protected function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
259 | + protected function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
260 | 260 | { |
261 | - if( !isset( $params['filter'] ) ) { |
|
261 | + if (!isset($params['filter'])) { |
|
262 | 262 | return $criteria; |
263 | 263 | } |
264 | 264 | |
265 | 265 | $existing = $criteria->getConditions(); |
266 | - $criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) ); |
|
266 | + $criteria->setConditions($criteria->toConditions((array) $params['filter'])); |
|
267 | 267 | |
268 | - $expr = array( $criteria->getConditions(), $existing ); |
|
269 | - return $criteria->setConditions( $criteria->combine( '&&', $expr ) ); |
|
268 | + $expr = array($criteria->getConditions(), $existing); |
|
269 | + return $criteria->setConditions($criteria->combine('&&', $expr)); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -277,12 +277,12 @@ discard block |
||
277 | 277 | * @param array $params List of criteria data with condition, sorting and paging |
278 | 278 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
279 | 279 | */ |
280 | - protected function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
280 | + protected function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
281 | 281 | { |
282 | - $start = ( isset( $params['page']['offset'] ) ? (int) $params['page']['offset'] : 0 ); |
|
283 | - $size = ( isset( $params['page']['limit'] ) ? (int) $params['page']['limit'] : 25 ); |
|
282 | + $start = (isset($params['page']['offset']) ? (int) $params['page']['offset'] : 0); |
|
283 | + $size = (isset($params['page']['limit']) ? (int) $params['page']['limit'] : 25); |
|
284 | 284 | |
285 | - return $criteria->setSlice( $start, $size ); |
|
285 | + return $criteria->setSlice($start, $size); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -293,23 +293,23 @@ discard block |
||
293 | 293 | * @param array $params List of criteria data with condition, sorting and paging |
294 | 294 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
295 | 295 | */ |
296 | - protected function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
296 | + protected function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
297 | 297 | { |
298 | - if( !isset( $params['sort'] ) ) { |
|
298 | + if (!isset($params['sort'])) { |
|
299 | 299 | return; |
300 | 300 | } |
301 | 301 | |
302 | 302 | $sortation = array(); |
303 | 303 | |
304 | - foreach( explode( ',', $params['sort'] ) as $sort ) |
|
304 | + foreach (explode(',', $params['sort']) as $sort) |
|
305 | 305 | { |
306 | - if( $sort[0] === '-' ) { |
|
307 | - $sortation[] = $criteria->sort( '-', substr( $sort, 1 ) ); |
|
306 | + if ($sort[0] === '-') { |
|
307 | + $sortation[] = $criteria->sort('-', substr($sort, 1)); |
|
308 | 308 | } else { |
309 | - $sortation[] = $criteria->sort( '+', $sort ); |
|
309 | + $sortation[] = $criteria->sort('+', $sort); |
|
310 | 310 | } |
311 | 311 | } |
312 | 312 | |
313 | - return $criteria->setSortations( $sortation ); |
|
313 | + return $criteria->setSortations($sortation); |
|
314 | 314 | } |
315 | 315 | } |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $context = \TestHelperJapi::getContext(); |
17 | 17 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
18 | 18 | |
19 | - $client = \Aimeos\Client\JsonApi\Factory::createClient( $context, $templatePaths, 'product' ); |
|
20 | - $this->assertInstanceOf( '\Aimeos\Client\JsonApi\Iface', $client ); |
|
19 | + $client = \Aimeos\Client\JsonApi\Factory::createClient($context, $templatePaths, 'product'); |
|
20 | + $this->assertInstanceOf('\Aimeos\Client\JsonApi\Iface', $client); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | $context = \TestHelperJapi::getContext(); |
27 | 27 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
28 | 28 | |
29 | - $client = \Aimeos\Client\JsonApi\Factory::createClient( $context, $templatePaths, '' ); |
|
30 | - $this->assertInstanceOf( '\Aimeos\Client\JsonApi\Iface', $client ); |
|
29 | + $client = \Aimeos\Client\JsonApi\Factory::createClient($context, $templatePaths, ''); |
|
30 | + $this->assertInstanceOf('\Aimeos\Client\JsonApi\Iface', $client); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | $context = \TestHelperJapi::getContext(); |
37 | 37 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
38 | 38 | |
39 | - $this->setExpectedException( '\Aimeos\Client\JsonApi\Exception' ); |
|
40 | - \Aimeos\Client\JsonApi\Factory::createClient( $context, $templatePaths, '%^' ); |
|
39 | + $this->setExpectedException('\Aimeos\Client\JsonApi\Exception'); |
|
40 | + \Aimeos\Client\JsonApi\Factory::createClient($context, $templatePaths, '%^'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -46,68 +46,68 @@ discard block |
||
46 | 46 | $context = \TestHelperJapi::getContext(); |
47 | 47 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
48 | 48 | |
49 | - $this->setExpectedException( '\Aimeos\Client\JsonApi\Exception' ); |
|
50 | - \Aimeos\Client\JsonApi\Factory::createClient( $context, $templatePaths, '', '%^' ); |
|
49 | + $this->setExpectedException('\Aimeos\Client\JsonApi\Exception'); |
|
50 | + \Aimeos\Client\JsonApi\Factory::createClient($context, $templatePaths, '', '%^'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
54 | 54 | public function testClear() |
55 | 55 | { |
56 | - $cache = \Aimeos\Client\JsonApi\Factory::setCache( true ); |
|
56 | + $cache = \Aimeos\Client\JsonApi\Factory::setCache(true); |
|
57 | 57 | |
58 | 58 | $context = \TestHelperJapi::getContext(); |
59 | 59 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
60 | 60 | |
61 | - $client1 = \Aimeos\Client\JsonApi\Factory::createClient( $context, $templatePaths, 'product' ); |
|
61 | + $client1 = \Aimeos\Client\JsonApi\Factory::createClient($context, $templatePaths, 'product'); |
|
62 | 62 | \Aimeos\Client\JsonApi\Factory::clear(); |
63 | - $client2 = \Aimeos\Client\JsonApi\Factory::createClient( $context, $templatePaths, 'product' ); |
|
63 | + $client2 = \Aimeos\Client\JsonApi\Factory::createClient($context, $templatePaths, 'product'); |
|
64 | 64 | |
65 | - \Aimeos\Client\JsonApi\Factory::setCache( $cache ); |
|
65 | + \Aimeos\Client\JsonApi\Factory::setCache($cache); |
|
66 | 66 | |
67 | - $this->assertNotSame( $client1, $client2 ); |
|
67 | + $this->assertNotSame($client1, $client2); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
71 | 71 | public function testClearSite() |
72 | 72 | { |
73 | - $cache = \Aimeos\Client\JsonApi\Factory::setCache( true ); |
|
73 | + $cache = \Aimeos\Client\JsonApi\Factory::setCache(true); |
|
74 | 74 | |
75 | 75 | $context = \TestHelperJapi::getContext(); |
76 | 76 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
77 | 77 | |
78 | - $cntlA1 = \Aimeos\Client\JsonApi\Factory::createClient( $context, $templatePaths, 'product' ); |
|
79 | - $cntlB1 = \Aimeos\Client\JsonApi\Factory::createClient( $context, $templatePaths, 'attribute' ); |
|
80 | - \Aimeos\Client\JsonApi\Factory::clear( (string) $context ); |
|
78 | + $cntlA1 = \Aimeos\Client\JsonApi\Factory::createClient($context, $templatePaths, 'product'); |
|
79 | + $cntlB1 = \Aimeos\Client\JsonApi\Factory::createClient($context, $templatePaths, 'attribute'); |
|
80 | + \Aimeos\Client\JsonApi\Factory::clear((string) $context); |
|
81 | 81 | |
82 | - $cntlA2 = \Aimeos\Client\JsonApi\Factory::createClient( $context, $templatePaths, 'product' ); |
|
83 | - $cntlB2 = \Aimeos\Client\JsonApi\Factory::createClient( $context, $templatePaths, 'attribute' ); |
|
82 | + $cntlA2 = \Aimeos\Client\JsonApi\Factory::createClient($context, $templatePaths, 'product'); |
|
83 | + $cntlB2 = \Aimeos\Client\JsonApi\Factory::createClient($context, $templatePaths, 'attribute'); |
|
84 | 84 | |
85 | - \Aimeos\Client\JsonApi\Factory::setCache( $cache ); |
|
85 | + \Aimeos\Client\JsonApi\Factory::setCache($cache); |
|
86 | 86 | |
87 | - $this->assertNotSame( $cntlA1, $cntlA2 ); |
|
88 | - $this->assertNotSame( $cntlB1, $cntlB2 ); |
|
87 | + $this->assertNotSame($cntlA1, $cntlA2); |
|
88 | + $this->assertNotSame($cntlB1, $cntlB2); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
92 | 92 | public function testClearSpecific() |
93 | 93 | { |
94 | - $cache = \Aimeos\Client\JsonApi\Factory::setCache( true ); |
|
94 | + $cache = \Aimeos\Client\JsonApi\Factory::setCache(true); |
|
95 | 95 | |
96 | 96 | $context = \TestHelperJapi::getContext(); |
97 | 97 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
98 | 98 | |
99 | - $cntlA1 = \Aimeos\Client\JsonApi\Factory::createClient( $context, $templatePaths, 'product' ); |
|
100 | - $cntlB1 = \Aimeos\Client\JsonApi\Factory::createClient( $context, $templatePaths, 'attribute' ); |
|
99 | + $cntlA1 = \Aimeos\Client\JsonApi\Factory::createClient($context, $templatePaths, 'product'); |
|
100 | + $cntlB1 = \Aimeos\Client\JsonApi\Factory::createClient($context, $templatePaths, 'attribute'); |
|
101 | 101 | |
102 | - \Aimeos\Client\JsonApi\Factory::clear( (string) $context, 'product' ); |
|
102 | + \Aimeos\Client\JsonApi\Factory::clear((string) $context, 'product'); |
|
103 | 103 | |
104 | - $cntlA2 = \Aimeos\Client\JsonApi\Factory::createClient( $context, $templatePaths, 'product' ); |
|
105 | - $cntlB2 = \Aimeos\Client\JsonApi\Factory::createClient( $context, $templatePaths, 'attribute' ); |
|
104 | + $cntlA2 = \Aimeos\Client\JsonApi\Factory::createClient($context, $templatePaths, 'product'); |
|
105 | + $cntlB2 = \Aimeos\Client\JsonApi\Factory::createClient($context, $templatePaths, 'attribute'); |
|
106 | 106 | |
107 | - \Aimeos\Client\JsonApi\Factory::setCache( $cache ); |
|
107 | + \Aimeos\Client\JsonApi\Factory::setCache($cache); |
|
108 | 108 | |
109 | - $this->assertNotSame( $cntlA1, $cntlA2 ); |
|
110 | - $this->assertSame( $cntlB1, $cntlB2 ); |
|
109 | + $this->assertNotSame($cntlA1, $cntlA2); |
|
110 | + $this->assertSame($cntlB1, $cntlB2); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } |
114 | 114 | \ No newline at end of file |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $context = \TestHelperJapi::getContext(); |
17 | 17 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
18 | 18 | |
19 | - $client = \Aimeos\Client\JsonApi\Catalog\Factory::createClient( $context, $templatePaths, 'attribute' ); |
|
20 | - $this->assertInstanceOf( '\Aimeos\Client\JsonApi\Iface', $client ); |
|
19 | + $client = \Aimeos\Client\JsonApi\Catalog\Factory::createClient($context, $templatePaths, 'attribute'); |
|
20 | + $this->assertInstanceOf('\Aimeos\Client\JsonApi\Iface', $client); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | $context = \TestHelperJapi::getContext(); |
27 | 27 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
28 | 28 | |
29 | - $this->setExpectedException( '\Aimeos\Client\JsonApi\Exception' ); |
|
30 | - \Aimeos\Client\JsonApi\Catalog\Factory::createClient( $context, $templatePaths, '' ); |
|
29 | + $this->setExpectedException('\Aimeos\Client\JsonApi\Exception'); |
|
30 | + \Aimeos\Client\JsonApi\Catalog\Factory::createClient($context, $templatePaths, ''); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | $context = \TestHelperJapi::getContext(); |
37 | 37 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
38 | 38 | |
39 | - $this->setExpectedException( '\Aimeos\Client\JsonApi\Exception' ); |
|
40 | - \Aimeos\Client\JsonApi\Catalog\Factory::createClient( $context, $templatePaths, '%^' ); |
|
39 | + $this->setExpectedException('\Aimeos\Client\JsonApi\Exception'); |
|
40 | + \Aimeos\Client\JsonApi\Catalog\Factory::createClient($context, $templatePaths, '%^'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $context = \TestHelperJapi::getContext(); |
47 | 47 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
48 | 48 | |
49 | - $this->setExpectedException( '\Aimeos\Client\JsonApi\Exception' ); |
|
50 | - \Aimeos\Client\JsonApi\Catalog\Factory::createClient( $context, $templatePaths, 'catalog', '%^' ); |
|
49 | + $this->setExpectedException('\Aimeos\Client\JsonApi\Exception'); |
|
50 | + \Aimeos\Client\JsonApi\Catalog\Factory::createClient($context, $templatePaths, 'catalog', '%^'); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | \ No newline at end of file |
@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | $this->context = \TestHelperJapi::getContext(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Client\JsonApi\Catalog\Standard( $this->context, $this->view, $templatePaths, 'catalog' ); |
|
25 | + $this->object = new \Aimeos\Client\JsonApi\Catalog\Standard($this->context, $this->view, $templatePaths, 'catalog'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | protected function tearDown() |
30 | 30 | { |
31 | - unset( $this->object, $this->context, $this->view ); |
|
31 | + unset($this->object, $this->context, $this->view); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | 35 | public function testGetItem() |
36 | 36 | { |
37 | - $catId = \Aimeos\MShop\Factory::createManager( $this->context, 'catalog' )->findItem( 'cafe' )->getId(); |
|
37 | + $catId = \Aimeos\MShop\Factory::createManager($this->context, 'catalog')->findItem('cafe')->getId(); |
|
38 | 38 | $params = array( |
39 | 39 | 'id' => $catId, |
40 | 40 | 'fields' => array( |
@@ -44,53 +44,53 @@ discard block |
||
44 | 44 | 'include' => 'catalog,media,text' |
45 | 45 | ); |
46 | 46 | |
47 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
48 | - $this->view->addHelper( 'param', $helper ); |
|
47 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
48 | + $this->view->addHelper('param', $helper); |
|
49 | 49 | |
50 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
51 | - $result = json_decode( (string) $response->getBody(), true ); |
|
50 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
51 | + $result = json_decode((string) $response->getBody(), true); |
|
52 | 52 | |
53 | 53 | |
54 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
55 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
56 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
54 | + $this->assertEquals(200, $response->getStatusCode()); |
|
55 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
56 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
57 | 57 | |
58 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
59 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
60 | - $this->assertEquals( 1, count( $result['data']['attributes']['text'] ) ); |
|
61 | - $this->assertEquals( 2, count( $result['data']['attributes']['media'] ) ); |
|
62 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
58 | + $this->assertEquals(1, $result['meta']['total']); |
|
59 | + $this->assertEquals('catalog', $result['data']['type']); |
|
60 | + $this->assertEquals(1, count($result['data']['attributes']['text'])); |
|
61 | + $this->assertEquals(2, count($result['data']['attributes']['media'])); |
|
62 | + $this->assertEquals(0, count($result['included'])); |
|
63 | 63 | |
64 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
64 | + $this->assertArrayNotHasKey('errors', $result); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | 68 | public function testGetItemNoID() |
69 | 69 | { |
70 | 70 | $params = array( |
71 | - 'filter' => array( '>=' => array( 'catalog.level' => 0 ) ), |
|
71 | + 'filter' => array('>=' => array('catalog.level' => 0)), |
|
72 | 72 | 'include' => 'catalog' |
73 | 73 | ); |
74 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
75 | - $this->view->addHelper( 'param', $helper ); |
|
76 | - |
|
77 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
78 | - $result = json_decode( (string) $response->getBody(), true ); |
|
79 | - |
|
80 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
81 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
82 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
83 | - |
|
84 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
85 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
86 | - $this->assertEquals( 'root', $result['data']['attributes']['catalog.code'] ); |
|
87 | - $this->assertEquals( 'Root', $result['data']['attributes']['catalog.label'] ); |
|
88 | - $this->assertEquals( 2, count( $result['data']['relationships']['catalog']['data'] ) ); |
|
89 | - $this->assertEquals( 'catalog', $result['data']['relationships']['catalog']['data'][0]['type'] ); |
|
90 | - $this->assertEquals( 2, count( $result['included'] ) ); |
|
91 | - $this->assertArrayHaskey( 'self', $result['included'][0]['links'] ); |
|
92 | - |
|
93 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
74 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
75 | + $this->view->addHelper('param', $helper); |
|
76 | + |
|
77 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
78 | + $result = json_decode((string) $response->getBody(), true); |
|
79 | + |
|
80 | + $this->assertEquals(200, $response->getStatusCode()); |
|
81 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
82 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
83 | + |
|
84 | + $this->assertEquals(1, $result['meta']['total']); |
|
85 | + $this->assertEquals('catalog', $result['data']['type']); |
|
86 | + $this->assertEquals('root', $result['data']['attributes']['catalog.code']); |
|
87 | + $this->assertEquals('Root', $result['data']['attributes']['catalog.label']); |
|
88 | + $this->assertEquals(2, count($result['data']['relationships']['catalog']['data'])); |
|
89 | + $this->assertEquals('catalog', $result['data']['relationships']['catalog']['data'][0]['type']); |
|
90 | + $this->assertEquals(2, count($result['included'])); |
|
91 | + $this->assertArrayHaskey('self', $result['included'][0]['links']); |
|
92 | + |
|
93 | + $this->assertArrayNotHasKey('errors', $result); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
@@ -98,21 +98,21 @@ discard block |
||
98 | 98 | { |
99 | 99 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
100 | 100 | |
101 | - $object = $this->getMockBuilder( '\Aimeos\Client\JsonApi\Catalog\Standard' ) |
|
102 | - ->setConstructorArgs( [$this->context, $this->view, $templatePaths, 'catalog'] ) |
|
103 | - ->setMethods( ['getItem'] ) |
|
101 | + $object = $this->getMockBuilder('\Aimeos\Client\JsonApi\Catalog\Standard') |
|
102 | + ->setConstructorArgs([$this->context, $this->view, $templatePaths, 'catalog']) |
|
103 | + ->setMethods(['getItem']) |
|
104 | 104 | ->getMock(); |
105 | 105 | |
106 | - $object->expects( $this->once() )->method( 'getItem' ) |
|
107 | - ->will( $this->throwException( new \Aimeos\MShop\Exception() ) ); |
|
106 | + $object->expects($this->once())->method('getItem') |
|
107 | + ->will($this->throwException(new \Aimeos\MShop\Exception())); |
|
108 | 108 | |
109 | 109 | |
110 | - $response = $object->get( $this->view->request(), $this->view->response() ); |
|
111 | - $result = json_decode( (string) $response->getBody(), true ); |
|
110 | + $response = $object->get($this->view->request(), $this->view->response()); |
|
111 | + $result = json_decode((string) $response->getBody(), true); |
|
112 | 112 | |
113 | 113 | |
114 | - $this->assertEquals( 404, $response->getStatusCode() ); |
|
115 | - $this->assertArrayHasKey( 'errors', $result ); |
|
114 | + $this->assertEquals(404, $response->getStatusCode()); |
|
115 | + $this->assertArrayHasKey('errors', $result); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -120,20 +120,20 @@ discard block |
||
120 | 120 | { |
121 | 121 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
122 | 122 | |
123 | - $object = $this->getMockBuilder( '\Aimeos\Client\JsonApi\Catalog\Standard' ) |
|
124 | - ->setConstructorArgs( [$this->context, $this->view, $templatePaths, 'catalog'] ) |
|
125 | - ->setMethods( ['getItem'] ) |
|
123 | + $object = $this->getMockBuilder('\Aimeos\Client\JsonApi\Catalog\Standard') |
|
124 | + ->setConstructorArgs([$this->context, $this->view, $templatePaths, 'catalog']) |
|
125 | + ->setMethods(['getItem']) |
|
126 | 126 | ->getMock(); |
127 | 127 | |
128 | - $object->expects( $this->once() )->method( 'getItem' ) |
|
129 | - ->will( $this->throwException( new \Exception() ) ); |
|
128 | + $object->expects($this->once())->method('getItem') |
|
129 | + ->will($this->throwException(new \Exception())); |
|
130 | 130 | |
131 | 131 | |
132 | - $response = $object->get( $this->view->request(), $this->view->response() ); |
|
133 | - $result = json_decode( (string) $response->getBody(), true ); |
|
132 | + $response = $object->get($this->view->request(), $this->view->response()); |
|
133 | + $result = json_decode((string) $response->getBody(), true); |
|
134 | 134 | |
135 | 135 | |
136 | - $this->assertEquals( 500, $response->getStatusCode() ); |
|
137 | - $this->assertArrayHasKey( 'errors', $result ); |
|
136 | + $this->assertEquals(500, $response->getStatusCode()); |
|
137 | + $this->assertArrayHasKey('errors', $result); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | \ No newline at end of file |
@@ -21,29 +21,29 @@ discard block |
||
21 | 21 | $this->context = \TestHelperJapi::getContext(); |
22 | 22 | $this->view = $this->context->getView(); |
23 | 23 | |
24 | - $this->client = new \Aimeos\Client\JsonApi\Product\Standard( $this->context, $this->view, [], '' ); |
|
24 | + $this->client = new \Aimeos\Client\JsonApi\Product\Standard($this->context, $this->view, [], ''); |
|
25 | 25 | |
26 | - $this->object = $this->getMockBuilder( '\Aimeos\Client\JsonApi\Common\Factory\Base' ) |
|
26 | + $this->object = $this->getMockBuilder('\Aimeos\Client\JsonApi\Common\Factory\Base') |
|
27 | 27 | ->getMockForAbstractClass(); |
28 | 28 | } |
29 | 29 | |
30 | 30 | |
31 | 31 | public function testinjectClient() |
32 | 32 | { |
33 | - $this->object->injectClient( 'test', $this->client ); |
|
33 | + $this->object->injectClient('test', $this->client); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | |
37 | 37 | public function testAddClientDecorators() |
38 | 38 | { |
39 | 39 | $config = $this->context->getConfig(); |
40 | - $config->set( 'client/jsonapi/common/decorators/default', ['Test'] ); |
|
41 | - $config->set( 'client/jsonapi/product/decorators/excludes', ['Test'] ); |
|
40 | + $config->set('client/jsonapi/common/decorators/default', ['Test']); |
|
41 | + $config->set('client/jsonapi/product/decorators/excludes', ['Test']); |
|
42 | 42 | |
43 | 43 | $params = [$this->client, $this->context, $this->view, [], 'product']; |
44 | - $result = $this->access( 'addClientDecorators' )->invokeArgs( $this->object, $params ); |
|
44 | + $result = $this->access('addClientDecorators')->invokeArgs($this->object, $params); |
|
45 | 45 | |
46 | - $this->assertInstanceOf( '\Aimeos\\Client\\JsonApi\\Iface', $result ); |
|
46 | + $this->assertInstanceOf('\Aimeos\\Client\\JsonApi\\Iface', $result); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | $prefix = '\Aimeos\\Client\\JsonApi\\Common\\Decorator\\'; |
53 | 53 | $params = [$this->client, ['Example'], $prefix, $this->context, $this->view, [], '']; |
54 | 54 | |
55 | - $result = $this->access( 'addDecorators' )->invokeArgs( $this->object, $params ); |
|
55 | + $result = $this->access('addDecorators')->invokeArgs($this->object, $params); |
|
56 | 56 | |
57 | - $this->assertInstanceOf( '\Aimeos\\Client\\JsonApi\\Iface', $result ); |
|
57 | + $this->assertInstanceOf('\Aimeos\\Client\\JsonApi\\Iface', $result); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | $prefix = '\Aimeos\\Client\\JsonApi\\Common\\Decorator\\'; |
64 | 64 | $params = [$this->client, ['Test'], $prefix, $this->context, $this->view, [], '']; |
65 | 65 | |
66 | - $this->setExpectedException( '\Aimeos\Client\JsonApi\Exception' ); |
|
67 | - $this->access( 'addDecorators' )->invokeArgs( $this->object, $params ); |
|
66 | + $this->setExpectedException('\Aimeos\Client\JsonApi\Exception'); |
|
67 | + $this->access('addDecorators')->invokeArgs($this->object, $params); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | $prefix = '\Aimeos\\Client\\JsonApi\\Common\\Decorator\\'; |
74 | 74 | $params = [$this->client, [''], $prefix, $this->context, $this->view, [], '']; |
75 | 75 | |
76 | - $this->setExpectedException( '\Aimeos\Client\JsonApi\Exception' ); |
|
77 | - $this->access( 'addDecorators' )->invokeArgs( $this->object, $params ); |
|
76 | + $this->setExpectedException('\Aimeos\Client\JsonApi\Exception'); |
|
77 | + $this->access('addDecorators')->invokeArgs($this->object, $params); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | $class = '\Aimeos\\Client\\JsonApi\\Product\\Standard'; |
85 | 85 | $params = [$class, $iface, $this->context, $this->view, [], '']; |
86 | 86 | |
87 | - $result = $this->access( 'createClientBase' )->invokeArgs( $this->object, $params ); |
|
87 | + $result = $this->access('createClientBase')->invokeArgs($this->object, $params); |
|
88 | 88 | |
89 | - $this->assertInstanceOf( '\Aimeos\\Client\\JsonApi\\Iface', $result ); |
|
89 | + $this->assertInstanceOf('\Aimeos\\Client\\JsonApi\\Iface', $result); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | $iface = '\Aimeos\\Client\\JsonApi\\Iface'; |
96 | 96 | $params = ['test', $iface, $this->context, $this->view, [], '']; |
97 | 97 | |
98 | - $this->object->injectClient( 'test', $this->client ); |
|
99 | - $result = $this->access( 'createClientBase' )->invokeArgs( $this->object, $params ); |
|
98 | + $this->object->injectClient('test', $this->client); |
|
99 | + $result = $this->access('createClientBase')->invokeArgs($this->object, $params); |
|
100 | 100 | |
101 | - $this->assertSame( $this->client, $result ); |
|
101 | + $this->assertSame($this->client, $result); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | $iface = '\Aimeos\\Client\\JsonApi\\Iface'; |
108 | 108 | $params = ['invalid', $iface, $this->context, $this->view, [], '']; |
109 | 109 | |
110 | - $this->setExpectedException( '\Aimeos\Client\JsonApi\Exception' ); |
|
111 | - $this->access( 'createClientBase' )->invokeArgs( $this->object, $params ); |
|
110 | + $this->setExpectedException('\Aimeos\Client\JsonApi\Exception'); |
|
111 | + $this->access('createClientBase')->invokeArgs($this->object, $params); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
@@ -118,16 +118,16 @@ discard block |
||
118 | 118 | $class = '\Aimeos\\Client\\JsonApi\\Product\\Standard'; |
119 | 119 | $params = [$class, $iface, $this->context, $this->view, [], '']; |
120 | 120 | |
121 | - $this->setExpectedException( '\Aimeos\Client\JsonApi\Exception' ); |
|
122 | - $this->access( 'createClientBase' )->invokeArgs( $this->object, $params ); |
|
121 | + $this->setExpectedException('\Aimeos\Client\JsonApi\Exception'); |
|
122 | + $this->access('createClientBase')->invokeArgs($this->object, $params); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
126 | - protected function access( $name ) |
|
126 | + protected function access($name) |
|
127 | 127 | { |
128 | - $class = new \ReflectionClass( '\Aimeos\Client\JsonApi\Common\Factory\Base' ); |
|
129 | - $method = $class->getMethod( $name ); |
|
130 | - $method->setAccessible( true ); |
|
128 | + $class = new \ReflectionClass('\Aimeos\Client\JsonApi\Common\Factory\Base'); |
|
129 | + $method = $class->getMethod($name); |
|
130 | + $method->setAccessible(true); |
|
131 | 131 | |
132 | 132 | return $method; |
133 | 133 | } |
@@ -21,88 +21,88 @@ |
||
21 | 21 | $context = \TestHelperJapi::getContext(); |
22 | 22 | $this->view = $context->getView(); |
23 | 23 | |
24 | - $this->stub = $this->getMockBuilder( '\\Aimeos\\Client\\JsonApi\\Standard' ) |
|
25 | - ->setConstructorArgs( [$context, $this->view, [], 'attribute'] ) |
|
24 | + $this->stub = $this->getMockBuilder('\\Aimeos\\Client\\JsonApi\\Standard') |
|
25 | + ->setConstructorArgs([$context, $this->view, [], 'attribute']) |
|
26 | 26 | ->getMock(); |
27 | 27 | |
28 | - $this->object = $this->getMockBuilder( '\\Aimeos\\Client\\JsonApi\\Common\\Decorator\Base' ) |
|
29 | - ->setConstructorArgs( [$this->stub, $context, $this->view, [], ''] ) |
|
28 | + $this->object = $this->getMockBuilder('\\Aimeos\\Client\\JsonApi\\Common\\Decorator\Base') |
|
29 | + ->setConstructorArgs([$this->stub, $context, $this->view, [], '']) |
|
30 | 30 | ->getMockForAbstractClass(); |
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | protected function tearDown() |
35 | 35 | { |
36 | - unset( $this->object, $this->stub, $this->view ); |
|
36 | + unset($this->object, $this->stub, $this->view); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
40 | 40 | public function testDelete() |
41 | 41 | { |
42 | - $this->stub->expects( $this->once() )->method( 'delete' )->will( $this->returnArgument( 1 ) ); |
|
42 | + $this->stub->expects($this->once())->method('delete')->will($this->returnArgument(1)); |
|
43 | 43 | $response = $this->view->response(); |
44 | 44 | |
45 | - $this->assertSame( $response, $this->object->delete( $this->view->request(), $response ) ); |
|
45 | + $this->assertSame($response, $this->object->delete($this->view->request(), $response)); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
49 | 49 | public function testGet() |
50 | 50 | { |
51 | - $this->stub->expects( $this->once() )->method( 'get' )->will( $this->returnArgument( 1 ) ); |
|
51 | + $this->stub->expects($this->once())->method('get')->will($this->returnArgument(1)); |
|
52 | 52 | $response = $this->view->response(); |
53 | 53 | |
54 | - $this->assertSame( $response, $this->object->get( $this->view->request(), $response ) ); |
|
54 | + $this->assertSame($response, $this->object->get($this->view->request(), $response)); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
58 | 58 | public function testPatch() |
59 | 59 | { |
60 | - $this->stub->expects( $this->once() )->method( 'patch' )->will( $this->returnArgument( 1 ) ); |
|
60 | + $this->stub->expects($this->once())->method('patch')->will($this->returnArgument(1)); |
|
61 | 61 | $response = $this->view->response(); |
62 | 62 | |
63 | - $this->assertSame( $response, $this->object->patch( $this->view->request(), $response ) ); |
|
63 | + $this->assertSame($response, $this->object->patch($this->view->request(), $response)); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
67 | 67 | public function testPost() |
68 | 68 | { |
69 | - $this->stub->expects( $this->once() )->method( 'post' )->will( $this->returnArgument( 1 ) ); |
|
69 | + $this->stub->expects($this->once())->method('post')->will($this->returnArgument(1)); |
|
70 | 70 | $response = $this->view->response(); |
71 | 71 | |
72 | - $this->assertSame( $response, $this->object->post( $this->view->request(), $response ) ); |
|
72 | + $this->assertSame($response, $this->object->post($this->view->request(), $response)); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
76 | 76 | public function testPut() |
77 | 77 | { |
78 | - $this->stub->expects( $this->once() )->method( 'put' )->will( $this->returnArgument( 1 ) ); |
|
78 | + $this->stub->expects($this->once())->method('put')->will($this->returnArgument(1)); |
|
79 | 79 | $response = $this->view->response(); |
80 | 80 | |
81 | - $this->assertSame( $response, $this->object->put( $this->view->request(), $response ) ); |
|
81 | + $this->assertSame($response, $this->object->put($this->view->request(), $response)); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
85 | 85 | public function testOptions() |
86 | 86 | { |
87 | - $this->stub->expects( $this->once() )->method( 'options' )->will( $this->returnArgument( 1 ) ); |
|
87 | + $this->stub->expects($this->once())->method('options')->will($this->returnArgument(1)); |
|
88 | 88 | $response = $this->view->response(); |
89 | 89 | |
90 | - $this->assertSame( $response, $this->object->options( $this->view->request(), $response ) ); |
|
90 | + $this->assertSame($response, $this->object->options($this->view->request(), $response)); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
94 | 94 | public function testGetClient() |
95 | 95 | { |
96 | - $result = $this->access( 'getClient' )->invokeArgs( $this->object, [] ); |
|
97 | - $this->assertSame( $this->stub, $result ); |
|
96 | + $result = $this->access('getClient')->invokeArgs($this->object, []); |
|
97 | + $this->assertSame($this->stub, $result); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
101 | - protected function access( $name ) |
|
101 | + protected function access($name) |
|
102 | 102 | { |
103 | - $class = new \ReflectionClass( '\Aimeos\Client\JsonApi\Common\Decorator\Base' ); |
|
104 | - $method = $class->getMethod( $name ); |
|
105 | - $method->setAccessible( true ); |
|
103 | + $class = new \ReflectionClass('\Aimeos\Client\JsonApi\Common\Decorator\Base'); |
|
104 | + $method = $class->getMethod($name); |
|
105 | + $method->setAccessible(true); |
|
106 | 106 | |
107 | 107 | return $method; |
108 | 108 | } |
@@ -22,111 +22,111 @@ |
||
22 | 22 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = $this->getMockBuilder( '\Aimeos\Client\JsonApi\Base' ) |
|
26 | - ->setConstructorArgs( [$this->context, $this->view, $templatePaths, 'test'] ) |
|
25 | + $this->object = $this->getMockBuilder('\Aimeos\Client\JsonApi\Base') |
|
26 | + ->setConstructorArgs([$this->context, $this->view, $templatePaths, 'test']) |
|
27 | 27 | ->getMockForAbstractClass(); |
28 | 28 | } |
29 | 29 | |
30 | 30 | |
31 | 31 | public function testDelete() |
32 | 32 | { |
33 | - $response = $this->object->delete( $this->view->request(), $this->view->response() ); |
|
34 | - $result = json_decode( (string) $response->getBody(), true ); |
|
33 | + $response = $this->object->delete($this->view->request(), $this->view->response()); |
|
34 | + $result = json_decode((string) $response->getBody(), true); |
|
35 | 35 | |
36 | - $this->assertEquals( 403, $response->getStatusCode() ); |
|
37 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
38 | - $this->assertArrayHasKey( 'errors', $result ); |
|
36 | + $this->assertEquals(403, $response->getStatusCode()); |
|
37 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
38 | + $this->assertArrayHasKey('errors', $result); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
42 | 42 | public function testGet() |
43 | 43 | { |
44 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
45 | - $result = json_decode( (string) $response->getBody(), true ); |
|
44 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
45 | + $result = json_decode((string) $response->getBody(), true); |
|
46 | 46 | |
47 | - $this->assertEquals( 403, $response->getStatusCode() ); |
|
48 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
49 | - $this->assertArrayHasKey( 'errors', $result ); |
|
47 | + $this->assertEquals(403, $response->getStatusCode()); |
|
48 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
49 | + $this->assertArrayHasKey('errors', $result); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
53 | 53 | public function testPatch() |
54 | 54 | { |
55 | - $response = $this->object->patch( $this->view->request(), $this->view->response() ); |
|
56 | - $result = json_decode( (string) $response->getBody(), true ); |
|
55 | + $response = $this->object->patch($this->view->request(), $this->view->response()); |
|
56 | + $result = json_decode((string) $response->getBody(), true); |
|
57 | 57 | |
58 | - $this->assertEquals( 403, $response->getStatusCode() ); |
|
59 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
60 | - $this->assertArrayHasKey( 'errors', $result ); |
|
58 | + $this->assertEquals(403, $response->getStatusCode()); |
|
59 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
60 | + $this->assertArrayHasKey('errors', $result); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | 64 | public function testPost() |
65 | 65 | { |
66 | - $response = $this->object->post( $this->view->request(), $this->view->response() ); |
|
67 | - $result = json_decode( (string) $response->getBody(), true ); |
|
66 | + $response = $this->object->post($this->view->request(), $this->view->response()); |
|
67 | + $result = json_decode((string) $response->getBody(), true); |
|
68 | 68 | |
69 | - $this->assertEquals( 403, $response->getStatusCode() ); |
|
70 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
71 | - $this->assertArrayHasKey( 'errors', $result ); |
|
69 | + $this->assertEquals(403, $response->getStatusCode()); |
|
70 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
71 | + $this->assertArrayHasKey('errors', $result); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
75 | 75 | public function testPut() |
76 | 76 | { |
77 | - $response = $this->object->put( $this->view->request(), $this->view->response() ); |
|
78 | - $result = json_decode( (string) $response->getBody(), true ); |
|
77 | + $response = $this->object->put($this->view->request(), $this->view->response()); |
|
78 | + $result = json_decode((string) $response->getBody(), true); |
|
79 | 79 | |
80 | - $this->assertEquals( 403, $response->getStatusCode() ); |
|
81 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
82 | - $this->assertArrayHasKey( 'errors', $result ); |
|
80 | + $this->assertEquals(403, $response->getStatusCode()); |
|
81 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
82 | + $this->assertArrayHasKey('errors', $result); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
86 | 86 | public function testOptions() |
87 | 87 | { |
88 | - $response = $this->object->options( $this->view->request(), $this->view->response() ); |
|
89 | - $result = json_decode( (string) $response->getBody(), true ); |
|
88 | + $response = $this->object->options($this->view->request(), $this->view->response()); |
|
89 | + $result = json_decode((string) $response->getBody(), true); |
|
90 | 90 | |
91 | - $this->assertEquals( 403, $response->getStatusCode() ); |
|
92 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
93 | - $this->assertArrayHasKey( 'errors', $result ); |
|
91 | + $this->assertEquals(403, $response->getStatusCode()); |
|
92 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
93 | + $this->assertArrayHasKey('errors', $result); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
97 | 97 | public function testGetContext() |
98 | 98 | { |
99 | - $result = $this->access( 'getContext' )->invokeArgs( $this->object, [] ); |
|
100 | - $this->assertInstanceOf( '\Aimeos\MShop\Context\Item\Iface', $result ); |
|
99 | + $result = $this->access('getContext')->invokeArgs($this->object, []); |
|
100 | + $this->assertInstanceOf('\Aimeos\MShop\Context\Item\Iface', $result); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
104 | 104 | public function testGetPath() |
105 | 105 | { |
106 | - $result = $this->access( 'getPath' )->invokeArgs( $this->object, [] ); |
|
107 | - $this->assertEquals( 'test', $result ); |
|
106 | + $result = $this->access('getPath')->invokeArgs($this->object, []); |
|
107 | + $this->assertEquals('test', $result); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | |
111 | 111 | public function testGetTemplatePaths() |
112 | 112 | { |
113 | - $result = $this->access( 'getTemplatePaths' )->invokeArgs( $this->object, [] ); |
|
114 | - $this->assertEquals( 1, count( $result ) ); |
|
113 | + $result = $this->access('getTemplatePaths')->invokeArgs($this->object, []); |
|
114 | + $this->assertEquals(1, count($result)); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
118 | 118 | public function testGetView() |
119 | 119 | { |
120 | - $result = $this->access( 'getView' )->invokeArgs( $this->object, [] ); |
|
121 | - $this->assertInstanceOf( '\Aimeos\MW\View\Iface', $result ); |
|
120 | + $result = $this->access('getView')->invokeArgs($this->object, []); |
|
121 | + $this->assertInstanceOf('\Aimeos\MW\View\Iface', $result); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | |
125 | - protected function access( $name ) |
|
125 | + protected function access($name) |
|
126 | 126 | { |
127 | - $class = new \ReflectionClass( '\Aimeos\Client\JsonApi\Base' ); |
|
128 | - $method = $class->getMethod( $name ); |
|
129 | - $method->setAccessible( true ); |
|
127 | + $class = new \ReflectionClass('\Aimeos\Client\JsonApi\Base'); |
|
128 | + $method = $class->getMethod($name); |
|
129 | + $method->setAccessible(true); |
|
130 | 130 | |
131 | 131 | return $method; |
132 | 132 | } |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | $context = \TestHelperJapi::getContext(); |
17 | 17 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
18 | 18 | |
19 | - $client = \Aimeos\Client\JsonApi\Stock\Factory::createClient( $context, $templatePaths, 'stock' ); |
|
20 | - $this->assertInstanceOf( '\Aimeos\Client\JsonApi\Iface', $client ); |
|
19 | + $client = \Aimeos\Client\JsonApi\Stock\Factory::createClient($context, $templatePaths, 'stock'); |
|
20 | + $this->assertInstanceOf('\Aimeos\Client\JsonApi\Iface', $client); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | $context = \TestHelperJapi::getContext(); |
27 | 27 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
28 | 28 | |
29 | - $this->setExpectedException( '\Aimeos\Client\JsonApi\Exception' ); |
|
30 | - \Aimeos\Client\JsonApi\Stock\Factory::createClient( $context, $templatePaths, '' ); |
|
29 | + $this->setExpectedException('\Aimeos\Client\JsonApi\Exception'); |
|
30 | + \Aimeos\Client\JsonApi\Stock\Factory::createClient($context, $templatePaths, ''); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | $context = \TestHelperJapi::getContext(); |
37 | 37 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
38 | 38 | |
39 | - $this->setExpectedException( '\Aimeos\Client\JsonApi\Exception' ); |
|
40 | - \Aimeos\Client\JsonApi\Stock\Factory::createClient( $context, $templatePaths, '%^' ); |
|
39 | + $this->setExpectedException('\Aimeos\Client\JsonApi\Exception'); |
|
40 | + \Aimeos\Client\JsonApi\Stock\Factory::createClient($context, $templatePaths, '%^'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $context = \TestHelperJapi::getContext(); |
47 | 47 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
48 | 48 | |
49 | - $this->setExpectedException( '\Aimeos\Client\JsonApi\Exception' ); |
|
50 | - \Aimeos\Client\JsonApi\Stock\Factory::createClient( $context, $templatePaths, 'stock', '%^' ); |
|
49 | + $this->setExpectedException('\Aimeos\Client\JsonApi\Exception'); |
|
50 | + \Aimeos\Client\JsonApi\Stock\Factory::createClient($context, $templatePaths, 'stock', '%^'); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | \ No newline at end of file |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Client\JsonApi\Stock\Standard( $this->context, $this->view, $templatePaths, 'stock' ); |
|
25 | + $this->object = new \Aimeos\Client\JsonApi\Stock\Standard($this->context, $this->view, $templatePaths, 'stock'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | public function testGetItem() |
30 | 30 | { |
31 | - $stockManager = \Aimeos\MShop\Factory::createManager( $this->context, 'stock' ); |
|
32 | - $stockId = $stockManager->findItem( 'CNE', [], 'product', 'default' )->getId(); |
|
31 | + $stockManager = \Aimeos\MShop\Factory::createManager($this->context, 'stock'); |
|
32 | + $stockId = $stockManager->findItem('CNE', [], 'product', 'default')->getId(); |
|
33 | 33 | |
34 | 34 | $params = array( |
35 | 35 | 'id' => $stockId, |
@@ -39,46 +39,46 @@ discard block |
||
39 | 39 | 'sort' => 'stock.id' |
40 | 40 | ); |
41 | 41 | |
42 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
43 | - $this->view->addHelper( 'param', $helper ); |
|
42 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
43 | + $this->view->addHelper('param', $helper); |
|
44 | 44 | |
45 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
46 | - $result = json_decode( (string) $response->getBody(), true ); |
|
45 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
46 | + $result = json_decode((string) $response->getBody(), true); |
|
47 | 47 | |
48 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
49 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
50 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
48 | + $this->assertEquals(200, $response->getStatusCode()); |
|
49 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
50 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
51 | 51 | |
52 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
53 | - $this->assertEquals( 'stock', $result['data']['type'] ); |
|
54 | - $this->assertEquals( 3, count( $result['data']['attributes'] ) ); |
|
55 | - $this->assertEquals( 'CNE', $result['data']['attributes']['stock.productcode'] ); |
|
52 | + $this->assertEquals(1, $result['meta']['total']); |
|
53 | + $this->assertEquals('stock', $result['data']['type']); |
|
54 | + $this->assertEquals(3, count($result['data']['attributes'])); |
|
55 | + $this->assertEquals('CNE', $result['data']['attributes']['stock.productcode']); |
|
56 | 56 | |
57 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
57 | + $this->assertArrayNotHasKey('errors', $result); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | 61 | public function testGetItems() |
62 | 62 | { |
63 | 63 | $params = array( |
64 | - 'filter' => array( 's_prodcode' => ['CNC', 'CNE'] ), |
|
64 | + 'filter' => array('s_prodcode' => ['CNC', 'CNE']), |
|
65 | 65 | 'sort' => 'stock.productcode', |
66 | 66 | ); |
67 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
68 | - $this->view->addHelper( 'param', $helper ); |
|
67 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
68 | + $this->view->addHelper('param', $helper); |
|
69 | 69 | |
70 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
71 | - $result = json_decode( (string) $response->getBody(), true ); |
|
70 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
71 | + $result = json_decode((string) $response->getBody(), true); |
|
72 | 72 | |
73 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
74 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
75 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
73 | + $this->assertEquals(200, $response->getStatusCode()); |
|
74 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
75 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
76 | 76 | |
77 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
78 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
79 | - $this->assertEquals( 'stock', $result['data'][0]['type'] ); |
|
77 | + $this->assertEquals(2, $result['meta']['total']); |
|
78 | + $this->assertEquals(2, count($result['data'])); |
|
79 | + $this->assertEquals('stock', $result['data'][0]['type']); |
|
80 | 80 | |
81 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
81 | + $this->assertArrayNotHasKey('errors', $result); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -86,21 +86,21 @@ discard block |
||
86 | 86 | { |
87 | 87 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
88 | 88 | |
89 | - $object = $this->getMockBuilder( '\Aimeos\Client\JsonApi\Stock\Standard' ) |
|
90 | - ->setConstructorArgs( [$this->context, $this->view, $templatePaths, 'stock'] ) |
|
91 | - ->setMethods( ['getItems'] ) |
|
89 | + $object = $this->getMockBuilder('\Aimeos\Client\JsonApi\Stock\Standard') |
|
90 | + ->setConstructorArgs([$this->context, $this->view, $templatePaths, 'stock']) |
|
91 | + ->setMethods(['getItems']) |
|
92 | 92 | ->getMock(); |
93 | 93 | |
94 | - $object->expects( $this->once() )->method( 'getItems' ) |
|
95 | - ->will( $this->throwException( new \Aimeos\MShop\Exception() ) ); |
|
94 | + $object->expects($this->once())->method('getItems') |
|
95 | + ->will($this->throwException(new \Aimeos\MShop\Exception())); |
|
96 | 96 | |
97 | 97 | |
98 | - $response = $object->get( $this->view->request(), $this->view->response() ); |
|
99 | - $result = json_decode( (string) $response->getBody(), true ); |
|
98 | + $response = $object->get($this->view->request(), $this->view->response()); |
|
99 | + $result = json_decode((string) $response->getBody(), true); |
|
100 | 100 | |
101 | 101 | |
102 | - $this->assertEquals( 404, $response->getStatusCode() ); |
|
103 | - $this->assertArrayHasKey( 'errors', $result ); |
|
102 | + $this->assertEquals(404, $response->getStatusCode()); |
|
103 | + $this->assertArrayHasKey('errors', $result); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -108,20 +108,20 @@ discard block |
||
108 | 108 | { |
109 | 109 | $templatePaths = \TestHelperJapi::getTemplatePaths(); |
110 | 110 | |
111 | - $object = $this->getMockBuilder( '\Aimeos\Client\JsonApi\Stock\Standard' ) |
|
112 | - ->setConstructorArgs( [$this->context, $this->view, $templatePaths, 'stock'] ) |
|
113 | - ->setMethods( ['getItems'] ) |
|
111 | + $object = $this->getMockBuilder('\Aimeos\Client\JsonApi\Stock\Standard') |
|
112 | + ->setConstructorArgs([$this->context, $this->view, $templatePaths, 'stock']) |
|
113 | + ->setMethods(['getItems']) |
|
114 | 114 | ->getMock(); |
115 | 115 | |
116 | - $object->expects( $this->once() )->method( 'getItems' ) |
|
117 | - ->will( $this->throwException( new \Exception() ) ); |
|
116 | + $object->expects($this->once())->method('getItems') |
|
117 | + ->will($this->throwException(new \Exception())); |
|
118 | 118 | |
119 | 119 | |
120 | - $response = $object->get( $this->view->request(), $this->view->response() ); |
|
121 | - $result = json_decode( (string) $response->getBody(), true ); |
|
120 | + $response = $object->get($this->view->request(), $this->view->response()); |
|
121 | + $result = json_decode((string) $response->getBody(), true); |
|
122 | 122 | |
123 | 123 | |
124 | - $this->assertEquals( 500, $response->getStatusCode() ); |
|
125 | - $this->assertArrayHasKey( 'errors', $result ); |
|
124 | + $this->assertEquals(500, $response->getStatusCode()); |
|
125 | + $this->assertArrayHasKey('errors', $result); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | \ No newline at end of file |