@@ -9,29 +9,29 @@ discard block |
||
9 | 9 | |
10 | 10 | |
11 | 11 | $options = 0; |
12 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
12 | +if (defined('JSON_PRETTY_PRINT')) { |
|
13 | 13 | $options = JSON_PRETTY_PRINT; |
14 | 14 | } |
15 | 15 | |
16 | 16 | |
17 | -$fields = $this->param( 'fields', [] ); |
|
17 | +$fields = $this->param('fields', []); |
|
18 | 18 | |
19 | -foreach( (array) $fields as $resource => $list ) { |
|
20 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
19 | +foreach ((array) $fields as $resource => $list) { |
|
20 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
24 | -$build = function( array $attrItems, $id ) use ( $fields ) |
|
24 | +$build = function(array $attrItems, $id) use ($fields) |
|
25 | 25 | { |
26 | 26 | $result = []; |
27 | 27 | $type = 'criteria/attribute'; |
28 | 28 | |
29 | - foreach( $attrItems as $attrItem ) |
|
29 | + foreach ($attrItems as $attrItem) |
|
30 | 30 | { |
31 | - $attributes = $attrItem->toArray( true ); |
|
31 | + $attributes = $attrItem->toArray(true); |
|
32 | 32 | |
33 | - if( isset( $fields[$type] ) ) { |
|
34 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
33 | + if (isset($fields[$type])) { |
|
34 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $result[] = array( |
@@ -45,23 +45,23 @@ discard block |
||
45 | 45 | }; |
46 | 46 | |
47 | 47 | |
48 | -$configItems = $this->get( 'configItems', [] ); |
|
48 | +$configItems = $this->get('configItems', []); |
|
49 | 49 | |
50 | 50 | |
51 | 51 | ?> |
52 | 52 | { |
53 | 53 | "meta": { |
54 | - "total": <?= count( $configItems ); ?> |
|
54 | + "total": <?= count($configItems); ?> |
|
55 | 55 | |
56 | 56 | } |
57 | 57 | |
58 | - <?php if( isset( $this->errors ) ) : ?> |
|
58 | + <?php if (isset($this->errors)) : ?> |
|
59 | 59 | |
60 | - , "errors": <?= $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
60 | + , "errors": <?= $this->partial($this->config($this->get('partial-errors', 'admin/jsonadm/partials/template-errors'), 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
61 | 61 | |
62 | 62 | <?php else : ?> |
63 | 63 | |
64 | - , "data": <?= json_encode( $build( $configItems, $this->param( 'id' ) ), $options ); ?> |
|
64 | + , "data": <?= json_encode($build($configItems, $this->param('id')), $options); ?> |
|
65 | 65 | |
66 | 66 | <?php endif; ?> |
67 | 67 | } |
@@ -59,9 +59,12 @@ |
||
59 | 59 | |
60 | 60 | , "errors": <?= $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
61 | 61 | |
62 | - <?php else : ?> |
|
62 | + <?php else { |
|
63 | + : ?> |
|
63 | 64 | |
64 | - , "data": <?= json_encode( $build( $configItems, $this->param( 'id' ) ), $options ); ?> |
|
65 | + , "data": <?= json_encode( $build( $configItems, $this->param( 'id' ) ), $options ); |
|
66 | +} |
|
67 | +?> |
|
65 | 68 | |
66 | 69 | <?php endif; ?> |
67 | 70 | } |
@@ -118,16 +118,14 @@ |
||
118 | 118 | { |
119 | 119 | $response = $this->getItems( $view, $request, $response ); |
120 | 120 | $status = 200; |
121 | - } |
|
122 | - catch( \Aimeos\MShop\Exception $e ) |
|
121 | + } catch( \Aimeos\MShop\Exception $e ) |
|
123 | 122 | { |
124 | 123 | $status = 404; |
125 | 124 | $view->errors = array( array( |
126 | 125 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
127 | 126 | 'detail' => $e->getTraceAsString(), |
128 | 127 | ) ); |
129 | - } |
|
130 | - catch( \Exception $e ) |
|
128 | + } catch( \Exception $e ) |
|
131 | 129 | { |
132 | 130 | $status = 500; |
133 | 131 | $view->errors = array( array( |
@@ -110,30 +110,30 @@ discard block |
||
110 | 110 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
111 | 111 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
112 | 112 | */ |
113 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
113 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
114 | 114 | { |
115 | 115 | $view = $this->getView(); |
116 | 116 | |
117 | 117 | try |
118 | 118 | { |
119 | - $response = $this->getItems( $view, $request, $response ); |
|
119 | + $response = $this->getItems($view, $request, $response); |
|
120 | 120 | $status = 200; |
121 | 121 | } |
122 | - catch( \Aimeos\MShop\Exception $e ) |
|
122 | + catch (\Aimeos\MShop\Exception $e) |
|
123 | 123 | { |
124 | 124 | $status = 404; |
125 | - $view->errors = array( array( |
|
126 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
125 | + $view->errors = array(array( |
|
126 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
127 | 127 | 'detail' => $e->getTraceAsString(), |
128 | - ) ); |
|
128 | + )); |
|
129 | 129 | } |
130 | - catch( \Exception $e ) |
|
130 | + catch (\Exception $e) |
|
131 | 131 | { |
132 | 132 | $status = 500; |
133 | - $view->errors = array( array( |
|
133 | + $view->errors = array(array( |
|
134 | 134 | 'title' => $e->getMessage(), |
135 | 135 | 'detail' => $e->getTraceAsString(), |
136 | - ) ); |
|
136 | + )); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** admin/jsonadm/service/config/template-get |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | $tplconf = 'admin/jsonadm/service/config/template-get'; |
159 | 159 | $default = 'config-default.php'; |
160 | 160 | |
161 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
161 | + $body = $view->render($view->config($tplconf, $default)); |
|
162 | 162 | |
163 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
164 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
165 | - ->withStatus( $status ); |
|
163 | + return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
164 | + ->withBody($view->response()->createStreamFromString($body)) |
|
165 | + ->withStatus($status); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -174,16 +174,16 @@ discard block |
||
174 | 174 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
175 | 175 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
176 | 176 | */ |
177 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
177 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
178 | 178 | { |
179 | - if( ( $id = $view->param( 'id' ) ) == null ) { |
|
180 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
179 | + if (($id = $view->param('id')) == null) { |
|
180 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
181 | 181 | } |
182 | 182 | |
183 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service' ); |
|
184 | - $item = $manager->createItem()->setProvider( $id ); |
|
183 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service'); |
|
184 | + $item = $manager->createItem()->setProvider($id); |
|
185 | 185 | |
186 | - $view->configItems = $manager->getProvider( $item, $view->param( 'type', 'payment' ) )->getConfigBE(); |
|
186 | + $view->configItems = $manager->getProvider($item, $view->param('type', 'payment'))->getConfigBE(); |
|
187 | 187 | |
188 | 188 | return $response; |
189 | 189 | } |
@@ -118,16 +118,14 @@ |
||
118 | 118 | { |
119 | 119 | $response = $this->getItems( $view, $request, $response ); |
120 | 120 | $status = 200; |
121 | - } |
|
122 | - catch( \Aimeos\MShop\Exception $e ) |
|
121 | + } catch( \Aimeos\MShop\Exception $e ) |
|
123 | 122 | { |
124 | 123 | $status = 404; |
125 | 124 | $view->errors = array( array( |
126 | 125 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
127 | 126 | 'detail' => $e->getTraceAsString(), |
128 | 127 | ) ); |
129 | - } |
|
130 | - catch( \Exception $e ) |
|
128 | + } catch( \Exception $e ) |
|
131 | 129 | { |
132 | 130 | $status = 500; |
133 | 131 | $view->errors = array( array( |
@@ -110,30 +110,30 @@ discard block |
||
110 | 110 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
111 | 111 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
112 | 112 | */ |
113 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
113 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
114 | 114 | { |
115 | 115 | $view = $this->getView(); |
116 | 116 | |
117 | 117 | try |
118 | 118 | { |
119 | - $response = $this->getItems( $view, $request, $response ); |
|
119 | + $response = $this->getItems($view, $request, $response); |
|
120 | 120 | $status = 200; |
121 | 121 | } |
122 | - catch( \Aimeos\MShop\Exception $e ) |
|
122 | + catch (\Aimeos\MShop\Exception $e) |
|
123 | 123 | { |
124 | 124 | $status = 404; |
125 | - $view->errors = array( array( |
|
126 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
125 | + $view->errors = array(array( |
|
126 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
127 | 127 | 'detail' => $e->getTraceAsString(), |
128 | - ) ); |
|
128 | + )); |
|
129 | 129 | } |
130 | - catch( \Exception $e ) |
|
130 | + catch (\Exception $e) |
|
131 | 131 | { |
132 | 132 | $status = 500; |
133 | - $view->errors = array( array( |
|
133 | + $view->errors = array(array( |
|
134 | 134 | 'title' => $e->getMessage(), |
135 | 135 | 'detail' => $e->getTraceAsString(), |
136 | - ) ); |
|
136 | + )); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** admin/jsonadm/plugin/config/template-get |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | $tplconf = 'admin/jsonadm/plugin/config/template-get'; |
159 | 159 | $default = 'config-default.php'; |
160 | 160 | |
161 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
161 | + $body = $view->render($view->config($tplconf, $default)); |
|
162 | 162 | |
163 | - return $response->withHeader( 'Content-Type', 'application/vnd.api+json; supported-ext="bulk"' ) |
|
164 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
165 | - ->withStatus( $status ); |
|
163 | + return $response->withHeader('Content-Type', 'application/vnd.api+json; supported-ext="bulk"') |
|
164 | + ->withBody($view->response()->createStreamFromString($body)) |
|
165 | + ->withStatus($status); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -174,16 +174,16 @@ discard block |
||
174 | 174 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
175 | 175 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
176 | 176 | */ |
177 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
177 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
178 | 178 | { |
179 | - if( ( $id = $view->param( 'id' ) ) == null ) { |
|
180 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
179 | + if (($id = $view->param('id')) == null) { |
|
180 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
181 | 181 | } |
182 | 182 | |
183 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'plugin' ); |
|
184 | - $item = $manager->createItem()->setProvider( $id ); |
|
183 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'plugin'); |
|
184 | + $item = $manager->createItem()->setProvider($id); |
|
185 | 185 | |
186 | - $view->configItems = $manager->getProvider( $item, 'order' )->getConfigBE(); |
|
186 | + $view->configItems = $manager->getProvider($item, 'order')->getConfigBE(); |
|
187 | 187 | |
188 | 188 | return $response; |
189 | 189 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param array $templatePaths List of file system paths where the templates are stored |
34 | 34 | * @param string $path Name of the client separated by slashes, e.g "product/property" |
35 | 35 | */ |
36 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path ) |
|
36 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MW\View\Iface $view, array $templatePaths, $path) |
|
37 | 37 | { |
38 | 38 | $this->view = $view; |
39 | 39 | $this->context = $context; |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * @param array $param List of method parameter |
50 | 50 | * @throws \Aimeos\Admin\JsonAdm\Exception If method call failed |
51 | 51 | */ |
52 | - public function __call( $name, array $param ) |
|
52 | + public function __call($name, array $param) |
|
53 | 53 | { |
54 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Unable to call method "%1$s"', $name ) ); |
|
54 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Unable to call method "%1$s"', $name)); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param array $include List of resource types that should be fetched |
63 | 63 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
64 | 64 | */ |
65 | - protected function getChildItems( array $items, array $include ) |
|
65 | + protected function getChildItems(array $items, array $include) |
|
66 | 66 | { |
67 | 67 | return []; |
68 | 68 | } |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter |
86 | 86 | * @return array List of domain names |
87 | 87 | */ |
88 | - protected function getDomains( \Aimeos\MW\View\Iface $view ) |
|
88 | + protected function getDomains(\Aimeos\MW\View\Iface $view) |
|
89 | 89 | { |
90 | - if( ( $domains = $view->param( 'resource' ) ) == '' ) |
|
90 | + if (($domains = $view->param('resource')) == '') |
|
91 | 91 | { |
92 | 92 | /** admin/jsonadm/domains |
93 | 93 | * A list of domain names whose clients are available for the JSON API |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | 'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', 'order', |
111 | 111 | 'plugin', 'price', 'product', 'service', 'supplier', 'stock', 'tag', 'text' |
112 | 112 | ); |
113 | - $domains = $this->getContext()->getConfig()->get( 'admin/jsonadm/domains', $default ); |
|
113 | + $domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | return (array) $domains; |
@@ -123,15 +123,15 @@ discard block |
||
123 | 123 | * @param \stdClass $request Decoded request body |
124 | 124 | * @return array List of item IDs |
125 | 125 | */ |
126 | - protected function getIds( $request ) |
|
126 | + protected function getIds($request) |
|
127 | 127 | { |
128 | 128 | $ids = []; |
129 | 129 | |
130 | - if( isset( $request->data ) ) |
|
130 | + if (isset($request->data)) |
|
131 | 131 | { |
132 | - foreach( (array) $request->data as $entry ) |
|
132 | + foreach ((array) $request->data as $entry) |
|
133 | 133 | { |
134 | - if( isset( $entry->id ) ) { |
|
134 | + if (isset($entry->id)) { |
|
135 | 135 | $ids[] = $entry->id; |
136 | 136 | } |
137 | 137 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param array $include List of resource types that should be fetched |
149 | 149 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
150 | 150 | */ |
151 | - protected function getListItems( array $items, array $include ) |
|
151 | + protected function getListItems(array $items, array $include) |
|
152 | 152 | { |
153 | 153 | return []; |
154 | 154 | } |
@@ -171,23 +171,23 @@ discard block |
||
171 | 171 | * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
172 | 172 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
173 | 173 | */ |
174 | - protected function getRefItems( array $listItems ) |
|
174 | + protected function getRefItems(array $listItems) |
|
175 | 175 | { |
176 | 176 | $list = $map = []; |
177 | 177 | $context = $this->getContext(); |
178 | 178 | |
179 | - foreach( $listItems as $listItem ) { |
|
179 | + foreach ($listItems as $listItem) { |
|
180 | 180 | $map[$listItem->getDomain()][] = $listItem->getRefId(); |
181 | 181 | } |
182 | 182 | |
183 | - foreach( $map as $domain => $ids ) |
|
183 | + foreach ($map as $domain => $ids) |
|
184 | 184 | { |
185 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
185 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
186 | 186 | |
187 | 187 | $search = $manager->createSearch(); |
188 | - $search->setConditions( $search->compare( '==', $domain . '.id', $ids ) ); |
|
188 | + $search->setConditions($search->compare('==', $domain . '.id', $ids)); |
|
189 | 189 | |
190 | - $list = array_merge( $list, $manager->searchItems( $search ) ); |
|
190 | + $list = array_merge($list, $manager->searchItems($search)); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | return $list; |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter |
201 | 201 | * @return array List of domain names |
202 | 202 | */ |
203 | - protected function getResources( \Aimeos\MW\View\Iface $view ) |
|
203 | + protected function getResources(\Aimeos\MW\View\Iface $view) |
|
204 | 204 | { |
205 | 205 | /** admin/jsonadm/resources |
206 | 206 | * A list of additional resources name whose clients are available for the JSON API |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @category Developer |
219 | 219 | * @see admin/jsonadm/domains |
220 | 220 | */ |
221 | - return (array) $view->config( 'admin/jsonadm/resources', ['coupon/config', 'plugin/config', 'service/config'] ); |
|
221 | + return (array) $view->config('admin/jsonadm/resources', ['coupon/config', 'plugin/config', 'service/config']); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -251,11 +251,11 @@ discard block |
||
251 | 251 | * @param array $params List of criteria data with condition, sorting and paging |
252 | 252 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
253 | 253 | */ |
254 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
254 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
255 | 255 | { |
256 | - $this->initCriteriaConditions( $criteria, $params ); |
|
257 | - $this->initCriteriaSortations( $criteria, $params ); |
|
258 | - $this->initCriteriaSlice( $criteria, $params ); |
|
256 | + $this->initCriteriaConditions($criteria, $params); |
|
257 | + $this->initCriteriaSortations($criteria, $params); |
|
258 | + $this->initCriteriaSlice($criteria, $params); |
|
259 | 259 | |
260 | 260 | return $criteria; |
261 | 261 | } |
@@ -267,17 +267,17 @@ discard block |
||
267 | 267 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
268 | 268 | * @param array $params List of criteria data with condition, sorting and paging |
269 | 269 | */ |
270 | - protected function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
270 | + protected function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
271 | 271 | { |
272 | - if( !isset( $params['filter'] ) ) { |
|
272 | + if (!isset($params['filter'])) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | 275 | |
276 | 276 | $existing = $criteria->getConditions(); |
277 | - $criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) ); |
|
277 | + $criteria->setConditions($criteria->toConditions((array) $params['filter'])); |
|
278 | 278 | |
279 | - $expr = array( $criteria->getConditions(), $existing ); |
|
280 | - $criteria->setConditions( $criteria->combine( '&&', $expr ) ); |
|
279 | + $expr = array($criteria->getConditions(), $existing); |
|
280 | + $criteria->setConditions($criteria->combine('&&', $expr)); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -287,12 +287,12 @@ discard block |
||
287 | 287 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
288 | 288 | * @param array $params List of criteria data with condition, sorting and paging |
289 | 289 | */ |
290 | - protected function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
290 | + protected function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
291 | 291 | { |
292 | - $start = ( isset( $params['page']['offset'] ) ? (int) $params['page']['offset'] : 0 ); |
|
293 | - $size = ( isset( $params['page']['limit'] ) ? (int) $params['page']['limit'] : 25 ); |
|
292 | + $start = (isset($params['page']['offset']) ? (int) $params['page']['offset'] : 0); |
|
293 | + $size = (isset($params['page']['limit']) ? (int) $params['page']['limit'] : 25); |
|
294 | 294 | |
295 | - $criteria->setSlice( $start, $size ); |
|
295 | + $criteria->setSlice($start, $size); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | |
@@ -302,24 +302,24 @@ discard block |
||
302 | 302 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
303 | 303 | * @param array $params List of criteria data with condition, sorting and paging |
304 | 304 | */ |
305 | - protected function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
305 | + protected function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
306 | 306 | { |
307 | - if( !isset( $params['sort'] ) ) { |
|
307 | + if (!isset($params['sort'])) { |
|
308 | 308 | return; |
309 | 309 | } |
310 | 310 | |
311 | 311 | $sortation = []; |
312 | 312 | |
313 | - foreach( explode( ',', $params['sort'] ) as $sort ) |
|
313 | + foreach (explode(',', $params['sort']) as $sort) |
|
314 | 314 | { |
315 | - if( $sort[0] === '-' ) { |
|
316 | - $sortation[] = $criteria->sort( '-', substr( $sort, 1 ) ); |
|
315 | + if ($sort[0] === '-') { |
|
316 | + $sortation[] = $criteria->sort('-', substr($sort, 1)); |
|
317 | 317 | } else { |
318 | - $sortation[] = $criteria->sort( '+', $sort ); |
|
318 | + $sortation[] = $criteria->sort('+', $sort); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
322 | - $criteria->setSortations( $sortation ); |
|
322 | + $criteria->setSortations($sortation); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -330,14 +330,14 @@ discard block |
||
330 | 330 | * @param \stdClass $request Object with request body data |
331 | 331 | * @return array List of items |
332 | 332 | */ |
333 | - protected function saveData( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request ) |
|
333 | + protected function saveData(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request) |
|
334 | 334 | { |
335 | 335 | $data = []; |
336 | 336 | |
337 | - if( isset( $request->data ) ) |
|
337 | + if (isset($request->data)) |
|
338 | 338 | { |
339 | - foreach( (array) $request->data as $entry ) { |
|
340 | - $data[] = $this->saveEntry( $manager, $entry ); |
|
339 | + foreach ((array) $request->data as $entry) { |
|
340 | + $data[] = $this->saveEntry($manager, $entry); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
@@ -352,22 +352,22 @@ discard block |
||
352 | 352 | * @param \stdClass $entry Object including "id" and "attributes" elements |
353 | 353 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
354 | 354 | */ |
355 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
355 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
356 | 356 | { |
357 | - if( isset( $entry->id ) ) { |
|
358 | - $item = $manager->getItem( $entry->id ); |
|
357 | + if (isset($entry->id)) { |
|
358 | + $item = $manager->getItem($entry->id); |
|
359 | 359 | } else { |
360 | 360 | $item = $manager->createItem(); |
361 | 361 | } |
362 | 362 | |
363 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
364 | - $item = $manager->saveItem( $item ); |
|
363 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
364 | + $item = $manager->saveItem($item); |
|
365 | 365 | |
366 | - if( isset( $entry->relationships ) ) { |
|
367 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
366 | + if (isset($entry->relationships)) { |
|
367 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
368 | 368 | } |
369 | 369 | |
370 | - return $manager->getItem( $item->getId() ); |
|
370 | + return $manager->getItem($item->getId()); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | |
@@ -378,28 +378,28 @@ discard block |
||
378 | 378 | * @param \Aimeos\MShop\Common\Item\Iface $item Domain item with an unique ID set |
379 | 379 | * @param \stdClass $relationships Object including the <domain>/data/attributes structure |
380 | 380 | */ |
381 | - protected function saveRelationships( \Aimeos\MShop\Common\Manager\Iface $manager, |
|
382 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships ) |
|
381 | + protected function saveRelationships(\Aimeos\MShop\Common\Manager\Iface $manager, |
|
382 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships) |
|
383 | 383 | { |
384 | 384 | $id = $item->getId(); |
385 | - $listManager = $manager->getSubManager( 'lists' ); |
|
385 | + $listManager = $manager->getSubManager('lists'); |
|
386 | 386 | |
387 | - foreach( (array) $relationships as $domain => $list ) |
|
387 | + foreach ((array) $relationships as $domain => $list) |
|
388 | 388 | { |
389 | - if( isset( $list->data ) ) |
|
389 | + if (isset($list->data)) |
|
390 | 390 | { |
391 | - foreach( (array) $list->data as $data ) |
|
391 | + foreach ((array) $list->data as $data) |
|
392 | 392 | { |
393 | - $listItem = $this->addItemData( $listManager, $listManager->createItem(), $data, $domain ); |
|
393 | + $listItem = $this->addItemData($listManager, $listManager->createItem(), $data, $domain); |
|
394 | 394 | |
395 | - if( isset( $data->id ) ) { |
|
396 | - $listItem->setRefId( $data->id ); |
|
395 | + if (isset($data->id)) { |
|
396 | + $listItem->setRefId($data->id); |
|
397 | 397 | } |
398 | 398 | |
399 | - $listItem->setParentId( $id ); |
|
400 | - $listItem->setDomain( $domain ); |
|
399 | + $listItem->setParentId($id); |
|
400 | + $listItem->setDomain($domain); |
|
401 | 401 | |
402 | - $listManager->saveItem( $listItem, false ); |
|
402 | + $listManager->saveItem($listItem, false); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | } |
@@ -416,20 +416,20 @@ discard block |
||
416 | 416 | * @return \Aimeos\MShop\Common\Item\Iface Item including the data |
417 | 417 | */ |
418 | 418 | protected function addItemData(\Aimeos\MShop\Common\Manager\Iface $manager, |
419 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain ) |
|
419 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain) |
|
420 | 420 | { |
421 | - if( isset( $data->attributes ) ) |
|
421 | + if (isset($data->attributes)) |
|
422 | 422 | { |
423 | 423 | $attr = (array) $data->attributes; |
424 | - $key = str_replace( '/', '.', $item->getResourceType() ); |
|
424 | + $key = str_replace('/', '.', $item->getResourceType()); |
|
425 | 425 | |
426 | - if( isset( $attr[$key.'.type'] ) ) |
|
426 | + if (isset($attr[$key . '.type'])) |
|
427 | 427 | { |
428 | - $typeItem = $manager->getSubManager( 'type' )->findItem( $attr[$key.'.type'], [], $domain ); |
|
429 | - $attr[$key.'.typeid'] = $typeItem->getId(); |
|
428 | + $typeItem = $manager->getSubManager('type')->findItem($attr[$key . '.type'], [], $domain); |
|
429 | + $attr[$key . '.typeid'] = $typeItem->getId(); |
|
430 | 430 | } |
431 | 431 | |
432 | - $item->fromArray( $attr ); |
|
432 | + $item->fromArray($attr); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | return $item; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $this->context = \TestHelperJadm::getContext(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Admin\JsonAdm\Plugin\Config\Standard( $this->context, $this->view, $templatePaths, 'plugin/config' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Plugin\Config\Standard($this->context, $this->view, $templatePaths, 'plugin/config'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -31,26 +31,26 @@ discard block |
||
31 | 31 | $params = array( |
32 | 32 | 'id' => 'Autofill,Log', |
33 | 33 | ); |
34 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
35 | - $this->view->addHelper( 'param', $helper ); |
|
36 | - |
|
37 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
38 | - $result = json_decode( (string) $response->getBody(), true ); |
|
39 | - |
|
40 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
41 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
42 | - |
|
43 | - $this->assertEquals( 8, $result['meta']['total'] ); |
|
44 | - $this->assertInternalType( 'array', $result['data'] ); |
|
45 | - $this->assertEquals( 'autofill.address', $result['data'][0]['id'] ); |
|
46 | - $this->assertEquals( 'autofill.delivery', $result['data'][1]['id'] ); |
|
47 | - $this->assertEquals( 'autofill.deliverycode', $result['data'][2]['id'] ); |
|
48 | - $this->assertEquals( 'autofill.payment', $result['data'][3]['id'] ); |
|
49 | - $this->assertEquals( 'autofill.paymentcode', $result['data'][4]['id'] ); |
|
50 | - $this->assertEquals( 'autofill.useorder', $result['data'][5]['id'] ); |
|
51 | - $this->assertEquals( 'autofill.orderaddress', $result['data'][6]['id'] ); |
|
52 | - $this->assertEquals( 'autofill.orderservice', $result['data'][7]['id'] ); |
|
53 | - |
|
54 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
34 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
35 | + $this->view->addHelper('param', $helper); |
|
36 | + |
|
37 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
38 | + $result = json_decode((string) $response->getBody(), true); |
|
39 | + |
|
40 | + $this->assertEquals(200, $response->getStatusCode()); |
|
41 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
42 | + |
|
43 | + $this->assertEquals(8, $result['meta']['total']); |
|
44 | + $this->assertInternalType('array', $result['data']); |
|
45 | + $this->assertEquals('autofill.address', $result['data'][0]['id']); |
|
46 | + $this->assertEquals('autofill.delivery', $result['data'][1]['id']); |
|
47 | + $this->assertEquals('autofill.deliverycode', $result['data'][2]['id']); |
|
48 | + $this->assertEquals('autofill.payment', $result['data'][3]['id']); |
|
49 | + $this->assertEquals('autofill.paymentcode', $result['data'][4]['id']); |
|
50 | + $this->assertEquals('autofill.useorder', $result['data'][5]['id']); |
|
51 | + $this->assertEquals('autofill.orderaddress', $result['data'][6]['id']); |
|
52 | + $this->assertEquals('autofill.orderservice', $result['data'][7]['id']); |
|
53 | + |
|
54 | + $this->assertArrayNotHasKey('errors', $result); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | \ No newline at end of file |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
111 | 111 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
112 | 112 | */ |
113 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
113 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
114 | 114 | { |
115 | 115 | /** admin/jsonadm/partials/locale/site/template-data |
116 | 116 | * Relative path to the data partial template file for the locale site client |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | * @since 2016.07 |
128 | 128 | * @category Developer |
129 | 129 | */ |
130 | - $this->getView()->assign( array( 'partial-data' => 'admin/jsonadm/partials/locale/site/template-data' ) ); |
|
130 | + $this->getView()->assign(array('partial-data' => 'admin/jsonadm/partials/locale/site/template-data')); |
|
131 | 131 | |
132 | - return parent::get( $request, $response ); |
|
132 | + return parent::get($request, $response); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -141,16 +141,16 @@ discard block |
||
141 | 141 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
142 | 142 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
143 | 143 | */ |
144 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
144 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
145 | 145 | { |
146 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale/site' ); |
|
147 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
146 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'locale/site'); |
|
147 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
148 | 148 | $total = 1; |
149 | 149 | |
150 | - if( ( $id = $view->param( 'id' ) ) == null ) { |
|
151 | - $view->data = $manager->searchItems( $search, [], $total ); |
|
150 | + if (($id = $view->param('id')) == null) { |
|
151 | + $view->data = $manager->searchItems($search, [], $total); |
|
152 | 152 | } else { |
153 | - $view->data = $manager->getTree( $id, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $search ); |
|
153 | + $view->data = $manager->getTree($id, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $search); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | $view->childItems = []; |
@@ -169,25 +169,25 @@ discard block |
||
169 | 169 | * @param \stdClass $entry Object including "id" and "attributes" elements |
170 | 170 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
171 | 171 | */ |
172 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
172 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
173 | 173 | { |
174 | - if( isset( $entry->id ) ) |
|
174 | + if (isset($entry->id)) |
|
175 | 175 | { |
176 | - $item = $manager->getItem( $entry->id ); |
|
177 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
178 | - $item = $manager->saveItem( $item ); |
|
176 | + $item = $manager->getItem($entry->id); |
|
177 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
178 | + $item = $manager->saveItem($item); |
|
179 | 179 | } |
180 | 180 | else |
181 | 181 | { |
182 | 182 | $item = $manager->createItem(); |
183 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
184 | - $manager->insertItem( $item ); |
|
183 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
184 | + $manager->insertItem($item); |
|
185 | 185 | } |
186 | 186 | |
187 | - if( isset( $entry->relationships ) ) { |
|
188 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
187 | + if (isset($entry->relationships)) { |
|
188 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
189 | 189 | } |
190 | 190 | |
191 | - return $manager->getItem( $item->getId() ); |
|
191 | + return $manager->getItem($item->getId()); |
|
192 | 192 | } |
193 | 193 | } |
@@ -176,8 +176,7 @@ |
||
176 | 176 | $item = $manager->getItem( $entry->id ); |
177 | 177 | $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
178 | 178 | $item = $manager->saveItem( $item ); |
179 | - } |
|
180 | - else |
|
179 | + } else |
|
181 | 180 | { |
182 | 181 | $item = $manager->createItem(); |
183 | 182 | $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
@@ -22,32 +22,32 @@ discard block |
||
22 | 22 | $this->context = \TestHelperJadm::getContext(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Admin\JsonAdm\Locale\Site\Standard( $this->context, $this->view, $templatePaths, 'locale/site' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Locale\Site\Standard($this->context, $this->view, $templatePaths, 'locale/site'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
29 | 29 | public function testGet() |
30 | 30 | { |
31 | 31 | $params = array( |
32 | - 'id' => $this->getSiteItem( 'unittest' )->getId(), |
|
32 | + 'id' => $this->getSiteItem('unittest')->getId(), |
|
33 | 33 | 'filter' => array( |
34 | - '==' => array( 'locale.status' => 0 ) |
|
34 | + '==' => array('locale.status' => 0) |
|
35 | 35 | ), |
36 | 36 | ); |
37 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
38 | - $this->view->addHelper( 'param', $helper ); |
|
37 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
38 | + $this->view->addHelper('param', $helper); |
|
39 | 39 | |
40 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
41 | - $result = json_decode( (string) $response->getBody(), true ); |
|
40 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
41 | + $result = json_decode((string) $response->getBody(), true); |
|
42 | 42 | |
43 | 43 | |
44 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
45 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
44 | + $this->assertEquals(200, $response->getStatusCode()); |
|
45 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
46 | 46 | |
47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
48 | - $this->assertEquals( 'locale/site', $result['data']['type'] ); |
|
47 | + $this->assertEquals(1, $result['meta']['total']); |
|
48 | + $this->assertEquals('locale/site', $result['data']['type']); |
|
49 | 49 | |
50 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
50 | + $this->assertArrayNotHasKey('errors', $result); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -55,124 +55,124 @@ discard block |
||
55 | 55 | { |
56 | 56 | $params = array( |
57 | 57 | 'filter' => array( |
58 | - '==' => array( 'locale.site.code' => 'unittest' ) |
|
58 | + '==' => array('locale.site.code' => 'unittest') |
|
59 | 59 | ), |
60 | 60 | ); |
61 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
62 | - $this->view->addHelper( 'param', $helper ); |
|
61 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
62 | + $this->view->addHelper('param', $helper); |
|
63 | 63 | |
64 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
65 | - $result = json_decode( (string) $response->getBody(), true ); |
|
64 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
65 | + $result = json_decode((string) $response->getBody(), true); |
|
66 | 66 | |
67 | 67 | |
68 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
69 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
68 | + $this->assertEquals(200, $response->getStatusCode()); |
|
69 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
70 | 70 | |
71 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
72 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
73 | - $this->assertEquals( 'locale/site', $result['data'][0]['type'] ); |
|
71 | + $this->assertEquals(1, $result['meta']['total']); |
|
72 | + $this->assertEquals(1, count($result['data'])); |
|
73 | + $this->assertEquals('locale/site', $result['data'][0]['type']); |
|
74 | 74 | |
75 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
75 | + $this->assertArrayNotHasKey('errors', $result); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
79 | 79 | public function testPatch() |
80 | 80 | { |
81 | - $stub = $this->getSiteMock( array( 'getItem', 'moveItem', 'saveItem' ) ); |
|
81 | + $stub = $this->getSiteMock(array('getItem', 'moveItem', 'saveItem')); |
|
82 | 82 | $item = $stub->createItem(); |
83 | 83 | |
84 | - $stub->expects( $this->once() )->method( 'saveItem' ) |
|
85 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
86 | - $stub->expects( $this->exactly( 2 ) )->method( 'getItem' ) // 2x due to decorator |
|
87 | - ->will( $this->returnValue( $item ) ); |
|
84 | + $stub->expects($this->once())->method('saveItem') |
|
85 | + ->will($this->returnValue($stub->createItem())); |
|
86 | + $stub->expects($this->exactly(2))->method('getItem') // 2x due to decorator |
|
87 | + ->will($this->returnValue($item)); |
|
88 | 88 | |
89 | 89 | |
90 | - $params = array( 'id' => '-1' ); |
|
91 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
92 | - $this->view->addHelper( 'param', $helper ); |
|
90 | + $params = array('id' => '-1'); |
|
91 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
92 | + $this->view->addHelper('param', $helper); |
|
93 | 93 | |
94 | 94 | $body = '{"data": {"parentid": "1", "targetid": 2, "type": "locale/site", "attributes": {"locale.site.label": "test"}}}'; |
95 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
95 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
96 | 96 | |
97 | - $response = $this->object->patch( $request, $this->view->response() ); |
|
98 | - $result = json_decode( (string) $response->getBody(), true ); |
|
97 | + $response = $this->object->patch($request, $this->view->response()); |
|
98 | + $result = json_decode((string) $response->getBody(), true); |
|
99 | 99 | |
100 | 100 | |
101 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
102 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
101 | + $this->assertEquals(200, $response->getStatusCode()); |
|
102 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
103 | 103 | |
104 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
105 | - $this->assertArrayHasKey( 'data', $result ); |
|
106 | - $this->assertEquals( 'locale/site', $result['data']['type'] ); |
|
104 | + $this->assertEquals(1, $result['meta']['total']); |
|
105 | + $this->assertArrayHasKey('data', $result); |
|
106 | + $this->assertEquals('locale/site', $result['data']['type']); |
|
107 | 107 | |
108 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
109 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
108 | + $this->assertArrayNotHasKey('included', $result); |
|
109 | + $this->assertArrayNotHasKey('errors', $result); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
113 | 113 | public function testPost() |
114 | 114 | { |
115 | - $stub = $this->getSiteMock( array( 'getItem', 'insertItem' ) ); |
|
115 | + $stub = $this->getSiteMock(array('getItem', 'insertItem')); |
|
116 | 116 | $item = $stub->createItem(); |
117 | 117 | |
118 | - $stub->expects( $this->any() )->method( 'getItem' ) |
|
119 | - ->will( $this->returnValue( $item ) ); |
|
120 | - $stub->expects( $this->once() )->method( 'insertItem' ); |
|
118 | + $stub->expects($this->any())->method('getItem') |
|
119 | + ->will($this->returnValue($item)); |
|
120 | + $stub->expects($this->once())->method('insertItem'); |
|
121 | 121 | |
122 | 122 | |
123 | 123 | $body = '{"data": {"type": "locale/site", "attributes": {"locale.site.code": "unittest", "locale.site.label": "Unit test"}}}'; |
124 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
124 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
125 | 125 | |
126 | - $response = $this->object->post( $request, $this->view->response() ); |
|
127 | - $result = json_decode( (string) $response->getBody(), true ); |
|
126 | + $response = $this->object->post($request, $this->view->response()); |
|
127 | + $result = json_decode((string) $response->getBody(), true); |
|
128 | 128 | |
129 | 129 | |
130 | - $this->assertEquals( 201, $response->getStatusCode() ); |
|
131 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
130 | + $this->assertEquals(201, $response->getStatusCode()); |
|
131 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
132 | 132 | |
133 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
134 | - $this->assertArrayHasKey( 'data', $result ); |
|
135 | - $this->assertEquals( 'locale/site', $result['data']['type'] ); |
|
133 | + $this->assertEquals(1, $result['meta']['total']); |
|
134 | + $this->assertArrayHasKey('data', $result); |
|
135 | + $this->assertEquals('locale/site', $result['data']['type']); |
|
136 | 136 | |
137 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
138 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
137 | + $this->assertArrayNotHasKey('included', $result); |
|
138 | + $this->assertArrayNotHasKey('errors', $result); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
142 | - protected function getSiteItem( $code ) |
|
142 | + protected function getSiteItem($code) |
|
143 | 143 | { |
144 | - $manager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $this->context )->getSubManager( 'site' ); |
|
144 | + $manager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->context)->getSubManager('site'); |
|
145 | 145 | $search = $manager->createSearch(); |
146 | - $search->setConditions( $search->compare( '==', 'locale.site.code', $code ) ); |
|
147 | - $items = $manager->searchItems( $search ); |
|
146 | + $search->setConditions($search->compare('==', 'locale.site.code', $code)); |
|
147 | + $items = $manager->searchItems($search); |
|
148 | 148 | |
149 | - if( ( $item = reset( $items ) ) === false ) { |
|
150 | - throw new \RuntimeException( sprintf( 'No locale site item with code "%1$s" found', $code ) ); |
|
149 | + if (($item = reset($items)) === false) { |
|
150 | + throw new \RuntimeException(sprintf('No locale site item with code "%1$s" found', $code)); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | return $item; |
154 | 154 | } |
155 | 155 | |
156 | 156 | |
157 | - protected function getSiteMock( array $methods ) |
|
157 | + protected function getSiteMock(array $methods) |
|
158 | 158 | { |
159 | 159 | $name = 'AdminJsonAdmStandard'; |
160 | - $this->context->getConfig()->set( 'mshop/locale/manager/name', $name ); |
|
160 | + $this->context->getConfig()->set('mshop/locale/manager/name', $name); |
|
161 | 161 | |
162 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Locale\\Manager\\Standard' ) |
|
163 | - ->setConstructorArgs( array( $this->context ) ) |
|
164 | - ->setMethods( array( 'getSubManager' ) ) |
|
162 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Locale\\Manager\\Standard') |
|
163 | + ->setConstructorArgs(array($this->context)) |
|
164 | + ->setMethods(array('getSubManager')) |
|
165 | 165 | ->getMock(); |
166 | 166 | |
167 | - $siteStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Locale\\Manager\\Site\\Standard' ) |
|
168 | - ->setConstructorArgs( array( $this->context ) ) |
|
169 | - ->setMethods( $methods ) |
|
167 | + $siteStub = $this->getMockBuilder('\\Aimeos\\MShop\\Locale\\Manager\\Site\\Standard') |
|
168 | + ->setConstructorArgs(array($this->context)) |
|
169 | + ->setMethods($methods) |
|
170 | 170 | ->getMock(); |
171 | 171 | |
172 | - $stub->expects( $this->once() )->method( 'getSubManager' ) |
|
173 | - ->will( $this->returnValue( $siteStub ) ); |
|
172 | + $stub->expects($this->once())->method('getSubManager') |
|
173 | + ->will($this->returnValue($siteStub)); |
|
174 | 174 | |
175 | - \Aimeos\MShop\Locale\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Locale\\Manager\\' . $name, $stub ); |
|
175 | + \Aimeos\MShop\Locale\Manager\Factory::injectManager('\\Aimeos\\MShop\\Locale\\Manager\\' . $name, $stub); |
|
176 | 176 | |
177 | 177 | return $siteStub; |
178 | 178 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
111 | 111 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
112 | 112 | */ |
113 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
113 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
114 | 114 | { |
115 | 115 | /** admin/jsonadm/partials/catalog/template-data |
116 | 116 | * Relative path to the data partial template file for the catalog client |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | * @since 2016.07 |
128 | 128 | * @category Developer |
129 | 129 | */ |
130 | - $this->getView()->assign( array( 'partial-data' => 'admin/jsonadm/partials/catalog/template-data' ) ); |
|
130 | + $this->getView()->assign(array('partial-data' => 'admin/jsonadm/partials/catalog/template-data')); |
|
131 | 131 | |
132 | - return parent::get( $request, $response ); |
|
132 | + return parent::get($request, $response); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -140,14 +140,14 @@ discard block |
||
140 | 140 | * @param array $include List of resource types that should be fetched |
141 | 141 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
142 | 142 | */ |
143 | - protected function getChildItems( array $items, array $include ) |
|
143 | + protected function getChildItems(array $items, array $include) |
|
144 | 144 | { |
145 | 145 | $list = []; |
146 | 146 | |
147 | - if( in_array( 'catalog', $include ) ) |
|
147 | + if (in_array('catalog', $include)) |
|
148 | 148 | { |
149 | - foreach( $items as $item ) { |
|
150 | - $list = array_merge( $list, [$item], $this->getChildItems( $item->getChildren(), $include ) ); |
|
149 | + foreach ($items as $item) { |
|
150 | + $list = array_merge($list, [$item], $this->getChildItems($item->getChildren(), $include)); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
@@ -162,40 +162,40 @@ discard block |
||
162 | 162 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
163 | 163 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
164 | 164 | */ |
165 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
165 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
166 | 166 | { |
167 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' ); |
|
167 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog'); |
|
168 | 168 | |
169 | - if( ( $key = $view->param( 'aggregate' ) ) !== null ) |
|
169 | + if (($key = $view->param('aggregate')) !== null) |
|
170 | 170 | { |
171 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
172 | - $view->data = $manager->aggregate( $search, $key ); |
|
171 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
172 | + $view->data = $manager->aggregate($search, $key); |
|
173 | 173 | return $response; |
174 | 174 | } |
175 | 175 | |
176 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : [] ); |
|
177 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
176 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : []); |
|
177 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
178 | 178 | $total = 1; |
179 | 179 | |
180 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
180 | + if (($id = $view->param('id')) == null) |
|
181 | 181 | { |
182 | - $view->data = $manager->searchItems( $search, [], $total ); |
|
183 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
182 | + $view->data = $manager->searchItems($search, [], $total); |
|
183 | + $view->listItems = $this->getListItems($view->data, $include); |
|
184 | 184 | $view->childItems = []; |
185 | 185 | } |
186 | 186 | else |
187 | 187 | { |
188 | 188 | $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE; |
189 | - if( in_array( 'catalog', $include ) ) { |
|
189 | + if (in_array('catalog', $include)) { |
|
190 | 190 | $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST; |
191 | 191 | } |
192 | 192 | |
193 | - $view->data = $manager->getTree( $id, $include, $level, $search ); |
|
194 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
195 | - $view->childItems = $this->getChildItems( $view->data->getChildren(), $include ); |
|
193 | + $view->data = $manager->getTree($id, $include, $level, $search); |
|
194 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
195 | + $view->childItems = $this->getChildItems($view->data->getChildren(), $include); |
|
196 | 196 | } |
197 | 197 | |
198 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
198 | + $view->refItems = $this->getRefItems($view->listItems); |
|
199 | 199 | $view->total = $total; |
200 | 200 | |
201 | 201 | return $response; |
@@ -209,18 +209,18 @@ discard block |
||
209 | 209 | * @param array $include List of resource types that should be fetched |
210 | 210 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
211 | 211 | */ |
212 | - protected function getListItems( array $items, array $include ) |
|
212 | + protected function getListItems(array $items, array $include) |
|
213 | 213 | { |
214 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
214 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
215 | 215 | |
216 | 216 | $search = $manager->createSearch(); |
217 | 217 | $expr = array( |
218 | - $search->compare( '==', 'catalog.lists.parentid', array_keys( $items ) ), |
|
219 | - $search->compare( '==', 'catalog.lists.domain', $include ), |
|
218 | + $search->compare('==', 'catalog.lists.parentid', array_keys($items)), |
|
219 | + $search->compare('==', 'catalog.lists.domain', $include), |
|
220 | 220 | ); |
221 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
221 | + $search->setConditions($search->combine('&&', $expr)); |
|
222 | 222 | |
223 | - return $manager->searchItems( $search ); |
|
223 | + return $manager->searchItems($search); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
@@ -231,32 +231,32 @@ discard block |
||
231 | 231 | * @param \stdClass $entry Object including "id" and "attributes" elements |
232 | 232 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
233 | 233 | */ |
234 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
234 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
235 | 235 | { |
236 | - $targetId = ( isset( $entry->targetid ) ? $entry->targetid : null ); |
|
237 | - $refId = ( isset( $entry->refid ) ? $entry->refid : null ); |
|
236 | + $targetId = (isset($entry->targetid) ? $entry->targetid : null); |
|
237 | + $refId = (isset($entry->refid) ? $entry->refid : null); |
|
238 | 238 | |
239 | - if( isset( $entry->id ) ) |
|
239 | + if (isset($entry->id)) |
|
240 | 240 | { |
241 | - $item = $manager->getItem( $entry->id ); |
|
242 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
243 | - $item = $manager->saveItem( $item ); |
|
241 | + $item = $manager->getItem($entry->id); |
|
242 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
243 | + $item = $manager->saveItem($item); |
|
244 | 244 | |
245 | - if( isset( $entry->parentid ) && $targetId !== null ) { |
|
246 | - $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
|
245 | + if (isset($entry->parentid) && $targetId !== null) { |
|
246 | + $manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | else |
250 | 250 | { |
251 | 251 | $item = $manager->createItem(); |
252 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
253 | - $manager->insertItem( $item, $targetId, $refId ); |
|
252 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
253 | + $manager->insertItem($item, $targetId, $refId); |
|
254 | 254 | } |
255 | 255 | |
256 | - if( isset( $entry->relationships ) ) { |
|
257 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
256 | + if (isset($entry->relationships)) { |
|
257 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
258 | 258 | } |
259 | 259 | |
260 | - return $manager->getItem( $item->getId() ); |
|
260 | + return $manager->getItem($item->getId()); |
|
261 | 261 | } |
262 | 262 | } |
@@ -182,8 +182,7 @@ discard block |
||
182 | 182 | $view->data = $manager->searchItems( $search, [], $total ); |
183 | 183 | $view->listItems = $this->getListItems( $view->data, $include ); |
184 | 184 | $view->childItems = []; |
185 | - } |
|
186 | - else |
|
185 | + } else |
|
187 | 186 | { |
188 | 187 | $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE; |
189 | 188 | if( in_array( 'catalog', $include ) ) { |
@@ -245,8 +244,7 @@ discard block |
||
245 | 244 | if( isset( $entry->parentid ) && $targetId !== null ) { |
246 | 245 | $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
247 | 246 | } |
248 | - } |
|
249 | - else |
|
247 | + } else |
|
250 | 248 | { |
251 | 249 | $item = $manager->createItem(); |
252 | 250 | $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $this->context = \TestHelperJadm::getContext(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Admin\JsonAdm\Catalog\Standard( $this->context, $this->view, $templatePaths, 'catalog' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Catalog\Standard($this->context, $this->view, $templatePaths, 'catalog'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -30,142 +30,142 @@ discard block |
||
30 | 30 | { |
31 | 31 | $params = array( |
32 | 32 | 'filter' => array( |
33 | - '==' => array( 'catalog.code' => 'cafe' ) |
|
33 | + '==' => array('catalog.code' => 'cafe') |
|
34 | 34 | ), |
35 | 35 | 'include' => 'text' |
36 | 36 | ); |
37 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
38 | - $this->view->addHelper( 'param', $helper ); |
|
37 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
38 | + $this->view->addHelper('param', $helper); |
|
39 | 39 | |
40 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
41 | - $result = json_decode( (string) $response->getBody(), true ); |
|
40 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
41 | + $result = json_decode((string) $response->getBody(), true); |
|
42 | 42 | |
43 | 43 | |
44 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
45 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
44 | + $this->assertEquals(200, $response->getStatusCode()); |
|
45 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
46 | 46 | |
47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
49 | - $this->assertEquals( 'catalog', $result['data'][0]['type'] ); |
|
50 | - $this->assertEquals( 6, count( $result['data'][0]['relationships']['text'] ) ); |
|
51 | - $this->assertEquals( 6, count( $result['included'] ) ); |
|
47 | + $this->assertEquals(1, $result['meta']['total']); |
|
48 | + $this->assertEquals(1, count($result['data'])); |
|
49 | + $this->assertEquals('catalog', $result['data'][0]['type']); |
|
50 | + $this->assertEquals(6, count($result['data'][0]['relationships']['text'])); |
|
51 | + $this->assertEquals(6, count($result['included'])); |
|
52 | 52 | |
53 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
53 | + $this->assertArrayNotHasKey('errors', $result); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | 57 | public function testGetTree() |
58 | 58 | { |
59 | 59 | $params = array( |
60 | - 'id' => $this->getCatalogItem( 'root' )->getId(), |
|
60 | + 'id' => $this->getCatalogItem('root')->getId(), |
|
61 | 61 | 'include' => 'catalog,text' |
62 | 62 | ); |
63 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
64 | - $this->view->addHelper( 'param', $helper ); |
|
63 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
64 | + $this->view->addHelper('param', $helper); |
|
65 | 65 | |
66 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
67 | - $result = json_decode( (string) $response->getBody(), true ); |
|
66 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
67 | + $result = json_decode((string) $response->getBody(), true); |
|
68 | 68 | |
69 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
70 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
69 | + $this->assertEquals(200, $response->getStatusCode()); |
|
70 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
71 | 71 | |
72 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
73 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
74 | - $this->assertEquals( 2, count( $result['data']['relationships']['catalog'] ) ); |
|
75 | - $this->assertEquals( 2, count( $result['included'] ) ); |
|
72 | + $this->assertEquals(1, $result['meta']['total']); |
|
73 | + $this->assertEquals('catalog', $result['data']['type']); |
|
74 | + $this->assertEquals(2, count($result['data']['relationships']['catalog'])); |
|
75 | + $this->assertEquals(2, count($result['included'])); |
|
76 | 76 | |
77 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
77 | + $this->assertArrayNotHasKey('errors', $result); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
81 | 81 | public function testPatch() |
82 | 82 | { |
83 | - $stub = $this->getCatalogMock( array( 'getItem', 'moveItem', 'saveItem' ) ); |
|
83 | + $stub = $this->getCatalogMock(array('getItem', 'moveItem', 'saveItem')); |
|
84 | 84 | |
85 | - $stub->expects( $this->once() )->method( 'moveItem' ); |
|
86 | - $stub->expects( $this->once() )->method( 'saveItem' ) |
|
87 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
88 | - $stub->expects( $this->exactly( 2 ) )->method( 'getItem' ) // 2x due to decorator |
|
89 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
85 | + $stub->expects($this->once())->method('moveItem'); |
|
86 | + $stub->expects($this->once())->method('saveItem') |
|
87 | + ->will($this->returnValue($stub->createItem())); |
|
88 | + $stub->expects($this->exactly(2))->method('getItem') // 2x due to decorator |
|
89 | + ->will($this->returnValue($stub->createItem())); |
|
90 | 90 | |
91 | 91 | |
92 | - $params = array( 'id' => '-1' ); |
|
93 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
94 | - $this->view->addHelper( 'param', $helper ); |
|
92 | + $params = array('id' => '-1'); |
|
93 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
94 | + $this->view->addHelper('param', $helper); |
|
95 | 95 | |
96 | 96 | $body = '{"data": {"parentid": "1", "targetid": 2, "type": "catalog", "attributes": {"catalog.label": "test"}}}'; |
97 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
97 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
98 | 98 | |
99 | - $response = $this->object->patch( $request, $this->view->response() ); |
|
100 | - $result = json_decode( (string) $response->getBody(), true ); |
|
99 | + $response = $this->object->patch($request, $this->view->response()); |
|
100 | + $result = json_decode((string) $response->getBody(), true); |
|
101 | 101 | |
102 | 102 | |
103 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
104 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
103 | + $this->assertEquals(200, $response->getStatusCode()); |
|
104 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
105 | 105 | |
106 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
107 | - $this->assertArrayHasKey( 'data', $result ); |
|
108 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
106 | + $this->assertEquals(1, $result['meta']['total']); |
|
107 | + $this->assertArrayHasKey('data', $result); |
|
108 | + $this->assertEquals('catalog', $result['data']['type']); |
|
109 | 109 | |
110 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
111 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
110 | + $this->assertArrayNotHasKey('included', $result); |
|
111 | + $this->assertArrayNotHasKey('errors', $result); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | public function testPost() |
116 | 116 | { |
117 | - $stub = $this->getCatalogMock( array( 'getItem', 'insertItem' ) ); |
|
117 | + $stub = $this->getCatalogMock(array('getItem', 'insertItem')); |
|
118 | 118 | |
119 | - $stub->expects( $this->any() )->method( 'getItem' ) |
|
120 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
121 | - $stub->expects( $this->once() )->method( 'insertItem' ); |
|
119 | + $stub->expects($this->any())->method('getItem') |
|
120 | + ->will($this->returnValue($stub->createItem())); |
|
121 | + $stub->expects($this->once())->method('insertItem'); |
|
122 | 122 | |
123 | 123 | |
124 | 124 | $body = '{"data": {"type": "catalog", "attributes": {"catalog.code": "test", "catalog.label": "Test catalog"}}}'; |
125 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
125 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
126 | 126 | |
127 | - $response = $this->object->post( $request, $this->view->response() ); |
|
128 | - $result = json_decode( (string) $response->getBody(), true ); |
|
127 | + $response = $this->object->post($request, $this->view->response()); |
|
128 | + $result = json_decode((string) $response->getBody(), true); |
|
129 | 129 | |
130 | 130 | |
131 | - $this->assertEquals( 201, $response->getStatusCode() ); |
|
132 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
131 | + $this->assertEquals(201, $response->getStatusCode()); |
|
132 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
133 | 133 | |
134 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
135 | - $this->assertArrayHasKey( 'data', $result ); |
|
136 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
134 | + $this->assertEquals(1, $result['meta']['total']); |
|
135 | + $this->assertArrayHasKey('data', $result); |
|
136 | + $this->assertEquals('catalog', $result['data']['type']); |
|
137 | 137 | |
138 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
139 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
138 | + $this->assertArrayNotHasKey('included', $result); |
|
139 | + $this->assertArrayNotHasKey('errors', $result); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | |
143 | - protected function getCatalogItem( $code ) |
|
143 | + protected function getCatalogItem($code) |
|
144 | 144 | { |
145 | - $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->context ); |
|
145 | + $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context); |
|
146 | 146 | $search = $manager->createSearch(); |
147 | - $search->setConditions( $search->compare( '==', 'catalog.code', $code ) ); |
|
148 | - $items = $manager->searchItems( $search ); |
|
147 | + $search->setConditions($search->compare('==', 'catalog.code', $code)); |
|
148 | + $items = $manager->searchItems($search); |
|
149 | 149 | |
150 | - if( ( $item = reset( $items ) ) === false ) { |
|
151 | - throw new \RuntimeException( sprintf( 'No catalog item with code "%1$s" found', $code ) ); |
|
150 | + if (($item = reset($items)) === false) { |
|
151 | + throw new \RuntimeException(sprintf('No catalog item with code "%1$s" found', $code)); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | return $item; |
155 | 155 | } |
156 | 156 | |
157 | 157 | |
158 | - protected function getCatalogMock( array $methods ) |
|
158 | + protected function getCatalogMock(array $methods) |
|
159 | 159 | { |
160 | 160 | $name = 'ClientJsonAdmStandard'; |
161 | - $this->context->getConfig()->set( 'mshop/catalog/manager/name', $name ); |
|
161 | + $this->context->getConfig()->set('mshop/catalog/manager/name', $name); |
|
162 | 162 | |
163 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Catalog\\Manager\\Standard' ) |
|
164 | - ->setConstructorArgs( array( $this->context ) ) |
|
165 | - ->setMethods( $methods ) |
|
163 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Catalog\\Manager\\Standard') |
|
164 | + ->setConstructorArgs(array($this->context)) |
|
165 | + ->setMethods($methods) |
|
166 | 166 | ->getMock(); |
167 | 167 | |
168 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub ); |
|
168 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub); |
|
169 | 169 | |
170 | 170 | return $stub; |
171 | 171 | } |