@@ -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,42 +34,42 @@ 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 | 43 | $header = array(); |
| 44 | 44 | $status = 500; |
| 45 | 45 | |
| 46 | - $result = json_decode( $this->object->delete( '', $header, $status ), true ); |
|
| 46 | + $result = json_decode($this->object->delete('', $header, $status), true); |
|
| 47 | 47 | |
| 48 | - $this->assertEquals( 200, $status ); |
|
| 49 | - $this->assertEquals( 1, count( $header ) ); |
|
| 50 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 51 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 52 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
| 53 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 48 | + $this->assertEquals(200, $status); |
|
| 49 | + $this->assertEquals(1, count($header)); |
|
| 50 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 51 | + $this->assertArrayNotHasKey('included', $result); |
|
| 52 | + $this->assertArrayNotHasKey('data', $result); |
|
| 53 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | public function testDeleteBulk() |
| 58 | 58 | { |
| 59 | - $this->getProductMock( array( 'deleteItems' ) )->expects( $this->once() )->method( 'deleteItems' ); |
|
| 59 | + $this->getProductMock(array('deleteItems'))->expects($this->once())->method('deleteItems'); |
|
| 60 | 60 | |
| 61 | 61 | $body = '{"data":[{"type": "product", "id": "-1"},{"type": "product", "id": "-2"}]}'; |
| 62 | 62 | $header = array(); |
| 63 | 63 | $status = 500; |
| 64 | 64 | |
| 65 | - $result = json_decode( $this->object->delete( $body, $header, $status ), true ); |
|
| 65 | + $result = json_decode($this->object->delete($body, $header, $status), true); |
|
| 66 | 66 | |
| 67 | - $this->assertEquals( 200, $status ); |
|
| 68 | - $this->assertEquals( 1, count( $header ) ); |
|
| 69 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
| 70 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 71 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
| 72 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 67 | + $this->assertEquals(200, $status); |
|
| 68 | + $this->assertEquals(1, count($header)); |
|
| 69 | + $this->assertEquals(2, $result['meta']['total']); |
|
| 70 | + $this->assertArrayNotHasKey('included', $result); |
|
| 71 | + $this->assertArrayNotHasKey('data', $result); |
|
| 72 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
@@ -79,52 +79,52 @@ discard block |
||
| 79 | 79 | $header = array(); |
| 80 | 80 | $status = 500; |
| 81 | 81 | |
| 82 | - $result = json_decode( $this->object->delete( $body, $header, $status ), true ); |
|
| 82 | + $result = json_decode($this->object->delete($body, $header, $status), true); |
|
| 83 | 83 | |
| 84 | - $this->assertEquals( 400, $status ); |
|
| 85 | - $this->assertEquals( 1, count( $header ) ); |
|
| 86 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
| 87 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 88 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 89 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
| 84 | + $this->assertEquals(400, $status); |
|
| 85 | + $this->assertEquals(1, count($header)); |
|
| 86 | + $this->assertEquals(0, $result['meta']['total']); |
|
| 87 | + $this->assertArrayHasKey('errors', $result); |
|
| 88 | + $this->assertArrayNotHasKey('included', $result); |
|
| 89 | + $this->assertArrayNotHasKey('data', $result); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | |
| 93 | 93 | public function testDeleteException() |
| 94 | 94 | { |
| 95 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ) |
|
| 96 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
| 95 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem') |
|
| 96 | + ->will($this->throwException(new \Exception('test exception'))); |
|
| 97 | 97 | |
| 98 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
| 99 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 100 | - $this->view->addHelper( 'param', $helper ); |
|
| 98 | + $params = array('id' => $this->getProductItem()->getId()); |
|
| 99 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 100 | + $this->view->addHelper('param', $helper); |
|
| 101 | 101 | |
| 102 | 102 | $header = array(); |
| 103 | 103 | $status = 500; |
| 104 | 104 | |
| 105 | - $result = json_decode( $this->object->delete( '', $header, $status ), true ); |
|
| 105 | + $result = json_decode($this->object->delete('', $header, $status), true); |
|
| 106 | 106 | |
| 107 | - $this->assertEquals( 500, $status ); |
|
| 108 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 107 | + $this->assertEquals(500, $status); |
|
| 108 | + $this->assertArrayHasKey('errors', $result); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | |
| 112 | 112 | public function testDeleteMShopException() |
| 113 | 113 | { |
| 114 | - $this->getProductMock( array( 'deleteItem' ) )->expects( $this->once() )->method( 'deleteItem' ) |
|
| 115 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
| 114 | + $this->getProductMock(array('deleteItem'))->expects($this->once())->method('deleteItem') |
|
| 115 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
| 116 | 116 | |
| 117 | - $params = array( 'id' => $this->getProductItem()->getId() ); |
|
| 118 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 119 | - $this->view->addHelper( 'param', $helper ); |
|
| 117 | + $params = array('id' => $this->getProductItem()->getId()); |
|
| 118 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 119 | + $this->view->addHelper('param', $helper); |
|
| 120 | 120 | |
| 121 | 121 | $header = array(); |
| 122 | 122 | $status = 500; |
| 123 | 123 | |
| 124 | - $result = json_decode( $this->object->delete( '', $header, $status ), true ); |
|
| 124 | + $result = json_decode($this->object->delete('', $header, $status), true); |
|
| 125 | 125 | |
| 126 | - $this->assertEquals( 404, $status ); |
|
| 127 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 126 | + $this->assertEquals(404, $status); |
|
| 127 | + $this->assertArrayHasKey('errors', $result); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | |
@@ -133,18 +133,18 @@ discard block |
||
| 133 | 133 | $header = array(); |
| 134 | 134 | $status = 500; |
| 135 | 135 | |
| 136 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
| 136 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
| 137 | 137 | |
| 138 | - $this->assertEquals( 200, $status ); |
|
| 139 | - $this->assertEquals( 1, count( $header ) ); |
|
| 140 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
| 141 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
| 142 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
| 143 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
| 144 | - $this->assertArrayHasKey( 'next', $result['links'] ); |
|
| 145 | - $this->assertArrayHasKey( 'last', $result['links'] ); |
|
| 146 | - $this->assertArrayHasKey( 'self', $result['links'] ); |
|
| 147 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 138 | + $this->assertEquals(200, $status); |
|
| 139 | + $this->assertEquals(1, count($header)); |
|
| 140 | + $this->assertEquals(28, $result['meta']['total']); |
|
| 141 | + $this->assertEquals(25, count($result['data'])); |
|
| 142 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
| 143 | + $this->assertEquals(0, count($result['included'])); |
|
| 144 | + $this->assertArrayHasKey('next', $result['links']); |
|
| 145 | + $this->assertArrayHasKey('last', $result['links']); |
|
| 146 | + $this->assertArrayHasKey('self', $result['links']); |
|
| 147 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | |
@@ -154,17 +154,17 @@ discard block |
||
| 154 | 154 | $status = 500; |
| 155 | 155 | |
| 156 | 156 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
| 157 | - $object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'product/stock/warehouse' ); |
|
| 157 | + $object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'product/stock/warehouse'); |
|
| 158 | 158 | |
| 159 | - $result = json_decode( $object->get( '', $header, $status ), true ); |
|
| 159 | + $result = json_decode($object->get('', $header, $status), true); |
|
| 160 | 160 | |
| 161 | - $this->assertEquals( 200, $status ); |
|
| 162 | - $this->assertEquals( 1, count( $header ) ); |
|
| 163 | - $this->assertEquals( 6, $result['meta']['total'] ); |
|
| 164 | - $this->assertEquals( 6, count( $result['data'] ) ); |
|
| 165 | - $this->assertEquals( 'product/stock/warehouse', $result['data'][0]['type'] ); |
|
| 166 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
| 167 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 161 | + $this->assertEquals(200, $status); |
|
| 162 | + $this->assertEquals(1, count($header)); |
|
| 163 | + $this->assertEquals(6, $result['meta']['total']); |
|
| 164 | + $this->assertEquals(6, count($result['data'])); |
|
| 165 | + $this->assertEquals('product/stock/warehouse', $result['data'][0]['type']); |
|
| 166 | + $this->assertEquals(0, count($result['included'])); |
|
| 167 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | |
@@ -174,55 +174,55 @@ discard block |
||
| 174 | 174 | $status = 500; |
| 175 | 175 | |
| 176 | 176 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
| 177 | - $object = new \Aimeos\Admin\JsonAdm\Standard( $this->context, $this->view, $templatePaths, 'invalid' ); |
|
| 177 | + $object = new \Aimeos\Admin\JsonAdm\Standard($this->context, $this->view, $templatePaths, 'invalid'); |
|
| 178 | 178 | |
| 179 | - $result = json_decode( $object->get( '', $header, $status ), true ); |
|
| 179 | + $result = json_decode($object->get('', $header, $status), true); |
|
| 180 | 180 | |
| 181 | - $this->assertEquals( 404, $status ); |
|
| 182 | - $this->assertEquals( 1, count( $header ) ); |
|
| 183 | - $this->assertEquals( 1, count( $result['errors'] ) ); |
|
| 184 | - $this->assertArrayHasKey( 'title', $result['errors'][0] ); |
|
| 185 | - $this->assertArrayHasKey( 'detail', $result['errors'][0] ); |
|
| 186 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
| 187 | - $this->assertArrayNotHasKey( 'indluded', $result ); |
|
| 181 | + $this->assertEquals(404, $status); |
|
| 182 | + $this->assertEquals(1, count($header)); |
|
| 183 | + $this->assertEquals(1, count($result['errors'])); |
|
| 184 | + $this->assertArrayHasKey('title', $result['errors'][0]); |
|
| 185 | + $this->assertArrayHasKey('detail', $result['errors'][0]); |
|
| 186 | + $this->assertArrayNotHasKey('data', $result); |
|
| 187 | + $this->assertArrayNotHasKey('indluded', $result); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | |
| 191 | 191 | public function testGetException() |
| 192 | 192 | { |
| 193 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
| 194 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
| 193 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
| 194 | + ->will($this->throwException(new \Exception('test exception'))); |
|
| 195 | 195 | |
| 196 | - $params = array( 'id' => -1 ); |
|
| 197 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 198 | - $this->view->addHelper( 'param', $helper ); |
|
| 196 | + $params = array('id' => -1); |
|
| 197 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 198 | + $this->view->addHelper('param', $helper); |
|
| 199 | 199 | |
| 200 | 200 | $header = array(); |
| 201 | 201 | $status = 500; |
| 202 | 202 | |
| 203 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
| 203 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
| 204 | 204 | |
| 205 | - $this->assertEquals( 500, $status ); |
|
| 206 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 205 | + $this->assertEquals(500, $status); |
|
| 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 | 219 | $header = array(); |
| 220 | 220 | $status = 500; |
| 221 | 221 | |
| 222 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
| 222 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
| 223 | 223 | |
| 224 | - $this->assertEquals( 404, $status ); |
|
| 225 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 224 | + $this->assertEquals(404, $status); |
|
| 225 | + $this->assertArrayHasKey('errors', $result); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | |
@@ -230,24 +230,24 @@ discard block |
||
| 230 | 230 | { |
| 231 | 231 | $params = array( |
| 232 | 232 | 'filter' => array( |
| 233 | - '==' => array( 'product.type.code' => 'select' ) |
|
| 233 | + '==' => array('product.type.code' => 'select') |
|
| 234 | 234 | ) |
| 235 | 235 | ); |
| 236 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 237 | - $this->view->addHelper( 'param', $helper ); |
|
| 236 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 237 | + $this->view->addHelper('param', $helper); |
|
| 238 | 238 | |
| 239 | 239 | $header = array(); |
| 240 | 240 | $status = 500; |
| 241 | 241 | |
| 242 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
| 242 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
| 243 | 243 | |
| 244 | - $this->assertEquals( 200, $status ); |
|
| 245 | - $this->assertEquals( 1, count( $header ) ); |
|
| 246 | - $this->assertEquals( 3, $result['meta']['total'] ); |
|
| 247 | - $this->assertEquals( 3, count( $result['data'] ) ); |
|
| 248 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
| 249 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
| 250 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 244 | + $this->assertEquals(200, $status); |
|
| 245 | + $this->assertEquals(1, count($header)); |
|
| 246 | + $this->assertEquals(3, $result['meta']['total']); |
|
| 247 | + $this->assertEquals(3, count($result['data'])); |
|
| 248 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
| 249 | + $this->assertEquals(0, count($result['included'])); |
|
| 250 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | |
@@ -256,26 +256,26 @@ discard block |
||
| 256 | 256 | $params = array( |
| 257 | 257 | 'filter' => array( |
| 258 | 258 | '&&' => array( |
| 259 | - array( '=~' => array( 'product.label' => 'Unittest: Test' ) ), |
|
| 260 | - array( '==' => array( 'product.type.code' => 'select' ) ), |
|
| 259 | + array('=~' => array('product.label' => 'Unittest: Test')), |
|
| 260 | + array('==' => array('product.type.code' => 'select')), |
|
| 261 | 261 | ) |
| 262 | 262 | ) |
| 263 | 263 | ); |
| 264 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 265 | - $this->view->addHelper( 'param', $helper ); |
|
| 264 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 265 | + $this->view->addHelper('param', $helper); |
|
| 266 | 266 | |
| 267 | 267 | $header = array(); |
| 268 | 268 | $status = 500; |
| 269 | 269 | |
| 270 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
| 270 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
| 271 | 271 | |
| 272 | - $this->assertEquals( 200, $status ); |
|
| 273 | - $this->assertEquals( 1, count( $header ) ); |
|
| 274 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
| 275 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
| 276 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
| 277 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
| 278 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 272 | + $this->assertEquals(200, $status); |
|
| 273 | + $this->assertEquals(1, count($header)); |
|
| 274 | + $this->assertEquals(2, $result['meta']['total']); |
|
| 275 | + $this->assertEquals(2, count($result['data'])); |
|
| 276 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
| 277 | + $this->assertEquals(0, count($result['included'])); |
|
| 278 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | |
@@ -287,24 +287,24 @@ 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 | 293 | $header = array(); |
| 294 | 294 | $status = 500; |
| 295 | 295 | |
| 296 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
| 296 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
| 297 | 297 | |
| 298 | - $this->assertEquals( 200, $status ); |
|
| 299 | - $this->assertEquals( 1, count( $header ) ); |
|
| 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 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 298 | + $this->assertEquals(200, $status); |
|
| 299 | + $this->assertEquals(1, count($header)); |
|
| 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 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | |
@@ -313,23 +313,23 @@ discard block |
||
| 313 | 313 | $params = array( |
| 314 | 314 | 'sort' => 'product.label,-product.code' |
| 315 | 315 | ); |
| 316 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 317 | - $this->view->addHelper( 'param', $helper ); |
|
| 316 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 317 | + $this->view->addHelper('param', $helper); |
|
| 318 | 318 | |
| 319 | 319 | $header = array(); |
| 320 | 320 | $status = 500; |
| 321 | 321 | |
| 322 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
| 322 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
| 323 | 323 | |
| 324 | - $this->assertEquals( 200, $status ); |
|
| 325 | - $this->assertEquals( 1, count( $header ) ); |
|
| 326 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
| 327 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
| 328 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
| 329 | - $this->assertEquals( 'ABCD', $result['data'][0]['attributes']['product.code'] ); |
|
| 330 | - $this->assertEquals( '16 discs', $result['data'][0]['attributes']['product.label'] ); |
|
| 331 | - $this->assertEquals( 0, count( $result['included'] ) ); |
|
| 332 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 324 | + $this->assertEquals(200, $status); |
|
| 325 | + $this->assertEquals(1, count($header)); |
|
| 326 | + $this->assertEquals(28, $result['meta']['total']); |
|
| 327 | + $this->assertEquals(25, count($result['data'])); |
|
| 328 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
| 329 | + $this->assertEquals('ABCD', $result['data'][0]['attributes']['product.code']); |
|
| 330 | + $this->assertEquals('16 discs', $result['data'][0]['attributes']['product.label']); |
|
| 331 | + $this->assertEquals(0, count($result['included'])); |
|
| 332 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | |
@@ -342,88 +342,88 @@ discard block |
||
| 342 | 342 | 'sort' => 'product.id', |
| 343 | 343 | 'include' => 'product' |
| 344 | 344 | ); |
| 345 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 346 | - $this->view->addHelper( 'param', $helper ); |
|
| 345 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 346 | + $this->view->addHelper('param', $helper); |
|
| 347 | 347 | |
| 348 | 348 | $header = array(); |
| 349 | 349 | $status = 500; |
| 350 | 350 | |
| 351 | - $result = json_decode( $this->object->get( '', $header, $status ), true ); |
|
| 351 | + $result = json_decode($this->object->get('', $header, $status), true); |
|
| 352 | 352 | |
| 353 | - $this->assertEquals( 200, $status ); |
|
| 354 | - $this->assertEquals( 1, count( $header ) ); |
|
| 355 | - $this->assertEquals( 28, $result['meta']['total'] ); |
|
| 356 | - $this->assertEquals( 25, count( $result['data'] ) ); |
|
| 357 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
| 358 | - $this->assertEquals( 2, count( $result['data'][0]['attributes'] ) ); |
|
| 359 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 353 | + $this->assertEquals(200, $status); |
|
| 354 | + $this->assertEquals(1, count($header)); |
|
| 355 | + $this->assertEquals(28, $result['meta']['total']); |
|
| 356 | + $this->assertEquals(25, count($result['data'])); |
|
| 357 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
| 358 | + $this->assertEquals(2, count($result['data'][0]['attributes'])); |
|
| 359 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | |
| 363 | 363 | public function testPatch() |
| 364 | 364 | { |
| 365 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
| 365 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
| 366 | 366 | |
| 367 | 367 | $item = $productManagerStub->createItem(); |
| 368 | - $item->setLabel( 'test' ); |
|
| 369 | - $item->setId( '-1' ); |
|
| 368 | + $item->setLabel('test'); |
|
| 369 | + $item->setId('-1'); |
|
| 370 | 370 | |
| 371 | - $productManagerStub->expects( $this->once() )->method( 'saveItem' ); |
|
| 372 | - $productManagerStub->expects( $this->exactly( 3 ) )->method( 'getItem' ) // 3x due to decorator |
|
| 373 | - ->will( $this->returnValue( $item ) ); |
|
| 371 | + $productManagerStub->expects($this->once())->method('saveItem'); |
|
| 372 | + $productManagerStub->expects($this->exactly(3))->method('getItem') // 3x due to decorator |
|
| 373 | + ->will($this->returnValue($item)); |
|
| 374 | 374 | |
| 375 | 375 | |
| 376 | - $params = array( 'id' => '-1' ); |
|
| 377 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 378 | - $this->view->addHelper( 'param', $helper ); |
|
| 376 | + $params = array('id' => '-1'); |
|
| 377 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 378 | + $this->view->addHelper('param', $helper); |
|
| 379 | 379 | |
| 380 | 380 | $body = '{"data": {"type": "product", "attributes": {"product.label": "test"}}}'; |
| 381 | 381 | $header = array(); |
| 382 | 382 | $status = 500; |
| 383 | 383 | |
| 384 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
| 384 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
| 385 | 385 | |
| 386 | - $this->assertEquals( 200, $status ); |
|
| 387 | - $this->assertEquals( 1, count( $header ) ); |
|
| 388 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 389 | - $this->assertArrayHasKey( 'data', $result ); |
|
| 390 | - $this->assertEquals( '-1', $result['data']['id'] ); |
|
| 391 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
| 392 | - $this->assertEquals( 'test', $result['data']['attributes']['product.label'] ); |
|
| 393 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 394 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 386 | + $this->assertEquals(200, $status); |
|
| 387 | + $this->assertEquals(1, count($header)); |
|
| 388 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 389 | + $this->assertArrayHasKey('data', $result); |
|
| 390 | + $this->assertEquals('-1', $result['data']['id']); |
|
| 391 | + $this->assertEquals('product', $result['data']['type']); |
|
| 392 | + $this->assertEquals('test', $result['data']['attributes']['product.label']); |
|
| 393 | + $this->assertArrayNotHasKey('included', $result); |
|
| 394 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | |
| 398 | 398 | public function testPatchBulk() |
| 399 | 399 | { |
| 400 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
| 400 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
| 401 | 401 | |
| 402 | 402 | $item = $productManagerStub->createItem(); |
| 403 | - $item->setLabel( 'test' ); |
|
| 404 | - $item->setId( '-1' ); |
|
| 403 | + $item->setLabel('test'); |
|
| 404 | + $item->setId('-1'); |
|
| 405 | 405 | |
| 406 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' ); |
|
| 407 | - $productManagerStub->expects( $this->exactly( 6 ) )->method( 'getItem' ) // 6x due to decorator |
|
| 408 | - ->will( $this->returnValue( $item ) ); |
|
| 406 | + $productManagerStub->expects($this->exactly(2))->method('saveItem'); |
|
| 407 | + $productManagerStub->expects($this->exactly(6))->method('getItem') // 6x due to decorator |
|
| 408 | + ->will($this->returnValue($item)); |
|
| 409 | 409 | |
| 410 | 410 | |
| 411 | 411 | $body = '{"data": [{"id": "-1", "type": "product", "attributes": {"product.label": "test"}}, {"id": "-1", "type": "product", "attributes": {"product.label": "test"}}]}'; |
| 412 | 412 | $header = array(); |
| 413 | 413 | $status = 500; |
| 414 | 414 | |
| 415 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
| 415 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
| 416 | 416 | |
| 417 | - $this->assertEquals( 200, $status ); |
|
| 418 | - $this->assertEquals( 1, count( $header ) ); |
|
| 419 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
| 420 | - $this->assertArrayHasKey( 'data', $result ); |
|
| 421 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
| 422 | - $this->assertEquals( '-1', $result['data'][0]['id'] ); |
|
| 423 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
| 424 | - $this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] ); |
|
| 425 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 426 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 417 | + $this->assertEquals(200, $status); |
|
| 418 | + $this->assertEquals(1, count($header)); |
|
| 419 | + $this->assertEquals(2, $result['meta']['total']); |
|
| 420 | + $this->assertArrayHasKey('data', $result); |
|
| 421 | + $this->assertEquals(2, count($result['data'])); |
|
| 422 | + $this->assertEquals('-1', $result['data'][0]['id']); |
|
| 423 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
| 424 | + $this->assertEquals('test', $result['data'][0]['attributes']['product.label']); |
|
| 425 | + $this->assertArrayNotHasKey('included', $result); |
|
| 426 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | |
@@ -433,14 +433,14 @@ discard block |
||
| 433 | 433 | $header = array(); |
| 434 | 434 | $status = 500; |
| 435 | 435 | |
| 436 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
| 436 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
| 437 | 437 | |
| 438 | - $this->assertEquals( 400, $status ); |
|
| 439 | - $this->assertEquals( 1, count( $header ) ); |
|
| 440 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
| 441 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 442 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 443 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
| 438 | + $this->assertEquals(400, $status); |
|
| 439 | + $this->assertEquals(1, count($header)); |
|
| 440 | + $this->assertEquals(0, $result['meta']['total']); |
|
| 441 | + $this->assertArrayHasKey('errors', $result); |
|
| 442 | + $this->assertArrayNotHasKey('included', $result); |
|
| 443 | + $this->assertArrayNotHasKey('data', $result); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | |
@@ -450,127 +450,127 @@ discard block |
||
| 450 | 450 | $header = array(); |
| 451 | 451 | $status = 500; |
| 452 | 452 | |
| 453 | - $result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
|
| 453 | + $result = json_decode($this->object->patch($body, $header, $status), true); |
|
| 454 | 454 | |
| 455 | - $this->assertEquals( 400, $status ); |
|
| 456 | - $this->assertEquals( 1, count( $header ) ); |
|
| 457 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
| 458 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 455 | + $this->assertEquals(400, $status); |
|
| 456 | + $this->assertEquals(1, count($header)); |
|
| 457 | + $this->assertEquals(0, $result['meta']['total']); |
|
| 458 | + $this->assertArrayHasKey('errors', $result); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | |
| 462 | 462 | public function testPatchException() |
| 463 | 463 | { |
| 464 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
| 465 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
| 464 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
| 465 | + ->will($this->throwException(new \Exception('test exception'))); |
|
| 466 | 466 | |
| 467 | 467 | $header = array(); |
| 468 | 468 | $status = 500; |
| 469 | 469 | |
| 470 | - $result = json_decode( $this->object->patch( '{"data":[{"id":-1}]}', $header, $status ), true ); |
|
| 470 | + $result = json_decode($this->object->patch('{"data":[{"id":-1}]}', $header, $status), true); |
|
| 471 | 471 | |
| 472 | - $this->assertEquals( 500, $status ); |
|
| 473 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 472 | + $this->assertEquals(500, $status); |
|
| 473 | + $this->assertArrayHasKey('errors', $result); |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | |
| 477 | 477 | public function testPatchMShopException() |
| 478 | 478 | { |
| 479 | - $this->getProductMock( array( 'getItem' ) )->expects( $this->once() )->method( 'getItem' ) |
|
| 480 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
| 479 | + $this->getProductMock(array('getItem'))->expects($this->once())->method('getItem') |
|
| 480 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
| 481 | 481 | |
| 482 | 482 | $header = array(); |
| 483 | 483 | $status = 500; |
| 484 | 484 | |
| 485 | - $result = json_decode( $this->object->patch( '{"data":[{"id":-1}]}', $header, $status ), true ); |
|
| 485 | + $result = json_decode($this->object->patch('{"data":[{"id":-1}]}', $header, $status), true); |
|
| 486 | 486 | |
| 487 | - $this->assertEquals( 404, $status ); |
|
| 488 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 487 | + $this->assertEquals(404, $status); |
|
| 488 | + $this->assertArrayHasKey('errors', $result); |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | |
| 492 | 492 | public function testPost() |
| 493 | 493 | { |
| 494 | - $productManagerStub = $this->getProductMock( array( 'createItem', 'getItem', 'saveItem' ) ); |
|
| 494 | + $productManagerStub = $this->getProductMock(array('createItem', 'getItem', 'saveItem')); |
|
| 495 | 495 | |
| 496 | 496 | $item = new \Aimeos\MShop\Product\Item\Standard(); |
| 497 | - $item->setId( '-1' ); |
|
| 497 | + $item->setId('-1'); |
|
| 498 | 498 | |
| 499 | - $productManagerStub->expects( $this->once() )->method( 'createItem' ) |
|
| 500 | - ->will( $this->returnValue( $item ) ); |
|
| 501 | - $productManagerStub->expects( $this->any() )->method( 'getItem' ) |
|
| 502 | - ->will( $this->returnValue( $item ) ); |
|
| 503 | - $productManagerStub->expects( $this->once() )->method( 'saveItem' ); |
|
| 499 | + $productManagerStub->expects($this->once())->method('createItem') |
|
| 500 | + ->will($this->returnValue($item)); |
|
| 501 | + $productManagerStub->expects($this->any())->method('getItem') |
|
| 502 | + ->will($this->returnValue($item)); |
|
| 503 | + $productManagerStub->expects($this->once())->method('saveItem'); |
|
| 504 | 504 | |
| 505 | 505 | |
| 506 | 506 | $body = '{"data": {"type": "product", "attributes": {"product.type": "default", "product.label": "test"}}}'; |
| 507 | 507 | $header = array(); |
| 508 | 508 | $status = 500; |
| 509 | 509 | |
| 510 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
| 510 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
| 511 | 511 | |
| 512 | - $this->assertEquals( 201, $status ); |
|
| 513 | - $this->assertEquals( 1, count( $header ) ); |
|
| 514 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 515 | - $this->assertArrayHasKey( 'data', $result ); |
|
| 516 | - $this->assertEquals( '-1', $result['data']['id'] ); |
|
| 517 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
| 518 | - $this->assertGreaterThan( 0, $result['data']['attributes']['product.typeid'] ); |
|
| 519 | - $this->assertEquals( 'test', $result['data']['attributes']['product.label'] ); |
|
| 520 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 521 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 512 | + $this->assertEquals(201, $status); |
|
| 513 | + $this->assertEquals(1, count($header)); |
|
| 514 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 515 | + $this->assertArrayHasKey('data', $result); |
|
| 516 | + $this->assertEquals('-1', $result['data']['id']); |
|
| 517 | + $this->assertEquals('product', $result['data']['type']); |
|
| 518 | + $this->assertGreaterThan(0, $result['data']['attributes']['product.typeid']); |
|
| 519 | + $this->assertEquals('test', $result['data']['attributes']['product.label']); |
|
| 520 | + $this->assertArrayNotHasKey('included', $result); |
|
| 521 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | |
| 525 | 525 | public function testPostBulk() |
| 526 | 526 | { |
| 527 | - $productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
|
| 527 | + $productManagerStub = $this->getProductMock(array('getItem', 'saveItem')); |
|
| 528 | 528 | |
| 529 | 529 | $item = $productManagerStub->createItem(); |
| 530 | - $item->setLabel( 'test' ); |
|
| 531 | - $item->setId( '-1' ); |
|
| 530 | + $item->setLabel('test'); |
|
| 531 | + $item->setId('-1'); |
|
| 532 | 532 | |
| 533 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' ); |
|
| 534 | - $productManagerStub->expects( $this->exactly( 2 ) )->method( 'getItem' ) |
|
| 535 | - ->will( $this->returnValue( $item ) ); |
|
| 533 | + $productManagerStub->expects($this->exactly(2))->method('saveItem'); |
|
| 534 | + $productManagerStub->expects($this->exactly(2))->method('getItem') |
|
| 535 | + ->will($this->returnValue($item)); |
|
| 536 | 536 | |
| 537 | 537 | |
| 538 | 538 | $body = '{"data": [{"type": "product", "attributes": {"product.label": "test"}}, {"type": "product", "attributes": {"product.label": "test"}}]}'; |
| 539 | 539 | $header = array(); |
| 540 | 540 | $status = 500; |
| 541 | 541 | |
| 542 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
| 542 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
| 543 | 543 | |
| 544 | - $this->assertEquals( 201, $status ); |
|
| 545 | - $this->assertEquals( 1, count( $header ) ); |
|
| 546 | - $this->assertEquals( 2, $result['meta']['total'] ); |
|
| 547 | - $this->assertArrayHasKey( 'data', $result ); |
|
| 548 | - $this->assertEquals( 2, count( $result['data'] ) ); |
|
| 549 | - $this->assertEquals( '-1', $result['data'][0]['id'] ); |
|
| 550 | - $this->assertEquals( 'product', $result['data'][0]['type'] ); |
|
| 551 | - $this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] ); |
|
| 552 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 553 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 544 | + $this->assertEquals(201, $status); |
|
| 545 | + $this->assertEquals(1, count($header)); |
|
| 546 | + $this->assertEquals(2, $result['meta']['total']); |
|
| 547 | + $this->assertArrayHasKey('data', $result); |
|
| 548 | + $this->assertEquals(2, count($result['data'])); |
|
| 549 | + $this->assertEquals('-1', $result['data'][0]['id']); |
|
| 550 | + $this->assertEquals('product', $result['data'][0]['type']); |
|
| 551 | + $this->assertEquals('test', $result['data'][0]['attributes']['product.label']); |
|
| 552 | + $this->assertArrayNotHasKey('included', $result); |
|
| 553 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | |
| 557 | 557 | public function testPostRelationships() |
| 558 | 558 | { |
| 559 | - $productManagerStub = $this->getProductMock( array( 'getSubManager', 'createItem', 'getItem', 'saveItem' ) ); |
|
| 560 | - $productManagerListsStub = $this->getProductListsMock( array( 'saveItem' ) ); |
|
| 559 | + $productManagerStub = $this->getProductMock(array('getSubManager', 'createItem', 'getItem', 'saveItem')); |
|
| 560 | + $productManagerListsStub = $this->getProductListsMock(array('saveItem')); |
|
| 561 | 561 | |
| 562 | 562 | $item = new \Aimeos\MShop\Product\Item\Standard(); |
| 563 | - $item->setId( '-1' ); |
|
| 563 | + $item->setId('-1'); |
|
| 564 | 564 | |
| 565 | - $productManagerStub->expects( $this->once() )->method( 'createItem' ) |
|
| 566 | - ->will( $this->returnValue( $item ) ); |
|
| 567 | - $productManagerStub->expects( $this->any() )->method( 'getItem' ) |
|
| 568 | - ->will( $this->returnValue( $item ) ); |
|
| 569 | - $productManagerStub->expects( $this->once() )->method( 'getSubManager' ) |
|
| 570 | - ->will( $this->returnValue( $productManagerListsStub ) ); |
|
| 571 | - $productManagerStub->expects( $this->once() )->method( 'saveItem' ); |
|
| 565 | + $productManagerStub->expects($this->once())->method('createItem') |
|
| 566 | + ->will($this->returnValue($item)); |
|
| 567 | + $productManagerStub->expects($this->any())->method('getItem') |
|
| 568 | + ->will($this->returnValue($item)); |
|
| 569 | + $productManagerStub->expects($this->once())->method('getSubManager') |
|
| 570 | + ->will($this->returnValue($productManagerListsStub)); |
|
| 571 | + $productManagerStub->expects($this->once())->method('saveItem'); |
|
| 572 | 572 | |
| 573 | - $productManagerListsStub->expects( $this->once() )->method( 'saveItem' ); |
|
| 573 | + $productManagerListsStub->expects($this->once())->method('saveItem'); |
|
| 574 | 574 | |
| 575 | 575 | $body = '{"data": {"type": "product", |
| 576 | 576 | "attributes": {"product.label": "test"}, |
@@ -581,17 +581,17 @@ discard block |
||
| 581 | 581 | $header = array(); |
| 582 | 582 | $status = 500; |
| 583 | 583 | |
| 584 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
| 584 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
| 585 | 585 | |
| 586 | - $this->assertEquals( 201, $status ); |
|
| 587 | - $this->assertEquals( 1, count( $header ) ); |
|
| 588 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 589 | - $this->assertArrayHasKey( 'data', $result ); |
|
| 590 | - $this->assertEquals( '-1', $result['data']['id'] ); |
|
| 591 | - $this->assertEquals( 'product', $result['data']['type'] ); |
|
| 592 | - $this->assertEquals( 'test', $result['data']['attributes']['product.label'] ); |
|
| 593 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 594 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 586 | + $this->assertEquals(201, $status); |
|
| 587 | + $this->assertEquals(1, count($header)); |
|
| 588 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 589 | + $this->assertArrayHasKey('data', $result); |
|
| 590 | + $this->assertEquals('-1', $result['data']['id']); |
|
| 591 | + $this->assertEquals('product', $result['data']['type']); |
|
| 592 | + $this->assertEquals('test', $result['data']['attributes']['product.label']); |
|
| 593 | + $this->assertArrayNotHasKey('included', $result); |
|
| 594 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | |
@@ -601,14 +601,14 @@ discard block |
||
| 601 | 601 | $header = array(); |
| 602 | 602 | $status = 500; |
| 603 | 603 | |
| 604 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
| 604 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
| 605 | 605 | |
| 606 | - $this->assertEquals( 400, $status ); |
|
| 607 | - $this->assertEquals( 1, count( $header ) ); |
|
| 608 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
| 609 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 610 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 611 | - $this->assertArrayNotHasKey( 'data', $result ); |
|
| 606 | + $this->assertEquals(400, $status); |
|
| 607 | + $this->assertEquals(1, count($header)); |
|
| 608 | + $this->assertEquals(0, $result['meta']['total']); |
|
| 609 | + $this->assertArrayHasKey('errors', $result); |
|
| 610 | + $this->assertArrayNotHasKey('included', $result); |
|
| 611 | + $this->assertArrayNotHasKey('data', $result); |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | |
@@ -618,42 +618,42 @@ discard block |
||
| 618 | 618 | $header = array(); |
| 619 | 619 | $status = 500; |
| 620 | 620 | |
| 621 | - $result = json_decode( $this->object->post( $body, $header, $status ), true ); |
|
| 621 | + $result = json_decode($this->object->post($body, $header, $status), true); |
|
| 622 | 622 | |
| 623 | - $this->assertEquals( 403, $status ); |
|
| 624 | - $this->assertEquals( 1, count( $header ) ); |
|
| 625 | - $this->assertEquals( 0, $result['meta']['total'] ); |
|
| 626 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 623 | + $this->assertEquals(403, $status); |
|
| 624 | + $this->assertEquals(1, count($header)); |
|
| 625 | + $this->assertEquals(0, $result['meta']['total']); |
|
| 626 | + $this->assertArrayHasKey('errors', $result); |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | |
| 630 | 630 | public function testPostException() |
| 631 | 631 | { |
| 632 | - $this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' ) |
|
| 633 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
| 632 | + $this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem') |
|
| 633 | + ->will($this->throwException(new \Exception('test exception'))); |
|
| 634 | 634 | |
| 635 | 635 | $header = array(); |
| 636 | 636 | $status = 500; |
| 637 | 637 | |
| 638 | - $result = json_decode( $this->object->post( '{"data":{}}', $header, $status ), true ); |
|
| 638 | + $result = json_decode($this->object->post('{"data":{}}', $header, $status), true); |
|
| 639 | 639 | |
| 640 | - $this->assertEquals( 500, $status ); |
|
| 641 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 640 | + $this->assertEquals(500, $status); |
|
| 641 | + $this->assertArrayHasKey('errors', $result); |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | |
| 645 | 645 | public function testPostMShopException() |
| 646 | 646 | { |
| 647 | - $this->getProductMock( array( 'saveItem' ) )->expects( $this->once() )->method( 'saveItem' ) |
|
| 648 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
| 647 | + $this->getProductMock(array('saveItem'))->expects($this->once())->method('saveItem') |
|
| 648 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
| 649 | 649 | |
| 650 | 650 | $header = array(); |
| 651 | 651 | $status = 500; |
| 652 | 652 | |
| 653 | - $result = json_decode( $this->object->post( '{"data":{}}', $header, $status ), true ); |
|
| 653 | + $result = json_decode($this->object->post('{"data":{}}', $header, $status), true); |
|
| 654 | 654 | |
| 655 | - $this->assertEquals( 404, $status ); |
|
| 656 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 655 | + $this->assertEquals(404, $status); |
|
| 656 | + $this->assertArrayHasKey('errors', $result); |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | |
@@ -663,11 +663,11 @@ discard block |
||
| 663 | 663 | $header = array(); |
| 664 | 664 | $status = 500; |
| 665 | 665 | |
| 666 | - $result = json_decode( $this->object->put( $body, $header, $status ), true ); |
|
| 666 | + $result = json_decode($this->object->put($body, $header, $status), true); |
|
| 667 | 667 | |
| 668 | - $this->assertEquals( 501, $status ); |
|
| 669 | - $this->assertEquals( 1, count( $header ) ); |
|
| 670 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 668 | + $this->assertEquals(501, $status); |
|
| 669 | + $this->assertEquals(1, count($header)); |
|
| 670 | + $this->assertArrayHasKey('errors', $result); |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | |
@@ -676,87 +676,87 @@ discard block |
||
| 676 | 676 | $header = array(); |
| 677 | 677 | $status = 500; |
| 678 | 678 | |
| 679 | - $result = json_decode( $this->object->options( '', $header, $status ), true ); |
|
| 679 | + $result = json_decode($this->object->options('', $header, $status), true); |
|
| 680 | 680 | |
| 681 | - $this->assertEquals( 200, $status ); |
|
| 682 | - $this->assertEquals( 2, count( $header ) ); |
|
| 683 | - $this->assertEquals( 59, count( $result['meta']['resources'] ) ); |
|
| 684 | - $this->assertGreaterThan( 0, count( $result['meta']['attributes'] ) ); |
|
| 685 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 681 | + $this->assertEquals(200, $status); |
|
| 682 | + $this->assertEquals(2, count($header)); |
|
| 683 | + $this->assertEquals(59, count($result['meta']['resources'])); |
|
| 684 | + $this->assertGreaterThan(0, count($result['meta']['attributes'])); |
|
| 685 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | |
| 689 | 689 | public function testOptionsException() |
| 690 | 690 | { |
| 691 | - $this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' ) |
|
| 692 | - ->will( $this->throwException( new \Exception( 'test exception' ) ) ); |
|
| 691 | + $this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType') |
|
| 692 | + ->will($this->throwException(new \Exception('test exception'))); |
|
| 693 | 693 | |
| 694 | 694 | $header = array(); |
| 695 | 695 | $status = 500; |
| 696 | 696 | |
| 697 | - $result = json_decode( $this->object->options( '', $header, $status ), true ); |
|
| 697 | + $result = json_decode($this->object->options('', $header, $status), true); |
|
| 698 | 698 | |
| 699 | - $this->assertEquals( 500, $status ); |
|
| 700 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 699 | + $this->assertEquals(500, $status); |
|
| 700 | + $this->assertArrayHasKey('errors', $result); |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | |
| 704 | 704 | public function testOptionsMShopException() |
| 705 | 705 | { |
| 706 | - $this->getProductMock( array( 'getResourceType' ) )->expects( $this->once() )->method( 'getResourceType' ) |
|
| 707 | - ->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) ); |
|
| 706 | + $this->getProductMock(array('getResourceType'))->expects($this->once())->method('getResourceType') |
|
| 707 | + ->will($this->throwException(new \Aimeos\MShop\Exception('test exception'))); |
|
| 708 | 708 | |
| 709 | 709 | $header = array(); |
| 710 | 710 | $status = 500; |
| 711 | 711 | |
| 712 | - $result = json_decode( $this->object->options( '', $header, $status ), true ); |
|
| 712 | + $result = json_decode($this->object->options('', $header, $status), true); |
|
| 713 | 713 | |
| 714 | - $this->assertEquals( 404, $status ); |
|
| 715 | - $this->assertArrayHasKey( 'errors', $result ); |
|
| 714 | + $this->assertEquals(404, $status); |
|
| 715 | + $this->assertArrayHasKey('errors', $result); |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | |
| 719 | - protected function getProductMock( array $methods ) |
|
| 719 | + protected function getProductMock(array $methods) |
|
| 720 | 720 | { |
| 721 | 721 | $name = 'ClientJsonAdmStandard'; |
| 722 | - $this->context->getConfig()->set( 'mshop/product/manager/name', $name ); |
|
| 722 | + $this->context->getConfig()->set('mshop/product/manager/name', $name); |
|
| 723 | 723 | |
| 724 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Standard' ) |
|
| 725 | - ->setConstructorArgs( array( $this->context ) ) |
|
| 726 | - ->setMethods( $methods ) |
|
| 724 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Standard') |
|
| 725 | + ->setConstructorArgs(array($this->context)) |
|
| 726 | + ->setMethods($methods) |
|
| 727 | 727 | ->getMock(); |
| 728 | 728 | |
| 729 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub ); |
|
| 729 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\' . $name, $stub); |
|
| 730 | 730 | |
| 731 | 731 | return $stub; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | |
| 735 | - protected function getProductListsMock( array $methods ) |
|
| 735 | + protected function getProductListsMock(array $methods) |
|
| 736 | 736 | { |
| 737 | 737 | $name = 'ClientJsonAdmStandard'; |
| 738 | - $this->context->getConfig()->set( 'mshop/product/manager/lists/name', $name ); |
|
| 738 | + $this->context->getConfig()->set('mshop/product/manager/lists/name', $name); |
|
| 739 | 739 | |
| 740 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard' ) |
|
| 741 | - ->setConstructorArgs( array( $this->context ) ) |
|
| 742 | - ->setMethods( $methods ) |
|
| 740 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Product\\Manager\\Lists\\Standard') |
|
| 741 | + ->setConstructorArgs(array($this->context)) |
|
| 742 | + ->setMethods($methods) |
|
| 743 | 743 | ->getMock(); |
| 744 | 744 | |
| 745 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub ); |
|
| 745 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Product\\Manager\\Lists\\' . $name, $stub); |
|
| 746 | 746 | |
| 747 | 747 | return $stub; |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | |
| 751 | - protected function getProductItem( $code = 'CNC' ) |
|
| 751 | + protected function getProductItem($code = 'CNC') |
|
| 752 | 752 | { |
| 753 | - $manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context ); |
|
| 753 | + $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context); |
|
| 754 | 754 | $search = $manager->createSearch(); |
| 755 | - $search->setConditions( $search->compare( '==', 'product.code', $code ) ); |
|
| 756 | - $items = $manager->searchItems( $search ); |
|
| 755 | + $search->setConditions($search->compare('==', 'product.code', $code)); |
|
| 756 | + $items = $manager->searchItems($search); |
|
| 757 | 757 | |
| 758 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 759 | - throw new \Exception( sprintf( 'No product item with code "%1$s" found', $code ) ); |
|
| 758 | + if (($item = reset($items)) === false) { |
|
| 759 | + throw new \Exception(sprintf('No product item with code "%1$s" found', $code)); |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | return $item; |
@@ -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/stock" |
| 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; |
@@ -50,40 +50,40 @@ discard block |
||
| 50 | 50 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 51 | 51 | * @return string Content for response body |
| 52 | 52 | */ |
| 53 | - public function delete( $body, array &$header, &$status ) |
|
| 53 | + public function delete($body, array &$header, &$status) |
|
| 54 | 54 | { |
| 55 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 55 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 56 | 56 | $context = $this->getContext(); |
| 57 | 57 | $view = $this->getView(); |
| 58 | 58 | |
| 59 | 59 | try |
| 60 | 60 | { |
| 61 | - $view = $this->deleteItems( $view, $body ); |
|
| 61 | + $view = $this->deleteItems($view, $body); |
|
| 62 | 62 | $status = 200; |
| 63 | 63 | } |
| 64 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 64 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
| 65 | 65 | { |
| 66 | 66 | $status = $e->getCode(); |
| 67 | - $view->errors = array( array( |
|
| 68 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
| 67 | + $view->errors = array(array( |
|
| 68 | + 'title' => $context->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
| 69 | 69 | 'detail' => $e->getTraceAsString(), |
| 70 | - ) ); |
|
| 70 | + )); |
|
| 71 | 71 | } |
| 72 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 72 | + catch (\Aimeos\MShop\Exception $e) |
|
| 73 | 73 | { |
| 74 | 74 | $status = 404; |
| 75 | - $view->errors = array( array( |
|
| 76 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 75 | + $view->errors = array(array( |
|
| 76 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
| 77 | 77 | 'detail' => $e->getTraceAsString(), |
| 78 | - ) ); |
|
| 78 | + )); |
|
| 79 | 79 | } |
| 80 | - catch( \Exception $e ) |
|
| 80 | + catch (\Exception $e) |
|
| 81 | 81 | { |
| 82 | 82 | $status = 500; |
| 83 | - $view->errors = array( array( |
|
| 83 | + $view->errors = array(array( |
|
| 84 | 84 | 'title' => $e->getMessage(), |
| 85 | 85 | 'detail' => $e->getTraceAsString(), |
| 86 | - ) ); |
|
| 86 | + )); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** admin/jsonadm/standard/template-delete |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | $tplconf = 'admin/jsonadm/standard/template-delete'; |
| 114 | 114 | $default = 'delete-default.php'; |
| 115 | 115 | |
| 116 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 116 | + return $view->render($view->config($tplconf, $default)); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | |
@@ -125,31 +125,31 @@ discard block |
||
| 125 | 125 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 126 | 126 | * @return string Content for response body |
| 127 | 127 | */ |
| 128 | - public function get( $body, array &$header, &$status ) |
|
| 128 | + public function get($body, array &$header, &$status) |
|
| 129 | 129 | { |
| 130 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 130 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 131 | 131 | $view = $this->getView(); |
| 132 | 132 | |
| 133 | 133 | try |
| 134 | 134 | { |
| 135 | - $view = $this->getItem( $view ); |
|
| 135 | + $view = $this->getItem($view); |
|
| 136 | 136 | $status = 200; |
| 137 | 137 | } |
| 138 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 138 | + catch (\Aimeos\MShop\Exception $e) |
|
| 139 | 139 | { |
| 140 | 140 | $status = 404; |
| 141 | - $view->errors = array( array( |
|
| 142 | - 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 141 | + $view->errors = array(array( |
|
| 142 | + 'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()), |
|
| 143 | 143 | 'detail' => $e->getTraceAsString(), |
| 144 | - ) ); |
|
| 144 | + )); |
|
| 145 | 145 | } |
| 146 | - catch( \Exception $e ) |
|
| 146 | + catch (\Exception $e) |
|
| 147 | 147 | { |
| 148 | 148 | $status = 500; |
| 149 | - $view->errors = array( array( |
|
| 149 | + $view->errors = array(array( |
|
| 150 | 150 | 'title' => $e->getMessage(), |
| 151 | 151 | 'detail' => $e->getTraceAsString(), |
| 152 | - ) ); |
|
| 152 | + )); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** admin/jsonadm/standard/template-get |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | $tplconf = 'admin/jsonadm/standard/template-get'; |
| 180 | 180 | $default = 'get-default.php'; |
| 181 | 181 | |
| 182 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 182 | + return $view->render($view->config($tplconf, $default)); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | |
@@ -191,40 +191,40 @@ discard block |
||
| 191 | 191 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 192 | 192 | * @return string Content for response body |
| 193 | 193 | */ |
| 194 | - public function patch( $body, array &$header, &$status ) |
|
| 194 | + public function patch($body, array &$header, &$status) |
|
| 195 | 195 | { |
| 196 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 196 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 197 | 197 | $context = $this->getContext(); |
| 198 | 198 | $view = $this->getView(); |
| 199 | 199 | |
| 200 | 200 | try |
| 201 | 201 | { |
| 202 | - $view = $this->patchItems( $view, $body, $header ); |
|
| 202 | + $view = $this->patchItems($view, $body, $header); |
|
| 203 | 203 | $status = 200; |
| 204 | 204 | } |
| 205 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 205 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
| 206 | 206 | { |
| 207 | 207 | $status = $e->getCode(); |
| 208 | - $view->errors = array( array( |
|
| 209 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
| 208 | + $view->errors = array(array( |
|
| 209 | + 'title' => $context->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
| 210 | 210 | 'detail' => $e->getTraceAsString(), |
| 211 | - ) ); |
|
| 211 | + )); |
|
| 212 | 212 | } |
| 213 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 213 | + catch (\Aimeos\MShop\Exception $e) |
|
| 214 | 214 | { |
| 215 | 215 | $status = 404; |
| 216 | - $view->errors = array( array( |
|
| 217 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 216 | + $view->errors = array(array( |
|
| 217 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
| 218 | 218 | 'detail' => $e->getTraceAsString(), |
| 219 | - ) ); |
|
| 219 | + )); |
|
| 220 | 220 | } |
| 221 | - catch( \Exception $e ) |
|
| 221 | + catch (\Exception $e) |
|
| 222 | 222 | { |
| 223 | 223 | $status = 500; |
| 224 | - $view->errors = array( array( |
|
| 224 | + $view->errors = array(array( |
|
| 225 | 225 | 'title' => $e->getMessage(), |
| 226 | 226 | 'detail' => $e->getTraceAsString(), |
| 227 | - ) ); |
|
| 227 | + )); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** admin/jsonadm/standard/template-patch |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | $tplconf = 'admin/jsonadm/standard/template-patch'; |
| 255 | 255 | $default = 'patch-default.php'; |
| 256 | 256 | |
| 257 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 257 | + return $view->render($view->config($tplconf, $default)); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | |
@@ -266,40 +266,40 @@ discard block |
||
| 266 | 266 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 267 | 267 | * @return string Content for response body |
| 268 | 268 | */ |
| 269 | - public function post( $body, array &$header, &$status ) |
|
| 269 | + public function post($body, array &$header, &$status) |
|
| 270 | 270 | { |
| 271 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 271 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 272 | 272 | $context = $this->getContext(); |
| 273 | 273 | $view = $this->getView(); |
| 274 | 274 | |
| 275 | 275 | try |
| 276 | 276 | { |
| 277 | - $view = $this->postItems( $view, $body, $header ); |
|
| 277 | + $view = $this->postItems($view, $body, $header); |
|
| 278 | 278 | $status = 201; |
| 279 | 279 | } |
| 280 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 280 | + catch (\Aimeos\Admin\JsonAdm\Exception $e) |
|
| 281 | 281 | { |
| 282 | 282 | $status = $e->getCode(); |
| 283 | - $view->errors = array( array( |
|
| 284 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
|
| 283 | + $view->errors = array(array( |
|
| 284 | + 'title' => $context->getI18n()->dt('admin/jsonadm', $e->getMessage()), |
|
| 285 | 285 | 'detail' => $e->getTraceAsString(), |
| 286 | - ) ); |
|
| 286 | + )); |
|
| 287 | 287 | } |
| 288 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 288 | + catch (\Aimeos\MShop\Exception $e) |
|
| 289 | 289 | { |
| 290 | 290 | $status = 404; |
| 291 | - $view->errors = array( array( |
|
| 292 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 291 | + $view->errors = array(array( |
|
| 292 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
| 293 | 293 | 'detail' => $e->getTraceAsString(), |
| 294 | - ) ); |
|
| 294 | + )); |
|
| 295 | 295 | } |
| 296 | - catch( \Exception $e ) |
|
| 296 | + catch (\Exception $e) |
|
| 297 | 297 | { |
| 298 | 298 | $status = 500; |
| 299 | - $view->errors = array( array( |
|
| 299 | + $view->errors = array(array( |
|
| 300 | 300 | 'title' => $e->getMessage(), |
| 301 | 301 | 'detail' => $e->getTraceAsString(), |
| 302 | - ) ); |
|
| 302 | + )); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** admin/jsonadm/standard/template-post |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | $tplconf = 'admin/jsonadm/standard/template-post'; |
| 330 | 330 | $default = 'post-default.php'; |
| 331 | 331 | |
| 332 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 332 | + return $view->render($view->config($tplconf, $default)); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | |
@@ -341,17 +341,17 @@ discard block |
||
| 341 | 341 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 342 | 342 | * @return string Content for response body |
| 343 | 343 | */ |
| 344 | - public function put( $body, array &$header, &$status ) |
|
| 344 | + public function put($body, array &$header, &$status) |
|
| 345 | 345 | { |
| 346 | - $header = array( 'Content-Type' => 'application/vnd.api+json; supported-ext="bulk"' ); |
|
| 346 | + $header = array('Content-Type' => 'application/vnd.api+json; supported-ext="bulk"'); |
|
| 347 | 347 | $status = 501; |
| 348 | 348 | |
| 349 | 349 | $context = $this->getContext(); |
| 350 | 350 | $view = $this->getView(); |
| 351 | 351 | |
| 352 | - $view->errors = array( array( |
|
| 353 | - 'title' => $context->getI18n()->dt( 'admin/jsonadm', 'Not implemented, use PATCH instead' ), |
|
| 354 | - ) ); |
|
| 352 | + $view->errors = array(array( |
|
| 353 | + 'title' => $context->getI18n()->dt('admin/jsonadm', 'Not implemented, use PATCH instead'), |
|
| 354 | + )); |
|
| 355 | 355 | |
| 356 | 356 | /** admin/jsonadm/standard/template-put |
| 357 | 357 | * Relative path to the JSON API template for PUT requests |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | $tplconf = 'admin/jsonadm/standard/template-put'; |
| 381 | 381 | $default = 'put-default.php'; |
| 382 | 382 | |
| 383 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 383 | + return $view->render($view->config($tplconf, $default)); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | * @param integer &$status Variable which contains the HTTP status afterwards |
| 393 | 393 | * @return string Content for response body |
| 394 | 394 | */ |
| 395 | - public function options( $body, array &$header, &$status ) |
|
| 395 | + public function options($body, array &$header, &$status) |
|
| 396 | 396 | { |
| 397 | 397 | $context = $this->getContext(); |
| 398 | 398 | $view = $this->getView(); |
@@ -401,11 +401,11 @@ discard block |
||
| 401 | 401 | { |
| 402 | 402 | $resources = $attributes = array(); |
| 403 | 403 | |
| 404 | - foreach( $this->getDomains( $view ) as $domain ) |
|
| 404 | + foreach ($this->getDomains($view) as $domain) |
|
| 405 | 405 | { |
| 406 | - $manager = \Aimeos\MShop\Factory::createManager( $context, $domain ); |
|
| 407 | - $resources = array_merge( $resources, $manager->getResourceType( true ) ); |
|
| 408 | - $attributes = array_merge( $attributes, $manager->getSearchAttributes( true ) ); |
|
| 406 | + $manager = \Aimeos\MShop\Factory::createManager($context, $domain); |
|
| 407 | + $resources = array_merge($resources, $manager->getResourceType(true)); |
|
| 408 | + $attributes = array_merge($attributes, $manager->getSearchAttributes(true)); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | $view->resources = $resources; |
@@ -417,21 +417,21 @@ discard block |
||
| 417 | 417 | ); |
| 418 | 418 | $status = 200; |
| 419 | 419 | } |
| 420 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 420 | + catch (\Aimeos\MShop\Exception $e) |
|
| 421 | 421 | { |
| 422 | 422 | $status = 404; |
| 423 | - $view->errors = array( array( |
|
| 424 | - 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
|
| 423 | + $view->errors = array(array( |
|
| 424 | + 'title' => $context->getI18n()->dt('mshop', $e->getMessage()), |
|
| 425 | 425 | 'detail' => $e->getTraceAsString(), |
| 426 | - ) ); |
|
| 426 | + )); |
|
| 427 | 427 | } |
| 428 | - catch( \Exception $e ) |
|
| 428 | + catch (\Exception $e) |
|
| 429 | 429 | { |
| 430 | 430 | $status = 500; |
| 431 | - $view->errors = array( array( |
|
| 431 | + $view->errors = array(array( |
|
| 432 | 432 | 'title' => $e->getMessage(), |
| 433 | 433 | 'detail' => $e->getTraceAsString(), |
| 434 | - ) ); |
|
| 434 | + )); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** admin/jsonadm/standard/template-options |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | $tplconf = 'admin/jsonadm/standard/template-options'; |
| 462 | 462 | $default = 'options-default.php'; |
| 463 | 463 | |
| 464 | - return $view->render( $view->config( $tplconf, $default ) ); |
|
| 464 | + return $view->render($view->config($tplconf, $default)); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | |
@@ -473,23 +473,23 @@ discard block |
||
| 473 | 473 | * @return \Aimeos\MW\View\Iface $view View object that will contain the "total" property afterwards |
| 474 | 474 | * @throws \Aimeos\Admin\JsonAdm\Exception If the request body is invalid |
| 475 | 475 | */ |
| 476 | - protected function deleteItems( \Aimeos\MW\View\Iface $view, $body ) |
|
| 476 | + protected function deleteItems(\Aimeos\MW\View\Iface $view, $body) |
|
| 477 | 477 | { |
| 478 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 478 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 479 | 479 | |
| 480 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
| 480 | + if (($id = $view->param('id')) == null) |
|
| 481 | 481 | { |
| 482 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) || !is_array( $request->data ) ) { |
|
| 483 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
| 482 | + if (($request = json_decode($body)) === null || !isset($request->data) || !is_array($request->data)) { |
|
| 483 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | - $ids = $this->getIds( $request ); |
|
| 487 | - $manager->deleteItems( $ids ); |
|
| 488 | - $view->total = count( $ids ); |
|
| 486 | + $ids = $this->getIds($request); |
|
| 487 | + $manager->deleteItems($ids); |
|
| 488 | + $view->total = count($ids); |
|
| 489 | 489 | } |
| 490 | 490 | else |
| 491 | 491 | { |
| 492 | - $manager->deleteItem( $id ); |
|
| 492 | + $manager->deleteItem($id); |
|
| 493 | 493 | $view->total = 1; |
| 494 | 494 | } |
| 495 | 495 | |
@@ -503,27 +503,27 @@ discard block |
||
| 503 | 503 | * @param \Aimeos\MW\View\Iface $view View instance |
| 504 | 504 | * @return \Aimeos\MW\View\Iface View instance with additional data assigned |
| 505 | 505 | */ |
| 506 | - protected function getItem( \Aimeos\MW\View\Iface $view ) |
|
| 506 | + protected function getItem(\Aimeos\MW\View\Iface $view) |
|
| 507 | 507 | { |
| 508 | 508 | $total = 1; |
| 509 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 510 | - $include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() ); |
|
| 509 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 510 | + $include = (($include = $view->param('include')) !== null ? explode(',', $include) : array()); |
|
| 511 | 511 | |
| 512 | - if( ( $id = $view->param( 'id' ) ) == null ) |
|
| 512 | + if (($id = $view->param('id')) == null) |
|
| 513 | 513 | { |
| 514 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
| 515 | - $view->data = $manager->searchItems( $search, array(), $total ); |
|
| 516 | - $view->childItems = $this->getChildItems( $view->data, $include ); |
|
| 517 | - $view->listItems = $this->getListItems( $view->data, $include ); |
|
| 514 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
| 515 | + $view->data = $manager->searchItems($search, array(), $total); |
|
| 516 | + $view->childItems = $this->getChildItems($view->data, $include); |
|
| 517 | + $view->listItems = $this->getListItems($view->data, $include); |
|
| 518 | 518 | } |
| 519 | 519 | else |
| 520 | 520 | { |
| 521 | - $view->data = $manager->getItem( $id, array() ); |
|
| 522 | - $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
|
| 523 | - $view->listItems = $this->getListItems( array( $id => $view->data ), $include ); |
|
| 521 | + $view->data = $manager->getItem($id, array()); |
|
| 522 | + $view->childItems = $this->getChildItems(array($id => $view->data), $include); |
|
| 523 | + $view->listItems = $this->getListItems(array($id => $view->data), $include); |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - $view->refItems = $this->getRefItems( $view->listItems ); |
|
| 526 | + $view->refItems = $this->getRefItems($view->listItems); |
|
| 527 | 527 | |
| 528 | 528 | $view->total = $total; |
| 529 | 529 | |
@@ -548,11 +548,11 @@ discard block |
||
| 548 | 548 | * @param array $params List of criteria data with condition, sorting and paging |
| 549 | 549 | * @return \Aimeos\MW\Criteria\Iface Initialized criteria object |
| 550 | 550 | */ |
| 551 | - protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
| 551 | + protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
| 552 | 552 | { |
| 553 | - $this->initCriteriaConditions( $criteria, $params ); |
|
| 554 | - $this->initCriteriaSortations( $criteria, $params ); |
|
| 555 | - $this->initCriteriaSlice( $criteria, $params ); |
|
| 553 | + $this->initCriteriaConditions($criteria, $params); |
|
| 554 | + $this->initCriteriaSortations($criteria, $params); |
|
| 555 | + $this->initCriteriaSlice($criteria, $params); |
|
| 556 | 556 | |
| 557 | 557 | return $criteria; |
| 558 | 558 | } |
@@ -564,15 +564,15 @@ discard block |
||
| 564 | 564 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
| 565 | 565 | * @param array $params List of criteria data with condition, sorting and paging |
| 566 | 566 | */ |
| 567 | - private function initCriteriaConditions( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
| 567 | + private function initCriteriaConditions(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
| 568 | 568 | { |
| 569 | - if( isset( $params['filter'] ) && is_array( $params['filter'] ) ) |
|
| 569 | + if (isset($params['filter']) && is_array($params['filter'])) |
|
| 570 | 570 | { |
| 571 | 571 | $existing = $criteria->getConditions(); |
| 572 | - $criteria->setConditions( $criteria->toConditions( (array) $params['filter'] ) ); |
|
| 572 | + $criteria->setConditions($criteria->toConditions((array) $params['filter'])); |
|
| 573 | 573 | |
| 574 | - $expr = array( $criteria->getConditions(), $existing ); |
|
| 575 | - $criteria->setConditions( $criteria->combine( '&&', $expr ) ); |
|
| 574 | + $expr = array($criteria->getConditions(), $existing); |
|
| 575 | + $criteria->setConditions($criteria->combine('&&', $expr)); |
|
| 576 | 576 | } |
| 577 | 577 | } |
| 578 | 578 | |
@@ -583,12 +583,12 @@ discard block |
||
| 583 | 583 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
| 584 | 584 | * @param array $params List of criteria data with condition, sorting and paging |
| 585 | 585 | */ |
| 586 | - private function initCriteriaSlice( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
| 586 | + private function initCriteriaSlice(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
| 587 | 587 | { |
| 588 | - $start = ( isset( $params['page']['offset'] ) ? $params['page']['offset'] : 0 ); |
|
| 589 | - $size = ( isset( $params['page']['limit'] ) ? $params['page']['limit'] : 25 ); |
|
| 588 | + $start = (isset($params['page']['offset']) ? $params['page']['offset'] : 0); |
|
| 589 | + $size = (isset($params['page']['limit']) ? $params['page']['limit'] : 25); |
|
| 590 | 590 | |
| 591 | - $criteria->setSlice( $start, $size ); |
|
| 591 | + $criteria->setSlice($start, $size); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | |
@@ -598,24 +598,24 @@ discard block |
||
| 598 | 598 | * @param \Aimeos\MW\Criteria\Iface $criteria Criteria object |
| 599 | 599 | * @param array $params List of criteria data with condition, sorting and paging |
| 600 | 600 | */ |
| 601 | - private function initCriteriaSortations( \Aimeos\MW\Criteria\Iface $criteria, array $params ) |
|
| 601 | + private function initCriteriaSortations(\Aimeos\MW\Criteria\Iface $criteria, array $params) |
|
| 602 | 602 | { |
| 603 | - if( !isset( $params['sort'] ) ) { |
|
| 603 | + if (!isset($params['sort'])) { |
|
| 604 | 604 | return; |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | $sortation = array(); |
| 608 | 608 | |
| 609 | - foreach( explode( ',', $params['sort'] ) as $sort ) |
|
| 609 | + foreach (explode(',', $params['sort']) as $sort) |
|
| 610 | 610 | { |
| 611 | - if( $sort[0] === '-' ) { |
|
| 612 | - $sortation[] = $criteria->sort( '-', substr( $sort, 1 ) ); |
|
| 611 | + if ($sort[0] === '-') { |
|
| 612 | + $sortation[] = $criteria->sort('-', substr($sort, 1)); |
|
| 613 | 613 | } else { |
| 614 | - $sortation[] = $criteria->sort( '+', $sort ); break; |
|
| 614 | + $sortation[] = $criteria->sort('+', $sort); break; |
|
| 615 | 615 | } |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - $criteria->setSortations( $sortation ); |
|
| 618 | + $criteria->setSortations($sortation); |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | |
@@ -625,9 +625,9 @@ discard block |
||
| 625 | 625 | * @param \Aimeos\MW\View\Iface $view View object with "resource" parameter |
| 626 | 626 | * @return array List of domain names |
| 627 | 627 | */ |
| 628 | - protected function getDomains( \Aimeos\MW\View\Iface $view ) |
|
| 628 | + protected function getDomains(\Aimeos\MW\View\Iface $view) |
|
| 629 | 629 | { |
| 630 | - if( ( $domains = $view->param( 'resource' ) ) == '' ) |
|
| 630 | + if (($domains = $view->param('resource')) == '') |
|
| 631 | 631 | { |
| 632 | 632 | /** admin/jsonadm/domains |
| 633 | 633 | * A list of domain names whose clients are available for the JSON API |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | 'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', |
| 650 | 650 | 'order', 'plugin', 'price', 'product', 'service', 'supplier', 'tag', 'text' |
| 651 | 651 | ); |
| 652 | - $domains = $this->getContext()->getConfig()->get( 'admin/jsonadm/domains', $default ); |
|
| 652 | + $domains = $this->getContext()->getConfig()->get('admin/jsonadm/domains', $default); |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | return (array) $domains; |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | * @param array $include List of resource types that should be fetched |
| 664 | 664 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
| 665 | 665 | */ |
| 666 | - protected function getChildItems( array $items, array $include ) |
|
| 666 | + protected function getChildItems(array $items, array $include) |
|
| 667 | 667 | { |
| 668 | 668 | return array(); |
| 669 | 669 | } |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | * @param array $include List of resource types that should be fetched |
| 677 | 677 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
| 678 | 678 | */ |
| 679 | - protected function getListItems( array $items, array $include ) |
|
| 679 | + protected function getListItems(array $items, array $include) |
|
| 680 | 680 | { |
| 681 | 681 | return array(); |
| 682 | 682 | } |
@@ -688,22 +688,22 @@ discard block |
||
| 688 | 688 | * @param array $listItems List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
| 689 | 689 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface |
| 690 | 690 | */ |
| 691 | - protected function getRefItems( array $listItems ) |
|
| 691 | + protected function getRefItems(array $listItems) |
|
| 692 | 692 | { |
| 693 | 693 | $list = $map = array(); |
| 694 | 694 | |
| 695 | - foreach( $listItems as $listItem ) { |
|
| 695 | + foreach ($listItems as $listItem) { |
|
| 696 | 696 | $map[$listItem->getDomain()][] = $listItem->getRefId(); |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | - foreach( $map as $domain => $ids ) |
|
| 699 | + foreach ($map as $domain => $ids) |
|
| 700 | 700 | { |
| 701 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
| 701 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
| 702 | 702 | |
| 703 | 703 | $search = $manager->createSearch(); |
| 704 | - $search->setConditions( $search->compare( '==', $domain . '.id', $ids ) ); |
|
| 704 | + $search->setConditions($search->compare('==', $domain . '.id', $ids)); |
|
| 705 | 705 | |
| 706 | - $list = array_merge( $list, $manager->searchItems( $search ) ); |
|
| 706 | + $list = array_merge($list, $manager->searchItems($search)); |
|
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | return $list; |
@@ -716,15 +716,15 @@ discard block |
||
| 716 | 716 | * @param \stdClass $request Decoded request body |
| 717 | 717 | * @return array List of item IDs |
| 718 | 718 | */ |
| 719 | - protected function getIds( $request ) |
|
| 719 | + protected function getIds($request) |
|
| 720 | 720 | { |
| 721 | 721 | $ids = array(); |
| 722 | 722 | |
| 723 | - if( isset( $request->data ) ) |
|
| 723 | + if (isset($request->data)) |
|
| 724 | 724 | { |
| 725 | - foreach( $request->data as $entry ) |
|
| 725 | + foreach ($request->data as $entry) |
|
| 726 | 726 | { |
| 727 | - if( isset( $entry->id ) ) { |
|
| 727 | + if (isset($entry->id)) { |
|
| 728 | 728 | $ids[] = $entry->id; |
| 729 | 729 | } |
| 730 | 730 | } |
@@ -776,30 +776,30 @@ discard block |
||
| 776 | 776 | * @throws \Aimeos\Admin\JsonAdm\Exception If "id" parameter isn't available or the body is invalid |
| 777 | 777 | * @return \Aimeos\MW\View\Iface Updated view instance |
| 778 | 778 | */ |
| 779 | - protected function patchItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
| 779 | + protected function patchItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
| 780 | 780 | { |
| 781 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
| 782 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
| 781 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
| 782 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
| 783 | 783 | } |
| 784 | 784 | |
| 785 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 785 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 786 | 786 | |
| 787 | - if( is_array( $request->data ) ) |
|
| 787 | + if (is_array($request->data)) |
|
| 788 | 788 | { |
| 789 | - $data = $this->saveData( $manager, $request ); |
|
| 789 | + $data = $this->saveData($manager, $request); |
|
| 790 | 790 | |
| 791 | 791 | $view->data = $data; |
| 792 | - $view->total = count( $data ); |
|
| 792 | + $view->total = count($data); |
|
| 793 | 793 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 794 | 794 | } |
| 795 | 795 | else |
| 796 | 796 | { |
| 797 | - if( ( $id = $view->param( 'id' ) ) == null ) { |
|
| 798 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
|
| 797 | + if (($id = $view->param('id')) == null) { |
|
| 798 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('No ID given'), 400); |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | $request->data->id = $id; |
| 802 | - $data = $this->saveEntry( $manager, $request->data ); |
|
| 802 | + $data = $this->saveEntry($manager, $request->data); |
|
| 803 | 803 | |
| 804 | 804 | $view->data = $data; |
| 805 | 805 | $view->total = 1; |
@@ -817,31 +817,31 @@ discard block |
||
| 817 | 817 | * @param array &$header Associative list of HTTP headers as value/result parameter |
| 818 | 818 | * @return \Aimeos\MW\View\Iface Updated view instance |
| 819 | 819 | */ |
| 820 | - protected function postItems( \Aimeos\MW\View\Iface $view, $body, array &$header ) |
|
| 820 | + protected function postItems(\Aimeos\MW\View\Iface $view, $body, array &$header) |
|
| 821 | 821 | { |
| 822 | - if( ( $request = json_decode( $body ) ) === null || !isset( $request->data ) ) { |
|
| 823 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid JSON in body' ), 400 ); |
|
| 822 | + if (($request = json_decode($body)) === null || !isset($request->data)) { |
|
| 823 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid JSON in body'), 400); |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | - if( isset( $request->data->id ) || $view->param( 'id' ) != null ) { |
|
| 827 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Client generated IDs are not supported' ), 403 ); |
|
| 826 | + if (isset($request->data->id) || $view->param('id') != null) { |
|
| 827 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Client generated IDs are not supported'), 403); |
|
| 828 | 828 | } |
| 829 | 829 | |
| 830 | 830 | |
| 831 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $this->getPath() ); |
|
| 831 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $this->getPath()); |
|
| 832 | 832 | |
| 833 | - if( is_array( $request->data ) ) |
|
| 833 | + if (is_array($request->data)) |
|
| 834 | 834 | { |
| 835 | - $data = $this->saveData( $manager, $request ); |
|
| 835 | + $data = $this->saveData($manager, $request); |
|
| 836 | 836 | |
| 837 | 837 | $view->data = $data; |
| 838 | - $view->total = count( $data ); |
|
| 838 | + $view->total = count($data); |
|
| 839 | 839 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 840 | 840 | } |
| 841 | 841 | else |
| 842 | 842 | { |
| 843 | 843 | $request->data->id = null; |
| 844 | - $data = $this->saveEntry( $manager, $request->data ); |
|
| 844 | + $data = $this->saveEntry($manager, $request->data); |
|
| 845 | 845 | |
| 846 | 846 | $view->data = $data; |
| 847 | 847 | $view->total = 1; |
@@ -858,14 +858,14 @@ discard block |
||
| 858 | 858 | * @param \stdClass $request Object with request body data |
| 859 | 859 | * @return array List of items |
| 860 | 860 | */ |
| 861 | - protected function saveData( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request ) |
|
| 861 | + protected function saveData(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $request) |
|
| 862 | 862 | { |
| 863 | 863 | $data = array(); |
| 864 | 864 | |
| 865 | - if( isset( $request->data ) ) |
|
| 865 | + if (isset($request->data)) |
|
| 866 | 866 | { |
| 867 | - foreach( (array) $request->data as $entry ) { |
|
| 868 | - $data[] = $this->saveEntry( $manager, $entry ); |
|
| 867 | + foreach ((array) $request->data as $entry) { |
|
| 868 | + $data[] = $this->saveEntry($manager, $entry); |
|
| 869 | 869 | } |
| 870 | 870 | } |
| 871 | 871 | |
@@ -880,22 +880,22 @@ discard block |
||
| 880 | 880 | * @param \stdClass $entry Object including "id" and "attributes" elements |
| 881 | 881 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
| 882 | 882 | */ |
| 883 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
| 883 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
| 884 | 884 | { |
| 885 | - if( isset( $entry->id ) && $entry->id !== null ) { |
|
| 886 | - $item = $manager->getItem( $entry->id ); |
|
| 885 | + if (isset($entry->id) && $entry->id !== null) { |
|
| 886 | + $item = $manager->getItem($entry->id); |
|
| 887 | 887 | } else { |
| 888 | 888 | $item = $manager->createItem(); |
| 889 | 889 | } |
| 890 | 890 | |
| 891 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
| 892 | - $manager->saveItem( $item ); |
|
| 891 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
| 892 | + $manager->saveItem($item); |
|
| 893 | 893 | |
| 894 | - if( isset( $entry->relationships ) ) { |
|
| 895 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
| 894 | + if (isset($entry->relationships)) { |
|
| 895 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - return $manager->getItem( $item->getId() ); |
|
| 898 | + return $manager->getItem($item->getId()); |
|
| 899 | 899 | } |
| 900 | 900 | |
| 901 | 901 | |
@@ -906,28 +906,28 @@ discard block |
||
| 906 | 906 | * @param \Aimeos\MShop\Common\Item\Iface $item Domain item with an unique ID set |
| 907 | 907 | * @param \stdClass $relationships Object including the <domain>/data/attributes structure |
| 908 | 908 | */ |
| 909 | - protected function saveRelationships( \Aimeos\MShop\Common\Manager\Iface $manager, |
|
| 910 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships ) |
|
| 909 | + protected function saveRelationships(\Aimeos\MShop\Common\Manager\Iface $manager, |
|
| 910 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $relationships) |
|
| 911 | 911 | { |
| 912 | 912 | $id = $item->getId(); |
| 913 | - $listManager = $manager->getSubManager( 'lists' ); |
|
| 913 | + $listManager = $manager->getSubManager('lists'); |
|
| 914 | 914 | |
| 915 | - foreach( (array) $relationships as $domain => $list ) |
|
| 915 | + foreach ((array) $relationships as $domain => $list) |
|
| 916 | 916 | { |
| 917 | - if( isset( $list->data ) ) |
|
| 917 | + if (isset($list->data)) |
|
| 918 | 918 | { |
| 919 | - foreach( (array) $list->data as $data ) |
|
| 919 | + foreach ((array) $list->data as $data) |
|
| 920 | 920 | { |
| 921 | - $listItem = $this->addItemData( $listManager, $listManager->createItem(), $data, $domain ); |
|
| 921 | + $listItem = $this->addItemData($listManager, $listManager->createItem(), $data, $domain); |
|
| 922 | 922 | |
| 923 | - if( isset( $data->id ) ) { |
|
| 924 | - $listItem->setRefId( $data->id ); |
|
| 923 | + if (isset($data->id)) { |
|
| 924 | + $listItem->setRefId($data->id); |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | - $listItem->setParentId( $id ); |
|
| 928 | - $listItem->setDomain( $domain ); |
|
| 927 | + $listItem->setParentId($id); |
|
| 928 | + $listItem->setDomain($domain); |
|
| 929 | 929 | |
| 930 | - $listManager->saveItem( $listItem, false ); |
|
| 930 | + $listManager->saveItem($listItem, false); |
|
| 931 | 931 | } |
| 932 | 932 | } |
| 933 | 933 | } |
@@ -944,20 +944,20 @@ discard block |
||
| 944 | 944 | * @return \Aimeos\MShop\Common\Item\Iface Item including the data |
| 945 | 945 | */ |
| 946 | 946 | protected function addItemData(\Aimeos\MShop\Common\Manager\Iface $manager, |
| 947 | - \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain ) |
|
| 947 | + \Aimeos\MShop\Common\Item\Iface $item, \stdClass $data, $domain) |
|
| 948 | 948 | { |
| 949 | - if( isset( $data->attributes ) ) |
|
| 949 | + if (isset($data->attributes)) |
|
| 950 | 950 | { |
| 951 | 951 | $attr = (array) $data->attributes; |
| 952 | - $key = str_replace( '/', '.', $item->getResourceType() ); |
|
| 952 | + $key = str_replace('/', '.', $item->getResourceType()); |
|
| 953 | 953 | |
| 954 | - if( isset( $attr[$key.'.type'] ) ) |
|
| 954 | + if (isset($attr[$key . '.type'])) |
|
| 955 | 955 | { |
| 956 | - $typeItem = $manager->getSubManager( 'type' )->findItem( $attr[$key.'.type'], array(), $domain ); |
|
| 957 | - $attr[$key.'.typeid'] = $typeItem->getId(); |
|
| 956 | + $typeItem = $manager->getSubManager('type')->findItem($attr[$key . '.type'], array(), $domain); |
|
| 957 | + $attr[$key . '.typeid'] = $typeItem->getId(); |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | - $item->fromArray( $attr ); |
|
| 960 | + $item->fromArray($attr); |
|
| 961 | 961 | } |
| 962 | 962 | |
| 963 | 963 | return $item; |
@@ -60,24 +60,21 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $view = $this->deleteItems( $view, $body ); |
| 62 | 62 | $status = 200; |
| 63 | - } |
|
| 64 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 63 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 65 | 64 | { |
| 66 | 65 | $status = $e->getCode(); |
| 67 | 66 | $view->errors = array( array( |
| 68 | 67 | 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
| 69 | 68 | 'detail' => $e->getTraceAsString(), |
| 70 | 69 | ) ); |
| 71 | - } |
|
| 72 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 70 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 73 | 71 | { |
| 74 | 72 | $status = 404; |
| 75 | 73 | $view->errors = array( array( |
| 76 | 74 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 77 | 75 | 'detail' => $e->getTraceAsString(), |
| 78 | 76 | ) ); |
| 79 | - } |
|
| 80 | - catch( \Exception $e ) |
|
| 77 | + } catch( \Exception $e ) |
|
| 81 | 78 | { |
| 82 | 79 | $status = 500; |
| 83 | 80 | $view->errors = array( array( |
@@ -134,16 +131,14 @@ discard block |
||
| 134 | 131 | { |
| 135 | 132 | $view = $this->getItem( $view ); |
| 136 | 133 | $status = 200; |
| 137 | - } |
|
| 138 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 134 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 139 | 135 | { |
| 140 | 136 | $status = 404; |
| 141 | 137 | $view->errors = array( array( |
| 142 | 138 | 'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 143 | 139 | 'detail' => $e->getTraceAsString(), |
| 144 | 140 | ) ); |
| 145 | - } |
|
| 146 | - catch( \Exception $e ) |
|
| 141 | + } catch( \Exception $e ) |
|
| 147 | 142 | { |
| 148 | 143 | $status = 500; |
| 149 | 144 | $view->errors = array( array( |
@@ -201,24 +196,21 @@ discard block |
||
| 201 | 196 | { |
| 202 | 197 | $view = $this->patchItems( $view, $body, $header ); |
| 203 | 198 | $status = 200; |
| 204 | - } |
|
| 205 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 199 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 206 | 200 | { |
| 207 | 201 | $status = $e->getCode(); |
| 208 | 202 | $view->errors = array( array( |
| 209 | 203 | 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
| 210 | 204 | 'detail' => $e->getTraceAsString(), |
| 211 | 205 | ) ); |
| 212 | - } |
|
| 213 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 206 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 214 | 207 | { |
| 215 | 208 | $status = 404; |
| 216 | 209 | $view->errors = array( array( |
| 217 | 210 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 218 | 211 | 'detail' => $e->getTraceAsString(), |
| 219 | 212 | ) ); |
| 220 | - } |
|
| 221 | - catch( \Exception $e ) |
|
| 213 | + } catch( \Exception $e ) |
|
| 222 | 214 | { |
| 223 | 215 | $status = 500; |
| 224 | 216 | $view->errors = array( array( |
@@ -276,24 +268,21 @@ discard block |
||
| 276 | 268 | { |
| 277 | 269 | $view = $this->postItems( $view, $body, $header ); |
| 278 | 270 | $status = 201; |
| 279 | - } |
|
| 280 | - catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 271 | + } catch( \Aimeos\Admin\JsonAdm\Exception $e ) |
|
| 281 | 272 | { |
| 282 | 273 | $status = $e->getCode(); |
| 283 | 274 | $view->errors = array( array( |
| 284 | 275 | 'title' => $context->getI18n()->dt( 'admin/jsonadm', $e->getMessage() ), |
| 285 | 276 | 'detail' => $e->getTraceAsString(), |
| 286 | 277 | ) ); |
| 287 | - } |
|
| 288 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 278 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 289 | 279 | { |
| 290 | 280 | $status = 404; |
| 291 | 281 | $view->errors = array( array( |
| 292 | 282 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 293 | 283 | 'detail' => $e->getTraceAsString(), |
| 294 | 284 | ) ); |
| 295 | - } |
|
| 296 | - catch( \Exception $e ) |
|
| 285 | + } catch( \Exception $e ) |
|
| 297 | 286 | { |
| 298 | 287 | $status = 500; |
| 299 | 288 | $view->errors = array( array( |
@@ -416,16 +405,14 @@ discard block |
||
| 416 | 405 | 'Allow' => 'DELETE,GET,POST,OPTIONS' |
| 417 | 406 | ); |
| 418 | 407 | $status = 200; |
| 419 | - } |
|
| 420 | - catch( \Aimeos\MShop\Exception $e ) |
|
| 408 | + } catch( \Aimeos\MShop\Exception $e ) |
|
| 421 | 409 | { |
| 422 | 410 | $status = 404; |
| 423 | 411 | $view->errors = array( array( |
| 424 | 412 | 'title' => $context->getI18n()->dt( 'mshop', $e->getMessage() ), |
| 425 | 413 | 'detail' => $e->getTraceAsString(), |
| 426 | 414 | ) ); |
| 427 | - } |
|
| 428 | - catch( \Exception $e ) |
|
| 415 | + } catch( \Exception $e ) |
|
| 429 | 416 | { |
| 430 | 417 | $status = 500; |
| 431 | 418 | $view->errors = array( array( |
@@ -486,8 +473,7 @@ discard block |
||
| 486 | 473 | $ids = $this->getIds( $request ); |
| 487 | 474 | $manager->deleteItems( $ids ); |
| 488 | 475 | $view->total = count( $ids ); |
| 489 | - } |
|
| 490 | - else |
|
| 476 | + } else |
|
| 491 | 477 | { |
| 492 | 478 | $manager->deleteItem( $id ); |
| 493 | 479 | $view->total = 1; |
@@ -515,8 +501,7 @@ discard block |
||
| 515 | 501 | $view->data = $manager->searchItems( $search, array(), $total ); |
| 516 | 502 | $view->childItems = $this->getChildItems( $view->data, $include ); |
| 517 | 503 | $view->listItems = $this->getListItems( $view->data, $include ); |
| 518 | - } |
|
| 519 | - else |
|
| 504 | + } else |
|
| 520 | 505 | { |
| 521 | 506 | $view->data = $manager->getItem( $id, array() ); |
| 522 | 507 | $view->childItems = $this->getChildItems( array( $id => $view->data ), $include ); |
@@ -791,8 +776,7 @@ discard block |
||
| 791 | 776 | $view->data = $data; |
| 792 | 777 | $view->total = count( $data ); |
| 793 | 778 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 794 | - } |
|
| 795 | - else |
|
| 779 | + } else |
|
| 796 | 780 | { |
| 797 | 781 | if( ( $id = $view->param( 'id' ) ) == null ) { |
| 798 | 782 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'No ID given' ), 400 ); |
@@ -837,8 +821,7 @@ discard block |
||
| 837 | 821 | $view->data = $data; |
| 838 | 822 | $view->total = count( $data ); |
| 839 | 823 | $header['Content-Type'] = 'application/vnd.api+json; ext="bulk"; supported-ext="bulk"'; |
| 840 | - } |
|
| 841 | - else |
|
| 824 | + } else |
|
| 842 | 825 | { |
| 843 | 826 | $request->data->id = null; |
| 844 | 827 | $data = $this->saveEntry( $manager, $request->data ); |