@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @param Container $container Container object to access parameters |
| 31 | 31 | */ |
| 32 | - public function __construct( Container $container ) |
|
| 32 | + public function __construct(Container $container) |
|
| 33 | 33 | { |
| 34 | 34 | $this->container = $container; |
| 35 | 35 | } |
@@ -41,27 +41,27 @@ discard block |
||
| 41 | 41 | * @param array $languageIds List of two letter ISO language IDs |
| 42 | 42 | * @return \Aimeos\MW\Translation\Interface[] List of translation objects |
| 43 | 43 | */ |
| 44 | - public function get( array $languageIds ) |
|
| 44 | + public function get(array $languageIds) |
|
| 45 | 45 | { |
| 46 | - $i18nPaths = $this->container->get( 'aimeos' )->get()->getI18nPaths(); |
|
| 46 | + $i18nPaths = $this->container->get('aimeos')->get()->getI18nPaths(); |
|
| 47 | 47 | |
| 48 | - foreach( $languageIds as $langid ) |
|
| 48 | + foreach ($languageIds as $langid) |
|
| 49 | 49 | { |
| 50 | - if( !isset( $this->i18n[$langid] ) ) |
|
| 50 | + if (!isset($this->i18n[$langid])) |
|
| 51 | 51 | { |
| 52 | - $i18n = new \Aimeos\MW\Translation\Gettext( $i18nPaths, $langid ); |
|
| 52 | + $i18n = new \Aimeos\MW\Translation\Gettext($i18nPaths, $langid); |
|
| 53 | 53 | |
| 54 | - $apc = (bool) $this->container->getParameter( 'aimeos_shop.apc_enable' ); |
|
| 55 | - $prefix = $this->container->getParameter( 'aimeos_shop.apc_prefix' ); |
|
| 54 | + $apc = (bool) $this->container->getParameter('aimeos_shop.apc_enable'); |
|
| 55 | + $prefix = $this->container->getParameter('aimeos_shop.apc_prefix'); |
|
| 56 | 56 | |
| 57 | - if( function_exists( 'apcu_store' ) === true && $apc === true ) { |
|
| 58 | - $i18n = new \Aimeos\MW\Translation\Decorator\APC( $i18n, $prefix ); |
|
| 57 | + if (function_exists('apcu_store') === true && $apc === true) { |
|
| 58 | + $i18n = new \Aimeos\MW\Translation\Decorator\APC($i18n, $prefix); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - $translations = $this->container->getParameter( 'aimeos_shop.i18n' ); |
|
| 61 | + $translations = $this->container->getParameter('aimeos_shop.i18n'); |
|
| 62 | 62 | |
| 63 | - if( isset( $translations[$langid] ) ) { |
|
| 64 | - $i18n = new \Aimeos\MW\Translation\Decorator\Memory( $i18n, $translations[$langid] ); |
|
| 63 | + if (isset($translations[$langid])) { |
|
| 64 | + $i18n = new \Aimeos\MW\Translation\Decorator\Memory($i18n, $translations[$langid]); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $this->i18n[$langid] = $i18n; |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @param Container $container Container object to access parameters |
| 30 | 30 | */ |
| 31 | - public function __construct( Container $container ) |
|
| 31 | + public function __construct(Container $container) |
|
| 32 | 32 | { |
| 33 | 33 | $this->container = $container; |
| 34 | 34 | } |
@@ -40,33 +40,33 @@ discard block |
||
| 40 | 40 | * @param string $type Configuration type ("frontend" or "backend") |
| 41 | 41 | * @return \Aimeos\MW\Config\Iface Config object |
| 42 | 42 | */ |
| 43 | - public function get( $type = 'frontend' ) |
|
| 43 | + public function get($type = 'frontend') |
|
| 44 | 44 | { |
| 45 | 45 | $configPaths = $this->container->get('aimeos')->get()->getConfigPaths(); |
| 46 | 46 | |
| 47 | - $conf = new \Aimeos\MW\Config\PHPArray( array(), $configPaths ); |
|
| 47 | + $conf = new \Aimeos\MW\Config\PHPArray(array(), $configPaths); |
|
| 48 | 48 | |
| 49 | - $apc = (bool) $this->container->getParameter( 'aimeos_shop.apc_enable' ); |
|
| 50 | - $prefix = $this->container->getParameter( 'aimeos_shop.apc_prefix' ); |
|
| 49 | + $apc = (bool) $this->container->getParameter('aimeos_shop.apc_enable'); |
|
| 50 | + $prefix = $this->container->getParameter('aimeos_shop.apc_prefix'); |
|
| 51 | 51 | |
| 52 | - if( function_exists( 'apcu_store' ) === true && $apc === true ) { |
|
| 53 | - $conf = new \Aimeos\MW\Config\Decorator\APC( $conf, $prefix ); |
|
| 52 | + if (function_exists('apcu_store') === true && $apc === true) { |
|
| 53 | + $conf = new \Aimeos\MW\Config\Decorator\APC($conf, $prefix); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $local = array( |
| 57 | - 'admin' => $this->container->getParameter( 'aimeos_shop.admin' ), |
|
| 58 | - 'client' => $this->container->getParameter( 'aimeos_shop.client' ), |
|
| 59 | - 'controller' => $this->container->getParameter( 'aimeos_shop.controller' ), |
|
| 60 | - 'madmin' => $this->container->getParameter( 'aimeos_shop.madmin' ), |
|
| 61 | - 'mshop' => $this->container->getParameter( 'aimeos_shop.mshop' ), |
|
| 62 | - 'resource' => $this->container->getParameter( 'aimeos_shop.resource' ), |
|
| 57 | + 'admin' => $this->container->getParameter('aimeos_shop.admin'), |
|
| 58 | + 'client' => $this->container->getParameter('aimeos_shop.client'), |
|
| 59 | + 'controller' => $this->container->getParameter('aimeos_shop.controller'), |
|
| 60 | + 'madmin' => $this->container->getParameter('aimeos_shop.madmin'), |
|
| 61 | + 'mshop' => $this->container->getParameter('aimeos_shop.mshop'), |
|
| 62 | + 'resource' => $this->container->getParameter('aimeos_shop.resource'), |
|
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | - $config = new \Aimeos\MW\Config\Decorator\Memory( $conf, $local ); |
|
| 66 | - $settings = $this->container->getParameter( 'aimeos_shop.' . $type ); |
|
| 65 | + $config = new \Aimeos\MW\Config\Decorator\Memory($conf, $local); |
|
| 66 | + $settings = $this->container->getParameter('aimeos_shop.'.$type); |
|
| 67 | 67 | |
| 68 | - if( $settings !== array() ) { |
|
| 69 | - $config = new \Aimeos\MW\Config\Decorator\Memory( $config, $settings ); |
|
| 68 | + if ($settings !== array()) { |
|
| 69 | + $config = new \Aimeos\MW\Config\Decorator\Memory($config, $settings); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | return $config; |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | * @param string Related resource location, e.g. "address" |
| 32 | 32 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
| 33 | 33 | */ |
| 34 | - public function deleteAction( ServerRequestInterface $request, $resource, $related = '' ) |
|
| 34 | + public function deleteAction(ServerRequestInterface $request, $resource, $related = '') |
|
| 35 | 35 | { |
| 36 | - return $this->createClient( $resource, $related )->delete( $request, new Response() ); |
|
| 36 | + return $this->createClient($resource, $related)->delete($request, new Response()); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | * @param string Related resource location, e.g. "address" |
| 46 | 46 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
| 47 | 47 | */ |
| 48 | - public function getAction( ServerRequestInterface $request, $resource, $related = '' ) |
|
| 48 | + public function getAction(ServerRequestInterface $request, $resource, $related = '') |
|
| 49 | 49 | { |
| 50 | - return $this->createClient( $resource, $related )->get( $request, new Response() ); |
|
| 50 | + return $this->createClient($resource, $related)->get($request, new Response()); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | * @param string Related resource location, e.g. "address" |
| 60 | 60 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
| 61 | 61 | */ |
| 62 | - public function patchAction( ServerRequestInterface $request, $resource, $related = '' ) |
|
| 62 | + public function patchAction(ServerRequestInterface $request, $resource, $related = '') |
|
| 63 | 63 | { |
| 64 | - return $this->createClient( $resource, $related )->patch( $request, new Response() ); |
|
| 64 | + return $this->createClient($resource, $related)->patch($request, new Response()); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | |
@@ -73,9 +73,9 @@ discard block |
||
| 73 | 73 | * @param string Related resource location, e.g. "address" |
| 74 | 74 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
| 75 | 75 | */ |
| 76 | - public function postAction( ServerRequestInterface $request, $resource, $related = '' ) |
|
| 76 | + public function postAction(ServerRequestInterface $request, $resource, $related = '') |
|
| 77 | 77 | { |
| 78 | - return $this->createClient( $resource, $related )->post( $request, new Response() ); |
|
| 78 | + return $this->createClient($resource, $related)->post($request, new Response()); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | * @param string Related resource location, e.g. "address" |
| 88 | 88 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
| 89 | 89 | */ |
| 90 | - public function putAction( ServerRequestInterface $request, $resource, $related = '' ) |
|
| 90 | + public function putAction(ServerRequestInterface $request, $resource, $related = '') |
|
| 91 | 91 | { |
| 92 | - return $this->createClient( $resource, $related )->put( $request, new Response() ); |
|
| 92 | + return $this->createClient($resource, $related)->put($request, new Response()); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | * @param string Resource location, e.g. "customer" |
| 101 | 101 | * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output |
| 102 | 102 | */ |
| 103 | - public function optionsAction( ServerRequestInterface $request, $resource = '' ) |
|
| 103 | + public function optionsAction(ServerRequestInterface $request, $resource = '') |
|
| 104 | 104 | { |
| 105 | - return $this->createClient( $resource )->options( $request, new Response() ); |
|
| 105 | + return $this->createClient($resource)->options($request, new Response()); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | * @param string Related resource location, e.g. "address" |
| 114 | 114 | * @return \Aimeos\Client\JsonApi\Iface JSON API client |
| 115 | 115 | */ |
| 116 | - protected function createClient( $resource, $related = '' ) |
|
| 116 | + protected function createClient($resource, $related = '') |
|
| 117 | 117 | { |
| 118 | - $tmplPaths = $this->container->get( 'aimeos' )->get()->getCustomPaths( 'client/jsonapi/templates' ); |
|
| 119 | - $context = $this->container->get( 'aimeos_context' )->get(); |
|
| 118 | + $tmplPaths = $this->container->get('aimeos')->get()->getCustomPaths('client/jsonapi/templates'); |
|
| 119 | + $context = $this->container->get('aimeos_context')->get(); |
|
| 120 | 120 | $langid = $context->getLocale()->getLanguageId(); |
| 121 | 121 | |
| 122 | - $view = $this->container->get( 'aimeos_view' )->create( $context, $tmplPaths, $langid ); |
|
| 123 | - $context->setView( $view ); |
|
| 122 | + $view = $this->container->get('aimeos_view')->create($context, $tmplPaths, $langid); |
|
| 123 | + $context->setView($view); |
|
| 124 | 124 | |
| 125 | - return \Aimeos\Client\JsonApi\Factory::createClient( $context, $tmplPaths, $resource . '/' . $related ); |
|
| 125 | + return \Aimeos\Client\JsonApi\Factory::createClient($context, $tmplPaths, $resource.'/'.$related); |
|
| 126 | 126 | } |
| 127 | 127 | } |
@@ -10,74 +10,74 @@ 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 | |
| 25 | 25 | public function testPutAction() |
| 26 | 26 | { |
| 27 | 27 | $client = static::createClient(); |
| 28 | - $client->request( 'PUT', '/unittest/de/EUR/jsonapi/basket' ); |
|
| 28 | + $client->request('PUT', '/unittest/de/EUR/jsonapi/basket'); |
|
| 29 | 29 | $response = $client->getResponse(); |
| 30 | 30 | |
| 31 | - $json = json_decode( $response->getContent(), true ); |
|
| 31 | + $json = json_decode($response->getContent(), true); |
|
| 32 | 32 | |
| 33 | - $this->assertNotNull( $json ); |
|
| 34 | - $this->assertEquals( 403, $response->getStatusCode() ); |
|
| 35 | - $this->assertArrayHasKey( 'errors', $json ); |
|
| 33 | + $this->assertNotNull($json); |
|
| 34 | + $this->assertEquals(403, $response->getStatusCode()); |
|
| 35 | + $this->assertArrayHasKey('errors', $json); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | public function testGetAttributeAction() |
| 40 | 40 | { |
| 41 | 41 | $client = static::createClient(); |
| 42 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/attribute', [] ); |
|
| 42 | + $client->request('GET', '/unittest/de/EUR/jsonapi/attribute', []); |
|
| 43 | 43 | $response = $client->getResponse(); |
| 44 | 44 | |
| 45 | - $json = json_decode( $response->getContent(), true ); |
|
| 45 | + $json = json_decode($response->getContent(), true); |
|
| 46 | 46 | |
| 47 | - $this->assertNotNull( $json ); |
|
| 48 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 49 | - $this->assertEquals( 24, $json['meta']['total'] ); |
|
| 50 | - $this->assertEquals( 24, count( $json['data'] ) ); |
|
| 47 | + $this->assertNotNull($json); |
|
| 48 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 49 | + $this->assertEquals(24, $json['meta']['total']); |
|
| 50 | + $this->assertEquals(24, count($json['data'])); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | public function testGetCatalogAction() |
| 55 | 55 | { |
| 56 | 56 | $client = static::createClient(); |
| 57 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/catalog', [] ); |
|
| 57 | + $client->request('GET', '/unittest/de/EUR/jsonapi/catalog', []); |
|
| 58 | 58 | $response = $client->getResponse(); |
| 59 | 59 | |
| 60 | - $json = json_decode( $response->getContent(), true ); |
|
| 60 | + $json = json_decode($response->getContent(), true); |
|
| 61 | 61 | |
| 62 | - $this->assertNotNull( $json ); |
|
| 63 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 64 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
| 65 | - $this->assertEquals( 4, count( $json['data'] ) ); |
|
| 62 | + $this->assertNotNull($json); |
|
| 63 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 64 | + $this->assertEquals(1, $json['meta']['total']); |
|
| 65 | + $this->assertEquals(4, count($json['data'])); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | public function testGetLocaleAction() |
| 70 | 70 | { |
| 71 | 71 | $client = static::createClient(); |
| 72 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/locale', [] ); |
|
| 72 | + $client->request('GET', '/unittest/de/EUR/jsonapi/locale', []); |
|
| 73 | 73 | $response = $client->getResponse(); |
| 74 | 74 | |
| 75 | - $json = json_decode( $response->getContent(), true ); |
|
| 75 | + $json = json_decode($response->getContent(), true); |
|
| 76 | 76 | |
| 77 | - $this->assertNotNull( $json ); |
|
| 78 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 79 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
| 80 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
| 77 | + $this->assertNotNull($json); |
|
| 78 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 79 | + $this->assertEquals(1, $json['meta']['total']); |
|
| 80 | + $this->assertEquals(1, count($json['data'])); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
@@ -86,60 +86,60 @@ discard block |
||
| 86 | 86 | $client = static::createClient(); |
| 87 | 87 | |
| 88 | 88 | $params = ['filter' => ['f_search' => 'Cafe Noire Cap', 'f_listtype' => 'unittype19']]; |
| 89 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/product', $params ); |
|
| 89 | + $client->request('GET', '/unittest/de/EUR/jsonapi/product', $params); |
|
| 90 | 90 | $response = $client->getResponse(); |
| 91 | 91 | |
| 92 | - $json = json_decode( $response->getContent(), true ); |
|
| 92 | + $json = json_decode($response->getContent(), true); |
|
| 93 | 93 | |
| 94 | - $this->assertNotNull( $json ); |
|
| 95 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 96 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
| 97 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
| 98 | - $this->assertArrayHasKey( 'id', $json['data'][0] ); |
|
| 99 | - $this->assertEquals( 'CNC', $json['data'][0]['attributes']['product.code'] ); |
|
| 94 | + $this->assertNotNull($json); |
|
| 95 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 96 | + $this->assertEquals(1, $json['meta']['total']); |
|
| 97 | + $this->assertEquals(1, count($json['data'])); |
|
| 98 | + $this->assertArrayHasKey('id', $json['data'][0]); |
|
| 99 | + $this->assertEquals('CNC', $json['data'][0]['attributes']['product.code']); |
|
| 100 | 100 | |
| 101 | 101 | $id = $json['data'][0]['id']; |
| 102 | 102 | |
| 103 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/product/' . $id ); |
|
| 103 | + $client->request('GET', '/unittest/de/EUR/jsonapi/product/'.$id); |
|
| 104 | 104 | $response = $client->getResponse(); |
| 105 | 105 | |
| 106 | - $json = json_decode( $response->getContent(), true ); |
|
| 106 | + $json = json_decode($response->getContent(), true); |
|
| 107 | 107 | |
| 108 | - $this->assertNotNull( $json ); |
|
| 109 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 110 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
| 111 | - $this->assertArrayHasKey( 'id', $json['data'] ); |
|
| 112 | - $this->assertEquals( 'CNC', $json['data']['attributes']['product.code'] ); |
|
| 108 | + $this->assertNotNull($json); |
|
| 109 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 110 | + $this->assertEquals(1, $json['meta']['total']); |
|
| 111 | + $this->assertArrayHasKey('id', $json['data']); |
|
| 112 | + $this->assertEquals('CNC', $json['data']['attributes']['product.code']); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | |
| 116 | 116 | public function testGetServiceAction() |
| 117 | 117 | { |
| 118 | 118 | $client = static::createClient(); |
| 119 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/service', [] ); |
|
| 119 | + $client->request('GET', '/unittest/de/EUR/jsonapi/service', []); |
|
| 120 | 120 | $response = $client->getResponse(); |
| 121 | 121 | |
| 122 | - $json = json_decode( $response->getContent(), true ); |
|
| 122 | + $json = json_decode($response->getContent(), true); |
|
| 123 | 123 | |
| 124 | - $this->assertNotNull( $json ); |
|
| 125 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 126 | - $this->assertEquals( 4, $json['meta']['total'] ); |
|
| 127 | - $this->assertEquals( 4, count( $json['data'] ) ); |
|
| 124 | + $this->assertNotNull($json); |
|
| 125 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 126 | + $this->assertEquals(4, $json['meta']['total']); |
|
| 127 | + $this->assertEquals(4, count($json['data'])); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | |
| 131 | 131 | public function testGetStockAction() |
| 132 | 132 | { |
| 133 | 133 | $client = static::createClient(); |
| 134 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/stock', ['filter' => ['s_prodcode' => ['CNC', 'CNE']]] ); |
|
| 134 | + $client->request('GET', '/unittest/de/EUR/jsonapi/stock', ['filter' => ['s_prodcode' => ['CNC', 'CNE']]]); |
|
| 135 | 135 | $response = $client->getResponse(); |
| 136 | 136 | |
| 137 | - $json = json_decode( $response->getContent(), true ); |
|
| 137 | + $json = json_decode($response->getContent(), true); |
|
| 138 | 138 | |
| 139 | - $this->assertNotNull( $json ); |
|
| 140 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 141 | - $this->assertEquals( 2, $json['meta']['total'] ); |
|
| 142 | - $this->assertEquals( 2, count( $json['data'] ) ); |
|
| 139 | + $this->assertNotNull($json); |
|
| 140 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 141 | + $this->assertEquals(2, $json['meta']['total']); |
|
| 142 | + $this->assertEquals(2, count($json['data'])); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | |
@@ -147,24 +147,24 @@ discard block |
||
| 147 | 147 | { |
| 148 | 148 | $client = static::createClient(); |
| 149 | 149 | |
| 150 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 151 | - $optJson = json_decode( $client->getResponse()->getContent(), true ); |
|
| 152 | - $this->assertGreaterThan( 8, count( $optJson['meta']['resources'] ) ); |
|
| 150 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 151 | + $optJson = json_decode($client->getResponse()->getContent(), true); |
|
| 152 | + $this->assertGreaterThan(8, count($optJson['meta']['resources'])); |
|
| 153 | 153 | |
| 154 | 154 | // catalog root |
| 155 | - $client->request( 'GET', $optJson['meta']['resources']['catalog'], ['include' => 'catalog'] ); |
|
| 156 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 157 | - $this->assertEquals( 'categories', $json['included'][0]['attributes']['catalog.code'] ); |
|
| 155 | + $client->request('GET', $optJson['meta']['resources']['catalog'], ['include' => 'catalog']); |
|
| 156 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 157 | + $this->assertEquals('categories', $json['included'][0]['attributes']['catalog.code']); |
|
| 158 | 158 | |
| 159 | 159 | // "categories" category |
| 160 | - $client->request( 'GET', $json['included'][0]['links']['self']['href'], ['include' => 'catalog'] ); |
|
| 161 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 162 | - $this->assertEquals( 'cafe', $json['included'][0]['attributes']['catalog.code'] ); |
|
| 160 | + $client->request('GET', $json['included'][0]['links']['self']['href'], ['include' => 'catalog']); |
|
| 161 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 162 | + $this->assertEquals('cafe', $json['included'][0]['attributes']['catalog.code']); |
|
| 163 | 163 | |
| 164 | 164 | // product list for "cafe" category |
| 165 | - $client->request( 'GET', $optJson['meta']['resources']['product'], ['f_catid' => $json['included'][0]['id']] ); |
|
| 166 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 167 | - $this->assertEquals( 'CNE', $json['data'][0]['attributes']['product.code'] ); |
|
| 165 | + $client->request('GET', $optJson['meta']['resources']['product'], ['f_catid' => $json['included'][0]['id']]); |
|
| 166 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 167 | + $this->assertEquals('CNE', $json['data'][0]['attributes']['product.code']); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | |
@@ -172,26 +172,26 @@ discard block |
||
| 172 | 172 | { |
| 173 | 173 | $client = static::createClient(); |
| 174 | 174 | |
| 175 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 176 | - $options = json_decode( $client->getResponse()->getContent(), true ); |
|
| 177 | - $this->assertGreaterThan( 8, count( $options['meta']['resources'] ) ); |
|
| 175 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 176 | + $options = json_decode($client->getResponse()->getContent(), true); |
|
| 177 | + $this->assertGreaterThan(8, count($options['meta']['resources'])); |
|
| 178 | 178 | |
| 179 | 179 | // all available attrbutes |
| 180 | - $client->request( 'GET', $options['meta']['resources']['attribute'] ); |
|
| 181 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 180 | + $client->request('GET', $options['meta']['resources']['attribute']); |
|
| 181 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 182 | 182 | |
| 183 | - foreach( $json['data'] as $entry ) |
|
| 183 | + foreach ($json['data'] as $entry) |
|
| 184 | 184 | { |
| 185 | - if( $entry['attributes']['attribute.code'] === 'xl' ) |
|
| 185 | + if ($entry['attributes']['attribute.code'] === 'xl') |
|
| 186 | 186 | { |
| 187 | 187 | // products with attrbute "xl" |
| 188 | - $client->request( 'GET', $options['meta']['resources']['product'], ['filter' => ['f_attrid' => $entry['id']]] ); |
|
| 188 | + $client->request('GET', $options['meta']['resources']['product'], ['filter' => ['f_attrid' => $entry['id']]]); |
|
| 189 | 189 | break; |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 194 | - $this->assertEquals( 2, $json['meta']['total'] ); |
|
| 193 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 194 | + $this->assertEquals(2, $json['meta']['total']); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | |
@@ -199,14 +199,14 @@ discard block |
||
| 199 | 199 | { |
| 200 | 200 | $client = static::createClient(); |
| 201 | 201 | |
| 202 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 203 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 204 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
| 202 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 203 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 204 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
| 205 | 205 | |
| 206 | 206 | // product list for full text search |
| 207 | - $client->request( 'GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'selection']] ); |
|
| 208 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 209 | - $this->assertEquals( 3, count( $json['data'] ) ); |
|
| 207 | + $client->request('GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'selection']]); |
|
| 208 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 209 | + $this->assertEquals(3, count($json['data'])); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | |
@@ -214,23 +214,23 @@ discard block |
||
| 214 | 214 | { |
| 215 | 215 | $client = static::createClient(); |
| 216 | 216 | |
| 217 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 218 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 219 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
| 217 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 218 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 219 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
| 220 | 220 | |
| 221 | 221 | // get empty basket |
| 222 | - $client->request( 'GET', $json['meta']['resources']['basket'] ); |
|
| 223 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 224 | - $this->assertEquals( 'basket', $json['data']['type'] ); |
|
| 222 | + $client->request('GET', $json['meta']['resources']['basket']); |
|
| 223 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 224 | + $this->assertEquals('basket', $json['data']['type']); |
|
| 225 | 225 | |
| 226 | 226 | $content = '{"data": {"id": "delivery", "attributes": {"order.base.address.firstname": "test"}}}'; |
| 227 | - $client->request( 'POST', $json['links']['basket/address']['href'], [], [], [], $content ); |
|
| 228 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 229 | - $this->assertEquals( 'basket/address', $json['included'][0]['type'] ); |
|
| 227 | + $client->request('POST', $json['links']['basket/address']['href'], [], [], [], $content); |
|
| 228 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 229 | + $this->assertEquals('basket/address', $json['included'][0]['type']); |
|
| 230 | 230 | |
| 231 | - $client->request( 'DELETE', $json['included'][0]['links']['self']['href'] ); |
|
| 232 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 233 | - $this->assertEquals( 0, count( $json['included'] ) ); |
|
| 231 | + $client->request('DELETE', $json['included'][0]['links']['self']['href']); |
|
| 232 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 233 | + $this->assertEquals(0, count($json['included'])); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | |
@@ -238,31 +238,31 @@ discard block |
||
| 238 | 238 | { |
| 239 | 239 | $client = static::createClient(); |
| 240 | 240 | |
| 241 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 242 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 243 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
| 241 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 242 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 243 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
| 244 | 244 | |
| 245 | 245 | // product for code "CNC" |
| 246 | - $client->request( 'GET', $json['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]] ); |
|
| 247 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 248 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
| 246 | + $client->request('GET', $json['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]]); |
|
| 247 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 248 | + $this->assertEquals(1, count($json['data'])); |
|
| 249 | 249 | |
| 250 | 250 | // add product "CNC" as prerequisite |
| 251 | - $content = '{"data": {"attributes": {"product.id": ' . $json['data'][0]['id'] . '}}}'; |
|
| 252 | - $client->request( 'POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content ); |
|
| 253 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 254 | - $this->assertEquals( 'basket/product', $json['included'][0]['type'] ); |
|
| 251 | + $content = '{"data": {"attributes": {"product.id": '.$json['data'][0]['id'].'}}}'; |
|
| 252 | + $client->request('POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content); |
|
| 253 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 254 | + $this->assertEquals('basket/product', $json['included'][0]['type']); |
|
| 255 | 255 | |
| 256 | 256 | // add coupon "GHIJ" |
| 257 | 257 | $content = '{"data": {"id": "GHIJ"}}'; |
| 258 | - $client->request( 'POST', $json['links']['basket/coupon']['href'], [], [], [], $content ); |
|
| 259 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 260 | - $this->assertEquals( 'basket/coupon', $json['included'][2]['type'] ); |
|
| 258 | + $client->request('POST', $json['links']['basket/coupon']['href'], [], [], [], $content); |
|
| 259 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 260 | + $this->assertEquals('basket/coupon', $json['included'][2]['type']); |
|
| 261 | 261 | |
| 262 | 262 | // remove coupon "GHIJ" again |
| 263 | - $client->request( 'DELETE', $json['included'][2]['links']['self']['href'] ); |
|
| 264 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 265 | - $this->assertEquals( 1, count( $json['included'] ) ); |
|
| 263 | + $client->request('DELETE', $json['included'][2]['links']['self']['href']); |
|
| 264 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 265 | + $this->assertEquals(1, count($json['included'])); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | |
@@ -270,28 +270,28 @@ discard block |
||
| 270 | 270 | { |
| 271 | 271 | $client = static::createClient(); |
| 272 | 272 | |
| 273 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 274 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 275 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
| 273 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 274 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 275 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
| 276 | 276 | |
| 277 | 277 | // product for code "CNC" |
| 278 | - $client->request( 'GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'ABCD']] ); |
|
| 279 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 280 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
| 278 | + $client->request('GET', $json['meta']['resources']['product'], ['filter' => ['f_search' => 'ABCD']]); |
|
| 279 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 280 | + $this->assertEquals(1, count($json['data'])); |
|
| 281 | 281 | |
| 282 | - $content = '{"data": {"attributes": {"product.id": ' . $json['data'][0]['id'] . '}}}'; |
|
| 283 | - $client->request( 'POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content ); |
|
| 284 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 285 | - $this->assertEquals( 'basket/product', $json['included'][0]['type'] ); |
|
| 282 | + $content = '{"data": {"attributes": {"product.id": '.$json['data'][0]['id'].'}}}'; |
|
| 283 | + $client->request('POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content); |
|
| 284 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 285 | + $this->assertEquals('basket/product', $json['included'][0]['type']); |
|
| 286 | 286 | |
| 287 | 287 | $content = '{"data": {"attributes": {"quantity": 2}}}'; |
| 288 | - $client->request( 'PATCH', $json['included'][0]['links']['self']['href'], [], [], [], $content ); |
|
| 289 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 290 | - $this->assertEquals( 2, $json['included'][0]['attributes']['order.base.product.quantity'] ); |
|
| 288 | + $client->request('PATCH', $json['included'][0]['links']['self']['href'], [], [], [], $content); |
|
| 289 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 290 | + $this->assertEquals(2, $json['included'][0]['attributes']['order.base.product.quantity']); |
|
| 291 | 291 | |
| 292 | - $client->request( 'DELETE', $json['included'][0]['links']['self']['href'] ); |
|
| 293 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 294 | - $this->assertEquals( 0, count( $json['included'] ) ); |
|
| 292 | + $client->request('DELETE', $json['included'][0]['links']['self']['href']); |
|
| 293 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 294 | + $this->assertEquals(0, count($json['included'])); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | |
@@ -299,14 +299,14 @@ discard block |
||
| 299 | 299 | { |
| 300 | 300 | $client = static::createClient(); |
| 301 | 301 | |
| 302 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 303 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 304 | - $this->assertGreaterThan( 8, count( $json['meta']['resources'] ) ); |
|
| 302 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 303 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 304 | + $this->assertGreaterThan(8, count($json['meta']['resources'])); |
|
| 305 | 305 | |
| 306 | 306 | // payment services |
| 307 | - $client->request( 'GET', $json['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']] ); |
|
| 308 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 309 | - $this->assertEquals( 3, count( $json['data'] ) ); |
|
| 307 | + $client->request('GET', $json['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']]); |
|
| 308 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 309 | + $this->assertEquals(3, count($json['data'])); |
|
| 310 | 310 | |
| 311 | 311 | $content = ['data' => ['id' => 'payment', 'attributes' => [ |
| 312 | 312 | 'service.id' => $json['data'][1]['id'], |
@@ -315,15 +315,15 @@ discard block |
||
| 315 | 315 | 'directdebit.bankcode' => 'ABCDEFGH', |
| 316 | 316 | 'directdebit.bankname' => 'test bank', |
| 317 | 317 | ]]]; |
| 318 | - $client->request( 'POST', $json['data'][1]['links']['basket/service']['href'], [], [], [], json_encode( $content ) ); |
|
| 319 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 320 | - $this->assertEquals( 'basket/service', $json['included'][0]['type'] ); |
|
| 321 | - $this->assertEquals( 'directdebit-test', $json['included'][0]['attributes']['order.base.service.code'] ); |
|
| 322 | - $this->assertEquals( 5, count( $json['included'][0]['attributes']['attribute'] ) ); |
|
| 323 | - |
|
| 324 | - $client->request( 'DELETE', $json['included'][0]['links']['self']['href'] ); |
|
| 325 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 326 | - $this->assertEquals( 0, count( $json['included'] ) ); |
|
| 318 | + $client->request('POST', $json['data'][1]['links']['basket/service']['href'], [], [], [], json_encode($content)); |
|
| 319 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 320 | + $this->assertEquals('basket/service', $json['included'][0]['type']); |
|
| 321 | + $this->assertEquals('directdebit-test', $json['included'][0]['attributes']['order.base.service.code']); |
|
| 322 | + $this->assertEquals(5, count($json['included'][0]['attributes']['attribute'])); |
|
| 323 | + |
|
| 324 | + $client->request('DELETE', $json['included'][0]['links']['self']['href']); |
|
| 325 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 326 | + $this->assertEquals(0, count($json['included'])); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | |
@@ -332,17 +332,17 @@ discard block |
||
| 332 | 332 | $client = static::createClient(array(), array( |
| 333 | 333 | 'PHP_AUTH_USER' => 'UTC001', |
| 334 | 334 | 'PHP_AUTH_PW' => 'unittest', |
| 335 | - ) ); |
|
| 335 | + )); |
|
| 336 | 336 | |
| 337 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/customer', [] ); |
|
| 337 | + $client->request('GET', '/unittest/de/EUR/jsonapi/customer', []); |
|
| 338 | 338 | $response = $client->getResponse(); |
| 339 | 339 | |
| 340 | - $json = json_decode( $response->getContent(), true ); |
|
| 340 | + $json = json_decode($response->getContent(), true); |
|
| 341 | 341 | |
| 342 | - $this->assertNotNull( $json ); |
|
| 343 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 344 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
| 345 | - $this->assertEquals( 4, count( $json['data'] ) ); |
|
| 342 | + $this->assertNotNull($json); |
|
| 343 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 344 | + $this->assertEquals(1, $json['meta']['total']); |
|
| 345 | + $this->assertEquals(4, count($json['data'])); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | |
@@ -351,22 +351,22 @@ discard block |
||
| 351 | 351 | $client = static::createClient(array(), array( |
| 352 | 352 | 'PHP_AUTH_USER' => 'UTC001', |
| 353 | 353 | 'PHP_AUTH_PW' => 'unittest', |
| 354 | - ) ); |
|
| 354 | + )); |
|
| 355 | 355 | |
| 356 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/customer', [] ); |
|
| 356 | + $client->request('GET', '/unittest/de/EUR/jsonapi/customer', []); |
|
| 357 | 357 | $response = $client->getResponse(); |
| 358 | 358 | |
| 359 | - $json = json_decode( $response->getContent(), true ); |
|
| 359 | + $json = json_decode($response->getContent(), true); |
|
| 360 | 360 | |
| 361 | - $client->request( 'GET', $json['links']['customer/address']['href'], [] ); |
|
| 361 | + $client->request('GET', $json['links']['customer/address']['href'], []); |
|
| 362 | 362 | $response = $client->getResponse(); |
| 363 | 363 | |
| 364 | - $json = json_decode( $response->getContent(), true ); |
|
| 364 | + $json = json_decode($response->getContent(), true); |
|
| 365 | 365 | |
| 366 | - $this->assertNotNull( $json ); |
|
| 367 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 368 | - $this->assertEquals( 1, $json['meta']['total'] ); |
|
| 369 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
| 366 | + $this->assertNotNull($json); |
|
| 367 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 368 | + $this->assertEquals(1, $json['meta']['total']); |
|
| 369 | + $this->assertEquals(1, count($json['data'])); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | |
@@ -375,17 +375,17 @@ discard block |
||
| 375 | 375 | $client = static::createClient(array(), array( |
| 376 | 376 | 'PHP_AUTH_USER' => 'UTC001', |
| 377 | 377 | 'PHP_AUTH_PW' => 'unittest', |
| 378 | - ) ); |
|
| 378 | + )); |
|
| 379 | 379 | |
| 380 | - $client->request( 'GET', '/unittest/de/EUR/jsonapi/order', [] ); |
|
| 380 | + $client->request('GET', '/unittest/de/EUR/jsonapi/order', []); |
|
| 381 | 381 | $response = $client->getResponse(); |
| 382 | 382 | |
| 383 | - $json = json_decode( $response->getContent(), true ); |
|
| 383 | + $json = json_decode($response->getContent(), true); |
|
| 384 | 384 | |
| 385 | - $this->assertNotNull( $json ); |
|
| 386 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 387 | - $this->assertEquals( 5, $json['meta']['total'] ); |
|
| 388 | - $this->assertEquals( 5, count( $json['data'] ) ); |
|
| 385 | + $this->assertNotNull($json); |
|
| 386 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 387 | + $this->assertEquals(5, $json['meta']['total']); |
|
| 388 | + $this->assertEquals(5, count($json['data'])); |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | |
@@ -393,63 +393,63 @@ discard block |
||
| 393 | 393 | { |
| 394 | 394 | $client = static::createClient(); |
| 395 | 395 | |
| 396 | - $client->request( 'OPTIONS', '/unittest/de/EUR/jsonapi' ); |
|
| 397 | - $optJson = json_decode( $client->getResponse()->getContent(), true ); |
|
| 398 | - $this->assertGreaterThan( 8, count( $optJson['meta']['resources'] ) ); |
|
| 396 | + $client->request('OPTIONS', '/unittest/de/EUR/jsonapi'); |
|
| 397 | + $optJson = json_decode($client->getResponse()->getContent(), true); |
|
| 398 | + $this->assertGreaterThan(8, count($optJson['meta']['resources'])); |
|
| 399 | 399 | |
| 400 | 400 | // product for code "CNC" |
| 401 | - $client->request( 'GET', $optJson['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]] ); |
|
| 402 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 403 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
| 401 | + $client->request('GET', $optJson['meta']['resources']['product'], ['filter' => ['==' => ['product.code' => 'CNC']]]); |
|
| 402 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 403 | + $this->assertEquals(1, count($json['data'])); |
|
| 404 | 404 | |
| 405 | 405 | // add product "CNC" |
| 406 | - $content = '{"data": {"attributes": {"product.id": ' . $json['data'][0]['id'] . '}}}'; |
|
| 407 | - $client->request( 'POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content ); |
|
| 408 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 409 | - $this->assertEquals( 'basket/product', $json['included'][0]['type'] ); |
|
| 406 | + $content = '{"data": {"attributes": {"product.id": '.$json['data'][0]['id'].'}}}'; |
|
| 407 | + $client->request('POST', $json['data'][0]['links']['basket/product']['href'], [], [], [], $content); |
|
| 408 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 409 | + $this->assertEquals('basket/product', $json['included'][0]['type']); |
|
| 410 | 410 | |
| 411 | 411 | // delivery services |
| 412 | - $client->request( 'GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'delivery']] ); |
|
| 413 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 414 | - $this->assertEquals( 1, count( $json['data'] ) ); |
|
| 412 | + $client->request('GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'delivery']]); |
|
| 413 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 414 | + $this->assertEquals(1, count($json['data'])); |
|
| 415 | 415 | |
| 416 | 416 | // add delivery service |
| 417 | - $content = '{"data": {"id": "delivery", "attributes": {"service.id": ' . $json['data'][0]['id'] . '}}}'; |
|
| 418 | - $client->request( 'POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content ); |
|
| 419 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 420 | - $this->assertEquals( 'basket/service', $json['included'][1]['type'] ); |
|
| 417 | + $content = '{"data": {"id": "delivery", "attributes": {"service.id": '.$json['data'][0]['id'].'}}}'; |
|
| 418 | + $client->request('POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content); |
|
| 419 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 420 | + $this->assertEquals('basket/service', $json['included'][1]['type']); |
|
| 421 | 421 | |
| 422 | 422 | // payment services |
| 423 | - $client->request( 'GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']] ); |
|
| 424 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 425 | - $this->assertEquals( 3, count( $json['data'] ) ); |
|
| 423 | + $client->request('GET', $optJson['meta']['resources']['service'], ['filter' => ['cs_type' => 'payment']]); |
|
| 424 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 425 | + $this->assertEquals(3, count($json['data'])); |
|
| 426 | 426 | |
| 427 | 427 | // add payment service |
| 428 | - $content = '{"data": {"id": "payment", "attributes": {"service.id": ' . $json['data'][0]['id'] . '}}}'; |
|
| 429 | - $client->request( 'POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content ); |
|
| 430 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 431 | - $this->assertEquals( 'basket/service', $json['included'][2]['type'] ); |
|
| 428 | + $content = '{"data": {"id": "payment", "attributes": {"service.id": '.$json['data'][0]['id'].'}}}'; |
|
| 429 | + $client->request('POST', $json['data'][0]['links']['basket/service']['href'], [], [], [], $content); |
|
| 430 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 431 | + $this->assertEquals('basket/service', $json['included'][2]['type']); |
|
| 432 | 432 | |
| 433 | 433 | // add address |
| 434 | 434 | $content = '{"data": {"id": "payment", "attributes": {"order.base.address.firstname": "test"}}}'; |
| 435 | - $client->request( 'POST', $json['links']['basket/address']['href'], [], [], [], $content ); |
|
| 436 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 437 | - $this->assertEquals( 'basket/address', $json['included'][3]['type'] ); |
|
| 435 | + $client->request('POST', $json['links']['basket/address']['href'], [], [], [], $content); |
|
| 436 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 437 | + $this->assertEquals('basket/address', $json['included'][3]['type']); |
|
| 438 | 438 | |
| 439 | 439 | // store basket |
| 440 | - $client->request( 'POST', $json['data']['links']['self']['href'] ); |
|
| 441 | - $basketJson = json_decode( $client->getResponse()->getContent(), true ); |
|
| 442 | - $this->assertEquals( true, ctype_digit( $basketJson['data']['id'] ) ); |
|
| 440 | + $client->request('POST', $json['data']['links']['self']['href']); |
|
| 441 | + $basketJson = json_decode($client->getResponse()->getContent(), true); |
|
| 442 | + $this->assertEquals(true, ctype_digit($basketJson['data']['id'])); |
|
| 443 | 443 | |
| 444 | 444 | // add order |
| 445 | - $content = '{"data": {"attributes": {"order.baseid": ' . $basketJson['data']['id'] . '}}}'; |
|
| 446 | - $client->request( 'POST', $basketJson['links']['order']['href'], [], [], [], $content ); |
|
| 447 | - $json = json_decode( $client->getResponse()->getContent(), true ); |
|
| 448 | - $this->assertEquals( true, ctype_digit( $json['data']['id'] ) ); |
|
| 445 | + $content = '{"data": {"attributes": {"order.baseid": '.$basketJson['data']['id'].'}}}'; |
|
| 446 | + $client->request('POST', $basketJson['links']['order']['href'], [], [], [], $content); |
|
| 447 | + $json = json_decode($client->getResponse()->getContent(), true); |
|
| 448 | + $this->assertEquals(true, ctype_digit($json['data']['id'])); |
|
| 449 | 449 | |
| 450 | 450 | |
| 451 | 451 | // delete created order |
| 452 | - $context = static::$kernel->getContainer()->get( 'aimeos_context' )->get(); |
|
| 453 | - \Aimeos\MShop\Factory::createManager( $context, 'order/base' )->deleteItem( $basketJson['data']['id'] ); |
|
| 452 | + $context = static::$kernel->getContainer()->get('aimeos_context')->get(); |
|
| 453 | + \Aimeos\MShop\Factory::createManager($context, 'order/base')->deleteItem($basketJson['data']['id']); |
|
| 454 | 454 | } |
| 455 | 455 | } |
@@ -28,18 +28,18 @@ discard block |
||
| 28 | 28 | * @param Event $event Event instance |
| 29 | 29 | * @throws \RuntimeException If an error occured |
| 30 | 30 | */ |
| 31 | - public static function setupDatabase( Event $event ) |
|
| 31 | + public static function setupDatabase(Event $event) |
|
| 32 | 32 | { |
| 33 | 33 | $options = $env = array(); |
| 34 | 34 | |
| 35 | - if( $event->isDevMode() ) { |
|
| 35 | + if ($event->isDevMode()) { |
|
| 36 | 36 | $options[] = '--option=setup/default/demo:1'; |
| 37 | 37 | } else { |
| 38 | 38 | $env[] = '--env=prod'; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - self::executeCommand( $event, 'aimeos:setup', $options + $env ); |
|
| 42 | - self::executeCommand( $event, 'aimeos:cache', $env ); |
|
| 41 | + self::executeCommand($event, 'aimeos:setup', $options + $env); |
|
| 42 | + self::executeCommand($event, 'aimeos:cache', $env); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
@@ -49,20 +49,20 @@ discard block |
||
| 49 | 49 | * @param Event $event Event instance |
| 50 | 50 | * @throws \RuntimeException If an error occured |
| 51 | 51 | */ |
| 52 | - public static function updateConfig( Event $event ) |
|
| 52 | + public static function updateConfig(Event $event) |
|
| 53 | 53 | { |
| 54 | - $event->getIO()->write( 'Ensure existing config and routing for the shop bundle' ); |
|
| 54 | + $event->getIO()->write('Ensure existing config and routing for the shop bundle'); |
|
| 55 | 55 | |
| 56 | - $options = self::getOptions( $event ); |
|
| 56 | + $options = self::getOptions($event); |
|
| 57 | 57 | |
| 58 | - if( !isset( $options['symfony-app-dir'] ) || !is_dir( $options['symfony-app-dir'] ) ) |
|
| 58 | + if (!isset($options['symfony-app-dir']) || !is_dir($options['symfony-app-dir'])) |
|
| 59 | 59 | { |
| 60 | 60 | $msg = 'An error occurred because the "%1$s" option or the "%2$s" directory isn\'t available'; |
| 61 | - throw new \RuntimeException( sprintf( $msg, 'symfony-app-dir', $options['symfony-app-dir'] ) ); |
|
| 61 | + throw new \RuntimeException(sprintf($msg, 'symfony-app-dir', $options['symfony-app-dir'])); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - self::updateConfigFile( $options['symfony-app-dir'] . '/config/config.yml' ); |
|
| 65 | - self::updateRoutingFile( $options['symfony-app-dir'] . '/config/routing.yml' ); |
|
| 64 | + self::updateConfigFile($options['symfony-app-dir'].'/config/config.yml'); |
|
| 65 | + self::updateRoutingFile($options['symfony-app-dir'].'/config/routing.yml'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
@@ -72,28 +72,28 @@ discard block |
||
| 72 | 72 | * @param Event $event Event instance |
| 73 | 73 | * @throws \RuntimeException If an error occured |
| 74 | 74 | */ |
| 75 | - public static function installBundle( Event $event ) |
|
| 75 | + public static function installBundle(Event $event) |
|
| 76 | 76 | { |
| 77 | - $event->getIO()->write( 'Installing the Aimeos shop bundle' ); |
|
| 77 | + $event->getIO()->write('Installing the Aimeos shop bundle'); |
|
| 78 | 78 | |
| 79 | - $options = self::getOptions( $event ); |
|
| 79 | + $options = self::getOptions($event); |
|
| 80 | 80 | |
| 81 | - if( !isset( $options['symfony-app-dir'] ) || !is_dir( $options['symfony-app-dir'] ) ) |
|
| 81 | + if (!isset($options['symfony-app-dir']) || !is_dir($options['symfony-app-dir'])) |
|
| 82 | 82 | { |
| 83 | 83 | $msg = 'An error occurred because the "%1$s" option or the "%2$s" directory isn\'t available'; |
| 84 | - throw new \RuntimeException( sprintf( $msg, 'symfony-app-dir', $options['symfony-app-dir'] ) ); |
|
| 84 | + throw new \RuntimeException(sprintf($msg, 'symfony-app-dir', $options['symfony-app-dir'])); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if( !isset( $options['symfony-web-dir'] ) || !is_dir( $options['symfony-web-dir'] ) ) |
|
| 87 | + if (!isset($options['symfony-web-dir']) || !is_dir($options['symfony-web-dir'])) |
|
| 88 | 88 | { |
| 89 | 89 | $msg = 'An error occurred because the "%1$s" option or the "%2$s" directory isn\'t available'; |
| 90 | - throw new \RuntimeException( sprintf( $msg, 'symfony-web-dir', $options['symfony-web-dir'] ) ); |
|
| 90 | + throw new \RuntimeException(sprintf($msg, 'symfony-web-dir', $options['symfony-web-dir'])); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - self::createDirectory( $options['symfony-app-dir'] . '/secure' ); |
|
| 94 | - self::createDirectory( $options['symfony-web-dir'] . '/uploads' ); |
|
| 95 | - self::createDirectory( $options['symfony-web-dir'] . '/preview' ); |
|
| 96 | - self::createDirectory( $options['symfony-web-dir'] . '/files' ); |
|
| 93 | + self::createDirectory($options['symfony-app-dir'].'/secure'); |
|
| 94 | + self::createDirectory($options['symfony-web-dir'].'/uploads'); |
|
| 95 | + self::createDirectory($options['symfony-web-dir'].'/preview'); |
|
| 96 | + self::createDirectory($options['symfony-web-dir'].'/files'); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | |
@@ -103,14 +103,14 @@ discard block |
||
| 103 | 103 | * @param string $dir Absolute path of the new directory |
| 104 | 104 | * @throws \RuntimeException If directory couldn't be created |
| 105 | 105 | */ |
| 106 | - protected static function createDirectory( $dir ) |
|
| 106 | + protected static function createDirectory($dir) |
|
| 107 | 107 | { |
| 108 | 108 | $perm = 0755; |
| 109 | 109 | |
| 110 | - if( !is_dir( $dir ) && !mkdir( $dir, $perm, true ) ) |
|
| 110 | + if (!is_dir($dir) && !mkdir($dir, $perm, true)) |
|
| 111 | 111 | { |
| 112 | 112 | $msg = 'Unable to create directory "%1$s" with permission "%2$s"'; |
| 113 | - throw new \RuntimeException( sprintf( $msg, $dir, $perm ) ); |
|
| 113 | + throw new \RuntimeException(sprintf($msg, $dir, $perm)); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
@@ -123,28 +123,28 @@ discard block |
||
| 123 | 123 | * @param array List of configuration options for the given command |
| 124 | 124 | * @throws \RuntimeException If the command couldn't be executed |
| 125 | 125 | */ |
| 126 | - protected static function executeCommand( Event $event, $cmd, array $options = array() ) |
|
| 126 | + protected static function executeCommand(Event $event, $cmd, array $options = array()) |
|
| 127 | 127 | { |
| 128 | - $php = escapeshellarg( self::getPhp() ); |
|
| 129 | - $console = escapeshellarg( self::getConsoleDir( $event ) . '/console' ); |
|
| 130 | - $cmd = escapeshellarg( $cmd ); |
|
| 128 | + $php = escapeshellarg(self::getPhp()); |
|
| 129 | + $console = escapeshellarg(self::getConsoleDir($event).'/console'); |
|
| 130 | + $cmd = escapeshellarg($cmd); |
|
| 131 | 131 | |
| 132 | - foreach( $options as $key => $option ) { |
|
| 133 | - $options[$key] = escapeshellarg( $option ); |
|
| 132 | + foreach ($options as $key => $option) { |
|
| 133 | + $options[$key] = escapeshellarg($option); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if( $event->getIO()->isDecorated() ) { |
|
| 136 | + if ($event->getIO()->isDecorated()) { |
|
| 137 | 137 | $console .= ' --ansi'; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $process = new Process( $php . ' ' . $console . ' ' . $cmd . ' ' . implode( ' ', $options ), null, null, null, 3600 ); |
|
| 140 | + $process = new Process($php.' '.$console.' '.$cmd.' '.implode(' ', $options), null, null, null, 3600); |
|
| 141 | 141 | |
| 142 | - $process->run( function( $type, $buffer ) use ( $event ) { |
|
| 143 | - $event->getIO()->write( $buffer, false ); |
|
| 142 | + $process->run(function($type, $buffer) use ($event) { |
|
| 143 | + $event->getIO()->write($buffer, false); |
|
| 144 | 144 | } ); |
| 145 | 145 | |
| 146 | - if( !$process->isSuccessful() ) { |
|
| 147 | - throw new \RuntimeException( sprintf( 'An error occurred when executing the "%s" command', escapeshellarg( $cmd ) ) ); |
|
| 146 | + if (!$process->isSuccessful()) { |
|
| 147 | + throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command', escapeshellarg($cmd))); |
|
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
@@ -157,19 +157,19 @@ discard block |
||
| 157 | 157 | * @return string The path to the console directory |
| 158 | 158 | * @throws \RuntimeException If console directory couldn't be found |
| 159 | 159 | */ |
| 160 | - protected static function getConsoleDir( Event $event ) |
|
| 160 | + protected static function getConsoleDir(Event $event) |
|
| 161 | 161 | { |
| 162 | - $options = self::getOptions( $event ); |
|
| 162 | + $options = self::getOptions($event); |
|
| 163 | 163 | |
| 164 | - if( isset( $options['symfony-bin-dir'] ) && is_dir( $options['symfony-bin-dir'] ) ) { |
|
| 164 | + if (isset($options['symfony-bin-dir']) && is_dir($options['symfony-bin-dir'])) { |
|
| 165 | 165 | return $options['symfony-bin-dir']; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if( isset( $options['symfony-app-dir'] ) && is_dir( $options['symfony-app-dir'] ) ) { |
|
| 168 | + if (isset($options['symfony-app-dir']) && is_dir($options['symfony-app-dir'])) { |
|
| 169 | 169 | return $options['symfony-app-dir']; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - throw new \RuntimeException( sprintf( 'Console directory not found. Neither %1$s nor %2$s option exist', 'symfony-app-dir', 'symfony-bin-dir' ) ); |
|
| 172 | + throw new \RuntimeException(sprintf('Console directory not found. Neither %1$s nor %2$s option exist', 'symfony-app-dir', 'symfony-bin-dir')); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | * @param Event $event Command event object |
| 180 | 180 | * @return array Associative list of option keys and values |
| 181 | 181 | */ |
| 182 | - protected static function getOptions( Event $event ) |
|
| 182 | + protected static function getOptions(Event $event) |
|
| 183 | 183 | { |
| 184 | 184 | return $event->getComposer()->getPackage()->getExtra(); |
| 185 | 185 | } |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | { |
| 196 | 196 | $phpFinder = new PhpExecutableFinder; |
| 197 | 197 | |
| 198 | - if( !( $phpPath = $phpFinder->find() ) ) { |
|
| 199 | - throw new \RuntimeException( 'The php executable could not be found, add it to your PATH environment variable and try again' ); |
|
| 198 | + if (!($phpPath = $phpFinder->find())) { |
|
| 199 | + throw new \RuntimeException('The php executable could not be found, add it to your PATH environment variable and try again'); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | return $phpPath; |
@@ -209,15 +209,15 @@ discard block |
||
| 209 | 209 | * @param string $filename Name of the YAML config file |
| 210 | 210 | * @throws \RuntimeException If file is not found |
| 211 | 211 | */ |
| 212 | - protected static function updateConfigFile( $filename ) |
|
| 212 | + protected static function updateConfigFile($filename) |
|
| 213 | 213 | { |
| 214 | - if( ( $content = file_get_contents( $filename ) ) === false ) { |
|
| 215 | - throw new \RuntimeException( sprintf( 'File "%1$s" not found', $filename ) ); |
|
| 214 | + if (($content = file_get_contents($filename)) === false) { |
|
| 215 | + throw new \RuntimeException(sprintf('File "%1$s" not found', $filename)); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if( self::addAsseticBundle( $content ) === true ) { |
|
| 218 | + if (self::addAsseticBundle($content) === true) { |
|
| 219 | 219 | $fs = new Filesystem(); |
| 220 | - $fs->dumpFile( $filename, $content ); |
|
| 220 | + $fs->dumpFile($filename, $content); |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | |
@@ -228,56 +228,56 @@ discard block |
||
| 228 | 228 | * @param string $filename Name of the YAML config file |
| 229 | 229 | * @throws \RuntimeException If file is not found |
| 230 | 230 | */ |
| 231 | - protected static function updateRoutingFile( $filename ) |
|
| 231 | + protected static function updateRoutingFile($filename) |
|
| 232 | 232 | { |
| 233 | - if( ( $content = file_get_contents( $filename ) ) === false ) { |
|
| 234 | - throw new \RuntimeException( sprintf( 'File "%1$s" not found', $filename ) ); |
|
| 233 | + if (($content = file_get_contents($filename)) === false) { |
|
| 234 | + throw new \RuntimeException(sprintf('File "%1$s" not found', $filename)); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - if( strpos( $content, 'aimeos_shop:' ) === false ) |
|
| 237 | + if (strpos($content, 'aimeos_shop:') === false) |
|
| 238 | 238 | { |
| 239 | - $content .= "\n" . 'aimeos_shop: |
|
| 239 | + $content .= "\n".'aimeos_shop: |
|
| 240 | 240 | resource: "@AimeosShopBundle/Resources/config/routing.yml" |
| 241 | 241 | prefix: /'; |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - if( strpos( $content, 'aimeos_shop_adm:' ) === false ) |
|
| 244 | + if (strpos($content, 'aimeos_shop_adm:') === false) |
|
| 245 | 245 | { |
| 246 | - $content .= "\n" . 'aimeos_shop_adm: |
|
| 246 | + $content .= "\n".'aimeos_shop_adm: |
|
| 247 | 247 | resource: "@AimeosShopBundle/Resources/config/routing_adm.yml" |
| 248 | 248 | prefix: /'; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - if( strpos( $content, 'aimeos_shop_extadm:' ) === false ) |
|
| 251 | + if (strpos($content, 'aimeos_shop_extadm:') === false) |
|
| 252 | 252 | { |
| 253 | - $content .= "\n" . 'aimeos_shop_extadm: |
|
| 253 | + $content .= "\n".'aimeos_shop_extadm: |
|
| 254 | 254 | resource: "@AimeosShopBundle/Resources/config/routing_extadm.yml" |
| 255 | 255 | prefix: /admin/{site}/extadm'; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - if( strpos( $content, 'aimeos_shop_jqadm:' ) === false ) |
|
| 258 | + if (strpos($content, 'aimeos_shop_jqadm:') === false) |
|
| 259 | 259 | { |
| 260 | - $content .= "\n" . 'aimeos_shop_jqadm: |
|
| 260 | + $content .= "\n".'aimeos_shop_jqadm: |
|
| 261 | 261 | resource: "@AimeosShopBundle/Resources/config/routing_jqadm.yml" |
| 262 | 262 | prefix: /admin/{site}/jqadm'; |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - if( strpos( $content, 'aimeos_shop_jsonadm:' ) === false ) |
|
| 265 | + if (strpos($content, 'aimeos_shop_jsonadm:') === false) |
|
| 266 | 266 | { |
| 267 | - $content .= "\n" . 'aimeos_shop_jsonadm: |
|
| 267 | + $content .= "\n".'aimeos_shop_jsonadm: |
|
| 268 | 268 | resource: "@AimeosShopBundle/Resources/config/routing_jsonadm.yml" |
| 269 | 269 | prefix: /admin/{site}/jsonadm'; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if( strpos( $content, 'aimeos_shop_jsonapi:' ) === false ) |
|
| 272 | + if (strpos($content, 'aimeos_shop_jsonapi:') === false) |
|
| 273 | 273 | { |
| 274 | - $content .= "\n" . 'aimeos_shop_jsonapi: |
|
| 274 | + $content .= "\n".'aimeos_shop_jsonapi: |
|
| 275 | 275 | resource: "@AimeosShopBundle/Resources/config/routing_jsonapi.yml" |
| 276 | 276 | prefix: /jsonapi'; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | $fs = new Filesystem(); |
| 280 | - $fs->dumpFile( $filename, $content ); |
|
| 280 | + $fs->dumpFile($filename, $content); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | |
@@ -287,14 +287,14 @@ discard block |
||
| 287 | 287 | * @param string &$content Content of the config.yml file |
| 288 | 288 | * @return boolean True if modified, false if not |
| 289 | 289 | */ |
| 290 | - protected static function addAsseticBundle( &$content ) |
|
| 290 | + protected static function addAsseticBundle(&$content) |
|
| 291 | 291 | { |
| 292 | - if( preg_match( "/ bundles:[ ]*\[.*'AimeosShopBundle'.*\]/", $content ) !== 1 ) |
|
| 292 | + if (preg_match("/ bundles:[ ]*\[.*'AimeosShopBundle'.*\]/", $content) !== 1) |
|
| 293 | 293 | { |
| 294 | - $search = array( "/ bundles:[ ]*\[([^\]]+)\]/", "/ bundles:[ ]*\[([ ]*)\]/" ); |
|
| 295 | - $replace = array( " bundles: [$1,'AimeosShopBundle']", " bundles: ['AimeosShopBundle']" ); |
|
| 294 | + $search = array("/ bundles:[ ]*\[([^\]]+)\]/", "/ bundles:[ ]*\[([ ]*)\]/"); |
|
| 295 | + $replace = array(" bundles: [$1,'AimeosShopBundle']", " bundles: ['AimeosShopBundle']"); |
|
| 296 | 296 | |
| 297 | - if( ( $content = preg_replace( $search, $replace, $content ) ) !== null ) { |
|
| 297 | + if (($content = preg_replace($search, $replace, $content)) !== null) { |
|
| 298 | 298 | return true; |
| 299 | 299 | } |
| 300 | 300 | } |
@@ -30,64 +30,64 @@ discard block |
||
| 30 | 30 | * @param Request $request Symfony request object |
| 31 | 31 | * @return Response Generated output for the admin interface |
| 32 | 32 | */ |
| 33 | - public function indexAction( Request $request ) |
|
| 33 | + public function indexAction(Request $request) |
|
| 34 | 34 | { |
| 35 | - $site = $request->attributes->get( 'site', $request->query->get( 'site', 'default' ) ); |
|
| 36 | - $lang = $request->attributes->get( 'lang', $request->query->get( 'lang', 'en' ) ); |
|
| 37 | - $tab = $request->attributes->get( 'tab', $request->query->get( 'tab', 0 ) ); |
|
| 35 | + $site = $request->attributes->get('site', $request->query->get('site', 'default')); |
|
| 36 | + $lang = $request->attributes->get('lang', $request->query->get('lang', 'en')); |
|
| 37 | + $tab = $request->attributes->get('tab', $request->query->get('tab', 0)); |
|
| 38 | 38 | |
| 39 | - $context = $this->get( 'aimeos_context' )->get( false, 'backend' ); |
|
| 40 | - $context->setLocale( $this->get( 'aimeos_locale' )->getBackend( $context, $site ) ); |
|
| 39 | + $context = $this->get('aimeos_context')->get(false, 'backend'); |
|
| 40 | + $context->setLocale($this->get('aimeos_locale')->getBackend($context, $site)); |
|
| 41 | 41 | |
| 42 | - $aimeos = $this->get( 'aimeos' ); |
|
| 42 | + $aimeos = $this->get('aimeos'); |
|
| 43 | 43 | $bootstrap = $aimeos->get(); |
| 44 | 44 | |
| 45 | - $cntlPaths = $bootstrap->getCustomPaths( 'controller/extjs' ); |
|
| 46 | - $controller = new \Aimeos\Controller\ExtJS\JsonRpc( $context, $cntlPaths ); |
|
| 45 | + $cntlPaths = $bootstrap->getCustomPaths('controller/extjs'); |
|
| 46 | + $controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths); |
|
| 47 | 47 | $cssFiles = array(); |
| 48 | 48 | |
| 49 | - foreach( $bootstrap->getCustomPaths( 'admin/extjs' ) as $base => $paths ) |
|
| 49 | + foreach ($bootstrap->getCustomPaths('admin/extjs') as $base => $paths) |
|
| 50 | 50 | { |
| 51 | - foreach( $paths as $path ) |
|
| 51 | + foreach ($paths as $path) |
|
| 52 | 52 | { |
| 53 | - $jsbAbsPath = $base . '/' . $path; |
|
| 53 | + $jsbAbsPath = $base.'/'.$path; |
|
| 54 | 54 | |
| 55 | - if( !is_file( $jsbAbsPath ) ) { |
|
| 56 | - throw new \Exception( sprintf( 'JSB2 file "%1$s" not found', $jsbAbsPath ) ); |
|
| 55 | + if (!is_file($jsbAbsPath)) { |
|
| 56 | + throw new \Exception(sprintf('JSB2 file "%1$s" not found', $jsbAbsPath)); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - $jsb2 = new \Aimeos\MW\Jsb2\Standard( $jsbAbsPath, dirname( $path ) ); |
|
| 60 | - $cssFiles = array_merge( $cssFiles, $jsb2->getUrls( 'css' ) ); |
|
| 59 | + $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($path)); |
|
| 60 | + $cssFiles = array_merge($cssFiles, $jsb2->getUrls('css')); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $params = array( 'site' => '{site}', 'lang' => '{lang}', 'tab' => '{tab}' ); |
|
| 65 | - $adminUrl = $this->generateUrl( 'aimeos_shop_extadm', $params ); |
|
| 64 | + $params = array('site' => '{site}', 'lang' => '{lang}', 'tab' => '{tab}'); |
|
| 65 | + $adminUrl = $this->generateUrl('aimeos_shop_extadm', $params); |
|
| 66 | 66 | |
| 67 | - $token = $this->get( 'security.csrf.token_manager' )->getToken( 'aimeos_admin_token' )->getValue(); |
|
| 68 | - $jsonUrl = $this->generateUrl( 'aimeos_shop_extadm_json', array( '_token' => $token, 'site' => $site ) ); |
|
| 67 | + $token = $this->get('security.csrf.token_manager')->getToken('aimeos_admin_token')->getValue(); |
|
| 68 | + $jsonUrl = $this->generateUrl('aimeos_shop_extadm_json', array('_token' => $token, 'site' => $site)); |
|
| 69 | 69 | |
| 70 | - $jqadmUrl = $this->generateUrl( 'aimeos_shop_jqadm_search', array( 'site' => $site, 'lang' => $lang, 'resource' => 'dashboard' ) ); |
|
| 70 | + $jqadmUrl = $this->generateUrl('aimeos_shop_jqadm_search', array('site' => $site, 'lang' => $lang, 'resource' => 'dashboard')); |
|
| 71 | 71 | |
| 72 | 72 | $vars = array( |
| 73 | 73 | 'lang' => $lang, |
| 74 | 74 | 'cssFiles' => $cssFiles, |
| 75 | 75 | 'languages' => $this->getJsonLanguages(), |
| 76 | - 'config' => $this->getJsonClientConfig( $context ), |
|
| 77 | - 'site' => $this->getJsonSiteItem( $context, $site ), |
|
| 78 | - 'i18nContent' => $this->getJsonClientI18n( $bootstrap->getI18nPaths(), $lang ), |
|
| 76 | + 'config' => $this->getJsonClientConfig($context), |
|
| 77 | + 'site' => $this->getJsonSiteItem($context, $site), |
|
| 78 | + 'i18nContent' => $this->getJsonClientI18n($bootstrap->getI18nPaths(), $lang), |
|
| 79 | 79 | 'searchSchemas' => $controller->getJsonSearchSchemas(), |
| 80 | 80 | 'itemSchemas' => $controller->getJsonItemSchemas(), |
| 81 | - 'smd' => $controller->getJsonSmd( $jsonUrl ), |
|
| 82 | - 'urlTemplate' => urldecode( $adminUrl ), |
|
| 83 | - 'uploaddir' => $this->container->getParameter( 'aimeos_shop.uploaddir' ), |
|
| 84 | - 'extensions' => implode( ',', $bootstrap->getExtensions() ), |
|
| 81 | + 'smd' => $controller->getJsonSmd($jsonUrl), |
|
| 82 | + 'urlTemplate' => urldecode($adminUrl), |
|
| 83 | + 'uploaddir' => $this->container->getParameter('aimeos_shop.uploaddir'), |
|
| 84 | + 'extensions' => implode(',', $bootstrap->getExtensions()), |
|
| 85 | 85 | 'version' => $aimeos->getVersion(), |
| 86 | 86 | 'jqadmurl' => $jqadmUrl, |
| 87 | 87 | 'activeTab' => $tab, |
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | - return $this->render( 'AimeosShopBundle:Extadm:index.html.twig', $vars ); |
|
| 90 | + return $this->render('AimeosShopBundle:Extadm:index.html.twig', $vars); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | |
@@ -97,23 +97,23 @@ discard block |
||
| 97 | 97 | * @param Request $request Symfony request object |
| 98 | 98 | * @return Response JSON RPC message response |
| 99 | 99 | */ |
| 100 | - public function doAction( Request $request ) |
|
| 100 | + public function doAction(Request $request) |
|
| 101 | 101 | { |
| 102 | 102 | $csrfProvider = $this->get('security.csrf.token_manager'); |
| 103 | 103 | |
| 104 | - if( $csrfProvider->isTokenValid( new CsrfToken( 'aimeos_admin_token', $request->query->get( '_token' ) ) ) !== true ) { |
|
| 105 | - throw new \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException( 'CSRF token is invalid' ); |
|
| 104 | + if ($csrfProvider->isTokenValid(new CsrfToken('aimeos_admin_token', $request->query->get('_token'))) !== true) { |
|
| 105 | + throw new \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException('CSRF token is invalid'); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - $cntlPaths = $this->get( 'aimeos' )->get()->getCustomPaths( 'controller/extjs' ); |
|
| 109 | - $context = $this->get( 'aimeos_context' )->get( false, 'backend' ); |
|
| 110 | - $context->setView( $this->get( 'aimeos_view' )->create( $context, array() ) ); |
|
| 111 | - $context->setLocale( $this->get( 'aimeos_locale' )->getBackend( $context, 'default' ) ); |
|
| 108 | + $cntlPaths = $this->get('aimeos')->get()->getCustomPaths('controller/extjs'); |
|
| 109 | + $context = $this->get('aimeos_context')->get(false, 'backend'); |
|
| 110 | + $context->setView($this->get('aimeos_view')->create($context, array())); |
|
| 111 | + $context->setLocale($this->get('aimeos_locale')->getBackend($context, 'default')); |
|
| 112 | 112 | |
| 113 | - $controller = new \Aimeos\Controller\ExtJS\JsonRpc( $context, $cntlPaths ); |
|
| 113 | + $controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths); |
|
| 114 | 114 | |
| 115 | - $response = $controller->process( $request->request->all(), $request->getContent() ); |
|
| 116 | - return $this->render( 'AimeosShopBundle:Extadm:do.html.twig', array( 'output' => $response ) ); |
|
| 115 | + $response = $controller->process($request->request->all(), $request->getContent()); |
|
| 116 | + return $this->render('AimeosShopBundle:Extadm:do.html.twig', array('output' => $response)); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | |
@@ -126,27 +126,27 @@ discard block |
||
| 126 | 126 | { |
| 127 | 127 | $contents = ''; |
| 128 | 128 | $jsFiles = array(); |
| 129 | - $aimeos = $this->get( 'aimeos' )->get(); |
|
| 129 | + $aimeos = $this->get('aimeos')->get(); |
|
| 130 | 130 | |
| 131 | - foreach( $aimeos->getCustomPaths( 'admin/extjs' ) as $base => $paths ) |
|
| 131 | + foreach ($aimeos->getCustomPaths('admin/extjs') as $base => $paths) |
|
| 132 | 132 | { |
| 133 | - foreach( $paths as $path ) |
|
| 133 | + foreach ($paths as $path) |
|
| 134 | 134 | { |
| 135 | - $jsbAbsPath = $base . '/' . $path; |
|
| 136 | - $jsb2 = new \Aimeos\MW\Jsb2\Standard( $jsbAbsPath, dirname( $jsbAbsPath ) ); |
|
| 137 | - $jsFiles = array_merge( $jsFiles, $jsb2->getFiles( 'js' ) ); |
|
| 135 | + $jsbAbsPath = $base.'/'.$path; |
|
| 136 | + $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($jsbAbsPath)); |
|
| 137 | + $jsFiles = array_merge($jsFiles, $jsb2->getFiles('js')); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - foreach( $jsFiles as $file ) |
|
| 141 | + foreach ($jsFiles as $file) |
|
| 142 | 142 | { |
| 143 | - if( ( $content = file_get_contents( $file ) ) !== false ) { |
|
| 143 | + if (($content = file_get_contents($file)) !== false) { |
|
| 144 | 144 | $contents .= $content; |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - $response = new Response( $contents ); |
|
| 149 | - $response->headers->set( 'Content-Type', 'application/javascript' ); |
|
| 148 | + $response = new Response($contents); |
|
| 149 | + $response->headers->set('Content-Type', 'application/javascript'); |
|
| 150 | 150 | |
| 151 | 151 | return $response; |
| 152 | 152 | } |
@@ -161,11 +161,11 @@ discard block |
||
| 161 | 161 | { |
| 162 | 162 | $result = array(); |
| 163 | 163 | |
| 164 | - foreach( $this->get( 'aimeos' )->get()->getI18nList( 'admin' ) as $id ) { |
|
| 165 | - $result[] = array( 'id' => $id, 'label' => $id ); |
|
| 164 | + foreach ($this->get('aimeos')->get()->getI18nList('admin') as $id) { |
|
| 165 | + $result[] = array('id' => $id, 'label' => $id); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - return json_encode( $result ); |
|
| 168 | + return json_encode($result); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
| 176 | 176 | * @return string JSON encoded configuration object |
| 177 | 177 | */ |
| 178 | - protected function getJsonClientConfig( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 178 | + protected function getJsonClientConfig(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 179 | 179 | { |
| 180 | - $config = $context->getConfig()->get( 'admin/extjs', array() ); |
|
| 181 | - return json_encode( array( 'admin' => array( 'extjs' => $config ) ), JSON_FORCE_OBJECT ); |
|
| 180 | + $config = $context->getConfig()->get('admin/extjs', array()); |
|
| 181 | + return json_encode(array('admin' => array('extjs' => $config)), JSON_FORCE_OBJECT); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | |
@@ -189,16 +189,16 @@ discard block |
||
| 189 | 189 | * @param string $lang ISO language code like "en" or "en_GB" |
| 190 | 190 | * @return string JSON encoded translation object |
| 191 | 191 | */ |
| 192 | - protected function getJsonClientI18n( array $i18nPaths, $lang ) |
|
| 192 | + protected function getJsonClientI18n(array $i18nPaths, $lang) |
|
| 193 | 193 | { |
| 194 | - $i18n = new \Aimeos\MW\Translation\Gettext( $i18nPaths, $lang ); |
|
| 194 | + $i18n = new \Aimeos\MW\Translation\Gettext($i18nPaths, $lang); |
|
| 195 | 195 | |
| 196 | 196 | $content = array( |
| 197 | - 'admin' => $i18n->getAll( 'admin' ), |
|
| 198 | - 'admin/ext' => $i18n->getAll( 'admin/ext' ), |
|
| 197 | + 'admin' => $i18n->getAll('admin'), |
|
| 198 | + 'admin/ext' => $i18n->getAll('admin/ext'), |
|
| 199 | 199 | ); |
| 200 | 200 | |
| 201 | - return json_encode( $content, JSON_FORCE_OBJECT ); |
|
| 201 | + return json_encode($content, JSON_FORCE_OBJECT); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | |
@@ -210,18 +210,18 @@ discard block |
||
| 210 | 210 | * @return string JSON encoded site item object |
| 211 | 211 | * @throws Exception If no site item was found for the code |
| 212 | 212 | */ |
| 213 | - protected function getJsonSiteItem( \Aimeos\MShop\Context\Item\Iface $context, $site ) |
|
| 213 | + protected function getJsonSiteItem(\Aimeos\MShop\Context\Item\Iface $context, $site) |
|
| 214 | 214 | { |
| 215 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'locale/site' ); |
|
| 215 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'locale/site'); |
|
| 216 | 216 | |
| 217 | 217 | $criteria = $manager->createSearch(); |
| 218 | - $criteria->setConditions( $criteria->compare( '==', 'locale.site.code', $site ) ); |
|
| 219 | - $items = $manager->searchItems( $criteria ); |
|
| 218 | + $criteria->setConditions($criteria->compare('==', 'locale.site.code', $site)); |
|
| 219 | + $items = $manager->searchItems($criteria); |
|
| 220 | 220 | |
| 221 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 222 | - throw new \Exception( sprintf( 'No site found for code "%1$s"', $site ) ); |
|
| 221 | + if (($item = reset($items)) === false) { |
|
| 222 | + throw new \Exception(sprintf('No site found for code "%1$s"', $site)); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - return json_encode( $item->toArray() ); |
|
| 225 | + return json_encode($item->toArray()); |
|
| 226 | 226 | } |
| 227 | 227 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @param Container $container Container object to access parameters |
| 33 | 33 | */ |
| 34 | - public function __construct( Container $container ) |
|
| 34 | + public function __construct(Container $container) |
|
| 35 | 35 | { |
| 36 | 36 | $this->container = $container; |
| 37 | 37 | } |
@@ -44,37 +44,37 @@ discard block |
||
| 44 | 44 | * @param string $type Configuration type ("frontend" or "backend") |
| 45 | 45 | * @return \Aimeos\MShop\Context\Item\Iface Context object |
| 46 | 46 | */ |
| 47 | - public function get( $locale = true, $type = 'frontend' ) |
|
| 47 | + public function get($locale = true, $type = 'frontend') |
|
| 48 | 48 | { |
| 49 | - $config = $this->container->get( 'aimeos_config' )->get( $type ); |
|
| 49 | + $config = $this->container->get('aimeos_config')->get($type); |
|
| 50 | 50 | |
| 51 | - if( self::$context === null ) |
|
| 51 | + if (self::$context === null) |
|
| 52 | 52 | { |
| 53 | 53 | $context = new \Aimeos\MShop\Context\Item\Standard(); |
| 54 | - $context->setConfig( $config ); |
|
| 54 | + $context->setConfig($config); |
|
| 55 | 55 | |
| 56 | - $this->addDataBaseManager( $context ); |
|
| 57 | - $this->addFilesystemManager( $context ); |
|
| 58 | - $this->addMessageQueueManager( $context ); |
|
| 59 | - $this->addLogger( $context ); |
|
| 60 | - $this->addCache( $context ); |
|
| 61 | - $this->addMailer( $context); |
|
| 56 | + $this->addDataBaseManager($context); |
|
| 57 | + $this->addFilesystemManager($context); |
|
| 58 | + $this->addMessageQueueManager($context); |
|
| 59 | + $this->addLogger($context); |
|
| 60 | + $this->addCache($context); |
|
| 61 | + $this->addMailer($context); |
|
| 62 | 62 | |
| 63 | 63 | self::$context = $context; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | $context = self::$context; |
| 67 | - $context->setConfig( $config ); |
|
| 67 | + $context->setConfig($config); |
|
| 68 | 68 | |
| 69 | - if( $locale === true ) |
|
| 69 | + if ($locale === true) |
|
| 70 | 70 | { |
| 71 | - $localeItem = $this->container->get('aimeos_locale')->get( $context ); |
|
| 72 | - $context->setI18n( $this->container->get('aimeos_i18n')->get( array( $localeItem->getLanguageId() ) ) ); |
|
| 73 | - $context->setLocale( $localeItem ); |
|
| 71 | + $localeItem = $this->container->get('aimeos_locale')->get($context); |
|
| 72 | + $context->setI18n($this->container->get('aimeos_i18n')->get(array($localeItem->getLanguageId()))); |
|
| 73 | + $context->setLocale($localeItem); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $this->addSession( $context ); |
|
| 77 | - $this->addUserGroups( $context); |
|
| 76 | + $this->addSession($context); |
|
| 77 | + $this->addUserGroups($context); |
|
| 78 | 78 | |
| 79 | 79 | return $context; |
| 80 | 80 | } |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object including config |
| 87 | 87 | * @return \Aimeos\MShop\Context\Item\Iface Modified context object |
| 88 | 88 | */ |
| 89 | - protected function addCache( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 89 | + protected function addCache(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 90 | 90 | { |
| 91 | - $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $context ); |
|
| 92 | - $context->setCache( $cache ); |
|
| 91 | + $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($context); |
|
| 92 | + $context->setCache($cache); |
|
| 93 | 93 | |
| 94 | 94 | return $context; |
| 95 | 95 | } |
@@ -101,10 +101,10 @@ discard block |
||
| 101 | 101 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 102 | 102 | * @return \Aimeos\MShop\Context\Item\Iface Modified context object |
| 103 | 103 | */ |
| 104 | - protected function addDatabaseManager( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 104 | + protected function addDatabaseManager(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 105 | 105 | { |
| 106 | - $dbm = new \Aimeos\MW\DB\Manager\DBAL( $context->getConfig() ); |
|
| 107 | - $context->setDatabaseManager( $dbm ); |
|
| 106 | + $dbm = new \Aimeos\MW\DB\Manager\DBAL($context->getConfig()); |
|
| 107 | + $context->setDatabaseManager($dbm); |
|
| 108 | 108 | |
| 109 | 109 | return $context; |
| 110 | 110 | } |
@@ -116,10 +116,10 @@ discard block |
||
| 116 | 116 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 117 | 117 | * @return \Aimeos\MShop\Context\Item\Iface Modified context object |
| 118 | 118 | */ |
| 119 | - protected function addFilesystemManager( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 119 | + protected function addFilesystemManager(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 120 | 120 | { |
| 121 | - $fs = new \Aimeos\MW\Filesystem\Manager\Standard( $context->getConfig() ); |
|
| 122 | - $context->setFilesystemManager( $fs ); |
|
| 121 | + $fs = new \Aimeos\MW\Filesystem\Manager\Standard($context->getConfig()); |
|
| 122 | + $context->setFilesystemManager($fs); |
|
| 123 | 123 | |
| 124 | 124 | return $context; |
| 125 | 125 | } |
@@ -131,10 +131,10 @@ discard block |
||
| 131 | 131 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 132 | 132 | * @return \Aimeos\MShop\Context\Item\Iface Modified context object |
| 133 | 133 | */ |
| 134 | - protected function addLogger( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 134 | + protected function addLogger(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 135 | 135 | { |
| 136 | - $logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager( $context ); |
|
| 137 | - $context->setLogger( $logger ); |
|
| 136 | + $logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager($context); |
|
| 137 | + $context->setLogger($logger); |
|
| 138 | 138 | |
| 139 | 139 | return $context; |
| 140 | 140 | } |
@@ -147,11 +147,11 @@ discard block |
||
| 147 | 147 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 148 | 148 | * @return \Aimeos\MShop\Context\Item\Iface Modified context object |
| 149 | 149 | */ |
| 150 | - protected function addMailer( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 150 | + protected function addMailer(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 151 | 151 | { |
| 152 | 152 | $container = $this->container; |
| 153 | - $mail = new \Aimeos\MW\Mail\Swift( function() use ( $container) { return $container->get( 'mailer' ); } ); |
|
| 154 | - $context->setMail( $mail ); |
|
| 153 | + $mail = new \Aimeos\MW\Mail\Swift(function() use ($container) { return $container->get('mailer'); } ); |
|
| 154 | + $context->setMail($mail); |
|
| 155 | 155 | |
| 156 | 156 | return $context; |
| 157 | 157 | } |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 164 | 164 | * @return \Aimeos\MShop\Context\Item\Iface Modified context object |
| 165 | 165 | */ |
| 166 | - protected function addMessageQueueManager( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 166 | + protected function addMessageQueueManager(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 167 | 167 | { |
| 168 | - $mq = new \Aimeos\MW\MQueue\Manager\Standard( $context->getConfig() ); |
|
| 169 | - $context->setMessageQueueManager( $mq ); |
|
| 168 | + $mq = new \Aimeos\MW\MQueue\Manager\Standard($context->getConfig()); |
|
| 169 | + $context->setMessageQueueManager($mq); |
|
| 170 | 170 | |
| 171 | 171 | return $context; |
| 172 | 172 | } |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 179 | 179 | * @return \Aimeos\MShop\Context\Item\Iface Modified context object |
| 180 | 180 | */ |
| 181 | - protected function addSession( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 181 | + protected function addSession(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 182 | 182 | { |
| 183 | - $session = new \Aimeos\MW\Session\Symfony2( $this->container->get( 'session' ) ); |
|
| 184 | - $context->setSession( $session ); |
|
| 183 | + $session = new \Aimeos\MW\Session\Symfony2($this->container->get('session')); |
|
| 184 | + $context->setSession($session); |
|
| 185 | 185 | |
| 186 | 186 | return $context; |
| 187 | 187 | } |
@@ -192,36 +192,36 @@ discard block |
||
| 192 | 192 | * |
| 193 | 193 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 194 | 194 | */ |
| 195 | - protected function addUserGroups( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 195 | + protected function addUserGroups(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 196 | 196 | { |
| 197 | 197 | $username = ''; |
| 198 | - $token = $this->container->get( 'security.token_storage' )->getToken(); |
|
| 198 | + $token = $this->container->get('security.token_storage')->getToken(); |
|
| 199 | 199 | |
| 200 | - if( is_object( $token ) ) |
|
| 200 | + if (is_object($token)) |
|
| 201 | 201 | { |
| 202 | - if( method_exists( $token->getUser(), 'getId' ) ) |
|
| 202 | + if (method_exists($token->getUser(), 'getId')) |
|
| 203 | 203 | { |
| 204 | 204 | $userid = $token->getUser()->getId(); |
| 205 | - $context->setUserId( $userid ); |
|
| 206 | - $context->setGroupIds( function() use ( $context, $userid ) |
|
| 205 | + $context->setUserId($userid); |
|
| 206 | + $context->setGroupIds(function() use ($context, $userid) |
|
| 207 | 207 | { |
| 208 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
| 209 | - return $manager->getItem( $userid, array( 'customer/group' ) )->getGroups(); |
|
| 208 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
| 209 | + return $manager->getItem($userid, array('customer/group'))->getGroups(); |
|
| 210 | 210 | } ); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if( is_object( $token->getUser() ) ) { |
|
| 214 | - $username = $token->getUser()->getUsername(); |
|
| 213 | + if (is_object($token->getUser())) { |
|
| 214 | + $username = $token->getUser()->getUsername(); |
|
| 215 | 215 | } else { |
| 216 | 216 | $username = $token->getUser(); |
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | - elseif( $this->container->has( 'request_stack' ) |
|
| 220 | - && ( $request = $this->container->get('request_stack')->getMasterRequest() ) !== null |
|
| 219 | + elseif ($this->container->has('request_stack') |
|
| 220 | + && ($request = $this->container->get('request_stack')->getMasterRequest()) !== null |
|
| 221 | 221 | ) { |
| 222 | 222 | $username = $request->getClientIp(); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - $context->setEditor( $username ); |
|
| 225 | + $context->setEditor($username); |
|
| 226 | 226 | } |
| 227 | 227 | } |
@@ -19,138 +19,138 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public function testGetId() |
| 21 | 21 | { |
| 22 | - $this->assertEquals( null, $this->object->getId() ); |
|
| 22 | + $this->assertEquals(null, $this->object->getId()); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | public function testGetSetCompany() |
| 27 | 27 | { |
| 28 | - $this->object->setCompany( 'ABC' ); |
|
| 29 | - $this->assertEquals( 'ABC', $this->object->getCompany() ); |
|
| 28 | + $this->object->setCompany('ABC'); |
|
| 29 | + $this->assertEquals('ABC', $this->object->getCompany()); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | public function testGetSetVatID() |
| 34 | 34 | { |
| 35 | - $this->object->setVatID( 'AT0000' ); |
|
| 36 | - $this->assertEquals( 'AT0000', $this->object->getVatID() ); |
|
| 35 | + $this->object->setVatID('AT0000'); |
|
| 36 | + $this->assertEquals('AT0000', $this->object->getVatID()); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | public function testGetSetSalutation() |
| 41 | 41 | { |
| 42 | - $this->object->setSalutation( \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN ); |
|
| 43 | - $this->assertEquals( \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN, $this->object->getSalutation() ); |
|
| 42 | + $this->object->setSalutation(\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN); |
|
| 43 | + $this->assertEquals(\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN, $this->object->getSalutation()); |
|
| 44 | 44 | |
| 45 | - $this->object->setSalutation( \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_COMPANY ); |
|
| 46 | - $this->assertEquals( \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_COMPANY, $this->object->getSalutation() ); |
|
| 45 | + $this->object->setSalutation(\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_COMPANY); |
|
| 46 | + $this->assertEquals(\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_COMPANY, $this->object->getSalutation()); |
|
| 47 | 47 | |
| 48 | - $this->object->setSalutation( \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS ); |
|
| 49 | - $this->assertEquals( \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS, $this->object->getSalutation() ); |
|
| 48 | + $this->object->setSalutation(\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS); |
|
| 49 | + $this->assertEquals(\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS, $this->object->getSalutation()); |
|
| 50 | 50 | |
| 51 | - $this->object->setSalutation( \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS ); |
|
| 52 | - $this->assertEquals( \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS, $this->object->getSalutation() ); |
|
| 51 | + $this->object->setSalutation(\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS); |
|
| 52 | + $this->assertEquals(\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS, $this->object->getSalutation()); |
|
| 53 | 53 | |
| 54 | - $this->object->setSalutation( \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR ); |
|
| 55 | - $this->assertEquals( \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR, $this->object->getSalutation() ); |
|
| 54 | + $this->object->setSalutation(\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR); |
|
| 55 | + $this->assertEquals(\Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR, $this->object->getSalutation()); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | public function testGetSetTitle() |
| 60 | 60 | { |
| 61 | - $this->object->setTitle( 'Prof. Dr.' ); |
|
| 62 | - $this->assertEquals( 'Prof. Dr.', $this->object->getTitle() ); |
|
| 61 | + $this->object->setTitle('Prof. Dr.'); |
|
| 62 | + $this->assertEquals('Prof. Dr.', $this->object->getTitle()); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | public function testGetSetFirstname() |
| 67 | 67 | { |
| 68 | - $this->object->setFirstname( 'first' ); |
|
| 69 | - $this->assertEquals( 'first', $this->object->getFirstname() ); |
|
| 68 | + $this->object->setFirstname('first'); |
|
| 69 | + $this->assertEquals('first', $this->object->getFirstname()); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | |
| 73 | 73 | public function testGetSetLastname() |
| 74 | 74 | { |
| 75 | - $this->object->setLastname( 'last' ); |
|
| 76 | - $this->assertEquals( 'last', $this->object->getLastname() ); |
|
| 75 | + $this->object->setLastname('last'); |
|
| 76 | + $this->assertEquals('last', $this->object->getLastname()); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | public function testGetSetAddress1() |
| 81 | 81 | { |
| 82 | - $this->object->setAddress1( 'test street' ); |
|
| 83 | - $this->assertEquals( 'test street', $this->object->getAddress1() ); |
|
| 82 | + $this->object->setAddress1('test street'); |
|
| 83 | + $this->assertEquals('test street', $this->object->getAddress1()); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | |
| 87 | 87 | public function testGetSetAddress2() |
| 88 | 88 | { |
| 89 | - $this->object->setAddress2( '1' ); |
|
| 90 | - $this->assertEquals( '1', $this->object->getAddress2() ); |
|
| 89 | + $this->object->setAddress2('1'); |
|
| 90 | + $this->assertEquals('1', $this->object->getAddress2()); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | public function testGetSetAddress3() |
| 95 | 95 | { |
| 96 | - $this->object->setAddress3( 'EG' ); |
|
| 97 | - $this->assertEquals( 'EG', $this->object->getAddress3() ); |
|
| 96 | + $this->object->setAddress3('EG'); |
|
| 97 | + $this->assertEquals('EG', $this->object->getAddress3()); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
| 101 | 101 | public function testGetSetPostal() |
| 102 | 102 | { |
| 103 | - $this->object->setPostal( '12345' ); |
|
| 104 | - $this->assertEquals( '12345', $this->object->getPostal() ); |
|
| 103 | + $this->object->setPostal('12345'); |
|
| 104 | + $this->assertEquals('12345', $this->object->getPostal()); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | |
| 108 | 108 | public function testGetSetCity() |
| 109 | 109 | { |
| 110 | - $this->object->setCity( 'Munich' ); |
|
| 111 | - $this->assertEquals( 'Munich', $this->object->getCity() ); |
|
| 110 | + $this->object->setCity('Munich'); |
|
| 111 | + $this->assertEquals('Munich', $this->object->getCity()); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | public function testGetSetState() |
| 116 | 116 | { |
| 117 | - $this->object->setState( 'Bayern' ); |
|
| 118 | - $this->assertEquals( 'Bayern', $this->object->getState() ); |
|
| 117 | + $this->object->setState('Bayern'); |
|
| 118 | + $this->assertEquals('Bayern', $this->object->getState()); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | |
| 122 | 122 | public function testGetSetCountryId() |
| 123 | 123 | { |
| 124 | - $this->object->setCountryId( 'DE' ); |
|
| 125 | - $this->assertEquals( 'DE', $this->object->getCountryId() ); |
|
| 124 | + $this->object->setCountryId('DE'); |
|
| 125 | + $this->assertEquals('DE', $this->object->getCountryId()); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
| 129 | 129 | public function testGetSetLanguageId() |
| 130 | 130 | { |
| 131 | - $this->object->setLanguageId( 'de' ); |
|
| 132 | - $this->assertEquals( 'de', $this->object->getLanguageId() ); |
|
| 131 | + $this->object->setLanguageId('de'); |
|
| 132 | + $this->assertEquals('de', $this->object->getLanguageId()); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | |
| 136 | 136 | public function testGetSetTelephone() |
| 137 | 137 | { |
| 138 | - $this->object->setTelephone( '089123456789' ); |
|
| 139 | - $this->assertEquals( '089123456789', $this->object->getTelephone() ); |
|
| 138 | + $this->object->setTelephone('089123456789'); |
|
| 139 | + $this->assertEquals('089123456789', $this->object->getTelephone()); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | |
| 143 | 143 | public function testGetSetTelefax() |
| 144 | 144 | { |
| 145 | - $this->object->setTelefax( '089987654321' ); |
|
| 146 | - $this->assertEquals( '089987654321', $this->object->getTelefax() ); |
|
| 145 | + $this->object->setTelefax('089987654321'); |
|
| 146 | + $this->assertEquals('089987654321', $this->object->getTelefax()); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | public function testGetSetWebsite() |
| 151 | 151 | { |
| 152 | - $this->object->setWebsite( 'http://aimeos.org' ); |
|
| 153 | - $this->assertEquals( 'http://aimeos.org', $this->object->getWebsite() ); |
|
| 152 | + $this->object->setWebsite('http://aimeos.org'); |
|
| 153 | + $this->assertEquals('http://aimeos.org', $this->object->getWebsite()); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | |
@@ -159,6 +159,6 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function testSetWebsiteInvalid() |
| 161 | 161 | { |
| 162 | - $this->object->setWebsite( 'aimeos+org' ); |
|
| 162 | + $this->object->setWebsite('aimeos+org'); |
|
| 163 | 163 | } |
| 164 | 164 | } |
@@ -19,50 +19,50 @@ |
||
| 19 | 19 | |
| 20 | 20 | public function testGetId() |
| 21 | 21 | { |
| 22 | - $this->assertEquals( null, $this->object->getId() ); |
|
| 22 | + $this->assertEquals(null, $this->object->getId()); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | public function testGetUsername() |
| 27 | 27 | { |
| 28 | - $this->assertEquals( null, $this->object->getUsername() ); |
|
| 28 | + $this->assertEquals(null, $this->object->getUsername()); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | public function testGetPassword() |
| 33 | 33 | { |
| 34 | - $this->assertEquals( null, $this->object->getPassword() ); |
|
| 34 | + $this->assertEquals(null, $this->object->getPassword()); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | public function testGetSalt() |
| 39 | 39 | { |
| 40 | - $this->assertEquals( 'mshop', $this->object->getSalt() ); |
|
| 40 | + $this->assertEquals('mshop', $this->object->getSalt()); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | public function testGetRoles() |
| 45 | 45 | { |
| 46 | - $this->assertEquals( array( 'ROLE_USER' ), $this->object->getRoles() ); |
|
| 46 | + $this->assertEquals(array('ROLE_USER'), $this->object->getRoles()); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | public function testEraseCredentials() |
| 51 | 51 | { |
| 52 | 52 | $this->object->eraseCredentials(); |
| 53 | - $this->assertNull( $this->object->getPassword() ); |
|
| 53 | + $this->assertNull($this->object->getPassword()); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | public function testSerialize() |
| 58 | 58 | { |
| 59 | - $this->assertEquals( 'a:3:{i:0;N;i:1;N;i:2;N;}', $this->object->serialize() ); |
|
| 59 | + $this->assertEquals('a:3:{i:0;N;i:1;N;i:2;N;}', $this->object->serialize()); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
| 63 | 63 | public function testUnserialize() |
| 64 | 64 | { |
| 65 | - $this->object->unserialize( 'a:3:{i:0;N;i:1;N;i:2;N;}' ); |
|
| 66 | - $this->assertNull( $this->object->getId() ); |
|
| 65 | + $this->object->unserialize('a:3:{i:0;N;i:1;N;i:2;N;}'); |
|
| 66 | + $this->assertNull($this->object->getId()); |
|
| 67 | 67 | } |
| 68 | 68 | } |