@@ -7,15 +7,15 @@ |
||
| 7 | 7 | |
| 8 | 8 | |
| 9 | 9 | error_reporting( -1 ); |
| 10 | -ini_set( 'display_errors', '1' ); |
|
| 10 | +ini_set('display_errors', '1'); |
|
| 11 | 11 | |
| 12 | -date_default_timezone_set( 'UTC' ); |
|
| 12 | +date_default_timezone_set('UTC'); |
|
| 13 | 13 | |
| 14 | 14 | // Set locale settings to reasonable defaults |
| 15 | -setlocale( LC_ALL, 'en_US.UTF-8' ); |
|
| 16 | -setlocale( LC_NUMERIC, 'POSIX' ); |
|
| 17 | -setlocale( LC_CTYPE, 'en_US.UTF-8' ); |
|
| 18 | -setlocale( LC_TIME, 'POSIX' ); |
|
| 15 | +setlocale(LC_ALL, 'en_US.UTF-8'); |
|
| 16 | +setlocale(LC_NUMERIC, 'POSIX'); |
|
| 17 | +setlocale(LC_CTYPE, 'en_US.UTF-8'); |
|
| 18 | +setlocale(LC_TIME, 'POSIX'); |
|
| 19 | 19 | |
| 20 | 20 | require_once 'TestHelperJadm.php'; |
| 21 | 21 | \TestHelperJadm::bootstrap(); |
@@ -107,17 +107,17 @@ |
||
| 107 | 107 | * @param array $include List of resource types that should be fetched |
| 108 | 108 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
| 109 | 109 | */ |
| 110 | - protected function getListItems( array $items, array $include ) |
|
| 110 | + protected function getListItems(array $items, array $include) |
|
| 111 | 111 | { |
| 112 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'text/lists' ); |
|
| 112 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'text/lists'); |
|
| 113 | 113 | |
| 114 | 114 | $search = $manager->createSearch(); |
| 115 | 115 | $expr = array( |
| 116 | - $search->compare( '==', 'text.lists.parentid', array_keys( $items ) ), |
|
| 117 | - $search->compare( '==', 'text.lists.domain', $include ), |
|
| 116 | + $search->compare('==', 'text.lists.parentid', array_keys($items)), |
|
| 117 | + $search->compare('==', 'text.lists.domain', $include), |
|
| 118 | 118 | ); |
| 119 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 119 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 120 | 120 | |
| 121 | - return $manager->searchItems( $search ); |
|
| 121 | + return $manager->searchItems($search); |
|
| 122 | 122 | } |
| 123 | 123 | } |
@@ -107,17 +107,17 @@ |
||
| 107 | 107 | * @param array $include List of resource types that should be fetched |
| 108 | 108 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
| 109 | 109 | */ |
| 110 | - protected function getListItems( array $items, array $include ) |
|
| 110 | + protected function getListItems(array $items, array $include) |
|
| 111 | 111 | { |
| 112 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'price/lists' ); |
|
| 112 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'price/lists'); |
|
| 113 | 113 | |
| 114 | 114 | $search = $manager->createSearch(); |
| 115 | 115 | $expr = array( |
| 116 | - $search->compare( '==', 'price.lists.parentid', array_keys( $items ) ), |
|
| 117 | - $search->compare( '==', 'price.lists.domain', $include ), |
|
| 116 | + $search->compare('==', 'price.lists.parentid', array_keys($items)), |
|
| 117 | + $search->compare('==', 'price.lists.domain', $include), |
|
| 118 | 118 | ); |
| 119 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 119 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 120 | 120 | |
| 121 | - return $manager->searchItems( $search ); |
|
| 121 | + return $manager->searchItems($search); |
|
| 122 | 122 | } |
| 123 | 123 | } |
@@ -107,17 +107,17 @@ |
||
| 107 | 107 | * @param array $include List of resource types that should be fetched |
| 108 | 108 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
| 109 | 109 | */ |
| 110 | - protected function getListItems( array $items, array $include ) |
|
| 110 | + protected function getListItems(array $items, array $include) |
|
| 111 | 111 | { |
| 112 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute/lists' ); |
|
| 112 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute/lists'); |
|
| 113 | 113 | |
| 114 | 114 | $search = $manager->createSearch(); |
| 115 | 115 | $expr = array( |
| 116 | - $search->compare( '==', 'attribute.lists.parentid', array_keys( $items ) ), |
|
| 117 | - $search->compare( '==', 'attribute.lists.domain', $include ), |
|
| 116 | + $search->compare('==', 'attribute.lists.parentid', array_keys($items)), |
|
| 117 | + $search->compare('==', 'attribute.lists.domain', $include), |
|
| 118 | 118 | ); |
| 119 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 119 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 120 | 120 | |
| 121 | - return $manager->searchItems( $search ); |
|
| 121 | + return $manager->searchItems($search); |
|
| 122 | 122 | } |
| 123 | 123 | } |
@@ -107,17 +107,17 @@ |
||
| 107 | 107 | * @param array $include List of resource types that should be fetched |
| 108 | 108 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
| 109 | 109 | */ |
| 110 | - protected function getListItems( array $items, array $include ) |
|
| 110 | + protected function getListItems(array $items, array $include) |
|
| 111 | 111 | { |
| 112 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service/lists' ); |
|
| 112 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service/lists'); |
|
| 113 | 113 | |
| 114 | 114 | $search = $manager->createSearch(); |
| 115 | 115 | $expr = array( |
| 116 | - $search->compare( '==', 'service.lists.parentid', array_keys( $items ) ), |
|
| 117 | - $search->compare( '==', 'service.lists.domain', $include ), |
|
| 116 | + $search->compare('==', 'service.lists.parentid', array_keys($items)), |
|
| 117 | + $search->compare('==', 'service.lists.domain', $include), |
|
| 118 | 118 | ); |
| 119 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 119 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 120 | 120 | |
| 121 | - return $manager->searchItems( $search ); |
|
| 121 | + return $manager->searchItems($search); |
|
| 122 | 122 | } |
| 123 | 123 | } |
@@ -107,17 +107,17 @@ |
||
| 107 | 107 | * @param array $include List of resource types that should be fetched |
| 108 | 108 | * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface |
| 109 | 109 | */ |
| 110 | - protected function getListItems( array $items, array $include ) |
|
| 110 | + protected function getListItems(array $items, array $include) |
|
| 111 | 111 | { |
| 112 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'media/lists' ); |
|
| 112 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'media/lists'); |
|
| 113 | 113 | |
| 114 | 114 | $search = $manager->createSearch(); |
| 115 | 115 | $expr = array( |
| 116 | - $search->compare( '==', 'media.lists.parentid', array_keys( $items ) ), |
|
| 117 | - $search->compare( '==', 'media.lists.domain', $include ), |
|
| 116 | + $search->compare('==', 'media.lists.parentid', array_keys($items)), |
|
| 117 | + $search->compare('==', 'media.lists.domain', $include), |
|
| 118 | 118 | ); |
| 119 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
| 119 | + $search->setConditions($search->combine('&&', $expr)); |
|
| 120 | 120 | |
| 121 | - return $manager->searchItems( $search ); |
|
| 121 | + return $manager->searchItems($search); |
|
| 122 | 122 | } |
| 123 | 123 | } |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | $context = \TestHelperJadm::getContext(); |
| 17 | 17 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
| 18 | 18 | |
| 19 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
| 20 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
| 19 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
| 20 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | $context = \TestHelperJadm::getContext(); |
| 27 | 27 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
| 28 | 28 | |
| 29 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
| 30 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
| 29 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
| 30 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | $context = \TestHelperJadm::getContext(); |
| 37 | 37 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
| 38 | 38 | |
| 39 | - $client = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '' ); |
|
| 40 | - $this->assertInstanceOf( '\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client ); |
|
| 39 | + $client = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, ''); |
|
| 40 | + $this->assertInstanceOf('\\Aimeos\\Admin\\JsonAdm\\Common\\Iface', $client); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | $context = \TestHelperJadm::getContext(); |
| 47 | 47 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
| 48 | 48 | |
| 49 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
| 50 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '%^' ); |
|
| 49 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
| 50 | + \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, '%^'); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |
@@ -56,68 +56,68 @@ discard block |
||
| 56 | 56 | $context = \TestHelperJadm::getContext(); |
| 57 | 57 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
| 58 | 58 | |
| 59 | - $this->setExpectedException( '\\Aimeos\\Admin\\JsonAdm\\Exception' ); |
|
| 60 | - \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, '', '%^' ); |
|
| 59 | + $this->setExpectedException('\\Aimeos\\Admin\\JsonAdm\\Exception'); |
|
| 60 | + \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, '', '%^'); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | |
| 64 | 64 | public function testClear() |
| 65 | 65 | { |
| 66 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
| 66 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
| 67 | 67 | |
| 68 | 68 | $context = \TestHelperJadm::getContext(); |
| 69 | 69 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
| 70 | 70 | |
| 71 | - $client1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
| 71 | + $client1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
| 72 | 72 | \Aimeos\Admin\JsonAdm\Factory::clear(); |
| 73 | - $client2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
| 73 | + $client2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
| 74 | 74 | |
| 75 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
| 75 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
| 76 | 76 | |
| 77 | - $this->assertNotSame( $client1, $client2 ); |
|
| 77 | + $this->assertNotSame($client1, $client2); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | public function testClearSite() |
| 82 | 82 | { |
| 83 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
| 83 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
| 84 | 84 | |
| 85 | 85 | $context = \TestHelperJadm::getContext(); |
| 86 | 86 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
| 87 | 87 | |
| 88 | - $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
| 89 | - $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
| 90 | - \Aimeos\Admin\JsonAdm\Factory::clear( (string) $context ); |
|
| 88 | + $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
| 89 | + $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
| 90 | + \Aimeos\Admin\JsonAdm\Factory::clear((string) $context); |
|
| 91 | 91 | |
| 92 | - $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
| 93 | - $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
| 92 | + $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
| 93 | + $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
| 94 | 94 | |
| 95 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
| 95 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
| 96 | 96 | |
| 97 | - $this->assertNotSame( $cntlA1, $cntlA2 ); |
|
| 98 | - $this->assertNotSame( $cntlB1, $cntlB2 ); |
|
| 97 | + $this->assertNotSame($cntlA1, $cntlA2); |
|
| 98 | + $this->assertNotSame($cntlB1, $cntlB2); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | public function testClearSpecific() |
| 103 | 103 | { |
| 104 | - $cache = \Aimeos\Admin\JsonAdm\Factory::setCache( true ); |
|
| 104 | + $cache = \Aimeos\Admin\JsonAdm\Factory::setCache(true); |
|
| 105 | 105 | |
| 106 | 106 | $context = \TestHelperJadm::getContext(); |
| 107 | 107 | $templatePaths = \TestHelperJadm::getJsonadmPaths(); |
| 108 | 108 | |
| 109 | - $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
| 110 | - $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
| 109 | + $cntlA1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
| 110 | + $cntlB1 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
| 111 | 111 | |
| 112 | - \Aimeos\Admin\JsonAdm\Factory::clear( (string) $context, 'order' ); |
|
| 112 | + \Aimeos\Admin\JsonAdm\Factory::clear((string) $context, 'order'); |
|
| 113 | 113 | |
| 114 | - $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order' ); |
|
| 115 | - $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, 'order/base' ); |
|
| 114 | + $cntlA2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order'); |
|
| 115 | + $cntlB2 = \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, 'order/base'); |
|
| 116 | 116 | |
| 117 | - \Aimeos\Admin\JsonAdm\Factory::setCache( $cache ); |
|
| 117 | + \Aimeos\Admin\JsonAdm\Factory::setCache($cache); |
|
| 118 | 118 | |
| 119 | - $this->assertNotSame( $cntlA1, $cntlA2 ); |
|
| 120 | - $this->assertSame( $cntlB1, $cntlB2 ); |
|
| 119 | + $this->assertNotSame($cntlA1, $cntlA2); |
|
| 120 | + $this->assertSame($cntlB1, $cntlB2); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | } |
| 124 | 124 | \ No newline at end of file |
@@ -136,8 +136,7 @@ |
||
| 136 | 136 | if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) { |
| 137 | 137 | throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); |
| 138 | 138 | } |
| 139 | - } |
|
| 140 | - else |
|
| 139 | + } else |
|
| 141 | 140 | { |
| 142 | 141 | $client = self::createClientRoot( $context, $view, $templatePaths, $path, $name ); |
| 143 | 142 | } |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | * @param integer $id Context ID the objects have been created with (string of \Aimeos\MShop\Context\Item\Iface) |
| 34 | 34 | * @param string $path Path describing the client to clear, e.g. "product/lists/type" |
| 35 | 35 | */ |
| 36 | - static public function clear( $id = null, $path = null ) |
|
| 36 | + static public function clear($id = null, $path = null) |
|
| 37 | 37 | { |
| 38 | - if( $id !== null ) |
|
| 38 | + if ($id !== null) |
|
| 39 | 39 | { |
| 40 | - if( $path !== null ) { |
|
| 40 | + if ($path !== null) { |
|
| 41 | 41 | self::$clients[$id][$path] = null; |
| 42 | 42 | } else { |
| 43 | 43 | self::$clients[$id] = []; |
@@ -65,19 +65,19 @@ discard block |
||
| 65 | 65 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
| 66 | 66 | * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid |
| 67 | 67 | */ |
| 68 | - static public function createClient( \Aimeos\MShop\Context\Item\Iface $context, |
|
| 69 | - array $templatePaths, $path, $name = null ) |
|
| 68 | + static public function createClient(\Aimeos\MShop\Context\Item\Iface $context, |
|
| 69 | + array $templatePaths, $path, $name = null) |
|
| 70 | 70 | { |
| 71 | - $path = strtolower( trim( $path, "/ \n\t\r\0\x0B" ) ); |
|
| 71 | + $path = strtolower(trim($path, "/ \n\t\r\0\x0B")); |
|
| 72 | 72 | |
| 73 | - if( empty( $path ) ) { |
|
| 74 | - return self::createClientRoot( $context, $context->getView(), $templatePaths, $path, $name ); |
|
| 73 | + if (empty($path)) { |
|
| 74 | + return self::createClientRoot($context, $context->getView(), $templatePaths, $path, $name); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $id = (string) $context; |
| 78 | 78 | |
| 79 | - if( self::$cache === false || !isset( self::$clients[$id][$path] ) ) { |
|
| 80 | - self::$clients[$id][$path] = self::createClientNew( $context, $templatePaths, $path, $name ); |
|
| 79 | + if (self::$cache === false || !isset(self::$clients[$id][$path])) { |
|
| 80 | + self::$clients[$id][$path] = self::createClientNew($context, $templatePaths, $path, $name); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | return self::$clients[$id][$path]; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param boolean $value True to enable caching, false to disable it. |
| 91 | 91 | * @return boolean Previous cache setting |
| 92 | 92 | */ |
| 93 | - static public function setCache( $value ) |
|
| 93 | + static public function setCache($value) |
|
| 94 | 94 | { |
| 95 | 95 | $old = self::$cache; |
| 96 | 96 | self::$cache = (boolean) $value; |
@@ -109,37 +109,37 @@ discard block |
||
| 109 | 109 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
| 110 | 110 | * @throws \Aimeos\Admin\JsonAdm\Exception If the given path is invalid |
| 111 | 111 | */ |
| 112 | - protected static function createClientNew( \Aimeos\MShop\Context\Item\Iface $context, |
|
| 113 | - array $templatePaths, $path, $name ) |
|
| 112 | + protected static function createClientNew(\Aimeos\MShop\Context\Item\Iface $context, |
|
| 113 | + array $templatePaths, $path, $name) |
|
| 114 | 114 | { |
| 115 | - $parts = explode( '/', $path ); |
|
| 115 | + $parts = explode('/', $path); |
|
| 116 | 116 | |
| 117 | - foreach( $parts as $key => $part ) |
|
| 117 | + foreach ($parts as $key => $part) |
|
| 118 | 118 | { |
| 119 | - if( ctype_alnum( $part ) === false ) |
|
| 119 | + if (ctype_alnum($part) === false) |
|
| 120 | 120 | { |
| 121 | - $msg = sprintf( 'Invalid client "%1$s" in "%2$s"', $part, $path ); |
|
| 122 | - throw new \Aimeos\Admin\JsonAdm\Exception( $msg, 400 ); |
|
| 121 | + $msg = sprintf('Invalid client "%1$s" in "%2$s"', $part, $path); |
|
| 122 | + throw new \Aimeos\Admin\JsonAdm\Exception($msg, 400); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $parts[$key] = ucwords( $part ); |
|
| 125 | + $parts[$key] = ucwords($part); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
| 129 | 129 | $view = $context->getView(); |
| 130 | - $factory = '\\Aimeos\\Admin\\JsonAdm\\' . join( '\\', $parts ) . '\\Factory'; |
|
| 130 | + $factory = '\\Aimeos\\Admin\\JsonAdm\\' . join('\\', $parts) . '\\Factory'; |
|
| 131 | 131 | |
| 132 | - if( class_exists( $factory ) === true ) |
|
| 132 | + if (class_exists($factory) === true) |
|
| 133 | 133 | { |
| 134 | - $args = array( $context, $view, $templatePaths, $path, $name ); |
|
| 134 | + $args = array($context, $view, $templatePaths, $path, $name); |
|
| 135 | 135 | |
| 136 | - if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) { |
|
| 137 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 ); |
|
| 136 | + if (($client = @call_user_func_array(array($factory, 'createClient'), $args)) === false) { |
|
| 137 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid factory "%1$s"', $factory), 400); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | else |
| 141 | 141 | { |
| 142 | - $client = self::createClientRoot( $context, $view, $templatePaths, $path, $name ); |
|
| 142 | + $client = self::createClientRoot($context, $view, $templatePaths, $path, $name); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | return $client; |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | * @return \Aimeos\Admin\JsonAdm\Iface JSON admin instance |
| 158 | 158 | * @throws \Aimeos\Admin\JsonAdm\Exception If the client couldn't be created |
| 159 | 159 | */ |
| 160 | - protected static function createClientRoot( \Aimeos\MShop\Context\Item\Iface $context, |
|
| 161 | - \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null ) |
|
| 160 | + protected static function createClientRoot(\Aimeos\MShop\Context\Item\Iface $context, |
|
| 161 | + \Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null) |
|
| 162 | 162 | { |
| 163 | 163 | /** admin/jsonadm/name |
| 164 | 164 | * Class name of the used JSON API client implementation |
@@ -193,20 +193,20 @@ discard block |
||
| 193 | 193 | * @since 2015.12 |
| 194 | 194 | * @category Developer |
| 195 | 195 | */ |
| 196 | - if( $name === null ) { |
|
| 197 | - $name = $context->getConfig()->get( 'admin/jsonadm/name', 'Standard' ); |
|
| 196 | + if ($name === null) { |
|
| 197 | + $name = $context->getConfig()->get('admin/jsonadm/name', 'Standard'); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if( ctype_alnum( $name ) === false ) |
|
| 200 | + if (ctype_alnum($name) === false) |
|
| 201 | 201 | { |
| 202 | - $classname = is_string( $name ) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
| 203 | - throw new \Aimeos\Admin\JsonAdm\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) ); |
|
| 202 | + $classname = is_string($name) ? '\\Aimeos\\Admin\\JsonAdm\\' . $name : '<not a string>'; |
|
| 203 | + throw new \Aimeos\Admin\JsonAdm\Exception(sprintf('Invalid class name "%1$s"', $classname)); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | $iface = '\\Aimeos\\Admin\\JsonAdm\\Iface'; |
| 207 | 207 | $classname = '\\Aimeos\\Admin\\JsonAdm\\' . $name; |
| 208 | 208 | |
| 209 | - $client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path ); |
|
| 209 | + $client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path); |
|
| 210 | 210 | |
| 211 | 211 | /** admin/jsonadm/decorators/excludes |
| 212 | 212 | * Excludes decorators added by the "common" option from the JSON API clients |
@@ -286,6 +286,6 @@ discard block |
||
| 286 | 286 | * @see admin/jsonadm/decorators/global |
| 287 | 287 | */ |
| 288 | 288 | |
| 289 | - return self::addClientDecorators( $client, $context, $view, $templatePaths, $path ); |
|
| 289 | + return self::addClientDecorators($client, $context, $view, $templatePaths, $path); |
|
| 290 | 290 | } |
| 291 | 291 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $this->context = \TestHelperJadm::getContext(); |
| 23 | 23 | $this->view = $this->context->getView(); |
| 24 | 24 | |
| 25 | - $this->object = new \Aimeos\Admin\JsonAdm\Catalog\Standard( $this->context, $this->view, $templatePaths, 'catalog' ); |
|
| 25 | + $this->object = new \Aimeos\Admin\JsonAdm\Catalog\Standard($this->context, $this->view, $templatePaths, 'catalog'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -30,145 +30,145 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $params = array( |
| 32 | 32 | 'filter' => array( |
| 33 | - '==' => array( 'catalog.code' => 'cafe' ) |
|
| 33 | + '==' => array('catalog.code' => 'cafe') |
|
| 34 | 34 | ), |
| 35 | 35 | 'include' => 'text' |
| 36 | 36 | ); |
| 37 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 38 | - $this->view->addHelper( 'param', $helper ); |
|
| 37 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 38 | + $this->view->addHelper('param', $helper); |
|
| 39 | 39 | |
| 40 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
| 41 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 40 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
| 41 | + $result = json_decode((string) $response->getBody(), true); |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 45 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 44 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 45 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 46 | 46 | |
| 47 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 48 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
| 49 | - $this->assertEquals( 'catalog', $result['data'][0]['type'] ); |
|
| 50 | - $this->assertEquals( 6, count( $result['data'][0]['relationships']['text'] ) ); |
|
| 51 | - $this->assertEquals( 6, count( $result['included'] ) ); |
|
| 47 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 48 | + $this->assertEquals(1, count($result['data'])); |
|
| 49 | + $this->assertEquals('catalog', $result['data'][0]['type']); |
|
| 50 | + $this->assertEquals(6, count($result['data'][0]['relationships']['text'])); |
|
| 51 | + $this->assertEquals(6, count($result['included'])); |
|
| 52 | 52 | |
| 53 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 53 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | public function testGetTree() |
| 58 | 58 | { |
| 59 | 59 | $params = array( |
| 60 | - 'id' => $this->getCatalogItem( 'group' )->getId(), |
|
| 60 | + 'id' => $this->getCatalogItem('group')->getId(), |
|
| 61 | 61 | 'filter' => array( |
| 62 | - '==' => array( 'catalog.status' => 1 ) |
|
| 62 | + '==' => array('catalog.status' => 1) |
|
| 63 | 63 | ), |
| 64 | 64 | 'include' => 'catalog,text' |
| 65 | 65 | ); |
| 66 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 67 | - $this->view->addHelper( 'param', $helper ); |
|
| 66 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 67 | + $this->view->addHelper('param', $helper); |
|
| 68 | 68 | |
| 69 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
| 70 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 69 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
| 70 | + $result = json_decode((string) $response->getBody(), true); |
|
| 71 | 71 | |
| 72 | 72 | |
| 73 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 74 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 73 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 74 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 75 | 75 | |
| 76 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 77 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
| 78 | - $this->assertEquals( 2, count( $result['data']['relationships']['catalog'] ) ); |
|
| 79 | - $this->assertEquals( 2, count( $result['included'] ) ); |
|
| 76 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 77 | + $this->assertEquals('catalog', $result['data']['type']); |
|
| 78 | + $this->assertEquals(2, count($result['data']['relationships']['catalog'])); |
|
| 79 | + $this->assertEquals(2, count($result['included'])); |
|
| 80 | 80 | |
| 81 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 81 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | public function testPatch() |
| 86 | 86 | { |
| 87 | - $stub = $this->getCatalogMock( array( 'getItem', 'moveItem', 'saveItem' ) ); |
|
| 87 | + $stub = $this->getCatalogMock(array('getItem', 'moveItem', 'saveItem')); |
|
| 88 | 88 | |
| 89 | - $stub->expects( $this->once() )->method( 'moveItem' ); |
|
| 90 | - $stub->expects( $this->once() )->method( 'saveItem' ); |
|
| 91 | - $stub->expects( $this->exactly( 2 ) )->method( 'getItem' ) // 2x due to decorator |
|
| 92 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
| 89 | + $stub->expects($this->once())->method('moveItem'); |
|
| 90 | + $stub->expects($this->once())->method('saveItem'); |
|
| 91 | + $stub->expects($this->exactly(2))->method('getItem') // 2x due to decorator |
|
| 92 | + ->will($this->returnValue($stub->createItem())); |
|
| 93 | 93 | |
| 94 | 94 | |
| 95 | - $params = array( 'id' => '-1' ); |
|
| 96 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
| 97 | - $this->view->addHelper( 'param', $helper ); |
|
| 95 | + $params = array('id' => '-1'); |
|
| 96 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
| 97 | + $this->view->addHelper('param', $helper); |
|
| 98 | 98 | |
| 99 | 99 | $body = '{"data": {"parentid": "1", "targetid": 2, "type": "catalog", "attributes": {"catalog.label": "test"}}}'; |
| 100 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
| 100 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
| 101 | 101 | |
| 102 | - $response = $this->object->patch( $request, $this->view->response() ); |
|
| 103 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 102 | + $response = $this->object->patch($request, $this->view->response()); |
|
| 103 | + $result = json_decode((string) $response->getBody(), true); |
|
| 104 | 104 | |
| 105 | 105 | |
| 106 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
| 107 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 106 | + $this->assertEquals(200, $response->getStatusCode()); |
|
| 107 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 108 | 108 | |
| 109 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 110 | - $this->assertArrayHasKey( 'data', $result ); |
|
| 111 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
| 109 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 110 | + $this->assertArrayHasKey('data', $result); |
|
| 111 | + $this->assertEquals('catalog', $result['data']['type']); |
|
| 112 | 112 | |
| 113 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 114 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 113 | + $this->assertArrayNotHasKey('included', $result); |
|
| 114 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
| 118 | 118 | public function testPost() |
| 119 | 119 | { |
| 120 | - $stub = $this->getCatalogMock( array( 'getItem', 'insertItem' ) ); |
|
| 120 | + $stub = $this->getCatalogMock(array('getItem', 'insertItem')); |
|
| 121 | 121 | |
| 122 | - $stub->expects( $this->any() )->method( 'getItem' ) |
|
| 123 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
| 124 | - $stub->expects( $this->once() )->method( 'insertItem' ); |
|
| 122 | + $stub->expects($this->any())->method('getItem') |
|
| 123 | + ->will($this->returnValue($stub->createItem())); |
|
| 124 | + $stub->expects($this->once())->method('insertItem'); |
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | $body = '{"data": {"type": "catalog", "attributes": {"catalog.code": "test", "catalog.label": "Test catalog"}}}'; |
| 128 | - $request = $this->view->request()->withBody( $this->view->response()->createStreamFromString( $body ) ); |
|
| 128 | + $request = $this->view->request()->withBody($this->view->response()->createStreamFromString($body)); |
|
| 129 | 129 | |
| 130 | - $response = $this->object->post( $request, $this->view->response() ); |
|
| 131 | - $result = json_decode( (string) $response->getBody(), true ); |
|
| 130 | + $response = $this->object->post($request, $this->view->response()); |
|
| 131 | + $result = json_decode((string) $response->getBody(), true); |
|
| 132 | 132 | |
| 133 | 133 | |
| 134 | - $this->assertEquals( 201, $response->getStatusCode() ); |
|
| 135 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
| 134 | + $this->assertEquals(201, $response->getStatusCode()); |
|
| 135 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
| 136 | 136 | |
| 137 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
| 138 | - $this->assertArrayHasKey( 'data', $result ); |
|
| 139 | - $this->assertEquals( 'catalog', $result['data']['type'] ); |
|
| 137 | + $this->assertEquals(1, $result['meta']['total']); |
|
| 138 | + $this->assertArrayHasKey('data', $result); |
|
| 139 | + $this->assertEquals('catalog', $result['data']['type']); |
|
| 140 | 140 | |
| 141 | - $this->assertArrayNotHasKey( 'included', $result ); |
|
| 142 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
| 141 | + $this->assertArrayNotHasKey('included', $result); |
|
| 142 | + $this->assertArrayNotHasKey('errors', $result); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | |
| 146 | - protected function getCatalogItem( $code ) |
|
| 146 | + protected function getCatalogItem($code) |
|
| 147 | 147 | { |
| 148 | - $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager( $this->context ); |
|
| 148 | + $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context); |
|
| 149 | 149 | $search = $manager->createSearch(); |
| 150 | - $search->setConditions( $search->compare( '==', 'catalog.code', $code ) ); |
|
| 151 | - $items = $manager->searchItems( $search ); |
|
| 150 | + $search->setConditions($search->compare('==', 'catalog.code', $code)); |
|
| 151 | + $items = $manager->searchItems($search); |
|
| 152 | 152 | |
| 153 | - if( ( $item = reset( $items ) ) === false ) { |
|
| 154 | - throw new \RuntimeException( sprintf( 'No catalog item with code "%1$s" found', $code ) ); |
|
| 153 | + if (($item = reset($items)) === false) { |
|
| 154 | + throw new \RuntimeException(sprintf('No catalog item with code "%1$s" found', $code)); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | return $item; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
| 161 | - protected function getCatalogMock( array $methods ) |
|
| 161 | + protected function getCatalogMock(array $methods) |
|
| 162 | 162 | { |
| 163 | 163 | $name = 'ClientJsonAdmStandard'; |
| 164 | - $this->context->getConfig()->set( 'mshop/catalog/manager/name', $name ); |
|
| 164 | + $this->context->getConfig()->set('mshop/catalog/manager/name', $name); |
|
| 165 | 165 | |
| 166 | - $stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Catalog\\Manager\\Standard' ) |
|
| 167 | - ->setConstructorArgs( array( $this->context ) ) |
|
| 168 | - ->setMethods( $methods ) |
|
| 166 | + $stub = $this->getMockBuilder('\\Aimeos\\MShop\\Catalog\\Manager\\Standard') |
|
| 167 | + ->setConstructorArgs(array($this->context)) |
|
| 168 | + ->setMethods($methods) |
|
| 169 | 169 | ->getMock(); |
| 170 | 170 | |
| 171 | - \Aimeos\MShop\Product\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub ); |
|
| 171 | + \Aimeos\MShop\Product\Manager\Factory::injectManager('\\Aimeos\\MShop\\Catalog\\Manager\\' . $name, $stub); |
|
| 172 | 172 | |
| 173 | 173 | return $stub; |
| 174 | 174 | } |