@@ -105,7 +105,7 @@ |
||
| 105 | 105 | * Returns the resource controller |
| 106 | 106 | * |
| 107 | 107 | * @param string Resource location, e.g. "product" |
| 108 | - * @return \Aimeos\MShop\Context\Item\Iface Context item |
|
| 108 | + * @return \Aimeos\Client\JsonApi\Iface Context item |
|
| 109 | 109 | */ |
| 110 | 110 | protected function createClient( $resource ) |
| 111 | 111 | { |
@@ -30,9 +30,9 @@ discard block |
||
| 30 | 30 | * @param string Resource location, e.g. "product" |
| 31 | 31 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
| 32 | 32 | */ |
| 33 | - public function deleteAction( ServerRequestInterface $request, $resource ) |
|
| 33 | + public function deleteAction(ServerRequestInterface $request, $resource) |
|
| 34 | 34 | { |
| 35 | - return $this->createClient( $resource )->delete( $request, new Response() ); |
|
| 35 | + return $this->createClient($resource)->delete($request, new Response()); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | * @param string Resource location, e.g. "product" |
| 44 | 44 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
| 45 | 45 | */ |
| 46 | - public function getAction( ServerRequestInterface $request, $resource ) |
|
| 46 | + public function getAction(ServerRequestInterface $request, $resource) |
|
| 47 | 47 | { |
| 48 | - return $this->createClient( $resource )->get( $request, new Response() ); |
|
| 48 | + return $this->createClient($resource)->get($request, new Response()); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | * @param string Resource location, e.g. "product" |
| 57 | 57 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
| 58 | 58 | */ |
| 59 | - public function patchAction( ServerRequestInterface $request, $resource ) |
|
| 59 | + public function patchAction(ServerRequestInterface $request, $resource) |
|
| 60 | 60 | { |
| 61 | - return $this->createClient( $resource )->patch( $request, new Response() ); |
|
| 61 | + return $this->createClient($resource)->patch($request, new Response()); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | * @param string Resource location, e.g. "product" |
| 70 | 70 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
| 71 | 71 | */ |
| 72 | - public function postAction( ServerRequestInterface $request, $resource ) |
|
| 72 | + public function postAction(ServerRequestInterface $request, $resource) |
|
| 73 | 73 | { |
| 74 | - return $this->createClient( $resource )->post( $request, new Response() ); |
|
| 74 | + return $this->createClient($resource)->post($request, new Response()); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | * @param string Resource location, e.g. "product" |
| 83 | 83 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
| 84 | 84 | */ |
| 85 | - public function putAction( ServerRequestInterface $request, $resource ) |
|
| 85 | + public function putAction(ServerRequestInterface $request, $resource) |
|
| 86 | 86 | { |
| 87 | - return $this->createClient( $resource )->put( $request, new Response() ); |
|
| 87 | + return $this->createClient($resource)->put($request, new Response()); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | * @param string Resource location, e.g. "product" |
| 96 | 96 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
| 97 | 97 | */ |
| 98 | - public function optionsAction( ServerRequestInterface $request, $resource = '' ) |
|
| 98 | + public function optionsAction(ServerRequestInterface $request, $resource = '') |
|
| 99 | 99 | { |
| 100 | - return $this->createClient( $resource )->options( $request, new Response() ); |
|
| 100 | + return $this->createClient($resource)->options($request, new Response()); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | |
@@ -107,15 +107,15 @@ discard block |
||
| 107 | 107 | * @param string Resource location, e.g. "product" |
| 108 | 108 | * @return \Aimeos\MShop\Context\Item\Iface Context item |
| 109 | 109 | */ |
| 110 | - protected function createClient( $resource ) |
|
| 110 | + protected function createClient($resource) |
|
| 111 | 111 | { |
| 112 | - $tmplPaths = $this->container->get( 'aimeos' )->get()->getCustomPaths( 'client/jsonapi/templates' ); |
|
| 113 | - $context = $this->container->get( 'aimeos_context' )->get(); |
|
| 112 | + $tmplPaths = $this->container->get('aimeos')->get()->getCustomPaths('client/jsonapi/templates'); |
|
| 113 | + $context = $this->container->get('aimeos_context')->get(); |
|
| 114 | 114 | $langid = $context->getLocale()->getLanguageId(); |
| 115 | 115 | |
| 116 | - $view = $this->container->get( 'aimeos_view' )->create( $context, $tmplPaths, $langid ); |
|
| 117 | - $context->setView( $view ); |
|
| 116 | + $view = $this->container->get('aimeos_view')->create($context, $tmplPaths, $langid); |
|
| 117 | + $context->setView($view); |
|
| 118 | 118 | |
| 119 | - return \Aimeos\Client\JsonApi\Factory::createClient( $context, $tmplPaths, $resource ); |
|
| 119 | + return \Aimeos\Client\JsonApi\Factory::createClient($context, $tmplPaths, $resource); |
|
| 120 | 120 | } |
| 121 | 121 | } |
@@ -10,15 +10,15 @@ discard block |
||
| 10 | 10 | public function testOptionsAction() |
| 11 | 11 | { |
| 12 | 12 | $client = static::createClient(); |
| 13 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 13 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 14 | 14 | $response = $client->getResponse(); |
| 15 | 15 | |
| 16 | - $json = json_decode( $response->getContent(), true ); |
|
| 16 | + $json = json_decode($response->getContent(), true); |
|
| 17 | 17 | |
| 18 | - $this->assertNotNull( $json ); |
|
| 19 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 20 | - $this->assertArrayHasKey( 'resources', $json['meta'] ); |
|
| 21 | - $this->assertGreaterThan( 1, count( $json['meta']['resources'] ) ); |
|
| 18 | + $this->assertNotNull($json); |
|
| 19 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 20 | + $this->assertArrayHasKey('resources', $json['meta']); |
|
| 21 | + $this->assertGreaterThan(1, count($json['meta']['resources'])); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
@@ -28,30 +28,30 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | $params = ['filter' => ['f_search' => 'Cafe Noire Cap', 'f_listtype' => 'unittype19']]; |
| 31 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/product', $params ); |
|
| 31 | + $client->request('GET', '/unittest/de/EUR/jsonapi/product', $params); |
|
| 32 | 32 | $response = $client->getResponse(); |
| 33 | 33 | |
| 34 | - $json = json_decode( $response->getContent(), true ); |
|
| 34 | + $json = json_decode($response->getContent(), true); |
|
| 35 | 35 | |
| 36 | - $this->assertNotNull( $json ); |
|
| 37 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 38 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
| 39 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
| 40 | - $this->assertArrayHasKey( 'id', $json['data'][0] ); |
|
| 41 | - $this->assertEquals( 'CNC', $json['data'][0]['attributes']['product.code'] ); |
|
| 36 | + $this->assertNotNull($json); |
|
| 37 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 38 | + $this->assertEquals(1, $json['meta']['total']); |
|
| 39 | + $this->assertEquals(1, count($json['data'])); |
|
| 40 | + $this->assertArrayHasKey('id', $json['data'][0]); |
|
| 41 | + $this->assertEquals('CNC', $json['data'][0]['attributes']['product.code']); |
|
| 42 | 42 | |
| 43 | 43 | $id = $json['data'][0]['id']; |
| 44 | 44 | |
| 45 | 45 | |
| 46 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/product/' . $id ); |
|
| 46 | + $client->request('GET', '/unittest/de/EUR/jsonapi/product/'.$id); |
|
| 47 | 47 | $response = $client->getResponse(); |
| 48 | 48 | |
| 49 | - $json = json_decode( $response->getContent(), true ); |
|
| 49 | + $json = json_decode($response->getContent(), true); |
|
| 50 | 50 | |
| 51 | - $this->assertNotNull( $json ); |
|
| 52 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 53 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
| 54 | - $this->assertArrayHasKey( 'id', $json['data'] ); |
|
| 55 | - $this->assertEquals( 'CNC', $json['data']['attributes']['product.code'] ); |
|
| 51 | + $this->assertNotNull($json); |
|
| 52 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 53 | + $this->assertEquals(1, $json['meta']['total']); |
|
| 54 | + $this->assertArrayHasKey('id', $json['data']); |
|
| 55 | + $this->assertEquals('CNC', $json['data']['attributes']['product.code']); |
|
| 56 | 56 | } |
| 57 | 57 | } |