@@ -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->getChildren() ); |
|
149 | + foreach ($items as $item) { |
|
150 | + $list = array_merge($list, $item->getChildren()); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
@@ -162,35 +162,35 @@ 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 ); |
|
184 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
182 | + $view->data = $manager->searchItems($search, [], $total); |
|
183 | + $view->listItems = $this->getListItems($view->data, $include); |
|
184 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
185 | 185 | } |
186 | 186 | else |
187 | 187 | { |
188 | - $view->data = $manager->getTree( $id, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search ); |
|
189 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
190 | - $view->childItems = $this->getChildItems( array( $view->data ), $include ); |
|
188 | + $view->data = $manager->getTree($id, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search); |
|
189 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
190 | + $view->childItems = $this->getChildItems(array($view->data), $include); |
|
191 | 191 | } |
192 | 192 | |
193 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
193 | + $view->refItems = $this->getRefItems($view->listItems); |
|
194 | 194 | $view->total = $total; |
195 | 195 | |
196 | 196 | return $response; |
@@ -204,18 +204,18 @@ discard block |
||
204 | 204 | * @param array $include List of resource types that should be fetched |
205 | 205 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
206 | 206 | */ |
207 | - protected function getListItems( array $items, array $include ) |
|
207 | + protected function getListItems(array $items, array $include) |
|
208 | 208 | { |
209 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
209 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
210 | 210 | |
211 | 211 | $search = $manager->createSearch(); |
212 | 212 | $expr = array( |
213 | - $search->compare( '==', 'catalog.lists.parentid', array_keys( $items ) ), |
|
214 | - $search->compare( '==', 'catalog.lists.domain', $include ), |
|
213 | + $search->compare('==', 'catalog.lists.parentid', array_keys($items)), |
|
214 | + $search->compare('==', 'catalog.lists.domain', $include), |
|
215 | 215 | ); |
216 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
216 | + $search->setConditions($search->combine('&&', $expr)); |
|
217 | 217 | |
218 | - return $manager->searchItems( $search ); |
|
218 | + return $manager->searchItems($search); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | |
@@ -226,32 +226,32 @@ discard block |
||
226 | 226 | * @param \stdClass $entry Object including "id" and "attributes" elements |
227 | 227 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
228 | 228 | */ |
229 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
229 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
230 | 230 | { |
231 | - $targetId = ( isset( $entry->targetid ) ? $entry->targetid : null ); |
|
232 | - $refId = ( isset( $entry->refid ) ? $entry->refid : null ); |
|
231 | + $targetId = (isset($entry->targetid) ? $entry->targetid : null); |
|
232 | + $refId = (isset($entry->refid) ? $entry->refid : null); |
|
233 | 233 | |
234 | - if( isset( $entry->id ) ) |
|
234 | + if (isset($entry->id)) |
|
235 | 235 | { |
236 | - $item = $manager->getItem( $entry->id ); |
|
237 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
238 | - $item = $manager->saveItem( $item ); |
|
236 | + $item = $manager->getItem($entry->id); |
|
237 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
238 | + $item = $manager->saveItem($item); |
|
239 | 239 | |
240 | - if( isset( $entry->parentid ) && $targetId !== null ) { |
|
241 | - $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
|
240 | + if (isset($entry->parentid) && $targetId !== null) { |
|
241 | + $manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | else |
245 | 245 | { |
246 | 246 | $item = $manager->createItem(); |
247 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
248 | - $manager->insertItem( $item, $targetId, $refId ); |
|
247 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
248 | + $manager->insertItem($item, $targetId, $refId); |
|
249 | 249 | } |
250 | 250 | |
251 | - if( isset( $entry->relationships ) ) { |
|
252 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
251 | + if (isset($entry->relationships)) { |
|
252 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
253 | 253 | } |
254 | 254 | |
255 | - return $manager->getItem( $item->getId() ); |
|
255 | + return $manager->getItem($item->getId()); |
|
256 | 256 | } |
257 | 257 | } |
@@ -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 | |
@@ -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( 'locale/site', $include ) ) |
|
147 | + if (in_array('locale/site', $include)) |
|
148 | 148 | { |
149 | - foreach( $items as $item ) { |
|
150 | - $list = array_merge( $list, $item->getChildren() ); |
|
149 | + foreach ($items as $item) { |
|
150 | + $list = array_merge($list, $item->getChildren()); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
@@ -163,23 +163,23 @@ discard block |
||
163 | 163 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
164 | 164 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
165 | 165 | */ |
166 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
166 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
167 | 167 | { |
168 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale/site' ); |
|
168 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'locale/site'); |
|
169 | 169 | |
170 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : [] ); |
|
171 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
170 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : []); |
|
171 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
172 | 172 | $total = 1; |
173 | 173 | |
174 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
174 | + if (($id = $view->param('id')) == null) |
|
175 | 175 | { |
176 | - $view->data = $manager->searchItems( $search, [], $total ); |
|
177 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
176 | + $view->data = $manager->searchItems($search, [], $total); |
|
177 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
178 | 178 | } |
179 | 179 | else |
180 | 180 | { |
181 | - $view->data = $manager->getTree( $id, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search ); |
|
182 | - $view->childItems = $this->getChildItems( array( $view->data ), $include ); |
|
181 | + $view->data = $manager->getTree($id, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search); |
|
182 | + $view->childItems = $this->getChildItems(array($view->data), $include); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | $view->listItems = []; |
@@ -197,32 +197,32 @@ discard block |
||
197 | 197 | * @param \stdClass $entry Object including "id" and "attributes" elements |
198 | 198 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
199 | 199 | */ |
200 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
200 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
201 | 201 | { |
202 | - $targetId = ( isset( $entry->targetid ) ? $entry->targetid : null ); |
|
203 | - $refId = ( isset( $entry->refid ) ? $entry->refid : null ); |
|
202 | + $targetId = (isset($entry->targetid) ? $entry->targetid : null); |
|
203 | + $refId = (isset($entry->refid) ? $entry->refid : null); |
|
204 | 204 | |
205 | - if( isset( $entry->id ) ) |
|
205 | + if (isset($entry->id)) |
|
206 | 206 | { |
207 | - $item = $manager->getItem( $entry->id ); |
|
208 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
209 | - $item = $manager->saveItem( $item ); |
|
207 | + $item = $manager->getItem($entry->id); |
|
208 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
209 | + $item = $manager->saveItem($item); |
|
210 | 210 | |
211 | - if( isset( $entry->parentid ) && $targetId !== null ) { |
|
212 | - $manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId ); |
|
211 | + if (isset($entry->parentid) && $targetId !== null) { |
|
212 | + $manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId); |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | else |
216 | 216 | { |
217 | 217 | $item = $manager->createItem(); |
218 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
219 | - $manager->insertItem( $item, $targetId, $refId ); |
|
218 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
219 | + $manager->insertItem($item, $targetId, $refId); |
|
220 | 220 | } |
221 | 221 | |
222 | - if( isset( $entry->relationships ) ) { |
|
223 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
222 | + if (isset($entry->relationships)) { |
|
223 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
224 | 224 | } |
225 | 225 | |
226 | - return $manager->getItem( $item->getId() ); |
|
226 | + return $manager->getItem($item->getId()); |
|
227 | 227 | } |
228 | 228 | } |
@@ -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 |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | 'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', 'order', |
110 | 110 | 'plugin', 'price', 'product', 'service', 'supplier', 'stock', 'tag', 'text' |
111 | 111 | ); |
112 | - $domains = $this->getContext()->getConfig()->get( 'admin/jsonadm/domains', $default ); |
|
112 | + $domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | return (array) $domains; |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | * @param \stdClass $request Decoded request body |
123 | 123 | * @return array List of item IDs |
124 | 124 | */ |
125 | - protected function getIds( $request ) |
|
125 | + protected function getIds($request) |
|
126 | 126 | { |
127 | 127 | $ids = []; |
128 | 128 | |
129 | - if( isset( $request->data ) ) |
|
129 | + if (isset($request->data)) |
|
130 | 130 | { |
131 | - foreach( (array) $request->data as $entry ) |
|
131 | + foreach ((array) $request->data as $entry) |
|
132 | 132 | { |
133 | - if( isset( $entry->id ) ) { |
|
133 | + if (isset($entry->id)) { |
|
134 | 134 | $ids[] = $entry->id; |
135 | 135 | } |
136 | 136 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param array $include List of resource types that should be fetched |
148 | 148 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
149 | 149 | */ |
150 | - protected function getListItems( array $items, array $include ) |
|
150 | + protected function getListItems(array $items, array $include) |
|
151 | 151 | { |
152 | 152 | return []; |
153 | 153 | } |
@@ -170,23 +170,23 @@ discard block |
||
170 | 170 | * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
171 | 171 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
172 | 172 | */ |
173 | - protected function getRefItems( array $listItems ) |
|
173 | + protected function getRefItems(array $listItems) |
|
174 | 174 | { |
175 | 175 | $list = $map = []; |
176 | 176 | $context = $this->getContext(); |
177 | 177 | |
178 | - foreach( $listItems as $listItem ) { |
|
178 | + foreach ($listItems as $listItem) { |
|
179 | 179 | $map[$listItem->getDomain()][] = $listItem->getRefId(); |
180 | 180 | } |
181 | 181 | |
182 | - foreach( $map as $domain => $ids ) |
|
182 | + foreach ($map as $domain => $ids) |
|
183 | 183 | { |
184 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
184 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
185 | 185 | |
186 | 186 | $search = $manager->createSearch(); |
187 | - $search->setConditions( $search->compare( '==', $domain . '.id', $ids ) ); |
|
187 | + $search->setConditions($search->compare('==', $domain . '.id', $ids)); |
|
188 | 188 | |
189 | - $list = array_merge( $list, $manager->searchItems( $search ) ); |
|
189 | + $list = array_merge($list, $manager->searchItems($search)); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | return $list; |
@@ -222,11 +222,11 @@ discard block |
||
222 | 222 | * @param array $params List of criteria data with condition, sorting and paging |
223 | 223 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
224 | 224 | */ |
225 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
225 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
226 | 226 | { |
227 | - $this->initCriteriaConditions( $criteria, $params ); |
|
228 | - $this->initCriteriaSortations( $criteria, $params ); |
|
229 | - $this->initCriteriaSlice( $criteria, $params ); |
|
227 | + $this->initCriteriaConditions($criteria, $params); |
|
228 | + $this->initCriteriaSortations($criteria, $params); |
|
229 | + $this->initCriteriaSlice($criteria, $params); |
|
230 | 230 | |
231 | 231 | return $criteria; |
232 | 232 | } |
@@ -238,17 +238,17 @@ discard block |
||
238 | 238 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
239 | 239 | * @param array $params List of criteria data with condition, sorting and paging |
240 | 240 | */ |
241 | - protected function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
241 | + protected function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
242 | 242 | { |
243 | - if( !isset( $params['filter'] ) ) { |
|
243 | + if (!isset($params['filter'])) { |
|
244 | 244 | return; |
245 | 245 | } |
246 | 246 | |
247 | 247 | $existing = $criteria->getConditions(); |
248 | - $criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) ); |
|
248 | + $criteria->setConditions($criteria->toConditions((array) $params['filter'])); |
|
249 | 249 | |
250 | - $expr = array( $criteria->getConditions(), $existing ); |
|
251 | - $criteria->setConditions( $criteria->combine( '&&', $expr ) ); |
|
250 | + $expr = array($criteria->getConditions(), $existing); |
|
251 | + $criteria->setConditions($criteria->combine('&&', $expr)); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
259 | 259 | * @param array $params List of criteria data with condition, sorting and paging |
260 | 260 | */ |
261 | - protected function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
261 | + protected function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
262 | 262 | { |
263 | - $start = ( isset( $params['page']['offset'] ) ? (int) $params['page']['offset'] : 0 ); |
|
264 | - $size = ( isset( $params['page']['limit'] ) ? (int) $params['page']['limit'] : 25 ); |
|
263 | + $start = (isset($params['page']['offset']) ? (int) $params['page']['offset'] : 0); |
|
264 | + $size = (isset($params['page']['limit']) ? (int) $params['page']['limit'] : 25); |
|
265 | 265 | |
266 | - $criteria->setSlice( $start, $size ); |
|
266 | + $criteria->setSlice($start, $size); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -273,24 +273,24 @@ discard block |
||
273 | 273 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
274 | 274 | * @param array $params List of criteria data with condition, sorting and paging |
275 | 275 | */ |
276 | - protected function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
276 | + protected function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
277 | 277 | { |
278 | - if( !isset( $params['sort'] ) ) { |
|
278 | + if (!isset($params['sort'])) { |
|
279 | 279 | return; |
280 | 280 | } |
281 | 281 | |
282 | 282 | $sortation = []; |
283 | 283 | |
284 | - foreach( explode( ',', $params['sort'] ) as $sort ) |
|
284 | + foreach (explode(',', $params['sort']) as $sort) |
|
285 | 285 | { |
286 | - if( $sort[0] === '-' ) { |
|
287 | - $sortation[] = $criteria->sort( '-', substr( $sort, 1 ) ); |
|
286 | + if ($sort[0] === '-') { |
|
287 | + $sortation[] = $criteria->sort('-', substr($sort, 1)); |
|
288 | 288 | } else { |
289 | - $sortation[] = $criteria->sort( '+', $sort ); |
|
289 | + $sortation[] = $criteria->sort('+', $sort); |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
293 | - $criteria->setSortations( $sortation ); |
|
293 | + $criteria->setSortations($sortation); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | |
@@ -301,14 +301,14 @@ discard block |
||
301 | 301 | * @param \stdClass $request Object with request body data |
302 | 302 | * @return array List of items |
303 | 303 | */ |
304 | - protected function saveData( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request ) |
|
304 | + protected function saveData(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request) |
|
305 | 305 | { |
306 | 306 | $data = []; |
307 | 307 | |
308 | - if( isset( $request->data ) ) |
|
308 | + if (isset($request->data)) |
|
309 | 309 | { |
310 | - foreach( (array) $request->data as $entry ) { |
|
311 | - $data[] = $this->saveEntry( $manager, $entry ); |
|
310 | + foreach ((array) $request->data as $entry) { |
|
311 | + $data[] = $this->saveEntry($manager, $entry); |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
@@ -323,22 +323,22 @@ discard block |
||
323 | 323 | * @param \stdClass $entry Object including "id" and "attributes" elements |
324 | 324 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
325 | 325 | */ |
326 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
326 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
327 | 327 | { |
328 | - if( isset( $entry->id ) ) { |
|
329 | - $item = $manager->getItem( $entry->id ); |
|
328 | + if (isset($entry->id)) { |
|
329 | + $item = $manager->getItem($entry->id); |
|
330 | 330 | } else { |
331 | 331 | $item = $manager->createItem(); |
332 | 332 | } |
333 | 333 | |
334 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
335 | - $item = $manager->saveItem( $item ); |
|
334 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
335 | + $item = $manager->saveItem($item); |
|
336 | 336 | |
337 | - if( isset( $entry->relationships ) ) { |
|
338 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
337 | + if (isset($entry->relationships)) { |
|
338 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
339 | 339 | } |
340 | 340 | |
341 | - return $manager->getItem( $item->getId() ); |
|
341 | + return $manager->getItem($item->getId()); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | |
@@ -349,28 +349,28 @@ discard block |
||
349 | 349 | * @param \Aimeos\MShop\Common\Item\Iface $item Domain item with an unique ID set |
350 | 350 | * @param \stdClass $relationships Object including the <domain>/data/attributes structure |
351 | 351 | */ |
352 | - protected function saveRelationships( \Aimeos\MShop\Common\Manager\Iface $manager, |
|
353 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships ) |
|
352 | + protected function saveRelationships(\Aimeos\MShop\Common\Manager\Iface $manager, |
|
353 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships) |
|
354 | 354 | { |
355 | 355 | $id = $item->getId(); |
356 | - $listManager = $manager->getSubManager( 'lists' ); |
|
356 | + $listManager = $manager->getSubManager('lists'); |
|
357 | 357 | |
358 | - foreach( (array) $relationships as $domain => $list ) |
|
358 | + foreach ((array) $relationships as $domain => $list) |
|
359 | 359 | { |
360 | - if( isset( $list->data ) ) |
|
360 | + if (isset($list->data)) |
|
361 | 361 | { |
362 | - foreach( (array) $list->data as $data ) |
|
362 | + foreach ((array) $list->data as $data) |
|
363 | 363 | { |
364 | - $listItem = $this->addItemData( $listManager, $listManager->createItem(), $data, $domain ); |
|
364 | + $listItem = $this->addItemData($listManager, $listManager->createItem(), $data, $domain); |
|
365 | 365 | |
366 | - if( isset( $data->id ) ) { |
|
367 | - $listItem->setRefId( $data->id ); |
|
366 | + if (isset($data->id)) { |
|
367 | + $listItem->setRefId($data->id); |
|
368 | 368 | } |
369 | 369 | |
370 | - $listItem->setParentId( $id ); |
|
371 | - $listItem->setDomain( $domain ); |
|
370 | + $listItem->setParentId($id); |
|
371 | + $listItem->setDomain($domain); |
|
372 | 372 | |
373 | - $listManager->saveItem( $listItem, false ); |
|
373 | + $listManager->saveItem($listItem, false); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | } |
@@ -387,20 +387,20 @@ discard block |
||
387 | 387 | * @return \Aimeos\MShop\Common\Item\Iface Item including the data |
388 | 388 | */ |
389 | 389 | protected function addItemData(\Aimeos\MShop\Common\Manager\Iface $manager, |
390 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain ) |
|
390 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain) |
|
391 | 391 | { |
392 | - if( isset( $data->attributes ) ) |
|
392 | + if (isset($data->attributes)) |
|
393 | 393 | { |
394 | 394 | $attr = (array) $data->attributes; |
395 | - $key = str_replace( '/', '.', $item->getResourceType() ); |
|
395 | + $key = str_replace('/', '.', $item->getResourceType()); |
|
396 | 396 | |
397 | - if( isset( $attr[$key.'.type'] ) ) |
|
397 | + if (isset($attr[$key . '.type'])) |
|
398 | 398 | { |
399 | - $typeItem = $manager->getSubManager( 'type' )->findItem( $attr[$key.'.type'], [], $domain ); |
|
400 | - $attr[$key.'.typeid'] = $typeItem->getId(); |
|
399 | + $typeItem = $manager->getSubManager('type')->findItem($attr[$key . '.type'], [], $domain); |
|
400 | + $attr[$key . '.typeid'] = $typeItem->getId(); |
|
401 | 401 | } |
402 | 402 | |
403 | - $item->fromArray( $attr ); |
|
403 | + $item->fromArray($attr); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | 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\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,146 +30,146 @@ 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( 'group' )->getId(), |
|
60 | + 'id' => $this->getCatalogItem('group')->getId(), |
|
61 | 61 | 'filter' => array( |
62 | - '==' => array( 'catalog.status' => 1 ) |
|
62 | + '==' => array('catalog.status' => 1) |
|
63 | 63 | ), |
64 | 64 | 'include' => 'catalog,text' |
65 | 65 | ); |
66 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
67 | - $this->view->addHelper( 'param', $helper ); |
|
66 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
67 | + $this->view->addHelper('param', $helper); |
|
68 | 68 | |
69 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
70 | - $result = json_decode( (string) $response->getBody(), true ); |
|
69 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
70 | + $result = json_decode((string) $response->getBody(), true); |
|
71 | 71 | |
72 | 72 | |
73 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
74 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
73 | + $this->assertEquals(200, $response->getStatusCode()); |
|
74 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
75 | 75 | |
76 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
77 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
78 | - $this->assertEquals( 2, count( $result['data']['relationships']['catalog'] ) ); |
|
79 | - $this->assertEquals( 2, count( $result['included'] ) ); |
|
76 | + $this->assertEquals(1, $result['meta']['total']); |
|
77 | + $this->assertEquals('catalog', $result['data']['type']); |
|
78 | + $this->assertEquals(2, count($result['data']['relationships']['catalog'])); |
|
79 | + $this->assertEquals(2, count($result['included'])); |
|
80 | 80 | |
81 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
81 | + $this->assertArrayNotHasKey('errors', $result); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
85 | 85 | public function testPatch() |
86 | 86 | { |
87 | - $stub = $this->getCatalogMock( array( 'getItem', 'moveItem', 'saveItem' ) ); |
|
87 | + $stub = $this->getCatalogMock(array('getItem', 'moveItem', 'saveItem')); |
|
88 | 88 | |
89 | - $stub->expects( $this->once() )->method( 'moveItem' ); |
|
90 | - $stub->expects( $this->once() )->method( 'saveItem' ) |
|
91 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
92 | - $stub->expects( $this->exactly( 2 ) )->method( 'getItem' ) // 2x due to decorator |
|
93 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
89 | + $stub->expects($this->once())->method('moveItem'); |
|
90 | + $stub->expects($this->once())->method('saveItem') |
|
91 | + ->will($this->returnValue($stub->createItem())); |
|
92 | + $stub->expects($this->exactly(2))->method('getItem') // 2x due to decorator |
|
93 | + ->will($this->returnValue($stub->createItem())); |
|
94 | 94 | |
95 | 95 | |
96 | - $params = array( 'id' => '-1' ); |
|
97 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
98 | - $this->view->addHelper( 'param', $helper ); |
|
96 | + $params = array('id' => '-1'); |
|
97 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
98 | + $this->view->addHelper('param', $helper); |
|
99 | 99 | |
100 | 100 | $body = '{"data": {"parentid": "1", "targetid": 2, "type": "catalog", "attributes": {"catalog.label": "test"}}}'; |
101 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
101 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
102 | 102 | |
103 | - $response = $this->object->patch( $request, $this->view->response() ); |
|
104 | - $result = json_decode( (string) $response->getBody(), true ); |
|
103 | + $response = $this->object->patch($request, $this->view->response()); |
|
104 | + $result = json_decode((string) $response->getBody(), true); |
|
105 | 105 | |
106 | 106 | |
107 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
108 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
107 | + $this->assertEquals(200, $response->getStatusCode()); |
|
108 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
109 | 109 | |
110 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
111 | - $this->assertArrayHasKey( 'data', $result ); |
|
112 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
110 | + $this->assertEquals(1, $result['meta']['total']); |
|
111 | + $this->assertArrayHasKey('data', $result); |
|
112 | + $this->assertEquals('catalog', $result['data']['type']); |
|
113 | 113 | |
114 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
115 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
114 | + $this->assertArrayNotHasKey('included', $result); |
|
115 | + $this->assertArrayNotHasKey('errors', $result); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
119 | 119 | public function testPost() |
120 | 120 | { |
121 | - $stub = $this->getCatalogMock( array( 'getItem', 'insertItem' ) ); |
|
121 | + $stub = $this->getCatalogMock(array('getItem', 'insertItem')); |
|
122 | 122 | |
123 | - $stub->expects( $this->any() )->method( 'getItem' ) |
|
124 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
125 | - $stub->expects( $this->once() )->method( 'insertItem' ); |
|
123 | + $stub->expects($this->any())->method('getItem') |
|
124 | + ->will($this->returnValue($stub->createItem())); |
|
125 | + $stub->expects($this->once())->method('insertItem'); |
|
126 | 126 | |
127 | 127 | |
128 | 128 | $body = '{"data": {"type": "catalog", "attributes": {"catalog.code": "test", "catalog.label": "Test catalog"}}}'; |
129 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
129 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
130 | 130 | |
131 | - $response = $this->object->post( $request, $this->view->response() ); |
|
132 | - $result = json_decode( (string) $response->getBody(), true ); |
|
131 | + $response = $this->object->post($request, $this->view->response()); |
|
132 | + $result = json_decode((string) $response->getBody(), true); |
|
133 | 133 | |
134 | 134 | |
135 | - $this->assertEquals( 201, $response->getStatusCode() ); |
|
136 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
135 | + $this->assertEquals(201, $response->getStatusCode()); |
|
136 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
137 | 137 | |
138 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
139 | - $this->assertArrayHasKey( 'data', $result ); |
|
140 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
138 | + $this->assertEquals(1, $result['meta']['total']); |
|
139 | + $this->assertArrayHasKey('data', $result); |
|
140 | + $this->assertEquals('catalog', $result['data']['type']); |
|
141 | 141 | |
142 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
143 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
142 | + $this->assertArrayNotHasKey('included', $result); |
|
143 | + $this->assertArrayNotHasKey('errors', $result); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
147 | - protected function getCatalogItem( $code ) |
|
147 | + protected function getCatalogItem($code) |
|
148 | 148 | { |
149 | - $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->context ); |
|
149 | + $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context); |
|
150 | 150 | $search = $manager->createSearch(); |
151 | - $search->setConditions( $search->compare( '==', 'catalog.code', $code ) ); |
|
152 | - $items = $manager->searchItems( $search ); |
|
151 | + $search->setConditions($search->compare('==', 'catalog.code', $code)); |
|
152 | + $items = $manager->searchItems($search); |
|
153 | 153 | |
154 | - if( ( $item = reset( $items ) ) === false ) { |
|
155 | - throw new \RuntimeException( sprintf( 'No catalog item with code "%1$s" found', $code ) ); |
|
154 | + if (($item = reset($items)) === false) { |
|
155 | + throw new \RuntimeException(sprintf('No catalog item with code "%1$s" found', $code)); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | return $item; |
159 | 159 | } |
160 | 160 | |
161 | 161 | |
162 | - protected function getCatalogMock( array $methods ) |
|
162 | + protected function getCatalogMock(array $methods) |
|
163 | 163 | { |
164 | 164 | $name = 'ClientJsonAdmStandard'; |
165 | - $this->context->getConfig()->set( 'mshop/catalog/manager/name', $name ); |
|
165 | + $this->context->getConfig()->set('mshop/catalog/manager/name', $name); |
|
166 | 166 | |
167 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Catalog\\Manager\\Standard' ) |
|
168 | - ->setConstructorArgs( array( $this->context ) ) |
|
169 | - ->setMethods( $methods ) |
|
167 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Catalog\\Manager\\Standard') |
|
168 | + ->setConstructorArgs(array($this->context)) |
|
169 | + ->setMethods($methods) |
|
170 | 170 | ->getMock(); |
171 | 171 | |
172 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub ); |
|
172 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub); |
|
173 | 173 | |
174 | 174 | return $stub; |
175 | 175 | } |
@@ -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\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 | |
@@ -30,153 +30,153 @@ discard block |
||
30 | 30 | { |
31 | 31 | $params = array( |
32 | 32 | 'filter' => array( |
33 | - '==' => array( 'locale.site.code' => 'unittest' ) |
|
33 | + '==' => array('locale.site.code' => 'unittest') |
|
34 | 34 | ), |
35 | 35 | ); |
36 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
37 | - $this->view->addHelper( 'param', $helper ); |
|
36 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
37 | + $this->view->addHelper('param', $helper); |
|
38 | 38 | |
39 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
40 | - $result = json_decode( (string) $response->getBody(), true ); |
|
39 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
40 | + $result = json_decode((string) $response->getBody(), true); |
|
41 | 41 | |
42 | 42 | |
43 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
44 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
43 | + $this->assertEquals(200, $response->getStatusCode()); |
|
44 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
45 | 45 | |
46 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
47 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
48 | - $this->assertEquals( 'locale/site', $result['data'][0]['type'] ); |
|
49 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
46 | + $this->assertEquals(1, $result['meta']['total']); |
|
47 | + $this->assertEquals(1, count($result['data'])); |
|
48 | + $this->assertEquals('locale/site', $result['data'][0]['type']); |
|
49 | + $this->assertEquals(0, count($result['included'])); |
|
50 | 50 | |
51 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
51 | + $this->assertArrayNotHasKey('errors', $result); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | public function testGetTree() |
56 | 56 | { |
57 | 57 | $params = array( |
58 | - 'id' => $this->getSiteItem( 'unittest' )->getId(), |
|
58 | + 'id' => $this->getSiteItem('unittest')->getId(), |
|
59 | 59 | 'filter' => array( |
60 | - '==' => array( 'locale.status' => 0 ) |
|
60 | + '==' => array('locale.status' => 0) |
|
61 | 61 | ), |
62 | 62 | 'include' => 'locale/site' |
63 | 63 | ); |
64 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
65 | - $this->view->addHelper( 'param', $helper ); |
|
64 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
65 | + $this->view->addHelper('param', $helper); |
|
66 | 66 | |
67 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
68 | - $result = json_decode( (string) $response->getBody(), true ); |
|
67 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
68 | + $result = json_decode((string) $response->getBody(), true); |
|
69 | 69 | |
70 | 70 | |
71 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
72 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
71 | + $this->assertEquals(200, $response->getStatusCode()); |
|
72 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
73 | 73 | |
74 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
75 | - $this->assertEquals( 'locale/site', $result['data']['type'] ); |
|
76 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
74 | + $this->assertEquals(1, $result['meta']['total']); |
|
75 | + $this->assertEquals('locale/site', $result['data']['type']); |
|
76 | + $this->assertEquals(0, count($result['included'])); |
|
77 | 77 | |
78 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
78 | + $this->assertArrayNotHasKey('errors', $result); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
82 | 82 | public function testPatch() |
83 | 83 | { |
84 | - $stub = $this->getSiteMock( array( 'getItem', 'moveItem', 'saveItem' ) ); |
|
84 | + $stub = $this->getSiteMock(array('getItem', 'moveItem', 'saveItem')); |
|
85 | 85 | $item = $stub->createItem(); |
86 | 86 | |
87 | - $stub->expects( $this->once() )->method( 'moveItem' ); |
|
88 | - $stub->expects( $this->once() )->method( 'saveItem' ) |
|
89 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
90 | - $stub->expects( $this->exactly( 2 ) )->method( 'getItem' ) // 2x due to decorator |
|
91 | - ->will( $this->returnValue( $item ) ); |
|
87 | + $stub->expects($this->once())->method('moveItem'); |
|
88 | + $stub->expects($this->once())->method('saveItem') |
|
89 | + ->will($this->returnValue($stub->createItem())); |
|
90 | + $stub->expects($this->exactly(2))->method('getItem') // 2x due to decorator |
|
91 | + ->will($this->returnValue($item)); |
|
92 | 92 | |
93 | 93 | |
94 | - $params = array( 'id' => '-1' ); |
|
95 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
96 | - $this->view->addHelper( 'param', $helper ); |
|
94 | + $params = array('id' => '-1'); |
|
95 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
96 | + $this->view->addHelper('param', $helper); |
|
97 | 97 | |
98 | 98 | $body = '{"data": {"parentid": "1", "targetid": 2, "type": "locale/site", "attributes": {"locale.site.label": "test"}}}'; |
99 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
99 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
100 | 100 | |
101 | - $response = $this->object->patch( $request, $this->view->response() ); |
|
102 | - $result = json_decode( (string) $response->getBody(), true ); |
|
101 | + $response = $this->object->patch($request, $this->view->response()); |
|
102 | + $result = json_decode((string) $response->getBody(), true); |
|
103 | 103 | |
104 | 104 | |
105 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
106 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
105 | + $this->assertEquals(200, $response->getStatusCode()); |
|
106 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
107 | 107 | |
108 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
109 | - $this->assertArrayHasKey( 'data', $result ); |
|
110 | - $this->assertEquals( 'locale/site', $result['data']['type'] ); |
|
108 | + $this->assertEquals(1, $result['meta']['total']); |
|
109 | + $this->assertArrayHasKey('data', $result); |
|
110 | + $this->assertEquals('locale/site', $result['data']['type']); |
|
111 | 111 | |
112 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
113 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
112 | + $this->assertArrayNotHasKey('included', $result); |
|
113 | + $this->assertArrayNotHasKey('errors', $result); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
117 | 117 | public function testPost() |
118 | 118 | { |
119 | - $stub = $this->getSiteMock( array( 'getItem', 'insertItem' ) ); |
|
119 | + $stub = $this->getSiteMock(array('getItem', 'insertItem')); |
|
120 | 120 | $item = $stub->createItem(); |
121 | 121 | |
122 | - $stub->expects( $this->any() )->method( 'getItem' ) |
|
123 | - ->will( $this->returnValue( $item ) ); |
|
124 | - $stub->expects( $this->once() )->method( 'insertItem' ); |
|
122 | + $stub->expects($this->any())->method('getItem') |
|
123 | + ->will($this->returnValue($item)); |
|
124 | + $stub->expects($this->once())->method('insertItem'); |
|
125 | 125 | |
126 | 126 | |
127 | 127 | $body = '{"data": {"type": "locale/site", "attributes": {"locale.site.code": "unittest", "locale.site.label": "Unit test"}}}'; |
128 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
128 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
129 | 129 | |
130 | - $response = $this->object->post( $request, $this->view->response() ); |
|
131 | - $result = json_decode( (string) $response->getBody(), true ); |
|
130 | + $response = $this->object->post($request, $this->view->response()); |
|
131 | + $result = json_decode((string) $response->getBody(), true); |
|
132 | 132 | |
133 | 133 | |
134 | - $this->assertEquals( 201, $response->getStatusCode() ); |
|
135 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
134 | + $this->assertEquals(201, $response->getStatusCode()); |
|
135 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
136 | 136 | |
137 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
138 | - $this->assertArrayHasKey( 'data', $result ); |
|
139 | - $this->assertEquals( 'locale/site', $result['data']['type'] ); |
|
137 | + $this->assertEquals(1, $result['meta']['total']); |
|
138 | + $this->assertArrayHasKey('data', $result); |
|
139 | + $this->assertEquals('locale/site', $result['data']['type']); |
|
140 | 140 | |
141 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
142 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
141 | + $this->assertArrayNotHasKey('included', $result); |
|
142 | + $this->assertArrayNotHasKey('errors', $result); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
146 | - protected function getSiteItem( $code ) |
|
146 | + protected function getSiteItem($code) |
|
147 | 147 | { |
148 | - $manager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $this->context )->getSubManager( 'site' ); |
|
148 | + $manager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->context)->getSubManager('site'); |
|
149 | 149 | $search = $manager->createSearch(); |
150 | - $search->setConditions( $search->compare( '==', 'locale.site.code', $code ) ); |
|
151 | - $items = $manager->searchItems( $search ); |
|
150 | + $search->setConditions($search->compare('==', 'locale.site.code', $code)); |
|
151 | + $items = $manager->searchItems($search); |
|
152 | 152 | |
153 | - if( ( $item = reset( $items ) ) === false ) { |
|
154 | - throw new \RuntimeException( sprintf( 'No locale site item with code "%1$s" found', $code ) ); |
|
153 | + if (($item = reset($items)) === false) { |
|
154 | + throw new \RuntimeException(sprintf('No locale site item with code "%1$s" found', $code)); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $item; |
158 | 158 | } |
159 | 159 | |
160 | 160 | |
161 | - protected function getSiteMock( array $methods ) |
|
161 | + protected function getSiteMock(array $methods) |
|
162 | 162 | { |
163 | 163 | $name = 'ClientJsonAdmStandard'; |
164 | - $this->context->getConfig()->set( 'mshop/locale/manager/name', $name ); |
|
164 | + $this->context->getConfig()->set('mshop/locale/manager/name', $name); |
|
165 | 165 | |
166 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Locale\\Manager\\Standard' ) |
|
167 | - ->setConstructorArgs( array( $this->context ) ) |
|
168 | - ->setMethods( array( 'getSubManager' ) ) |
|
166 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Locale\\Manager\\Standard') |
|
167 | + ->setConstructorArgs(array($this->context)) |
|
168 | + ->setMethods(array('getSubManager')) |
|
169 | 169 | ->getMock(); |
170 | 170 | |
171 | - $siteStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Locale\\Manager\\Site\\Standard' ) |
|
172 | - ->setConstructorArgs( array( $this->context ) ) |
|
173 | - ->setMethods( $methods ) |
|
171 | + $siteStub = $this->getMockBuilder('\\Aimeos\\MShop\\Locale\\Manager\\Site\\Standard') |
|
172 | + ->setConstructorArgs(array($this->context)) |
|
173 | + ->setMethods($methods) |
|
174 | 174 | ->getMock(); |
175 | 175 | |
176 | - $stub->expects( $this->once() )->method( 'getSubManager' ) |
|
177 | - ->will( $this->returnValue( $siteStub ) ); |
|
176 | + $stub->expects($this->once())->method('getSubManager') |
|
177 | + ->will($this->returnValue($siteStub)); |
|
178 | 178 | |
179 | - \Aimeos\MShop\Locale\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Locale\\Manager\\' . $name, $stub ); |
|
179 | + \Aimeos\MShop\Locale\Manager\Factory::injectManager('\\Aimeos\\MShop\\Locale\\Manager\\' . $name, $stub); |
|
180 | 180 | |
181 | 181 | return $siteStub; |
182 | 182 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'product' ); |
|
25 | + $this->object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'product'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -34,193 +34,193 @@ discard block |
||
34 | 34 | |
35 | 35 | public function testDelete() |
36 | 36 | { |
37 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ); |
|
37 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem'); |
|
38 | 38 | |
39 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
40 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
41 | - $this->view->addHelper( 'param', $helper ); |
|
39 | + $params = array('id' => $this->getProductItem()->getId()); |
|
40 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
41 | + $this->view->addHelper('param', $helper); |
|
42 | 42 | |
43 | - $response = $this->object->delete( $this->view->request(), $this->view->response() ); |
|
44 | - $result = json_decode( (string) $response->getBody(), true ); |
|
43 | + $response = $this->object->delete($this->view->request(), $this->view->response()); |
|
44 | + $result = json_decode((string) $response->getBody(), true); |
|
45 | 45 | |
46 | 46 | |
47 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
48 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
47 | + $this->assertEquals(200, $response->getStatusCode()); |
|
48 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
49 | 49 | |
50 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
50 | + $this->assertEquals(1, $result['meta']['total']); |
|
51 | 51 | |
52 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
53 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
54 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
52 | + $this->assertArrayNotHasKey('included', $result); |
|
53 | + $this->assertArrayNotHasKey('data', $result); |
|
54 | + $this->assertArrayNotHasKey('errors', $result); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
58 | 58 | public function testDeleteBulk() |
59 | 59 | { |
60 | - $this->getProductMock( array( 'deleteItems' ) )->expects( $this->once() )->method( 'deleteItems' ); |
|
60 | + $this->getProductMock(array('deleteItems'))->expects($this->once())->method('deleteItems'); |
|
61 | 61 | |
62 | 62 | $body = '{"data":[{"type": "product", "id": "-1"},{"type": "product", "id": "-2"}]}'; |
63 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
63 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
64 | 64 | |
65 | - $response = $this->object->delete( $request, $this->view->response() ); |
|
66 | - $result = json_decode( (string) $response->getBody(), true ); |
|
65 | + $response = $this->object->delete($request, $this->view->response()); |
|
66 | + $result = json_decode((string) $response->getBody(), true); |
|
67 | 67 | |
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( 2, $result['meta']['total'] ); |
|
73 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
74 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
75 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
72 | + $this->assertEquals(2, $result['meta']['total']); |
|
73 | + $this->assertArrayNotHasKey('included', $result); |
|
74 | + $this->assertArrayNotHasKey('data', $result); |
|
75 | + $this->assertArrayNotHasKey('errors', $result); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
79 | 79 | public function testDeleteInvalid() |
80 | 80 | { |
81 | 81 | $body = '{"data":null}'; |
82 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
82 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
83 | 83 | |
84 | - $response = $this->object->delete( $request, $this->view->response() ); |
|
85 | - $result = json_decode( (string) $response->getBody(), true ); |
|
84 | + $response = $this->object->delete($request, $this->view->response()); |
|
85 | + $result = json_decode((string) $response->getBody(), true); |
|
86 | 86 | |
87 | 87 | |
88 | - $this->assertEquals( 400, $response->getStatusCode() ); |
|
89 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
88 | + $this->assertEquals(400, $response->getStatusCode()); |
|
89 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
90 | 90 | |
91 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
92 | - $this->assertArrayHasKey( 'errors', $result ); |
|
93 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
94 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
91 | + $this->assertEquals(0, $result['meta']['total']); |
|
92 | + $this->assertArrayHasKey('errors', $result); |
|
93 | + $this->assertArrayNotHasKey('included', $result); |
|
94 | + $this->assertArrayNotHasKey('data', $result); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | |
98 | 98 | public function testDeleteException() |
99 | 99 | { |
100 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ) |
|
101 | - ->will( $this->throwException( new \RuntimeException( 'test exception' ) ) ); |
|
100 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem') |
|
101 | + ->will($this->throwException(new \RuntimeException('test exception'))); |
|
102 | 102 | |
103 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
104 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
105 | - $this->view->addHelper( 'param', $helper ); |
|
103 | + $params = array('id' => $this->getProductItem()->getId()); |
|
104 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
105 | + $this->view->addHelper('param', $helper); |
|
106 | 106 | |
107 | - $response = $this->object->delete( $this->view->request(), $this->view->response() ); |
|
108 | - $result = json_decode( (string) $response->getBody(), true ); |
|
107 | + $response = $this->object->delete($this->view->request(), $this->view->response()); |
|
108 | + $result = json_decode((string) $response->getBody(), true); |
|
109 | 109 | |
110 | - $this->assertEquals( 500, $response->getStatusCode() ); |
|
111 | - $this->assertArrayHasKey( 'errors', $result ); |
|
110 | + $this->assertEquals(500, $response->getStatusCode()); |
|
111 | + $this->assertArrayHasKey('errors', $result); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | public function testDeleteMShopException() |
116 | 116 | { |
117 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ) |
|
118 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
117 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem') |
|
118 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
119 | 119 | |
120 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
121 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
122 | - $this->view->addHelper( 'param', $helper ); |
|
120 | + $params = array('id' => $this->getProductItem()->getId()); |
|
121 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
122 | + $this->view->addHelper('param', $helper); |
|
123 | 123 | |
124 | - $response = $this->object->delete( $this->view->request(), $this->view->response() ); |
|
125 | - $result = json_decode( (string) $response->getBody(), true ); |
|
124 | + $response = $this->object->delete($this->view->request(), $this->view->response()); |
|
125 | + $result = json_decode((string) $response->getBody(), true); |
|
126 | 126 | |
127 | - $this->assertEquals( 404, $response->getStatusCode() ); |
|
128 | - $this->assertArrayHasKey( 'errors', $result ); |
|
127 | + $this->assertEquals(404, $response->getStatusCode()); |
|
128 | + $this->assertArrayHasKey('errors', $result); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
132 | 132 | public function testGet() |
133 | 133 | { |
134 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
135 | - $result = json_decode( (string) $response->getBody(), true ); |
|
134 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
135 | + $result = json_decode((string) $response->getBody(), true); |
|
136 | 136 | |
137 | 137 | |
138 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
139 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
138 | + $this->assertEquals(200, $response->getStatusCode()); |
|
139 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
140 | 140 | |
141 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
142 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
143 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
144 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
145 | - $this->assertArrayHasKey( 'next', $result['links'] ); |
|
146 | - $this->assertArrayHasKey( 'last', $result['links'] ); |
|
147 | - $this->assertArrayHasKey( 'self', $result['links'] ); |
|
148 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
141 | + $this->assertEquals(28, $result['meta']['total']); |
|
142 | + $this->assertEquals(25, count($result['data'])); |
|
143 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
144 | + $this->assertEquals(0, count($result['included'])); |
|
145 | + $this->assertArrayHasKey('next', $result['links']); |
|
146 | + $this->assertArrayHasKey('last', $result['links']); |
|
147 | + $this->assertArrayHasKey('self', $result['links']); |
|
148 | + $this->assertArrayNotHasKey('errors', $result); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
152 | 152 | public function testGetType() |
153 | 153 | { |
154 | 154 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
155 | - $object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'product/property/type' ); |
|
155 | + $object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'product/property/type'); |
|
156 | 156 | |
157 | - $response = $object->get( $this->view->request(), $this->view->response() ); |
|
158 | - $result = json_decode( (string) $response->getBody(), true ); |
|
157 | + $response = $object->get($this->view->request(), $this->view->response()); |
|
158 | + $result = json_decode((string) $response->getBody(), true); |
|
159 | 159 | |
160 | 160 | |
161 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
162 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
161 | + $this->assertEquals(200, $response->getStatusCode()); |
|
162 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
163 | 163 | |
164 | - $this->assertEquals( 4, $result['meta']['total'] ); |
|
165 | - $this->assertEquals( 4, count( $result['data'] ) ); |
|
166 | - $this->assertEquals( 'product/property/type', $result['data'][0]['type'] ); |
|
167 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
164 | + $this->assertEquals(4, $result['meta']['total']); |
|
165 | + $this->assertEquals(4, count($result['data'])); |
|
166 | + $this->assertEquals('product/property/type', $result['data'][0]['type']); |
|
167 | + $this->assertEquals(0, count($result['included'])); |
|
168 | 168 | |
169 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
169 | + $this->assertArrayNotHasKey('errors', $result); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
173 | 173 | public function testGetInvalid() |
174 | 174 | { |
175 | 175 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
176 | - $object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'invalid' ); |
|
176 | + $object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'invalid'); |
|
177 | 177 | |
178 | - $response = $object->get( $this->view->request(), $this->view->response() ); |
|
179 | - $result = json_decode( (string) $response->getBody(), true ); |
|
178 | + $response = $object->get($this->view->request(), $this->view->response()); |
|
179 | + $result = json_decode((string) $response->getBody(), true); |
|
180 | 180 | |
181 | 181 | |
182 | - $this->assertEquals( 404, $response->getStatusCode() ); |
|
183 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
182 | + $this->assertEquals(404, $response->getStatusCode()); |
|
183 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
184 | 184 | |
185 | - $this->assertEquals( 1, count( $result['errors'] ) ); |
|
186 | - $this->assertArrayHasKey( 'title', $result['errors'][0] ); |
|
187 | - $this->assertArrayHasKey( 'detail', $result['errors'][0] ); |
|
188 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
189 | - $this->assertArrayNotHasKey( 'indluded', $result ); |
|
185 | + $this->assertEquals(1, count($result['errors'])); |
|
186 | + $this->assertArrayHasKey('title', $result['errors'][0]); |
|
187 | + $this->assertArrayHasKey('detail', $result['errors'][0]); |
|
188 | + $this->assertArrayNotHasKey('data', $result); |
|
189 | + $this->assertArrayNotHasKey('indluded', $result); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | |
193 | 193 | public function testGetException() |
194 | 194 | { |
195 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
196 | - ->will( $this->throwException( new \RuntimeException( 'test exception' ) ) ); |
|
195 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
196 | + ->will($this->throwException(new \RuntimeException('test exception'))); |
|
197 | 197 | |
198 | - $params = array( 'id' => -1 ); |
|
199 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
200 | - $this->view->addHelper( 'param', $helper ); |
|
198 | + $params = array('id' => -1); |
|
199 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
200 | + $this->view->addHelper('param', $helper); |
|
201 | 201 | |
202 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
203 | - $result = json_decode( (string) $response->getBody(), true ); |
|
202 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
203 | + $result = json_decode((string) $response->getBody(), true); |
|
204 | 204 | |
205 | - $this->assertEquals( 500, $response->getStatusCode() ); |
|
206 | - $this->assertArrayHasKey( 'errors', $result ); |
|
205 | + $this->assertEquals(500, $response->getStatusCode()); |
|
206 | + $this->assertArrayHasKey('errors', $result); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | |
210 | 210 | public function testGetMShopException() |
211 | 211 | { |
212 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
213 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
212 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
213 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
214 | 214 | |
215 | - $params = array( 'id' => -1 ); |
|
216 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
217 | - $this->view->addHelper( 'param', $helper ); |
|
215 | + $params = array('id' => -1); |
|
216 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
217 | + $this->view->addHelper('param', $helper); |
|
218 | 218 | |
219 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
220 | - $result = json_decode( (string) $response->getBody(), true ); |
|
219 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
220 | + $result = json_decode((string) $response->getBody(), true); |
|
221 | 221 | |
222 | - $this->assertEquals( 404, $response->getStatusCode() ); |
|
223 | - $this->assertArrayHasKey( 'errors', $result ); |
|
222 | + $this->assertEquals(404, $response->getStatusCode()); |
|
223 | + $this->assertArrayHasKey('errors', $result); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
@@ -228,25 +228,25 @@ discard block |
||
228 | 228 | { |
229 | 229 | $params = array( |
230 | 230 | 'filter' => array( |
231 | - '==' => array( 'product.type.code' => 'select' ) |
|
231 | + '==' => array('product.type.code' => 'select') |
|
232 | 232 | ) |
233 | 233 | ); |
234 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
235 | - $this->view->addHelper( 'param', $helper ); |
|
234 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
235 | + $this->view->addHelper('param', $helper); |
|
236 | 236 | |
237 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
238 | - $result = json_decode( (string) $response->getBody(), true ); |
|
237 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
238 | + $result = json_decode((string) $response->getBody(), true); |
|
239 | 239 | |
240 | 240 | |
241 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
242 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
241 | + $this->assertEquals(200, $response->getStatusCode()); |
|
242 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
243 | 243 | |
244 | - $this->assertEquals( 3, $result['meta']['total'] ); |
|
245 | - $this->assertEquals( 3, count( $result['data'] ) ); |
|
246 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
247 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
244 | + $this->assertEquals(3, $result['meta']['total']); |
|
245 | + $this->assertEquals(3, count($result['data'])); |
|
246 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
247 | + $this->assertEquals(0, count($result['included'])); |
|
248 | 248 | |
249 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
249 | + $this->assertArrayNotHasKey('errors', $result); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -255,27 +255,27 @@ discard block |
||
255 | 255 | $params = array( |
256 | 256 | 'filter' => array( |
257 | 257 | '&&' => array( |
258 | - array( '=~' => array( 'product.label' => 'Unittest: Test' ) ), |
|
259 | - array( '==' => array( 'product.type.code' => 'select' ) ), |
|
258 | + array('=~' => array('product.label' => 'Unittest: Test')), |
|
259 | + array('==' => array('product.type.code' => 'select')), |
|
260 | 260 | ) |
261 | 261 | ) |
262 | 262 | ); |
263 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
264 | - $this->view->addHelper( 'param', $helper ); |
|
263 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
264 | + $this->view->addHelper('param', $helper); |
|
265 | 265 | |
266 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
267 | - $result = json_decode( (string) $response->getBody(), true ); |
|
266 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
267 | + $result = json_decode((string) $response->getBody(), true); |
|
268 | 268 | |
269 | 269 | |
270 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
271 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
270 | + $this->assertEquals(200, $response->getStatusCode()); |
|
271 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
272 | 272 | |
273 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
274 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
275 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
276 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
273 | + $this->assertEquals(2, $result['meta']['total']); |
|
274 | + $this->assertEquals(2, count($result['data'])); |
|
275 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
276 | + $this->assertEquals(0, count($result['included'])); |
|
277 | 277 | |
278 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
278 | + $this->assertArrayNotHasKey('errors', $result); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | |
@@ -287,25 +287,25 @@ discard block |
||
287 | 287 | 'limit' => 25 |
288 | 288 | ) |
289 | 289 | ); |
290 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
291 | - $this->view->addHelper( 'param', $helper ); |
|
290 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
291 | + $this->view->addHelper('param', $helper); |
|
292 | 292 | |
293 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
294 | - $result = json_decode( (string) $response->getBody(), true ); |
|
293 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
294 | + $result = json_decode((string) $response->getBody(), true); |
|
295 | 295 | |
296 | 296 | |
297 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
298 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
297 | + $this->assertEquals(200, $response->getStatusCode()); |
|
298 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
299 | 299 | |
300 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
301 | - $this->assertEquals( 3, count( $result['data'] ) ); |
|
302 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
303 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
304 | - $this->assertArrayHasKey( 'first', $result['links'] ); |
|
305 | - $this->assertArrayHasKey( 'prev', $result['links'] ); |
|
306 | - $this->assertArrayHasKey( 'self', $result['links'] ); |
|
300 | + $this->assertEquals(28, $result['meta']['total']); |
|
301 | + $this->assertEquals(3, count($result['data'])); |
|
302 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
303 | + $this->assertEquals(0, count($result['included'])); |
|
304 | + $this->assertArrayHasKey('first', $result['links']); |
|
305 | + $this->assertArrayHasKey('prev', $result['links']); |
|
306 | + $this->assertArrayHasKey('self', $result['links']); |
|
307 | 307 | |
308 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
308 | + $this->assertArrayNotHasKey('errors', $result); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | |
@@ -314,24 +314,24 @@ discard block |
||
314 | 314 | $params = array( |
315 | 315 | 'sort' => 'product.label,-product.code' |
316 | 316 | ); |
317 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
318 | - $this->view->addHelper( 'param', $helper ); |
|
317 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
318 | + $this->view->addHelper('param', $helper); |
|
319 | 319 | |
320 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
321 | - $result = json_decode( (string) $response->getBody(), true ); |
|
320 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
321 | + $result = json_decode((string) $response->getBody(), true); |
|
322 | 322 | |
323 | 323 | |
324 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
325 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
324 | + $this->assertEquals(200, $response->getStatusCode()); |
|
325 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
326 | 326 | |
327 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
328 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
329 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
330 | - $this->assertEquals( 'QRST', $result['data'][0]['attributes']['product.code'] ); |
|
331 | - $this->assertEquals( '16 discs', $result['data'][0]['attributes']['product.label'] ); |
|
332 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
327 | + $this->assertEquals(28, $result['meta']['total']); |
|
328 | + $this->assertEquals(25, count($result['data'])); |
|
329 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
330 | + $this->assertEquals('QRST', $result['data'][0]['attributes']['product.code']); |
|
331 | + $this->assertEquals('16 discs', $result['data'][0]['attributes']['product.label']); |
|
332 | + $this->assertEquals(0, count($result['included'])); |
|
333 | 333 | |
334 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
334 | + $this->assertArrayNotHasKey('errors', $result); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | |
@@ -344,262 +344,262 @@ discard block |
||
344 | 344 | 'sort' => 'product.id', |
345 | 345 | 'include' => 'product' |
346 | 346 | ); |
347 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
348 | - $this->view->addHelper( 'param', $helper ); |
|
347 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
348 | + $this->view->addHelper('param', $helper); |
|
349 | 349 | |
350 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
351 | - $result = json_decode( (string) $response->getBody(), true ); |
|
350 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
351 | + $result = json_decode((string) $response->getBody(), true); |
|
352 | 352 | |
353 | 353 | |
354 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
355 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
354 | + $this->assertEquals(200, $response->getStatusCode()); |
|
355 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
356 | 356 | |
357 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
358 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
359 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
360 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
357 | + $this->assertEquals(28, $result['meta']['total']); |
|
358 | + $this->assertEquals(25, count($result['data'])); |
|
359 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
360 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
361 | 361 | |
362 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
362 | + $this->assertArrayNotHasKey('errors', $result); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
366 | 366 | public function testPatch() |
367 | 367 | { |
368 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
368 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
369 | 369 | |
370 | 370 | $item = $productManagerStub->createItem(); |
371 | - $item->setLabel( 'test' ); |
|
372 | - $item->setId( '-1' ); |
|
371 | + $item->setLabel('test'); |
|
372 | + $item->setId('-1'); |
|
373 | 373 | |
374 | - $productManagerStub->expects( $this->once() )->method( 'saveItem' ) |
|
375 | - ->will( $this->returnValue( $productManagerStub->createItem() ) ); |
|
376 | - $productManagerStub->expects( $this->atLeastOnce() )->method( 'getItem' ) |
|
377 | - ->will( $this->returnValue( $item ) ); |
|
374 | + $productManagerStub->expects($this->once())->method('saveItem') |
|
375 | + ->will($this->returnValue($productManagerStub->createItem())); |
|
376 | + $productManagerStub->expects($this->atLeastOnce())->method('getItem') |
|
377 | + ->will($this->returnValue($item)); |
|
378 | 378 | |
379 | 379 | |
380 | - $params = array( 'id' => '-1' ); |
|
381 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
382 | - $this->view->addHelper( 'param', $helper ); |
|
380 | + $params = array('id' => '-1'); |
|
381 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
382 | + $this->view->addHelper('param', $helper); |
|
383 | 383 | |
384 | 384 | $body = '{"data": {"type": "product", "attributes": {"product.label": "test"}}}'; |
385 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
385 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
386 | 386 | |
387 | - $response = $this->object->patch( $request, $this->view->response() ); |
|
388 | - $result = json_decode( (string) $response->getBody(), true ); |
|
387 | + $response = $this->object->patch($request, $this->view->response()); |
|
388 | + $result = json_decode((string) $response->getBody(), true); |
|
389 | 389 | |
390 | 390 | |
391 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
392 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
391 | + $this->assertEquals(200, $response->getStatusCode()); |
|
392 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
393 | 393 | |
394 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
395 | - $this->assertArrayHasKey( 'data', $result ); |
|
396 | - $this->assertEquals( '-1', $result['data']['id'] ); |
|
397 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
398 | - $this->assertEquals( 'test', $result['data']['attributes']['product.label'] ); |
|
394 | + $this->assertEquals(1, $result['meta']['total']); |
|
395 | + $this->assertArrayHasKey('data', $result); |
|
396 | + $this->assertEquals('-1', $result['data']['id']); |
|
397 | + $this->assertEquals('product', $result['data']['type']); |
|
398 | + $this->assertEquals('test', $result['data']['attributes']['product.label']); |
|
399 | 399 | |
400 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
401 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
400 | + $this->assertArrayNotHasKey('included', $result); |
|
401 | + $this->assertArrayNotHasKey('errors', $result); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | |
405 | 405 | public function testPatchBulk() |
406 | 406 | { |
407 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
407 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
408 | 408 | |
409 | 409 | $item = $productManagerStub->createItem(); |
410 | - $item->setLabel( 'test' ); |
|
411 | - $item->setId( '-1' ); |
|
410 | + $item->setLabel('test'); |
|
411 | + $item->setId('-1'); |
|
412 | 412 | |
413 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' ) |
|
414 | - ->will( $this->returnValue( $productManagerStub->createItem() ) ); |
|
415 | - $productManagerStub->expects( $this->atLeastOnce() )->method( 'getItem' ) |
|
416 | - ->will( $this->returnValue( $item ) ); |
|
413 | + $productManagerStub->expects($this->exactly(2))->method('saveItem') |
|
414 | + ->will($this->returnValue($productManagerStub->createItem())); |
|
415 | + $productManagerStub->expects($this->atLeastOnce())->method('getItem') |
|
416 | + ->will($this->returnValue($item)); |
|
417 | 417 | |
418 | 418 | |
419 | 419 | $body = '{"data": [{"id": "-1", "type": "product", "attributes": {"product.label": "test"}}, {"id": "-1", "type": "product", "attributes": {"product.label": "test"}}]}'; |
420 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
420 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
421 | 421 | |
422 | - $response = $this->object->patch( $request, $this->view->response() ); |
|
423 | - $result = json_decode( (string) $response->getBody(), true ); |
|
422 | + $response = $this->object->patch($request, $this->view->response()); |
|
423 | + $result = json_decode((string) $response->getBody(), true); |
|
424 | 424 | |
425 | 425 | |
426 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
427 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
426 | + $this->assertEquals(200, $response->getStatusCode()); |
|
427 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
428 | 428 | |
429 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
430 | - $this->assertArrayHasKey( 'data', $result ); |
|
431 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
432 | - $this->assertEquals( '-1', $result['data'][0]['id'] ); |
|
433 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
434 | - $this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] ); |
|
429 | + $this->assertEquals(2, $result['meta']['total']); |
|
430 | + $this->assertArrayHasKey('data', $result); |
|
431 | + $this->assertEquals(2, count($result['data'])); |
|
432 | + $this->assertEquals('-1', $result['data'][0]['id']); |
|
433 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
434 | + $this->assertEquals('test', $result['data'][0]['attributes']['product.label']); |
|
435 | 435 | |
436 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
437 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
436 | + $this->assertArrayNotHasKey('included', $result); |
|
437 | + $this->assertArrayNotHasKey('errors', $result); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | |
441 | 441 | public function testPatchInvalid() |
442 | 442 | { |
443 | 443 | $body = '{"data":null}'; |
444 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
444 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
445 | 445 | |
446 | - $response = $this->object->patch( $request, $this->view->response() ); |
|
447 | - $result = json_decode( (string) $response->getBody(), true ); |
|
446 | + $response = $this->object->patch($request, $this->view->response()); |
|
447 | + $result = json_decode((string) $response->getBody(), true); |
|
448 | 448 | |
449 | 449 | |
450 | - $this->assertEquals( 400, $response->getStatusCode() ); |
|
451 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
450 | + $this->assertEquals(400, $response->getStatusCode()); |
|
451 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
452 | 452 | |
453 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
454 | - $this->assertArrayHasKey( 'errors', $result ); |
|
455 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
456 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
453 | + $this->assertEquals(0, $result['meta']['total']); |
|
454 | + $this->assertArrayHasKey('errors', $result); |
|
455 | + $this->assertArrayNotHasKey('included', $result); |
|
456 | + $this->assertArrayNotHasKey('data', $result); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | |
460 | 460 | public function testPatchInvalidId() |
461 | 461 | { |
462 | 462 | $body = '{"data":{"id":-1}}'; |
463 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
463 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
464 | 464 | |
465 | - $response = $this->object->patch( $request, $this->view->response() ); |
|
466 | - $result = json_decode( (string) $response->getBody(), true ); |
|
465 | + $response = $this->object->patch($request, $this->view->response()); |
|
466 | + $result = json_decode((string) $response->getBody(), true); |
|
467 | 467 | |
468 | 468 | |
469 | - $this->assertEquals( 400, $response->getStatusCode() ); |
|
470 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
469 | + $this->assertEquals(400, $response->getStatusCode()); |
|
470 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
471 | 471 | |
472 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
473 | - $this->assertArrayHasKey( 'errors', $result ); |
|
472 | + $this->assertEquals(0, $result['meta']['total']); |
|
473 | + $this->assertArrayHasKey('errors', $result); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
477 | 477 | public function testPatchException() |
478 | 478 | { |
479 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
480 | - ->will( $this->throwException( new \RuntimeException( 'test exception' ) ) ); |
|
479 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
480 | + ->will($this->throwException(new \RuntimeException('test exception'))); |
|
481 | 481 | |
482 | 482 | $body = '{"data":[{"id":-1}]}'; |
483 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
483 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
484 | 484 | |
485 | - $response = $this->object->patch( $request, $this->view->response() ); |
|
486 | - $result = json_decode( (string) $response->getBody(), true ); |
|
485 | + $response = $this->object->patch($request, $this->view->response()); |
|
486 | + $result = json_decode((string) $response->getBody(), true); |
|
487 | 487 | |
488 | 488 | |
489 | - $this->assertEquals( 500, $response->getStatusCode() ); |
|
490 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
491 | - $this->assertArrayHasKey( 'errors', $result ); |
|
489 | + $this->assertEquals(500, $response->getStatusCode()); |
|
490 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
491 | + $this->assertArrayHasKey('errors', $result); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | |
495 | 495 | public function testPatchMShopException() |
496 | 496 | { |
497 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
498 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
497 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
498 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
499 | 499 | |
500 | 500 | $body = '{"data":[{"id":-1}]}'; |
501 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
501 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
502 | 502 | |
503 | - $response = $this->object->patch( $request, $this->view->response() ); |
|
504 | - $result = json_decode( (string) $response->getBody(), true ); |
|
503 | + $response = $this->object->patch($request, $this->view->response()); |
|
504 | + $result = json_decode((string) $response->getBody(), true); |
|
505 | 505 | |
506 | 506 | |
507 | - $this->assertEquals( 404, $response->getStatusCode() ); |
|
508 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
509 | - $this->assertArrayHasKey( 'errors', $result ); |
|
507 | + $this->assertEquals(404, $response->getStatusCode()); |
|
508 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
509 | + $this->assertArrayHasKey('errors', $result); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | |
513 | 513 | public function testPost() |
514 | 514 | { |
515 | - $productManagerStub = $this->getProductMock( array( 'createItem', 'getItem', 'saveItem' ) ); |
|
515 | + $productManagerStub = $this->getProductMock(array('createItem', 'getItem', 'saveItem')); |
|
516 | 516 | |
517 | 517 | $item = new \Aimeos\MShop\Product\Item\Standard(); |
518 | - $item->setId( '-1' ); |
|
518 | + $item->setId('-1'); |
|
519 | 519 | |
520 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'createItem' ) |
|
521 | - ->will( $this->returnValue( $item ) ); |
|
522 | - $productManagerStub->expects( $this->any() )->method( 'getItem' ) |
|
523 | - ->will( $this->returnValue( $item ) ); |
|
524 | - $productManagerStub->expects( $this->once() )->method( 'saveItem' ) |
|
525 | - ->will( $this->returnValue( $productManagerStub->createItem() ) ); |
|
520 | + $productManagerStub->expects($this->exactly(2))->method('createItem') |
|
521 | + ->will($this->returnValue($item)); |
|
522 | + $productManagerStub->expects($this->any())->method('getItem') |
|
523 | + ->will($this->returnValue($item)); |
|
524 | + $productManagerStub->expects($this->once())->method('saveItem') |
|
525 | + ->will($this->returnValue($productManagerStub->createItem())); |
|
526 | 526 | |
527 | 527 | |
528 | 528 | $body = '{"data": {"type": "product", "attributes": {"product.type": "default", "product.label": "test"}}}'; |
529 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
529 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
530 | 530 | |
531 | - $response = $this->object->post( $request, $this->view->response() ); |
|
532 | - $result = json_decode( (string) $response->getBody(), true ); |
|
531 | + $response = $this->object->post($request, $this->view->response()); |
|
532 | + $result = json_decode((string) $response->getBody(), true); |
|
533 | 533 | |
534 | - $this->assertEquals( 201, $response->getStatusCode() ); |
|
535 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
534 | + $this->assertEquals(201, $response->getStatusCode()); |
|
535 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
536 | 536 | |
537 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
538 | - $this->assertArrayHasKey( 'data', $result ); |
|
539 | - $this->assertEquals( '-1', $result['data']['id'] ); |
|
540 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
541 | - $this->assertGreaterThan( 0, $result['data']['attributes']['product.typeid'] ); |
|
542 | - $this->assertEquals( 'test', $result['data']['attributes']['product.label'] ); |
|
537 | + $this->assertEquals(1, $result['meta']['total']); |
|
538 | + $this->assertArrayHasKey('data', $result); |
|
539 | + $this->assertEquals('-1', $result['data']['id']); |
|
540 | + $this->assertEquals('product', $result['data']['type']); |
|
541 | + $this->assertGreaterThan(0, $result['data']['attributes']['product.typeid']); |
|
542 | + $this->assertEquals('test', $result['data']['attributes']['product.label']); |
|
543 | 543 | |
544 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
545 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
544 | + $this->assertArrayNotHasKey('included', $result); |
|
545 | + $this->assertArrayNotHasKey('errors', $result); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | |
549 | 549 | public function testPostBulk() |
550 | 550 | { |
551 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
551 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
552 | 552 | |
553 | 553 | $item = $productManagerStub->createItem(); |
554 | - $item->setLabel( 'test' ); |
|
555 | - $item->setId( '-1' ); |
|
554 | + $item->setLabel('test'); |
|
555 | + $item->setId('-1'); |
|
556 | 556 | |
557 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' ) |
|
558 | - ->will( $this->returnValue( $productManagerStub->createItem() ) ); |
|
559 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'getItem' ) |
|
560 | - ->will( $this->returnValue( $item ) ); |
|
557 | + $productManagerStub->expects($this->exactly(2))->method('saveItem') |
|
558 | + ->will($this->returnValue($productManagerStub->createItem())); |
|
559 | + $productManagerStub->expects($this->exactly(2))->method('getItem') |
|
560 | + ->will($this->returnValue($item)); |
|
561 | 561 | |
562 | 562 | |
563 | 563 | $body = '{"data": [{"type": "product", "attributes": {"product.label": "test"}}, {"type": "product", "attributes": {"product.label": "test"}}]}'; |
564 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
564 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
565 | 565 | |
566 | - $response = $this->object->post( $request, $this->view->response() ); |
|
567 | - $result = json_decode( (string) $response->getBody(), true ); |
|
566 | + $response = $this->object->post($request, $this->view->response()); |
|
567 | + $result = json_decode((string) $response->getBody(), true); |
|
568 | 568 | |
569 | 569 | |
570 | - $this->assertEquals( 201, $response->getStatusCode() ); |
|
571 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
570 | + $this->assertEquals(201, $response->getStatusCode()); |
|
571 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
572 | 572 | |
573 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
574 | - $this->assertArrayHasKey( 'data', $result ); |
|
575 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
576 | - $this->assertEquals( '-1', $result['data'][0]['id'] ); |
|
577 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
578 | - $this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] ); |
|
573 | + $this->assertEquals(2, $result['meta']['total']); |
|
574 | + $this->assertArrayHasKey('data', $result); |
|
575 | + $this->assertEquals(2, count($result['data'])); |
|
576 | + $this->assertEquals('-1', $result['data'][0]['id']); |
|
577 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
578 | + $this->assertEquals('test', $result['data'][0]['attributes']['product.label']); |
|
579 | 579 | |
580 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
581 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
580 | + $this->assertArrayNotHasKey('included', $result); |
|
581 | + $this->assertArrayNotHasKey('errors', $result); |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | |
585 | 585 | public function testPostRelationships() |
586 | 586 | { |
587 | - $productManagerStub = $this->getProductMock( array( 'getSubManager', 'createItem', 'getItem', 'saveItem' ) ); |
|
588 | - $productManagerListsStub = $this->getProductListsMock( array( 'saveItem' ) ); |
|
587 | + $productManagerStub = $this->getProductMock(array('getSubManager', 'createItem', 'getItem', 'saveItem')); |
|
588 | + $productManagerListsStub = $this->getProductListsMock(array('saveItem')); |
|
589 | 589 | |
590 | 590 | $item = new \Aimeos\MShop\Product\Item\Standard(); |
591 | - $item->setId( '-1' ); |
|
591 | + $item->setId('-1'); |
|
592 | 592 | |
593 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'createItem' ) |
|
594 | - ->will( $this->returnValue( $item ) ); |
|
595 | - $productManagerStub->expects( $this->any() )->method( 'getItem' ) |
|
596 | - ->will( $this->returnValue( $item ) ); |
|
597 | - $productManagerStub->expects( $this->once() )->method( 'getSubManager' ) |
|
598 | - ->will( $this->returnValue( $productManagerListsStub ) ); |
|
599 | - $productManagerStub->expects( $this->once() )->method( 'saveItem' ) |
|
600 | - ->will( $this->returnValue( $productManagerStub->createItem() ) ); |
|
593 | + $productManagerStub->expects($this->exactly(2))->method('createItem') |
|
594 | + ->will($this->returnValue($item)); |
|
595 | + $productManagerStub->expects($this->any())->method('getItem') |
|
596 | + ->will($this->returnValue($item)); |
|
597 | + $productManagerStub->expects($this->once())->method('getSubManager') |
|
598 | + ->will($this->returnValue($productManagerListsStub)); |
|
599 | + $productManagerStub->expects($this->once())->method('saveItem') |
|
600 | + ->will($this->returnValue($productManagerStub->createItem())); |
|
601 | 601 | |
602 | - $productManagerListsStub->expects( $this->once() )->method( 'saveItem' ); |
|
602 | + $productManagerListsStub->expects($this->once())->method('saveItem'); |
|
603 | 603 | |
604 | 604 | $body = '{"data": {"type": "product", |
605 | 605 | "attributes": {"product.label": "test"}, |
@@ -607,212 +607,212 @@ discard block |
||
607 | 607 | {"type": "text", "id": "-2", "attributes": {"product.lists.type": "default"}} |
608 | 608 | ]}} |
609 | 609 | }}'; |
610 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
610 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
611 | 611 | |
612 | - $response = $this->object->post( $request, $this->view->response() ); |
|
613 | - $result = json_decode( (string) $response->getBody(), true ); |
|
612 | + $response = $this->object->post($request, $this->view->response()); |
|
613 | + $result = json_decode((string) $response->getBody(), true); |
|
614 | 614 | |
615 | 615 | |
616 | - $this->assertEquals( 201, $response->getStatusCode() ); |
|
617 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
616 | + $this->assertEquals(201, $response->getStatusCode()); |
|
617 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
618 | 618 | |
619 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
620 | - $this->assertArrayHasKey( 'data', $result ); |
|
621 | - $this->assertEquals( '-1', $result['data']['id'] ); |
|
622 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
623 | - $this->assertEquals( 'test', $result['data']['attributes']['product.label'] ); |
|
619 | + $this->assertEquals(1, $result['meta']['total']); |
|
620 | + $this->assertArrayHasKey('data', $result); |
|
621 | + $this->assertEquals('-1', $result['data']['id']); |
|
622 | + $this->assertEquals('product', $result['data']['type']); |
|
623 | + $this->assertEquals('test', $result['data']['attributes']['product.label']); |
|
624 | 624 | |
625 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
626 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
625 | + $this->assertArrayNotHasKey('included', $result); |
|
626 | + $this->assertArrayNotHasKey('errors', $result); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | |
630 | 630 | public function testPostInvalid() |
631 | 631 | { |
632 | 632 | $body = '{"data":null}'; |
633 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
633 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
634 | 634 | |
635 | - $response = $this->object->post( $request, $this->view->response() ); |
|
636 | - $result = json_decode( (string) $response->getBody(), true ); |
|
635 | + $response = $this->object->post($request, $this->view->response()); |
|
636 | + $result = json_decode((string) $response->getBody(), true); |
|
637 | 637 | |
638 | 638 | |
639 | - $this->assertEquals( 400, $response->getStatusCode() ); |
|
640 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
639 | + $this->assertEquals(400, $response->getStatusCode()); |
|
640 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
641 | 641 | |
642 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
643 | - $this->assertArrayHasKey( 'errors', $result ); |
|
644 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
645 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
642 | + $this->assertEquals(0, $result['meta']['total']); |
|
643 | + $this->assertArrayHasKey('errors', $result); |
|
644 | + $this->assertArrayNotHasKey('included', $result); |
|
645 | + $this->assertArrayNotHasKey('data', $result); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | |
649 | 649 | public function testPostInvalidId() |
650 | 650 | { |
651 | 651 | $body = '{"data":{"id":-1}}'; |
652 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
652 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
653 | 653 | |
654 | - $response = $this->object->post( $request, $this->view->response() ); |
|
655 | - $result = json_decode( (string) $response->getBody(), true ); |
|
654 | + $response = $this->object->post($request, $this->view->response()); |
|
655 | + $result = json_decode((string) $response->getBody(), true); |
|
656 | 656 | |
657 | 657 | |
658 | - $this->assertEquals( 403, $response->getStatusCode() ); |
|
659 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
658 | + $this->assertEquals(403, $response->getStatusCode()); |
|
659 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
660 | 660 | |
661 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
662 | - $this->assertArrayHasKey( 'errors', $result ); |
|
661 | + $this->assertEquals(0, $result['meta']['total']); |
|
662 | + $this->assertArrayHasKey('errors', $result); |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | |
666 | 666 | public function testPostException() |
667 | 667 | { |
668 | - $this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' ) |
|
669 | - ->will( $this->throwException( new \RuntimeException( 'test exception' ) ) ); |
|
668 | + $this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem') |
|
669 | + ->will($this->throwException(new \RuntimeException('test exception'))); |
|
670 | 670 | |
671 | 671 | $body = '{"data":{}}'; |
672 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
672 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
673 | 673 | |
674 | - $response = $this->object->post( $request, $this->view->response() ); |
|
675 | - $result = json_decode( (string) $response->getBody(), true ); |
|
674 | + $response = $this->object->post($request, $this->view->response()); |
|
675 | + $result = json_decode((string) $response->getBody(), true); |
|
676 | 676 | |
677 | 677 | |
678 | - $this->assertEquals( 500, $response->getStatusCode() ); |
|
679 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
680 | - $this->assertArrayHasKey( 'errors', $result ); |
|
678 | + $this->assertEquals(500, $response->getStatusCode()); |
|
679 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
680 | + $this->assertArrayHasKey('errors', $result); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | |
684 | 684 | public function testPostMShopException() |
685 | 685 | { |
686 | - $this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' ) |
|
687 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
686 | + $this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem') |
|
687 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
688 | 688 | |
689 | 689 | $body = '{"data":{}}'; |
690 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
690 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
691 | 691 | |
692 | - $response = $this->object->post( $request, $this->view->response() ); |
|
693 | - $result = json_decode( (string) $response->getBody(), true ); |
|
692 | + $response = $this->object->post($request, $this->view->response()); |
|
693 | + $result = json_decode((string) $response->getBody(), true); |
|
694 | 694 | |
695 | 695 | |
696 | - $this->assertEquals( 404, $response->getStatusCode() ); |
|
697 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
698 | - $this->assertArrayHasKey( 'errors', $result ); |
|
696 | + $this->assertEquals(404, $response->getStatusCode()); |
|
697 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
698 | + $this->assertArrayHasKey('errors', $result); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | |
702 | 702 | public function testPut() |
703 | 703 | { |
704 | - $response = $this->object->put( $this->view->request(), $this->view->response() ); |
|
705 | - $result = json_decode( (string) $response->getBody(), true ); |
|
704 | + $response = $this->object->put($this->view->request(), $this->view->response()); |
|
705 | + $result = json_decode((string) $response->getBody(), true); |
|
706 | 706 | |
707 | - $this->assertEquals( 501, $response->getStatusCode() ); |
|
708 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
709 | - $this->assertArrayHasKey( 'errors', $result ); |
|
707 | + $this->assertEquals(501, $response->getStatusCode()); |
|
708 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
709 | + $this->assertArrayHasKey('errors', $result); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | |
713 | 713 | public function testOptions() |
714 | 714 | { |
715 | - $response = $this->object->options( $this->view->request(), $this->view->response() ); |
|
716 | - $result = json_decode( (string) $response->getBody(), true ); |
|
715 | + $response = $this->object->options($this->view->request(), $this->view->response()); |
|
716 | + $result = json_decode((string) $response->getBody(), true); |
|
717 | 717 | |
718 | 718 | |
719 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
720 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
721 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
719 | + $this->assertEquals(200, $response->getStatusCode()); |
|
720 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
721 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
722 | 722 | |
723 | - $this->assertNull( $result['meta']['prefix'] ); |
|
724 | - $this->assertEquals( 59, count( $result['meta']['resources'] ) ); |
|
725 | - $this->assertGreaterThan( 0, count( $result['meta']['attributes'] ) ); |
|
723 | + $this->assertNull($result['meta']['prefix']); |
|
724 | + $this->assertEquals(59, count($result['meta']['resources'])); |
|
725 | + $this->assertGreaterThan(0, count($result['meta']['attributes'])); |
|
726 | 726 | |
727 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
727 | + $this->assertArrayNotHasKey('errors', $result); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | |
731 | 731 | public function testOptionsWithPrefix() |
732 | 732 | { |
733 | - $response = $this->object->options( $this->view->request(), $this->view->response(), 'prefix' ); |
|
734 | - $result = json_decode( (string) $response->getBody(), true ); |
|
733 | + $response = $this->object->options($this->view->request(), $this->view->response(), 'prefix'); |
|
734 | + $result = json_decode((string) $response->getBody(), true); |
|
735 | 735 | |
736 | 736 | |
737 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
738 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
739 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
737 | + $this->assertEquals(200, $response->getStatusCode()); |
|
738 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
739 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
740 | 740 | |
741 | - $this->assertEquals( 'prefix', $result['meta']['prefix'] ); |
|
742 | - $this->assertEquals( 59, count( $result['meta']['resources'] ) ); |
|
743 | - $this->assertGreaterThan( 0, count( $result['meta']['attributes'] ) ); |
|
741 | + $this->assertEquals('prefix', $result['meta']['prefix']); |
|
742 | + $this->assertEquals(59, count($result['meta']['resources'])); |
|
743 | + $this->assertGreaterThan(0, count($result['meta']['attributes'])); |
|
744 | 744 | |
745 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
745 | + $this->assertArrayNotHasKey('errors', $result); |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | |
749 | 749 | public function testOptionsException() |
750 | 750 | { |
751 | - $this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' ) |
|
752 | - ->will( $this->throwException( new \RuntimeException( 'test exception' ) ) ); |
|
751 | + $this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType') |
|
752 | + ->will($this->throwException(new \RuntimeException('test exception'))); |
|
753 | 753 | |
754 | - $response = $this->object->options( $this->view->request(), $this->view->response() ); |
|
755 | - $result = json_decode( (string) $response->getBody(), true ); |
|
754 | + $response = $this->object->options($this->view->request(), $this->view->response()); |
|
755 | + $result = json_decode((string) $response->getBody(), true); |
|
756 | 756 | |
757 | - $this->assertEquals( 500, $response->getStatusCode() ); |
|
758 | - $this->assertArrayHasKey( 'errors', $result ); |
|
757 | + $this->assertEquals(500, $response->getStatusCode()); |
|
758 | + $this->assertArrayHasKey('errors', $result); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | |
762 | 762 | public function testOptionsMShopException() |
763 | 763 | { |
764 | - $this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' ) |
|
765 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
764 | + $this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType') |
|
765 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
766 | 766 | |
767 | - $response = $this->object->options( $this->view->request(), $this->view->response() ); |
|
768 | - $result = json_decode( (string) $response->getBody(), true ); |
|
767 | + $response = $this->object->options($this->view->request(), $this->view->response()); |
|
768 | + $result = json_decode((string) $response->getBody(), true); |
|
769 | 769 | |
770 | - $this->assertEquals( 404, $response->getStatusCode() ); |
|
771 | - $this->assertArrayHasKey( 'errors', $result ); |
|
770 | + $this->assertEquals(404, $response->getStatusCode()); |
|
771 | + $this->assertArrayHasKey('errors', $result); |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | |
775 | - protected function getProductMock( array $methods ) |
|
775 | + protected function getProductMock(array $methods) |
|
776 | 776 | { |
777 | 777 | $name = 'ClientJsonAdmStandard'; |
778 | - $this->context->getConfig()->set( 'mshop/product/manager/name', $name ); |
|
778 | + $this->context->getConfig()->set('mshop/product/manager/name', $name); |
|
779 | 779 | |
780 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Standard' ) |
|
781 | - ->setConstructorArgs( array( $this->context ) ) |
|
782 | - ->setMethods( $methods ) |
|
780 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Standard') |
|
781 | + ->setConstructorArgs(array($this->context)) |
|
782 | + ->setMethods($methods) |
|
783 | 783 | ->getMock(); |
784 | 784 | |
785 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub ); |
|
785 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub); |
|
786 | 786 | |
787 | 787 | return $stub; |
788 | 788 | } |
789 | 789 | |
790 | 790 | |
791 | - protected function getProductListsMock( array $methods ) |
|
791 | + protected function getProductListsMock(array $methods) |
|
792 | 792 | { |
793 | 793 | $name = 'ClientJsonAdmStandard'; |
794 | - $this->context->getConfig()->set( 'mshop/product/manager/lists/name', $name ); |
|
794 | + $this->context->getConfig()->set('mshop/product/manager/lists/name', $name); |
|
795 | 795 | |
796 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard' ) |
|
797 | - ->setConstructorArgs( array( $this->context ) ) |
|
798 | - ->setMethods( $methods ) |
|
796 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard') |
|
797 | + ->setConstructorArgs(array($this->context)) |
|
798 | + ->setMethods($methods) |
|
799 | 799 | ->getMock(); |
800 | 800 | |
801 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub ); |
|
801 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub); |
|
802 | 802 | |
803 | 803 | return $stub; |
804 | 804 | } |
805 | 805 | |
806 | 806 | |
807 | - protected function getProductItem( $code = 'CNC' ) |
|
807 | + protected function getProductItem($code = 'CNC') |
|
808 | 808 | { |
809 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
809 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
810 | 810 | $search = $manager->createSearch(); |
811 | - $search->setConditions( $search->compare( '==', 'product.code', $code ) ); |
|
812 | - $items = $manager->searchItems( $search ); |
|
811 | + $search->setConditions($search->compare('==', 'product.code', $code)); |
|
812 | + $items = $manager->searchItems($search); |
|
813 | 813 | |
814 | - if( ( $item = reset( $items ) ) === false ) { |
|
815 | - throw new \RuntimeException( sprintf( 'No product item with code "%1$s" found', $code ) ); |
|
814 | + if (($item = reset($items)) === false) { |
|
815 | + throw new \RuntimeException(sprintf('No product item with code "%1$s" found', $code)); |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | return $item; |