@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
| 111 | 111 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
| 112 | 112 | */ |
| 113 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) |
|
| 113 | + public function get(ServerRequestInterface $request, ResponseInterface $response) |
|
| 114 | 114 | { |
| 115 | 115 | /** admin/jsonadm/partials/locale/site/template-data |
| 116 | 116 | * Relative path to the data partial template file for the locale site client |
@@ -127,9 +127,9 @@ discard block |
||
| 127 | 127 | * @since 2016.07 |
| 128 | 128 | * @category Developer |
| 129 | 129 | */ |
| 130 | - $this->getView()->assign( array( 'partial-data' => 'admin/jsonadm/partials/locale/site/template-data' ) ); |
|
| 130 | + $this->getView()->assign(array('partial-data' => 'admin/jsonadm/partials/locale/site/template-data')); |
|
| 131 | 131 | |
| 132 | - return parent::get( $request, $response ); |
|
| 132 | + return parent::get($request, $response); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | |
@@ -141,16 +141,16 @@ discard block |
||
| 141 | 141 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
| 142 | 142 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
| 143 | 143 | */ |
| 144 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) |
|
| 144 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) |
|
| 145 | 145 | { |
| 146 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale/site' ); |
|
| 147 | - $search = $this->initCriteria( $manager->createSearch(), $view->param() ); |
|
| 146 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'locale/site'); |
|
| 147 | + $search = $this->initCriteria($manager->createSearch(), $view->param()); |
|
| 148 | 148 | $total = 1; |
| 149 | 149 | |
| 150 | - if( ( $id = $view->param( 'id' ) ) == null ) { |
|
| 151 | - $view->data = $manager->searchItems( $search, [], $total ); |
|
| 150 | + if (($id = $view->param('id')) == null) { |
|
| 151 | + $view->data = $manager->searchItems($search, [], $total); |
|
| 152 | 152 | } else { |
| 153 | - $view->data = $manager->getTree( $id, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $search ); |
|
| 153 | + $view->data = $manager->getTree($id, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $search); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | $view->childItems = []; |
@@ -169,25 +169,25 @@ discard block |
||
| 169 | 169 | * @param \stdClass $entry Object including "id" and "attributes" elements |
| 170 | 170 | * @return \Aimeos\MShop\Common\Item\Iface New or updated item |
| 171 | 171 | */ |
| 172 | - protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry ) |
|
| 172 | + protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry) |
|
| 173 | 173 | { |
| 174 | - if( isset( $entry->id ) ) |
|
| 174 | + if (isset($entry->id)) |
|
| 175 | 175 | { |
| 176 | - $item = $manager->getItem( $entry->id ); |
|
| 177 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
| 178 | - $item = $manager->saveItem( $item ); |
|
| 176 | + $item = $manager->getItem($entry->id); |
|
| 177 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
| 178 | + $item = $manager->saveItem($item); |
|
| 179 | 179 | } |
| 180 | 180 | else |
| 181 | 181 | { |
| 182 | 182 | $item = $manager->createItem(); |
| 183 | - $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
|
| 184 | - $manager->insertItem( $item ); |
|
| 183 | + $item = $this->addItemData($manager, $item, $entry, $item->getResourceType()); |
|
| 184 | + $manager->insertItem($item); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if( isset( $entry->relationships ) ) { |
|
| 188 | - $this->saveRelationships( $manager, $item, $entry->relationships ); |
|
| 187 | + if (isset($entry->relationships)) { |
|
| 188 | + $this->saveRelationships($manager, $item, $entry->relationships); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - return $manager->getItem( $item->getId() ); |
|
| 191 | + return $manager->getItem($item->getId()); |
|
| 192 | 192 | } |
| 193 | 193 | } |
@@ -176,8 +176,7 @@ |
||
| 176 | 176 | $item = $manager->getItem( $entry->id ); |
| 177 | 177 | $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
| 178 | 178 | $item = $manager->saveItem( $item ); |
| 179 | - } |
|
| 180 | - else |
|
| 179 | + } else |
|
| 181 | 180 | { |
| 182 | 181 | $item = $manager->createItem(); |
| 183 | 182 | $item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() ); |
@@ -22,32 +22,32 @@ discard block |
||
| 22 | 22 | $this->context = \TestHelperJadm::getContext(); |
| 23 | 23 | $this->view = $this->context->getView(); |
| 24 | 24 | |
| 25 | - $this->object = new \Aimeos\Admin\JsonAdm\Locale\Site\Standard( $this->context, $this->view, $templatePaths, 'locale/site' ); |
|
| 25 | + $this->object = new \Aimeos\Admin\JsonAdm\Locale\Site\Standard($this->context, $this->view, $templatePaths, 'locale/site'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | public function testGet() |
| 30 | 30 | { |
| 31 | 31 | $params = array( |
| 32 | - 'id' => $this->getSiteItem( 'unittest' )->getId(), |
|
| 32 | + 'id' => $this->getSiteItem('unittest')->getId(), |
|
| 33 | 33 | 'filter' => array( |
| 34 | - '==' => array( 'locale.status' => 0 ) |
|
| 34 | + '==' => array('locale.status' => 0) |
|
| 35 | 35 | ), |
| 36 | 36 | ); |
| 37 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 38 | - $this->view->addHelper( 'param', $helper ); |
|
| 37 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 38 | + $this->view->addHelper('param', $helper); |
|
| 39 | 39 | |
| 40 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
| 41 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 40 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
| 41 | + $result = json_decode((string) $response->getBody(), true); |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 45 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 44 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 45 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 46 | 46 | |
| 47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 48 | - $this->assertEquals( 'locale/site', $result['data']['type'] ); |
|
| 47 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 48 | + $this->assertEquals('locale/site', $result['data']['type']); |
|
| 49 | 49 | |
| 50 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 50 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |
@@ -55,125 +55,125 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $params = array( |
| 57 | 57 | 'filter' => array( |
| 58 | - '==' => array( 'locale.site.code' => 'unittest' ) |
|
| 58 | + '==' => array('locale.site.code' => 'unittest') |
|
| 59 | 59 | ), |
| 60 | 60 | ); |
| 61 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 62 | - $this->view->addHelper( 'param', $helper ); |
|
| 61 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 62 | + $this->view->addHelper('param', $helper); |
|
| 63 | 63 | |
| 64 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
| 65 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 64 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
| 65 | + $result = json_decode((string) $response->getBody(), true); |
|
| 66 | 66 | |
| 67 | 67 | |
| 68 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 69 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 68 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 69 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 70 | 70 | |
| 71 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 72 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
| 73 | - $this->assertEquals( 'locale/site', $result['data'][0]['type'] ); |
|
| 71 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 72 | + $this->assertEquals(1, count($result['data'])); |
|
| 73 | + $this->assertEquals('locale/site', $result['data'][0]['type']); |
|
| 74 | 74 | |
| 75 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 75 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | public function testPatch() |
| 80 | 80 | { |
| 81 | - $stub = $this->getSiteMock( array( 'getItem', 'moveItem', 'saveItem' ) ); |
|
| 81 | + $stub = $this->getSiteMock(array('getItem', 'moveItem', 'saveItem')); |
|
| 82 | 82 | $item = $stub->createItem(); |
| 83 | 83 | |
| 84 | - $stub->expects( $this->once() )->method( 'moveItem' ); |
|
| 85 | - $stub->expects( $this->once() )->method( 'saveItem' ) |
|
| 86 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
| 87 | - $stub->expects( $this->exactly( 2 ) )->method( 'getItem' ) // 2x due to decorator |
|
| 88 | - ->will( $this->returnValue( $item ) ); |
|
| 84 | + $stub->expects($this->once())->method('moveItem'); |
|
| 85 | + $stub->expects($this->once())->method('saveItem') |
|
| 86 | + ->will($this->returnValue($stub->createItem())); |
|
| 87 | + $stub->expects($this->exactly(2))->method('getItem') // 2x due to decorator |
|
| 88 | + ->will($this->returnValue($item)); |
|
| 89 | 89 | |
| 90 | 90 | |
| 91 | - $params = array( 'id' => '-1' ); |
|
| 92 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 93 | - $this->view->addHelper( 'param', $helper ); |
|
| 91 | + $params = array('id' => '-1'); |
|
| 92 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 93 | + $this->view->addHelper('param', $helper); |
|
| 94 | 94 | |
| 95 | 95 | $body = '{"data": {"parentid": "1", "targetid": 2, "type": "locale/site", "attributes": {"locale.site.label": "test"}}}'; |
| 96 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
| 96 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
| 97 | 97 | |
| 98 | - $response = $this->object->patch( $request, $this->view->response() ); |
|
| 99 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 98 | + $response = $this->object->patch($request, $this->view->response()); |
|
| 99 | + $result = json_decode((string) $response->getBody(), true); |
|
| 100 | 100 | |
| 101 | 101 | |
| 102 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 103 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 102 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 103 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 104 | 104 | |
| 105 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 106 | - $this->assertArrayHasKey( 'data', $result ); |
|
| 107 | - $this->assertEquals( 'locale/site', $result['data']['type'] ); |
|
| 105 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 106 | + $this->assertArrayHasKey('data', $result); |
|
| 107 | + $this->assertEquals('locale/site', $result['data']['type']); |
|
| 108 | 108 | |
| 109 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 110 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 109 | + $this->assertArrayNotHasKey('included', $result); |
|
| 110 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | |
| 114 | 114 | public function testPost() |
| 115 | 115 | { |
| 116 | - $stub = $this->getSiteMock( array( 'getItem', 'insertItem' ) ); |
|
| 116 | + $stub = $this->getSiteMock(array('getItem', 'insertItem')); |
|
| 117 | 117 | $item = $stub->createItem(); |
| 118 | 118 | |
| 119 | - $stub->expects( $this->any() )->method( 'getItem' ) |
|
| 120 | - ->will( $this->returnValue( $item ) ); |
|
| 121 | - $stub->expects( $this->once() )->method( 'insertItem' ); |
|
| 119 | + $stub->expects($this->any())->method('getItem') |
|
| 120 | + ->will($this->returnValue($item)); |
|
| 121 | + $stub->expects($this->once())->method('insertItem'); |
|
| 122 | 122 | |
| 123 | 123 | |
| 124 | 124 | $body = '{"data": {"type": "locale/site", "attributes": {"locale.site.code": "unittest", "locale.site.label": "Unit test"}}}'; |
| 125 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
| 125 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
| 126 | 126 | |
| 127 | - $response = $this->object->post( $request, $this->view->response() ); |
|
| 128 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 127 | + $response = $this->object->post($request, $this->view->response()); |
|
| 128 | + $result = json_decode((string) $response->getBody(), true); |
|
| 129 | 129 | |
| 130 | 130 | |
| 131 | - $this->assertEquals( 201, $response->getStatusCode() ); |
|
| 132 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 131 | + $this->assertEquals(201, $response->getStatusCode()); |
|
| 132 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 133 | 133 | |
| 134 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 135 | - $this->assertArrayHasKey( 'data', $result ); |
|
| 136 | - $this->assertEquals( 'locale/site', $result['data']['type'] ); |
|
| 134 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 135 | + $this->assertArrayHasKey('data', $result); |
|
| 136 | + $this->assertEquals('locale/site', $result['data']['type']); |
|
| 137 | 137 | |
| 138 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 139 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 138 | + $this->assertArrayNotHasKey('included', $result); |
|
| 139 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | |
| 143 | - protected function getSiteItem( $code ) |
|
| 143 | + protected function getSiteItem($code) |
|
| 144 | 144 | { |
| 145 | - $manager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $this->context )->getSubManager( 'site' ); |
|
| 145 | + $manager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->context)->getSubManager('site'); |
|
| 146 | 146 | $search = $manager->createSearch(); |
| 147 | - $search->setConditions( $search->compare( '==', 'locale.site.code', $code ) ); |
|
| 148 | - $items = $manager->searchItems( $search ); |
|
| 147 | + $search->setConditions($search->compare('==', 'locale.site.code', $code)); |
|
| 148 | + $items = $manager->searchItems($search); |
|
| 149 | 149 | |
| 150 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 151 | - throw new \RuntimeException( sprintf( 'No locale site item with code "%1$s" found', $code ) ); |
|
| 150 | + if (($item = reset($items)) === false) { |
|
| 151 | + throw new \RuntimeException(sprintf('No locale site item with code "%1$s" found', $code)); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | return $item; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | |
| 158 | - protected function getSiteMock( array $methods ) |
|
| 158 | + protected function getSiteMock(array $methods) |
|
| 159 | 159 | { |
| 160 | 160 | $name = 'AdminJsonAdmStandard'; |
| 161 | - $this->context->getConfig()->set( 'mshop/locale/manager/name', $name ); |
|
| 161 | + $this->context->getConfig()->set('mshop/locale/manager/name', $name); |
|
| 162 | 162 | |
| 163 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Locale\\Manager\\Standard' ) |
|
| 164 | - ->setConstructorArgs( array( $this->context ) ) |
|
| 165 | - ->setMethods( array( 'getSubManager' ) ) |
|
| 163 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Locale\\Manager\\Standard') |
|
| 164 | + ->setConstructorArgs(array($this->context)) |
|
| 165 | + ->setMethods(array('getSubManager')) |
|
| 166 | 166 | ->getMock(); |
| 167 | 167 | |
| 168 | - $siteStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Locale\\Manager\\Site\\Standard' ) |
|
| 169 | - ->setConstructorArgs( array( $this->context ) ) |
|
| 170 | - ->setMethods( $methods ) |
|
| 168 | + $siteStub = $this->getMockBuilder('\\Aimeos\\MShop\\Locale\\Manager\\Site\\Standard') |
|
| 169 | + ->setConstructorArgs(array($this->context)) |
|
| 170 | + ->setMethods($methods) |
|
| 171 | 171 | ->getMock(); |
| 172 | 172 | |
| 173 | - $stub->expects( $this->once() )->method( 'getSubManager' ) |
|
| 174 | - ->will( $this->returnValue( $siteStub ) ); |
|
| 173 | + $stub->expects($this->once())->method('getSubManager') |
|
| 174 | + ->will($this->returnValue($siteStub)); |
|
| 175 | 175 | |
| 176 | - \Aimeos\MShop\Locale\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Locale\\Manager\\' . $name, $stub ); |
|
| 176 | + \Aimeos\MShop\Locale\Manager\Factory::injectManager('\\Aimeos\\MShop\\Locale\\Manager\\' . $name, $stub); |
|
| 177 | 177 | |
| 178 | 178 | return $siteStub; |
| 179 | 179 | } |