@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string $classname Full name of the class for which the object should be returned |
32 | 32 | * @param \Aimeos\Controller\Frontend\Iface|null $controller Frontend controller object |
33 | 33 | */ |
34 | - public static function injectController( $classname, \Aimeos\Controller\Frontend\Iface $controller = null ) |
|
34 | + public static function injectController($classname, \Aimeos\Controller\Frontend\Iface $controller = null) |
|
35 | 35 | { |
36 | 36 | self::$objects[$classname] = $controller; |
37 | 37 | } |
@@ -46,29 +46,29 @@ discard block |
||
46 | 46 | * @param string $classprefix Decorator class prefix, e.g. "\Aimeos\Controller\Frontend\Basket\Decorator\" |
47 | 47 | * @return \Aimeos\Controller\Frontend\Common\Iface Controller object |
48 | 48 | */ |
49 | - protected static function addDecorators( \Aimeos\MShop\Context\Item\Iface $context, |
|
50 | - \Aimeos\Controller\Frontend\Iface $controller, array $decorators, $classprefix ) |
|
49 | + protected static function addDecorators(\Aimeos\MShop\Context\Item\Iface $context, |
|
50 | + \Aimeos\Controller\Frontend\Iface $controller, array $decorators, $classprefix) |
|
51 | 51 | { |
52 | 52 | $iface = '\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\Iface'; |
53 | 53 | |
54 | - foreach( $decorators as $name ) |
|
54 | + foreach ($decorators as $name) |
|
55 | 55 | { |
56 | - if( ctype_alnum( $name ) === false ) |
|
56 | + if (ctype_alnum($name) === false) |
|
57 | 57 | { |
58 | - $classname = is_string( $name ) ? $classprefix . $name : '<not a string>'; |
|
59 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
58 | + $classname = is_string($name) ? $classprefix . $name : '<not a string>'; |
|
59 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $classname = $classprefix . $name; |
63 | 63 | |
64 | - if( class_exists( $classname ) === false ) { |
|
65 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $classname ) ); |
|
64 | + if (class_exists($classname) === false) { |
|
65 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" not available', $classname)); |
|
66 | 66 | } |
67 | 67 | |
68 | - $controller = new $classname( $controller, $context ); |
|
68 | + $controller = new $classname($controller, $context); |
|
69 | 69 | |
70 | - if( !( $controller instanceof $iface ) ) { |
|
71 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $iface ) ); |
|
70 | + if (!($controller instanceof $iface)) { |
|
71 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $iface)); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | * @param string $domain Domain name in lower case, e.g. "product" |
85 | 85 | * @return \Aimeos\Controller\Frontend\Common\Iface Controller object |
86 | 86 | */ |
87 | - protected static function addControllerDecorators( \Aimeos\MShop\Context\Item\Iface $context, |
|
88 | - \Aimeos\Controller\Frontend\Iface $controller, $domain ) |
|
87 | + protected static function addControllerDecorators(\Aimeos\MShop\Context\Item\Iface $context, |
|
88 | + \Aimeos\Controller\Frontend\Iface $controller, $domain) |
|
89 | 89 | { |
90 | - if( !is_string( $domain ) || $domain === '' ) { |
|
91 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid domain "%1$s"', $domain ) ); |
|
90 | + if (!is_string($domain) || $domain === '') { |
|
91 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid domain "%1$s"', $domain)); |
|
92 | 92 | } |
93 | 93 | |
94 | - $localClass = str_replace( ' ', '\\', ucwords( str_replace( '/', ' ', $domain ) ) ); |
|
94 | + $localClass = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $domain))); |
|
95 | 95 | $config = $context->getConfig(); |
96 | 96 | |
97 | 97 | /** controller/frontend/common/decorators/default |
@@ -116,26 +116,26 @@ discard block |
||
116 | 116 | * @since 2014.03 |
117 | 117 | * @category Developer |
118 | 118 | */ |
119 | - $decorators = $config->get( 'controller/frontend/common/decorators/default', [] ); |
|
120 | - $excludes = $config->get( 'controller/frontend/' . $domain . '/decorators/excludes', [] ); |
|
119 | + $decorators = $config->get('controller/frontend/common/decorators/default', []); |
|
120 | + $excludes = $config->get('controller/frontend/' . $domain . '/decorators/excludes', []); |
|
121 | 121 | |
122 | - foreach( $decorators as $key => $name ) |
|
122 | + foreach ($decorators as $key => $name) |
|
123 | 123 | { |
124 | - if( in_array( $name, $excludes ) ) { |
|
125 | - unset( $decorators[$key] ); |
|
124 | + if (in_array($name, $excludes)) { |
|
125 | + unset($decorators[$key]); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | 129 | $classprefix = '\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\'; |
130 | - $controller = self::addDecorators( $context, $controller, $decorators, $classprefix ); |
|
130 | + $controller = self::addDecorators($context, $controller, $decorators, $classprefix); |
|
131 | 131 | |
132 | 132 | $classprefix = '\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\'; |
133 | - $decorators = $config->get( 'controller/frontend/' . $domain . '/decorators/global', [] ); |
|
134 | - $controller = self::addDecorators( $context, $controller, $decorators, $classprefix ); |
|
133 | + $decorators = $config->get('controller/frontend/' . $domain . '/decorators/global', []); |
|
134 | + $controller = self::addDecorators($context, $controller, $decorators, $classprefix); |
|
135 | 135 | |
136 | - $classprefix = '\\Aimeos\\Controller\\Frontend\\' . ucfirst( $localClass ) . '\\Decorator\\'; |
|
137 | - $decorators = $config->get( 'controller/frontend/' . $domain . '/decorators/local', [] ); |
|
138 | - $controller = self::addDecorators( $context, $controller, $decorators, $classprefix ); |
|
136 | + $classprefix = '\\Aimeos\\Controller\\Frontend\\' . ucfirst($localClass) . '\\Decorator\\'; |
|
137 | + $decorators = $config->get('controller/frontend/' . $domain . '/decorators/local', []); |
|
138 | + $controller = self::addDecorators($context, $controller, $decorators, $classprefix); |
|
139 | 139 | |
140 | 140 | return $controller; |
141 | 141 | } |
@@ -149,20 +149,20 @@ discard block |
||
149 | 149 | * @param string $interface Name of the controller interface |
150 | 150 | * @return \Aimeos\Controller\Frontend\Common\Iface Controller object |
151 | 151 | */ |
152 | - protected static function createControllerBase( \Aimeos\MShop\Context\Item\Iface $context, $classname, $interface ) |
|
152 | + protected static function createControllerBase(\Aimeos\MShop\Context\Item\Iface $context, $classname, $interface) |
|
153 | 153 | { |
154 | - if( isset( self::$objects[$classname] ) ) { |
|
154 | + if (isset(self::$objects[$classname])) { |
|
155 | 155 | return self::$objects[$classname]; |
156 | 156 | } |
157 | 157 | |
158 | - if( class_exists( $classname ) === false ) { |
|
159 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $classname ) ); |
|
158 | + if (class_exists($classname) === false) { |
|
159 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" not available', $classname)); |
|
160 | 160 | } |
161 | 161 | |
162 | - $controller = new $classname( $context ); |
|
162 | + $controller = new $classname($context); |
|
163 | 163 | |
164 | - if( !( $controller instanceof $interface ) ) { |
|
165 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $interface ) ); |
|
164 | + if (!($controller instanceof $interface)) { |
|
165 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $interface)); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | return $controller; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @return \Aimeos\MShop\Locale\Item\Iface Locale item including the referenced domains items |
37 | 37 | * @since 2017.03 |
38 | 38 | */ |
39 | - public function getItem( $id, array $domains = [] ); |
|
39 | + public function getItem($id, array $domains = []); |
|
40 | 40 | |
41 | 41 | |
42 | 42 | /** |
@@ -48,5 +48,5 @@ discard block |
||
48 | 48 | * @return array Ordered list of locale items implementing \Aimeos\MShop\Locale\Item\Iface |
49 | 49 | * @since 2017.03 |
50 | 50 | */ |
51 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = [], &$total = null ); |
|
51 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = [], &$total = null); |
|
52 | 52 | } |
@@ -30,18 +30,18 @@ discard block |
||
30 | 30 | * @param \Aimeos\Controller\Frontend\Iface $controller Controller object |
31 | 31 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
32 | 32 | */ |
33 | - public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context ) |
|
33 | + public function __construct(\Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context) |
|
34 | 34 | { |
35 | 35 | $iface = '\Aimeos\Controller\Frontend\Locale\Iface'; |
36 | - if( !( $controller instanceof $iface ) ) |
|
36 | + if (!($controller instanceof $iface)) |
|
37 | 37 | { |
38 | - $msg = sprintf( 'Class "%1$s" does not implement interface "%2$s"', get_class( $controller ), $iface ); |
|
39 | - throw new \Aimeos\Controller\Frontend\Exception( $msg ); |
|
38 | + $msg = sprintf('Class "%1$s" does not implement interface "%2$s"', get_class($controller), $iface); |
|
39 | + throw new \Aimeos\Controller\Frontend\Exception($msg); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $this->controller = $controller; |
43 | 43 | |
44 | - parent::__construct( $context ); |
|
44 | + parent::__construct($context); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * @return mixed Returns the value of the called method |
54 | 54 | * @throws \Aimeos\Controller\Frontend\Exception If method call failed |
55 | 55 | */ |
56 | - public function __call( $name, array $param ) |
|
56 | + public function __call($name, array $param) |
|
57 | 57 | { |
58 | - return @call_user_func_array( array( $this->controller, $name ), $param ); |
|
58 | + return @call_user_func_array(array($this->controller, $name), $param); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * @return \Aimeos\MShop\Locale\Item\Iface Locale item including the referenced domains items |
81 | 81 | * @since 2017.03 |
82 | 82 | */ |
83 | - public function getItem( $id, array $domains = [] ) |
|
83 | + public function getItem($id, array $domains = []) |
|
84 | 84 | { |
85 | - return $this->controller->getItem( $id, $domains ); |
|
85 | + return $this->controller->getItem($id, $domains); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @return array Ordered list of locale items implementing \Aimeos\MShop\Locale\Item\Iface |
96 | 96 | * @since 2017.03 |
97 | 97 | */ |
98 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = [], &$total = null ) |
|
98 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = [], &$total = null) |
|
99 | 99 | { |
100 | - return $this->controller->searchItems( $filter, $domains, $total ); |
|
100 | + return $this->controller->searchItems($filter, $domains, $total); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 |
@@ -31,15 +31,15 @@ discard block |
||
31 | 31 | public function createFilter() |
32 | 32 | { |
33 | 33 | $context = $this->getContext(); |
34 | - $filter = \Aimeos\MShop\Factory::createManager( $context, 'locale' )->createSearch( true ); |
|
34 | + $filter = \Aimeos\MShop\Factory::createManager($context, 'locale')->createSearch(true); |
|
35 | 35 | |
36 | 36 | $expr = array( |
37 | - $filter->compare( '==', 'locale.siteid', $context->getLocale()->getSitePath() ), |
|
37 | + $filter->compare('==', 'locale.siteid', $context->getLocale()->getSitePath()), |
|
38 | 38 | $filter->getConditions(), |
39 | 39 | ); |
40 | 40 | |
41 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
42 | - $filter->setSortations( array( $filter->sort( '+', 'locale.position' ) ) ); |
|
41 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
42 | + $filter->setSortations(array($filter->sort('+', 'locale.position'))); |
|
43 | 43 | |
44 | 44 | return $filter; |
45 | 45 | } |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * @return \Aimeos\MShop\Locale\Item\Iface Locale item including the referenced domains items |
54 | 54 | * @since 2017.03 |
55 | 55 | */ |
56 | - public function getItem( $id, array $domains = [] ) |
|
56 | + public function getItem($id, array $domains = []) |
|
57 | 57 | { |
58 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale' )->getItem( $id, $domains, true ); |
|
58 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'locale')->getItem($id, $domains, true); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @return array Ordered list of locale items implementing \Aimeos\MShop\Locale\Item\Iface |
69 | 69 | * @since 2017.03 |
70 | 70 | */ |
71 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = [], &$total = null ) |
|
71 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = [], &$total = null) |
|
72 | 72 | { |
73 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale' )->searchItems( $filter, $domains, $total ); |
|
73 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'locale')->searchItems($filter, $domains, $total); |
|
74 | 74 | } |
75 | 75 | } |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | * @param integer $id Context ID the objects have been created with (string of \Aimeos\MShop\Context\Item\Iface) |
31 | 31 | * @param string $path Path describing the controller to clear, e.g. "basket" |
32 | 32 | */ |
33 | - static public function clear( $id = null, $path = null ) |
|
33 | + static public function clear($id = null, $path = null) |
|
34 | 34 | { |
35 | - if( $id !== null ) |
|
35 | + if ($id !== null) |
|
36 | 36 | { |
37 | - if( $path !== null ) { |
|
37 | + if ($path !== null) { |
|
38 | 38 | self::$controllers[$id][$path] = null; |
39 | 39 | } else { |
40 | 40 | self::$controllers[$id] = []; |
@@ -62,37 +62,37 @@ discard block |
||
62 | 62 | * @return \Aimeos\Controller\Frontend\Iface New frontend controller |
63 | 63 | * @throws \Aimeos\Controller\Frontend\Exception If the given path is invalid or the manager wasn't found |
64 | 64 | */ |
65 | - static public function createController( \Aimeos\MShop\Context\Item\Iface $context, $path ) |
|
65 | + static public function createController(\Aimeos\MShop\Context\Item\Iface $context, $path) |
|
66 | 66 | { |
67 | - if( empty( $path ) ) { |
|
68 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Controller path is empty' ) ); |
|
67 | + if (empty($path)) { |
|
68 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Controller path is empty')); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $id = (string) $context; |
72 | 72 | |
73 | - if( self::$cache === false || !isset( self::$controllers[$id][$path] ) ) |
|
73 | + if (self::$cache === false || !isset(self::$controllers[$id][$path])) |
|
74 | 74 | { |
75 | - $parts = explode( '/', $path ); |
|
75 | + $parts = explode('/', $path); |
|
76 | 76 | |
77 | - foreach( $parts as $key => $part ) |
|
77 | + foreach ($parts as $key => $part) |
|
78 | 78 | { |
79 | - if( ctype_alnum( $part ) === false ) { |
|
80 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in controller name "%1$s" in "%2$s"', $part, $path ) ); |
|
79 | + if (ctype_alnum($part) === false) { |
|
80 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid characters in controller name "%1$s" in "%2$s"', $part, $path)); |
|
81 | 81 | } |
82 | 82 | |
83 | - $parts[$key] = ucwords( $part ); |
|
83 | + $parts[$key] = ucwords($part); |
|
84 | 84 | } |
85 | 85 | |
86 | - $factory = '\\Aimeos\\Controller\\Frontend\\' . join( '\\', $parts ) . '\\Factory'; |
|
86 | + $factory = '\\Aimeos\\Controller\\Frontend\\' . join('\\', $parts) . '\\Factory'; |
|
87 | 87 | |
88 | - if( class_exists( $factory ) === false ) { |
|
89 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $factory ) ); |
|
88 | + if (class_exists($factory) === false) { |
|
89 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" not available', $factory)); |
|
90 | 90 | } |
91 | 91 | |
92 | - $manager = call_user_func_array( array( $factory, 'createController' ), array( $context ) ); |
|
92 | + $manager = call_user_func_array(array($factory, 'createController'), array($context)); |
|
93 | 93 | |
94 | - if( $manager === false ) { |
|
95 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid factory "%1$s"', $factory ) ); |
|
94 | + if ($manager === false) { |
|
95 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid factory "%1$s"', $factory)); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | self::$controllers[$id][$path] = $manager; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param boolean $value True to enable caching, false to disable it. |
109 | 109 | * @return boolean Previous cache setting |
110 | 110 | */ |
111 | - static public function setCache( $value ) |
|
111 | + static public function setCache($value) |
|
112 | 112 | { |
113 | 113 | $old = self::$cache; |
114 | 114 | self::$cache = (boolean) $value; |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
30 | 30 | * @since 2017.03 |
31 | 31 | */ |
32 | - public function addFilterTypes( \Aimeos\MW\Criteria\Iface $filter, array $codes ) |
|
32 | + public function addFilterTypes(\Aimeos\MW\Criteria\Iface $filter, array $codes) |
|
33 | 33 | { |
34 | - if( !empty( $codes ) ) |
|
34 | + if (!empty($codes)) |
|
35 | 35 | { |
36 | 36 | $expr = [ |
37 | - $filter->compare( '==', 'attribute.type.code', $codes ), |
|
37 | + $filter->compare('==', 'attribute.type.code', $codes), |
|
38 | 38 | $filter->getConditions(), |
39 | 39 | ]; |
40 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
40 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | return $filter; |
@@ -53,15 +53,15 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function createFilter() |
55 | 55 | { |
56 | - $filter = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' )->createSearch( true ); |
|
56 | + $filter = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute')->createSearch(true); |
|
57 | 57 | |
58 | 58 | $expr = array( |
59 | - $filter->compare( '==', 'attribute.domain', 'product' ), |
|
59 | + $filter->compare('==', 'attribute.domain', 'product'), |
|
60 | 60 | $filter->getConditions(), |
61 | 61 | ); |
62 | 62 | |
63 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
64 | - $filter->setSortations( array( $filter->sort( '+', 'attribute.position' ) ) ); |
|
63 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
64 | + $filter->setSortations(array($filter->sort('+', 'attribute.position'))); |
|
65 | 65 | |
66 | 66 | return $filter; |
67 | 67 | } |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | * @return \Aimeos\MShop\Attribute\Item\Iface Attribute item including the referenced domains items |
76 | 76 | * @since 2017.03 |
77 | 77 | */ |
78 | - public function getItem( $id, array $domains = array( 'media', 'price', 'text' ) ) |
|
78 | + public function getItem($id, array $domains = array('media', 'price', 'text')) |
|
79 | 79 | { |
80 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' )->getItem( $id, $domains, true ); |
|
80 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute')->getItem($id, $domains, true); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -89,20 +89,20 @@ discard block |
||
89 | 89 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute item including the referenced domains items |
90 | 90 | * @since 2017.03 |
91 | 91 | */ |
92 | - public function getItems( array $ids, array $domains = array( 'media', 'price', 'text' ) ) |
|
92 | + public function getItems(array $ids, array $domains = array('media', 'price', 'text')) |
|
93 | 93 | { |
94 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
94 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
95 | 95 | |
96 | - $filter = $manager->createSearch( true ); |
|
96 | + $filter = $manager->createSearch(true); |
|
97 | 97 | $expr = [ |
98 | - $filter->compare( '==', 'attribute.domain', 'product' ), |
|
99 | - $filter->compare( '==', 'attribute.id', $ids ), |
|
98 | + $filter->compare('==', 'attribute.domain', 'product'), |
|
99 | + $filter->compare('==', 'attribute.id', $ids), |
|
100 | 100 | $filter->getConditions(), |
101 | 101 | ]; |
102 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
103 | - $filter->setSortations( array( $filter->sort( '+', 'attribute.position' ) ) ); |
|
102 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
103 | + $filter->setSortations(array($filter->sort('+', 'attribute.position'))); |
|
104 | 104 | |
105 | - return $manager->searchItems( $filter, $domains ); |
|
105 | + return $manager->searchItems($filter, $domains); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | * @return array Ordered list of attribute items implementing \Aimeos\MShop\Attribute\Item\Iface |
116 | 116 | * @since 2017.03 |
117 | 117 | */ |
118 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
118 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null) |
|
119 | 119 | { |
120 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' )->searchItems( $filter, $domains, $total ); |
|
120 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute')->searchItems($filter, $domains, $total); |
|
121 | 121 | } |
122 | 122 | } |
@@ -19,112 +19,112 @@ discard block |
||
19 | 19 | public static function setUpBeforeClass() |
20 | 20 | { |
21 | 21 | $context = \TestHelperFrontend::getContext(); |
22 | - self::$testItem = \Aimeos\MShop\Factory::createManager( $context, 'product' )->findItem( 'U:TESTP' ); |
|
22 | + self::$testItem = \Aimeos\MShop\Factory::createManager($context, 'product')->findItem('U:TESTP'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
26 | 26 | protected function setUp() |
27 | 27 | { |
28 | - \Aimeos\MShop\Factory::setCache( true ); |
|
28 | + \Aimeos\MShop\Factory::setCache(true); |
|
29 | 29 | |
30 | 30 | $this->context = \TestHelperFrontend::getContext(); |
31 | - $this->object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
31 | + $this->object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | 35 | protected function tearDown() |
36 | 36 | { |
37 | - \Aimeos\MShop\Factory::setCache( false ); |
|
37 | + \Aimeos\MShop\Factory::setCache(false); |
|
38 | 38 | \Aimeos\MShop\Factory::clear(); |
39 | 39 | |
40 | 40 | $this->object->clear(); |
41 | - $this->context->getSession()->set( 'aimeos', [] ); |
|
41 | + $this->context->getSession()->set('aimeos', []); |
|
42 | 42 | |
43 | - unset( $this->context, $this->object ); |
|
43 | + unset($this->context, $this->object); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
47 | 47 | public function testClear() |
48 | 48 | { |
49 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
49 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
50 | 50 | $this->object->clear(); |
51 | 51 | |
52 | - $this->assertEquals( 0, count( $this->object->get()->getProducts() ) ); |
|
52 | + $this->assertEquals(0, count($this->object->get()->getProducts())); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | 56 | public function testGet() |
57 | 57 | { |
58 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get() ); |
|
58 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get()); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | 62 | public function testSave() |
63 | 63 | { |
64 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
65 | - ->setConstructorArgs( [$this->context] ) |
|
66 | - ->setMethods( ['setSession'] ) |
|
64 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
65 | + ->setConstructorArgs([$this->context]) |
|
66 | + ->setMethods(['setSession']) |
|
67 | 67 | ->getMock(); |
68 | 68 | |
69 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
69 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
70 | 70 | |
71 | - $stub->expects( $this->exactly( 2 ) )->method( 'setSession' ); |
|
71 | + $stub->expects($this->exactly(2))->method('setSession'); |
|
72 | 72 | |
73 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
74 | - $object->addProduct( self::$testItem->getId(), 2 ); |
|
73 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
74 | + $object->addProduct(self::$testItem->getId(), 2); |
|
75 | 75 | $object->save(); |
76 | 76 | } |
77 | 77 | |
78 | 78 | |
79 | 79 | public function testSetType() |
80 | 80 | { |
81 | - $this->assertInstanceOf( '\Aimeos\Controller\Frontend\Basket\Iface', $this->object->setType( 'test' ) ); |
|
81 | + $this->assertInstanceOf('\Aimeos\Controller\Frontend\Basket\Iface', $this->object->setType('test')); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
85 | 85 | public function testStore() |
86 | 86 | { |
87 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
88 | - ->setConstructorArgs( [$this->context] ) |
|
89 | - ->setMethods( ['store'] ) |
|
87 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
88 | + ->setConstructorArgs([$this->context]) |
|
89 | + ->setMethods(['store']) |
|
90 | 90 | ->getMock(); |
91 | 91 | |
92 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
92 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
93 | 93 | |
94 | - $stub->expects( $this->once() )->method( 'store' ); |
|
94 | + $stub->expects($this->once())->method('store'); |
|
95 | 95 | |
96 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
96 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
97 | 97 | $object->store(); |
98 | 98 | } |
99 | 99 | |
100 | 100 | |
101 | 101 | public function testStoreLimit() |
102 | 102 | { |
103 | - $this->context->setEditor( 'core:unittest' ); |
|
103 | + $this->context->setEditor('core:unittest'); |
|
104 | 104 | $config = $this->context->getConfig(); |
105 | - $config->set( 'controller/frontend/basket/limit-count', 0 ); |
|
106 | - $config->set( 'controller/frontend/basket/limit-seconds', 86400 * 365 ); |
|
105 | + $config->set('controller/frontend/basket/limit-count', 0); |
|
106 | + $config->set('controller/frontend/basket/limit-seconds', 86400 * 365); |
|
107 | 107 | |
108 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
108 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
109 | 109 | |
110 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' ); |
|
110 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception'); |
|
111 | 111 | $object->store(); |
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | public function testLoad() |
116 | 116 | { |
117 | - $stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' ) |
|
118 | - ->setConstructorArgs( [$this->context] ) |
|
119 | - ->setMethods( ['load'] ) |
|
117 | + $stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard') |
|
118 | + ->setConstructorArgs([$this->context]) |
|
119 | + ->setMethods(['load']) |
|
120 | 120 | ->getMock(); |
121 | 121 | |
122 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub ); |
|
122 | + \Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub); |
|
123 | 123 | |
124 | - $stub->expects( $this->once() )->method( 'load' ) |
|
125 | - ->will( $this->returnValue( $stub->createItem() ) ); |
|
124 | + $stub->expects($this->once())->method('load') |
|
125 | + ->will($this->returnValue($stub->createItem())); |
|
126 | 126 | |
127 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
127 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
128 | 128 | $object->load( -1 ); |
129 | 129 | } |
130 | 130 | |
@@ -132,250 +132,250 @@ discard block |
||
132 | 132 | public function testAddDeleteProduct() |
133 | 133 | { |
134 | 134 | $basket = $this->object->get(); |
135 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
135 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
136 | 136 | |
137 | - $this->object->addProduct( $item->getId(), 2, [], [], [], [], [], 'default' ); |
|
138 | - $item2 = $this->object->get()->getProduct( 0 ); |
|
139 | - $this->object->deleteProduct( 0 ); |
|
137 | + $this->object->addProduct($item->getId(), 2, [], [], [], [], [], 'default'); |
|
138 | + $item2 = $this->object->get()->getProduct(0); |
|
139 | + $this->object->deleteProduct(0); |
|
140 | 140 | |
141 | - $this->assertEquals( 0, count( $basket->getProducts() ) ); |
|
142 | - $this->assertEquals( 'CNC', $item2->getProductCode() ); |
|
141 | + $this->assertEquals(0, count($basket->getProducts())); |
|
142 | + $this->assertEquals('CNC', $item2->getProductCode()); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
146 | 146 | public function testAddProductCustomAttribute() |
147 | 147 | { |
148 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
148 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
149 | 149 | |
150 | 150 | $search = $attributeManager->createSearch(); |
151 | 151 | $expr = array( |
152 | - $search->compare( '==', 'attribute.code', 'custom' ), |
|
153 | - $search->compare( '==', 'attribute.type.code', 'date' ), |
|
152 | + $search->compare('==', 'attribute.code', 'custom'), |
|
153 | + $search->compare('==', 'attribute.type.code', 'date'), |
|
154 | 154 | ); |
155 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
155 | + $search->setConditions($search->combine('&&', $expr)); |
|
156 | 156 | |
157 | - $attributes = $attributeManager->searchItems( $search ); |
|
157 | + $attributes = $attributeManager->searchItems($search); |
|
158 | 158 | |
159 | - if( ( $attrItem = reset( $attributes ) ) === false ) { |
|
160 | - throw new \RuntimeException( 'Attribute not found' ); |
|
159 | + if (($attrItem = reset($attributes)) === false) { |
|
160 | + throw new \RuntimeException('Attribute not found'); |
|
161 | 161 | } |
162 | 162 | |
163 | - $attrValues = array( $attrItem->getId() => '2000-01-01' ); |
|
163 | + $attrValues = array($attrItem->getId() => '2000-01-01'); |
|
164 | 164 | |
165 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues ); |
|
165 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], [], [], $attrValues); |
|
166 | 166 | $basket = $this->object->get(); |
167 | 167 | |
168 | - $this->assertEquals( 1, count( $basket->getProducts() ) ); |
|
169 | - $this->assertEquals( '2000-01-01', $basket->getProduct( 0 )->getAttribute( 'date', 'custom' ) ); |
|
168 | + $this->assertEquals(1, count($basket->getProducts())); |
|
169 | + $this->assertEquals('2000-01-01', $basket->getProduct(0)->getAttribute('date', 'custom')); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
173 | 173 | public function testAddProductAttributeNotAssigned() |
174 | 174 | { |
175 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
175 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
176 | 176 | |
177 | 177 | $search = $attributeManager->createSearch(); |
178 | 178 | $expr = array( |
179 | - $search->compare( '==', 'attribute.code', '30' ), |
|
180 | - $search->compare( '==', 'attribute.type.code', 'width' ), |
|
179 | + $search->compare('==', 'attribute.code', '30'), |
|
180 | + $search->compare('==', 'attribute.type.code', 'width'), |
|
181 | 181 | ); |
182 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
182 | + $search->setConditions($search->combine('&&', $expr)); |
|
183 | 183 | |
184 | - $attribute = $attributeManager->searchItems( $search ); |
|
184 | + $attribute = $attributeManager->searchItems($search); |
|
185 | 185 | |
186 | - if( empty( $attribute ) ) { |
|
187 | - throw new \RuntimeException( 'Attribute not found' ); |
|
186 | + if (empty($attribute)) { |
|
187 | + throw new \RuntimeException('Attribute not found'); |
|
188 | 188 | } |
189 | 189 | |
190 | - $hiddenAttrIds = array_keys( $attribute ); |
|
191 | - $configAttrIds = array_keys( $attribute ); |
|
190 | + $hiddenAttrIds = array_keys($attribute); |
|
191 | + $configAttrIds = array_keys($attribute); |
|
192 | 192 | |
193 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
194 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], $configAttrIds, $hiddenAttrIds ); |
|
193 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
194 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], $configAttrIds, $hiddenAttrIds); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | |
198 | 198 | public function testAddProductNegativeQuantityException() |
199 | 199 | { |
200 | - $this->setExpectedException( '\\Aimeos\\MShop\\Order\\Exception' ); |
|
201 | - $this->object->addProduct( self::$testItem->getId(), -1 ); |
|
200 | + $this->setExpectedException('\\Aimeos\\MShop\\Order\\Exception'); |
|
201 | + $this->object->addProduct(self::$testItem->getId(), -1); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
205 | 205 | public function testAddProductNoPriceException() |
206 | 206 | { |
207 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'MNOP' ); |
|
207 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('MNOP'); |
|
208 | 208 | |
209 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
210 | - $this->object->addProduct( $item->getId(), 1 ); |
|
209 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
210 | + $this->object->addProduct($item->getId(), 1); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
214 | 214 | public function testAddProductConfigAttributeException() |
215 | 215 | { |
216 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
217 | - $this->object->addProduct( self::$testItem->getId(), 1, [], [], array( -1 ) ); |
|
216 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
217 | + $this->object->addProduct(self::$testItem->getId(), 1, [], [], array( -1 )); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | |
221 | 221 | public function testAddProductLowQuantityPriceException() |
222 | 222 | { |
223 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
223 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
224 | 224 | |
225 | - $this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' ); |
|
226 | - $this->object->addProduct( $item->getId(), 1 ); |
|
225 | + $this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception'); |
|
226 | + $this->object->addProduct($item->getId(), 1); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | |
230 | 230 | public function testAddProductHigherQuantities() |
231 | 231 | { |
232 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' ); |
|
232 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL'); |
|
233 | 233 | |
234 | - $this->object->addProduct( $item->getId(), 2, [], [], [], [], [], 'unit_type3' ); |
|
234 | + $this->object->addProduct($item->getId(), 2, [], [], [], [], [], 'unit_type3'); |
|
235 | 235 | |
236 | - $this->assertEquals( 2, $this->object->get()->getProduct( 0 )->getQuantity() ); |
|
237 | - $this->assertEquals( 'IJKL', $this->object->get()->getProduct( 0 )->getProductCode() ); |
|
236 | + $this->assertEquals(2, $this->object->get()->getProduct(0)->getQuantity()); |
|
237 | + $this->assertEquals('IJKL', $this->object->get()->getProduct(0)->getProductCode()); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
241 | 241 | public function testDeleteProductFlagError() |
242 | 242 | { |
243 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
243 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
244 | 244 | |
245 | - $item = $this->object->get()->getProduct( 0 ); |
|
246 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
245 | + $item = $this->object->get()->getProduct(0); |
|
246 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
247 | 247 | |
248 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
249 | - $this->object->deleteProduct( 0 ); |
|
248 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
249 | + $this->object->deleteProduct(0); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
253 | 253 | public function testEditProduct() |
254 | 254 | { |
255 | - $this->object->addProduct( self::$testItem->getId(), 1 ); |
|
255 | + $this->object->addProduct(self::$testItem->getId(), 1); |
|
256 | 256 | |
257 | - $item = $this->object->get()->getProduct( 0 ); |
|
258 | - $this->assertEquals( 1, $item->getQuantity() ); |
|
257 | + $item = $this->object->get()->getProduct(0); |
|
258 | + $this->assertEquals(1, $item->getQuantity()); |
|
259 | 259 | |
260 | - $this->object->editProduct( 0, 4 ); |
|
260 | + $this->object->editProduct(0, 4); |
|
261 | 261 | |
262 | - $item = $this->object->get()->getProduct( 0 ); |
|
263 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
264 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
262 | + $item = $this->object->get()->getProduct(0); |
|
263 | + $this->assertEquals(4, $item->getQuantity()); |
|
264 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
268 | 268 | public function testEditProductAttributes() |
269 | 269 | { |
270 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' ); |
|
270 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute'); |
|
271 | 271 | |
272 | 272 | $search = $attributeManager->createSearch(); |
273 | 273 | $conditions = array( |
274 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
275 | - $search->combine( '||', array( |
|
276 | - $search->combine( '&&', array( |
|
277 | - $search->compare( '==', 'attribute.code', 'xs' ), |
|
278 | - $search->compare( '==', 'attribute.type.code', 'size' ), |
|
279 | - ) ), |
|
280 | - $search->combine( '&&', array( |
|
281 | - $search->compare( '==', 'attribute.code', 'white' ), |
|
282 | - $search->compare( '==', 'attribute.type.code', 'color' ), |
|
283 | - ) ), |
|
284 | - ) ) |
|
274 | + $search->compare('==', 'attribute.domain', 'product'), |
|
275 | + $search->combine('||', array( |
|
276 | + $search->combine('&&', array( |
|
277 | + $search->compare('==', 'attribute.code', 'xs'), |
|
278 | + $search->compare('==', 'attribute.type.code', 'size'), |
|
279 | + )), |
|
280 | + $search->combine('&&', array( |
|
281 | + $search->compare('==', 'attribute.code', 'white'), |
|
282 | + $search->compare('==', 'attribute.type.code', 'color'), |
|
283 | + )), |
|
284 | + )) |
|
285 | 285 | ); |
286 | - $search->setConditions( $search->combine( '&&', $conditions ) ); |
|
287 | - $attributes = $attributeManager->searchItems( $search ); |
|
286 | + $search->setConditions($search->combine('&&', $conditions)); |
|
287 | + $attributes = $attributeManager->searchItems($search); |
|
288 | 288 | |
289 | - if( ( $attribute = reset( $attributes ) ) === false ) { |
|
290 | - throw new \RuntimeException( 'No attributes available' ); |
|
289 | + if (($attribute = reset($attributes)) === false) { |
|
290 | + throw new \RuntimeException('No attributes available'); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | |
294 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' ); |
|
294 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP'); |
|
295 | 295 | |
296 | - $this->object->addProduct( $item->getId(), 1, [], [], array_keys( $attributes ) ); |
|
297 | - $this->object->editProduct( 0, 4 ); |
|
296 | + $this->object->addProduct($item->getId(), 1, [], [], array_keys($attributes)); |
|
297 | + $this->object->editProduct(0, 4); |
|
298 | 298 | |
299 | - $item = $this->object->get()->getProduct( 0 ); |
|
300 | - $this->assertEquals( 2, count( $item->getAttributes() ) ); |
|
301 | - $this->assertEquals( 4, $item->getQuantity() ); |
|
299 | + $item = $this->object->get()->getProduct(0); |
|
300 | + $this->assertEquals(2, count($item->getAttributes())); |
|
301 | + $this->assertEquals(4, $item->getQuantity()); |
|
302 | 302 | |
303 | 303 | |
304 | - $this->object->editProduct( 0, 3, [], array( $attribute->getType() ) ); |
|
304 | + $this->object->editProduct(0, 3, [], array($attribute->getType())); |
|
305 | 305 | |
306 | - $item = $this->object->get()->getProduct( 0 ); |
|
307 | - $this->assertEquals( 3, $item->getQuantity() ); |
|
308 | - $this->assertEquals( 1, count( $item->getAttributes() ) ); |
|
309 | - $this->assertEquals( 'U:TESTP', $item->getProductCode() ); |
|
306 | + $item = $this->object->get()->getProduct(0); |
|
307 | + $this->assertEquals(3, $item->getQuantity()); |
|
308 | + $this->assertEquals(1, count($item->getAttributes())); |
|
309 | + $this->assertEquals('U:TESTP', $item->getProductCode()); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | |
313 | 313 | public function testEditProductFlagError() |
314 | 314 | { |
315 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
315 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
316 | 316 | |
317 | - $item = $this->object->get()->getProduct( 0 ); |
|
318 | - $item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
|
317 | + $item = $this->object->get()->getProduct(0); |
|
318 | + $item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE); |
|
319 | 319 | |
320 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
321 | - $this->object->editProduct( 0, 4 ); |
|
320 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
321 | + $this->object->editProduct(0, 4); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | |
325 | 325 | public function testAddCoupon() |
326 | 326 | { |
327 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
328 | - $this->object->addCoupon( 'GHIJ' ); |
|
327 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
328 | + $this->object->addCoupon('GHIJ'); |
|
329 | 329 | |
330 | 330 | $basket = $this->object->get(); |
331 | 331 | |
332 | - $this->assertEquals( 1, count( $basket->getCoupons() ) ); |
|
332 | + $this->assertEquals(1, count($basket->getCoupons())); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
336 | 336 | public function testAddCouponInvalidCode() |
337 | 337 | { |
338 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
339 | - $this->object->addCoupon( 'invalid' ); |
|
338 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
339 | + $this->object->addCoupon('invalid'); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | |
343 | 343 | public function testAddCouponMissingRequirements() |
344 | 344 | { |
345 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
346 | - $this->object->addCoupon( 'OPQR' ); |
|
345 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
346 | + $this->object->addCoupon('OPQR'); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
350 | 350 | public function testDeleteCoupon() |
351 | 351 | { |
352 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
353 | - $this->object->addCoupon( '90AB' ); |
|
354 | - $this->object->deleteCoupon( '90AB' ); |
|
352 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
353 | + $this->object->addCoupon('90AB'); |
|
354 | + $this->object->deleteCoupon('90AB'); |
|
355 | 355 | |
356 | 356 | $basket = $this->object->get(); |
357 | 357 | |
358 | - $this->assertEquals( 0, count( $basket->getCoupons() ) ); |
|
358 | + $this->assertEquals(0, count($basket->getCoupons())); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | |
362 | 362 | public function testSetAddressDelete() |
363 | 363 | { |
364 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null ); |
|
364 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null); |
|
365 | 365 | |
366 | - $this->setExpectedException( '\Aimeos\MShop\Order\Exception' ); |
|
367 | - $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
366 | + $this->setExpectedException('\Aimeos\MShop\Order\Exception'); |
|
367 | + $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | |
371 | 371 | public function testSetBillingAddressByItem() |
372 | 372 | { |
373 | - $item = $this->getAddress( 'Example company' ); |
|
373 | + $item = $this->getAddress('Example company'); |
|
374 | 374 | |
375 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item ); |
|
375 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item); |
|
376 | 376 | |
377 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
378 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
377 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
378 | + $this->assertEquals('Example company', $address->getCompany()); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | |
@@ -403,37 +403,37 @@ discard block |
||
403 | 403 | 'order.base.address.flag' => 0, |
404 | 404 | ); |
405 | 405 | |
406 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture ); |
|
406 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture); |
|
407 | 407 | |
408 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
409 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
410 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
411 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
408 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
409 | + $this->assertEquals('Example company', $address->getCompany()); |
|
410 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
411 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | |
415 | 415 | public function testSetBillingAddressByArrayError() |
416 | 416 | { |
417 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
418 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array( 'error' => false ) ); |
|
417 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
418 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array('error' => false)); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | |
422 | 422 | public function testSetBillingAddressParameterError() |
423 | 423 | { |
424 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
425 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error' ); |
|
424 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
425 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error'); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | |
429 | 429 | public function testSetDeliveryAddressByItem() |
430 | 430 | { |
431 | - $item = $this->getAddress( 'Example company' ); |
|
431 | + $item = $this->getAddress('Example company'); |
|
432 | 432 | |
433 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item ); |
|
433 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item); |
|
434 | 434 | |
435 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
436 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
435 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
436 | + $this->assertEquals('Example company', $address->getCompany()); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | |
@@ -460,119 +460,119 @@ discard block |
||
460 | 460 | 'order.base.address.website' => 'www.example.com', |
461 | 461 | 'order.base.address.flag' => 0, |
462 | 462 | ); |
463 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture ); |
|
463 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture); |
|
464 | 464 | |
465 | - $address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY ); |
|
466 | - $this->assertEquals( 'Example company', $address->getCompany() ); |
|
467 | - $this->assertEquals( 'Dr.', $address->getTitle() ); |
|
468 | - $this->assertEquals( 'firstunit', $address->getFirstname() ); |
|
465 | + $address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY); |
|
466 | + $this->assertEquals('Example company', $address->getCompany()); |
|
467 | + $this->assertEquals('Dr.', $address->getTitle()); |
|
468 | + $this->assertEquals('firstunit', $address->getFirstname()); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | |
472 | 472 | public function testSetDeliveryAddressByArrayError() |
473 | 473 | { |
474 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
475 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array( 'error' => false ) ); |
|
474 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
475 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array('error' => false)); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
479 | 479 | public function testSetDeliveryAddressTypeError() |
480 | 480 | { |
481 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
482 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error' ); |
|
481 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
482 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error'); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | |
486 | 486 | public function testSetServicePayment() |
487 | 487 | { |
488 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
489 | - $service = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
488 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
489 | + $service = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
490 | 490 | |
491 | - $this->object->setService( 'payment', $service->getId(), [] ); |
|
492 | - $this->assertEquals( 'unitpaymentcode', $this->object->get()->getService( 'payment' )->getCode() ); |
|
491 | + $this->object->setService('payment', $service->getId(), []); |
|
492 | + $this->assertEquals('unitpaymentcode', $this->object->get()->getService('payment')->getCode()); |
|
493 | 493 | |
494 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
495 | - $this->object->setService( 'payment', $service->getId(), array( 'prepay' => true ) ); |
|
494 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
495 | + $this->object->setService('payment', $service->getId(), array('prepay' => true)); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | |
499 | 499 | public function testSetDeliveryOption() |
500 | 500 | { |
501 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
502 | - $service = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
501 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
502 | + $service = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
503 | 503 | |
504 | - $this->object->setService( 'delivery', $service->getId(), [] ); |
|
505 | - $this->assertEquals( 'unitcode', $this->object->get()->getService( 'delivery' )->getCode() ); |
|
504 | + $this->object->setService('delivery', $service->getId(), []); |
|
505 | + $this->assertEquals('unitcode', $this->object->get()->getService('delivery')->getCode()); |
|
506 | 506 | |
507 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' ); |
|
508 | - $this->object->setService( 'delivery', $service->getId(), array( 'fast shipping' => true, 'air shipping' => false ) ); |
|
507 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception'); |
|
508 | + $this->object->setService('delivery', $service->getId(), array('fast shipping' => true, 'air shipping' => false)); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
512 | 512 | public function testCheckLocale() |
513 | 513 | { |
514 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
515 | - $payment = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' ); |
|
516 | - $delivery = $manager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
514 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
515 | + $payment = $manager->findItem('unitpaymentcode', [], 'service', 'payment'); |
|
516 | + $delivery = $manager->findItem('unitcode', [], 'service', 'delivery'); |
|
517 | 517 | |
518 | - $this->object->addProduct( self::$testItem->getId(), 2 ); |
|
519 | - $this->object->addCoupon( 'OPQR' ); |
|
518 | + $this->object->addProduct(self::$testItem->getId(), 2); |
|
519 | + $this->object->addCoupon('OPQR'); |
|
520 | 520 | |
521 | - $this->object->setService( 'payment', $payment->getId() ); |
|
522 | - $this->object->setService( 'delivery', $delivery->getId() ); |
|
521 | + $this->object->setService('payment', $payment->getId()); |
|
522 | + $this->object->setService('delivery', $delivery->getId()); |
|
523 | 523 | |
524 | 524 | $basket = $this->object->get(); |
525 | 525 | $price = $basket->getPrice(); |
526 | 526 | |
527 | - foreach( $basket->getProducts() as $product ) |
|
527 | + foreach ($basket->getProducts() as $product) |
|
528 | 528 | { |
529 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
530 | - $product->getPrice()->setCurrencyId( 'CHF' ); |
|
529 | + $this->assertEquals(2, $product->getQuantity()); |
|
530 | + $product->getPrice()->setCurrencyId('CHF'); |
|
531 | 531 | } |
532 | 532 | |
533 | - $basket->getService( 'delivery' )->getPrice()->setCurrencyId( 'CHF' ); |
|
534 | - $basket->getService( 'payment' )->getPrice()->setCurrencyId( 'CHF' ); |
|
535 | - $basket->getLocale()->setCurrencyId( 'CHF' ); |
|
536 | - $price->setCurrencyId( 'CHF' ); |
|
533 | + $basket->getService('delivery')->getPrice()->setCurrencyId('CHF'); |
|
534 | + $basket->getService('payment')->getPrice()->setCurrencyId('CHF'); |
|
535 | + $basket->getLocale()->setCurrencyId('CHF'); |
|
536 | + $price->setCurrencyId('CHF'); |
|
537 | 537 | |
538 | - $this->context->getLocale()->setCurrencyId( 'CHF' ); |
|
539 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress( 'Example company' ) ); |
|
538 | + $this->context->getLocale()->setCurrencyId('CHF'); |
|
539 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress('Example company')); |
|
540 | 540 | |
541 | - $this->context->getSession()->set( 'aimeos/basket/currency', 'CHF' ); |
|
542 | - $this->context->getLocale()->setCurrencyId( 'EUR' ); |
|
541 | + $this->context->getSession()->set('aimeos/basket/currency', 'CHF'); |
|
542 | + $this->context->getLocale()->setCurrencyId('EUR'); |
|
543 | 543 | |
544 | - $this->context->getSession()->set( 'aimeos/basket/content-unittest-en-EUR-', null ); |
|
544 | + $this->context->getSession()->set('aimeos/basket/content-unittest-en-EUR-', null); |
|
545 | 545 | |
546 | - $object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context ); |
|
546 | + $object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context); |
|
547 | 547 | $basket = $object->get(); |
548 | 548 | |
549 | - foreach( $basket->getProducts() as $product ) |
|
549 | + foreach ($basket->getProducts() as $product) |
|
550 | 550 | { |
551 | - $this->assertEquals( 'EUR', $product->getPrice()->getCurrencyId() ); |
|
552 | - $this->assertEquals( 2, $product->getQuantity() ); |
|
551 | + $this->assertEquals('EUR', $product->getPrice()->getCurrencyId()); |
|
552 | + $this->assertEquals(2, $product->getQuantity()); |
|
553 | 553 | } |
554 | 554 | |
555 | - $this->assertEquals( 'EUR', $basket->getService( 'payment' )->getPrice()->getCurrencyId() ); |
|
556 | - $this->assertEquals( 'EUR', $basket->getService( 'delivery' )->getPrice()->getCurrencyId() ); |
|
557 | - $this->assertEquals( 'EUR', $basket->getLocale()->getCurrencyId() ); |
|
558 | - $this->assertEquals( 'EUR', $basket->getPrice()->getCurrencyId() ); |
|
555 | + $this->assertEquals('EUR', $basket->getService('payment')->getPrice()->getCurrencyId()); |
|
556 | + $this->assertEquals('EUR', $basket->getService('delivery')->getPrice()->getCurrencyId()); |
|
557 | + $this->assertEquals('EUR', $basket->getLocale()->getCurrencyId()); |
|
558 | + $this->assertEquals('EUR', $basket->getPrice()->getCurrencyId()); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | |
562 | 562 | /** |
563 | 563 | * @param string $company |
564 | 564 | */ |
565 | - protected function getAddress( $company ) |
|
565 | + protected function getAddress($company) |
|
566 | 566 | { |
567 | - $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager( \TestHelperFrontend::getContext(), 'Standard' ); |
|
568 | - $addressManager = $customer->getSubManager( 'address', 'Standard' ); |
|
567 | + $customer = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelperFrontend::getContext(), 'Standard'); |
|
568 | + $addressManager = $customer->getSubManager('address', 'Standard'); |
|
569 | 569 | |
570 | 570 | $search = $addressManager->createSearch(); |
571 | - $search->setConditions( $search->compare( '==', 'customer.address.company', $company ) ); |
|
572 | - $items = $addressManager->searchItems( $search ); |
|
571 | + $search->setConditions($search->compare('==', 'customer.address.company', $company)); |
|
572 | + $items = $addressManager->searchItems($search); |
|
573 | 573 | |
574 | - if( ( $item = reset( $items ) ) === false ) { |
|
575 | - throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) ); |
|
574 | + if (($item = reset($items)) === false) { |
|
575 | + throw new \RuntimeException(sprintf('No address item with company "%1$s" found', $company)); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | return $item; |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | * @param string[] $attributes List of attribute codes as keys and strings entered by the customer as value |
36 | 36 | * @return string[] List of attributes codes as keys and error messages as values for invalid or missing values |
37 | 37 | */ |
38 | - public function checkAttributes( $serviceId, array $attributes ) |
|
38 | + public function checkAttributes($serviceId, array $attributes) |
|
39 | 39 | { |
40 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service' ); |
|
41 | - $provider = $manager->getProvider( $manager->getItem( $serviceId, [], true ) ); |
|
40 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service'); |
|
41 | + $provider = $manager->getProvider($manager->getItem($serviceId, [], true)); |
|
42 | 42 | |
43 | - return array_filter( $provider->checkConfigFE( $attributes ) ); |
|
43 | + return array_filter($provider->checkConfigFE($attributes)); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | * @param string[] $ref List of domain names whose items should be fetched too |
52 | 52 | * @return \Aimeos\MShop\Service\Provider\Iface Service provider object |
53 | 53 | */ |
54 | - public function getProvider( $serviceId, $ref = ['media', 'price', 'text'] ) |
|
54 | + public function getProvider($serviceId, $ref = ['media', 'price', 'text']) |
|
55 | 55 | { |
56 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service' ); |
|
57 | - return $manager->getProvider( $manager->getItem( $serviceId, $ref, true ) ); |
|
56 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service'); |
|
57 | + return $manager->getProvider($manager->getItem($serviceId, $ref, true)); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -65,26 +65,26 @@ discard block |
||
65 | 65 | * @param string[] $ref List of domain names whose items should be fetched too |
66 | 66 | * @return \Aimeos\MShop\Service\Provider\Iface[] List of service IDs as keys and service provider objects as values |
67 | 67 | */ |
68 | - public function getProviders( $type = null, $ref = ['media', 'price', 'text'] ) |
|
68 | + public function getProviders($type = null, $ref = ['media', 'price', 'text']) |
|
69 | 69 | { |
70 | 70 | $list = []; |
71 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service' ); |
|
71 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service'); |
|
72 | 72 | |
73 | - $search = $manager->createSearch( true ); |
|
74 | - $search->setSortations( array( $search->sort( '+', 'service.position' ) ) ); |
|
73 | + $search = $manager->createSearch(true); |
|
74 | + $search->setSortations(array($search->sort('+', 'service.position'))); |
|
75 | 75 | |
76 | - if( $type != null ) |
|
76 | + if ($type != null) |
|
77 | 77 | { |
78 | 78 | $expr = array( |
79 | 79 | $search->getConditions(), |
80 | - $search->compare( '==', 'service.type.code', $type ), |
|
81 | - $search->compare( '==', 'service.type.domain', 'service' ), |
|
80 | + $search->compare('==', 'service.type.code', $type), |
|
81 | + $search->compare('==', 'service.type.domain', 'service'), |
|
82 | 82 | ); |
83 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
83 | + $search->setConditions($search->combine('&&', $expr)); |
|
84 | 84 | } |
85 | 85 | |
86 | - foreach( $manager->searchItems( $search, $ref ) as $id => $item ) { |
|
87 | - $list[$id] = $manager->getProvider( $item ); |
|
86 | + foreach ($manager->searchItems($search, $ref) as $id => $item) { |
|
87 | + $list[$id] = $manager->getProvider($item); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | return $list; |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | * @return \Aimeos\MShop\Common\Item\Helper\Form\Iface|null Form object with URL, parameters, etc. |
103 | 103 | * or null if no form data is required |
104 | 104 | */ |
105 | - public function process( \Aimeos\MShop\Order\Item\Iface $orderItem, $serviceId, array $urls, array $params ) |
|
105 | + public function process(\Aimeos\MShop\Order\Item\Iface $orderItem, $serviceId, array $urls, array $params) |
|
106 | 106 | { |
107 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service' ); |
|
107 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service'); |
|
108 | 108 | |
109 | - $provider = $manager->getProvider( $manager->getItem( $serviceId, [], true ) ); |
|
110 | - $provider->injectGlobalConfigBE( $urls ); |
|
109 | + $provider = $manager->getProvider($manager->getItem($serviceId, [], true)); |
|
110 | + $provider->injectGlobalConfigBE($urls); |
|
111 | 111 | |
112 | - return $provider->process( $orderItem, $params ); |
|
112 | + return $provider->process($orderItem, $params); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
@@ -122,41 +122,41 @@ discard block |
||
122 | 122 | * (keys are <type>.url-self, <type>.url-success, <type>.url-update where type can be "delivery" or "payment") |
123 | 123 | * @return \Aimeos\MShop\Order\Item\Iface $orderItem Order item that has been updated |
124 | 124 | */ |
125 | - public function updateSync( ServerRequestInterface $request, ResponseInterface $response, array $urls ) |
|
125 | + public function updateSync(ServerRequestInterface $request, ResponseInterface $response, array $urls) |
|
126 | 126 | { |
127 | 127 | $params = (array) $request->getAttributes() + (array) $request->getParsedBody() + (array) $request->getQueryParams(); |
128 | 128 | |
129 | - if( !isset( $params['code'] ) ) { |
|
129 | + if (!isset($params['code'])) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
133 | 133 | $context = $this->getContext(); |
134 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
134 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
135 | 135 | |
136 | - $provider = $manager->getProvider( $manager->findItem( $params['code'] ) ); |
|
137 | - $provider->injectGlobalConfigBE( $urls ); |
|
136 | + $provider = $manager->getProvider($manager->findItem($params['code'])); |
|
137 | + $provider->injectGlobalConfigBE($urls); |
|
138 | 138 | |
139 | 139 | $body = (string) $request->getBody(); |
140 | 140 | $output = null; |
141 | 141 | $headers = []; |
142 | 142 | |
143 | - if( ( $orderItem = $provider->updateSync( $params, $body, $output, $headers ) ) !== null ) |
|
143 | + if (($orderItem = $provider->updateSync($params, $body, $output, $headers)) !== null) |
|
144 | 144 | { |
145 | - if( $orderItem->getPaymentStatus() === \Aimeos\MShop\Order\Item\Base::PAY_UNFINISHED |
|
146 | - && $provider->isImplemented( \Aimeos\MShop\Service\Provider\Payment\Base::FEAT_QUERY ) |
|
145 | + if ($orderItem->getPaymentStatus() === \Aimeos\MShop\Order\Item\Base::PAY_UNFINISHED |
|
146 | + && $provider->isImplemented(\Aimeos\MShop\Service\Provider\Payment\Base::FEAT_QUERY) |
|
147 | 147 | ) { |
148 | - $provider->query( $orderItem ); |
|
148 | + $provider->query($orderItem); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | // update stock, coupons, etc. |
152 | - \Aimeos\Controller\Frontend\Factory::createController( $context, 'order' )->update( $orderItem ); |
|
152 | + \Aimeos\Controller\Frontend\Factory::createController($context, 'order')->update($orderItem); |
|
153 | 153 | } |
154 | 154 | |
155 | - foreach( $headers as $name => $header ) { |
|
156 | - $response->withHeader( $name, $header ); |
|
155 | + foreach ($headers as $name => $header) { |
|
156 | + $response->withHeader($name, $header); |
|
157 | 157 | } |
158 | 158 | |
159 | - $response->withBody( $response->createStreamFromString( $output ) ); |
|
159 | + $response->withBody($response->createStreamFromString($output)); |
|
160 | 160 | |
161 | 161 | return $orderItem; |
162 | 162 | } |
@@ -172,38 +172,38 @@ discard block |
||
172 | 172 | * @throws \Exception If an error occurs |
173 | 173 | * @deprecated Use getProviders() instead |
174 | 174 | */ |
175 | - public function getServices( $type, \Aimeos\MShop\Order\Item\Base\Iface $basket, $ref = ['media', 'price', 'text'] ) |
|
175 | + public function getServices($type, \Aimeos\MShop\Order\Item\Base\Iface $basket, $ref = ['media', 'price', 'text']) |
|
176 | 176 | { |
177 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service' ); |
|
177 | + $serviceManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service'); |
|
178 | 178 | |
179 | - $search = $serviceManager->createSearch( true ); |
|
179 | + $search = $serviceManager->createSearch(true); |
|
180 | 180 | $expr = array( |
181 | 181 | $search->getConditions(), |
182 | - $search->compare( '==', 'service.type.domain', 'service' ), |
|
183 | - $search->compare( '==', 'service.type.code', $type ), |
|
182 | + $search->compare('==', 'service.type.domain', 'service'), |
|
183 | + $search->compare('==', 'service.type.code', $type), |
|
184 | 184 | ); |
185 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
186 | - $search->setSortations( array( $search->sort( '+', 'service.position' ) ) ); |
|
185 | + $search->setConditions($search->combine('&&', $expr)); |
|
186 | + $search->setSortations(array($search->sort('+', 'service.position'))); |
|
187 | 187 | |
188 | - $items = $serviceManager->searchItems( $search, $ref ); |
|
188 | + $items = $serviceManager->searchItems($search, $ref); |
|
189 | 189 | |
190 | 190 | |
191 | - foreach( $items as $id => $service ) |
|
191 | + foreach ($items as $id => $service) |
|
192 | 192 | { |
193 | 193 | try |
194 | 194 | { |
195 | - $provider = $serviceManager->getProvider( $service ); |
|
195 | + $provider = $serviceManager->getProvider($service); |
|
196 | 196 | |
197 | - if( $provider->isAvailable( $basket ) ) { |
|
197 | + if ($provider->isAvailable($basket)) { |
|
198 | 198 | $this->providers[$type][$id] = $provider; |
199 | 199 | } else { |
200 | - unset( $items[$id] ); |
|
200 | + unset($items[$id]); |
|
201 | 201 | } |
202 | 202 | } |
203 | - catch( \Aimeos\MShop\Service\Exception $e ) |
|
203 | + catch (\Aimeos\MShop\Service\Exception $e) |
|
204 | 204 | { |
205 | - $msg = sprintf( 'Unable to create provider "%1$s" for service with ID "%2$s"', $service->getCode(), $id ); |
|
206 | - $this->getContext()->getLogger()->log( $msg, \Aimeos\MW\Logger\Base::WARN ); |
|
205 | + $msg = sprintf('Unable to create provider "%1$s" for service with ID "%2$s"', $service->getCode(), $id); |
|
206 | + $this->getContext()->getLogger()->log($msg, \Aimeos\MW\Logger\Base::WARN); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -224,16 +224,16 @@ discard block |
||
224 | 224 | * @throws \Exception If an error occurs |
225 | 225 | * @deprecated Use getProvider() instead |
226 | 226 | */ |
227 | - public function getServiceAttributes( $type, $serviceId, \Aimeos\MShop\Order\Item\Base\Iface $basket ) |
|
227 | + public function getServiceAttributes($type, $serviceId, \Aimeos\MShop\Order\Item\Base\Iface $basket) |
|
228 | 228 | { |
229 | - if( isset( $this->providers[$type][$serviceId] ) ) { |
|
230 | - return $this->providers[$type][$serviceId]->getConfigFE( $basket ); |
|
229 | + if (isset($this->providers[$type][$serviceId])) { |
|
230 | + return $this->providers[$type][$serviceId]->getConfigFE($basket); |
|
231 | 231 | } |
232 | 232 | |
233 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service' ); |
|
234 | - $item = $serviceManager->getItem( $serviceId, ['price'], true ); |
|
233 | + $serviceManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service'); |
|
234 | + $item = $serviceManager->getItem($serviceId, ['price'], true); |
|
235 | 235 | |
236 | - return $serviceManager->getProvider( $item )->getConfigFE( $basket ); |
|
236 | + return $serviceManager->getProvider($item)->getConfigFE($basket); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | |
@@ -249,16 +249,16 @@ discard block |
||
249 | 249 | * @throws \Exception If an error occurs |
250 | 250 | * @deprecated Use getProvider() instead |
251 | 251 | */ |
252 | - public function getServicePrice( $type, $serviceId, \Aimeos\MShop\Order\Item\Base\Iface $basket ) |
|
252 | + public function getServicePrice($type, $serviceId, \Aimeos\MShop\Order\Item\Base\Iface $basket) |
|
253 | 253 | { |
254 | - if( isset( $this->providers[$type][$serviceId] ) ) { |
|
255 | - return $this->providers[$type][$serviceId]->calcPrice( $basket ); |
|
254 | + if (isset($this->providers[$type][$serviceId])) { |
|
255 | + return $this->providers[$type][$serviceId]->calcPrice($basket); |
|
256 | 256 | } |
257 | 257 | |
258 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service' ); |
|
259 | - $item = $serviceManager->getItem( $serviceId, ['price'], true ); |
|
258 | + $serviceManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service'); |
|
259 | + $item = $serviceManager->getItem($serviceId, ['price'], true); |
|
260 | 260 | |
261 | - return $serviceManager->getProvider( $item )->calcPrice( $basket ); |
|
261 | + return $serviceManager->getProvider($item)->calcPrice($basket); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -274,22 +274,22 @@ discard block |
||
274 | 274 | * @throws \Aimeos\Controller\Frontend\Service\Exception If no active service provider for this ID is available |
275 | 275 | * @deprecated Use checkAttributes() instead |
276 | 276 | */ |
277 | - public function checkServiceAttributes( $type, $serviceId, array $attributes ) |
|
277 | + public function checkServiceAttributes($type, $serviceId, array $attributes) |
|
278 | 278 | { |
279 | - if( !isset( $this->providers[$type][$serviceId] ) ) |
|
279 | + if (!isset($this->providers[$type][$serviceId])) |
|
280 | 280 | { |
281 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service' ); |
|
282 | - $item = $serviceManager->getItem( $serviceId, ['price'], true ); |
|
281 | + $serviceManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service'); |
|
282 | + $item = $serviceManager->getItem($serviceId, ['price'], true); |
|
283 | 283 | |
284 | - $this->providers[$type][$serviceId] = $serviceManager->getProvider( $item ); |
|
284 | + $this->providers[$type][$serviceId] = $serviceManager->getProvider($item); |
|
285 | 285 | } |
286 | 286 | |
287 | - $errors = $this->providers[$type][$serviceId]->checkConfigFE( $attributes ); |
|
287 | + $errors = $this->providers[$type][$serviceId]->checkConfigFE($attributes); |
|
288 | 288 | |
289 | - foreach( $errors as $key => $msg ) |
|
289 | + foreach ($errors as $key => $msg) |
|
290 | 290 | { |
291 | - if( $msg === null ) { |
|
292 | - unset( $errors[$key] ); |
|
291 | + if ($msg === null) { |
|
292 | + unset($errors[$key]); |
|
293 | 293 | } |
294 | 294 | } |
295 | 295 |
@@ -17,125 +17,125 @@ discard block |
||
17 | 17 | |
18 | 18 | protected function setUp() |
19 | 19 | { |
20 | - \Aimeos\MShop\Factory::setCache( true ); |
|
20 | + \Aimeos\MShop\Factory::setCache(true); |
|
21 | 21 | |
22 | 22 | $this->context = \TestHelperFrontend::getContext(); |
23 | - $this->object = new \Aimeos\Controller\Frontend\Service\Standard( $this->context ); |
|
23 | + $this->object = new \Aimeos\Controller\Frontend\Service\Standard($this->context); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
27 | 27 | public static function setUpBeforeClass() |
28 | 28 | { |
29 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
30 | - $orderBaseMgr = $orderManager->getSubManager( 'base' ); |
|
29 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
30 | + $orderBaseMgr = $orderManager->getSubManager('base'); |
|
31 | 31 | self::$basket = $orderBaseMgr->createItem(); |
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | 35 | protected function tearDown() |
36 | 36 | { |
37 | - unset( $this->object, $this->context ); |
|
37 | + unset($this->object, $this->context); |
|
38 | 38 | |
39 | - \Aimeos\MShop\Factory::setCache( false ); |
|
39 | + \Aimeos\MShop\Factory::setCache(false); |
|
40 | 40 | \Aimeos\MShop\Factory::clear(); |
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | 44 | public function testCheckAttributes() |
45 | 45 | { |
46 | - $attributes = $this->object->checkAttributes( $this->getServiceItem()->getId(), [] ); |
|
47 | - $this->assertEquals( [], $attributes ); |
|
46 | + $attributes = $this->object->checkAttributes($this->getServiceItem()->getId(), []); |
|
47 | + $this->assertEquals([], $attributes); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
51 | 51 | public function testGetProviders() |
52 | 52 | { |
53 | - $providers = $this->object->getProviders( 'delivery' ); |
|
54 | - $this->assertGreaterThan( 0, count( $providers ) ); |
|
53 | + $providers = $this->object->getProviders('delivery'); |
|
54 | + $this->assertGreaterThan(0, count($providers)); |
|
55 | 55 | |
56 | - foreach( $providers as $provider ) { |
|
57 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Service\\Provider\\Iface', $provider ); |
|
56 | + foreach ($providers as $provider) { |
|
57 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Service\\Provider\\Iface', $provider); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | 62 | public function testGetProvider() |
63 | 63 | { |
64 | - $provider = $this->object->getProvider( $this->getServiceItem()->getId() ); |
|
65 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Service\\Provider\\Iface', $provider ); |
|
64 | + $provider = $this->object->getProvider($this->getServiceItem()->getId()); |
|
65 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Service\\Provider\\Iface', $provider); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | 69 | public function testProcess() |
70 | 70 | { |
71 | 71 | $form = new \Aimeos\MShop\Common\Item\Helper\Form\Standard(); |
72 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem(); |
|
73 | - $serviceId = \Aimeos\MShop\Factory::createManager( $this->context, 'service' )->findItem( 'unitcode' )->getId(); |
|
72 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem(); |
|
73 | + $serviceId = \Aimeos\MShop\Factory::createManager($this->context, 'service')->findItem('unitcode')->getId(); |
|
74 | 74 | |
75 | - $provider = $this->getMockBuilder( '\\Aimeos\\MShop\\Service\\Provider\\Delivery\\Standard' ) |
|
75 | + $provider = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Provider\\Delivery\\Standard') |
|
76 | 76 | ->disableOriginalConstructor() |
77 | - ->setMethods( ['process'] ) |
|
77 | + ->setMethods(['process']) |
|
78 | 78 | ->getMock(); |
79 | 79 | |
80 | - $manager = $this->getMockBuilder( '\\Aimeos\\MShop\\Service\\Manager\\Standard' ) |
|
81 | - ->setConstructorArgs( [$this->context] ) |
|
82 | - ->setMethods( ['getProvider'] ) |
|
80 | + $manager = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Manager\\Standard') |
|
81 | + ->setConstructorArgs([$this->context]) |
|
82 | + ->setMethods(['getProvider']) |
|
83 | 83 | ->getMock(); |
84 | 84 | |
85 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'service', $manager ); |
|
85 | + \Aimeos\MShop\Factory::injectManager($this->context, 'service', $manager); |
|
86 | 86 | |
87 | - $provider->expects( $this->once() )->method( 'process' )->will( $this->returnValue( $form ) ); |
|
88 | - $manager->expects( $this->once() )->method( 'getProvider' )->will( $this->returnValue( $provider ) ); |
|
87 | + $provider->expects($this->once())->method('process')->will($this->returnValue($form)); |
|
88 | + $manager->expects($this->once())->method('getProvider')->will($this->returnValue($provider)); |
|
89 | 89 | |
90 | 90 | |
91 | - $result = $this->object->process( $item, $serviceId, [], [] ); |
|
92 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Helper\Form\Iface', $result ); |
|
91 | + $result = $this->object->process($item, $serviceId, [], []); |
|
92 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Helper\Form\Iface', $result); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
96 | 96 | public function testUpdateSync() |
97 | 97 | { |
98 | - $item = \Aimeos\MShop\Factory::createManager( $this->context, 'order' )->createItem(); |
|
98 | + $item = \Aimeos\MShop\Factory::createManager($this->context, 'order')->createItem(); |
|
99 | 99 | |
100 | - $stream = $this->getMockBuilder( 'Psr\Http\Message\StreamInterface' )->getMock(); |
|
101 | - $request = $this->getMockBuilder( '\Psr\Http\Message\ServerRequestInterface' )->getMock(); |
|
102 | - $response = $this->getMockBuilder( '\Aimeos\MW\View\Helper\Response\Iface' ) |
|
100 | + $stream = $this->getMockBuilder('Psr\Http\Message\StreamInterface')->getMock(); |
|
101 | + $request = $this->getMockBuilder('\Psr\Http\Message\ServerRequestInterface')->getMock(); |
|
102 | + $response = $this->getMockBuilder('\Aimeos\MW\View\Helper\Response\Iface') |
|
103 | 103 | ->getMock(); |
104 | 104 | |
105 | - $provider = $this->getMockBuilder( '\\Aimeos\\MShop\\Service\\Provider\\Delivery\\Standard' ) |
|
106 | - ->setMethods( ['updateSync', 'query', 'isImplemented'] ) |
|
105 | + $provider = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Provider\\Delivery\\Standard') |
|
106 | + ->setMethods(['updateSync', 'query', 'isImplemented']) |
|
107 | 107 | ->disableOriginalConstructor() |
108 | 108 | ->getMock(); |
109 | 109 | |
110 | - $manager = $this->getMockBuilder( '\\Aimeos\\MShop\\Service\\Manager\\Standard' ) |
|
111 | - ->setConstructorArgs( array( $this->context ) ) |
|
112 | - ->setMethods( ['getProvider'] ) |
|
110 | + $manager = $this->getMockBuilder('\\Aimeos\\MShop\\Service\\Manager\\Standard') |
|
111 | + ->setConstructorArgs(array($this->context)) |
|
112 | + ->setMethods(['getProvider']) |
|
113 | 113 | ->getMock(); |
114 | 114 | |
115 | - \Aimeos\MShop\Factory::injectManager( $this->context, 'service', $manager ); |
|
115 | + \Aimeos\MShop\Factory::injectManager($this->context, 'service', $manager); |
|
116 | 116 | |
117 | 117 | |
118 | - $request->expects( $this->once() )->method( 'getQueryParams' )->will( $this->returnValue( ['code' => 'unitcode'] ) ); |
|
119 | - $response->expects( $this->once() )->method( 'createStreamFromString' )->will( $this->returnValue( $stream ) ); |
|
120 | - $manager->expects( $this->once() )->method( 'getProvider' )->will( $this->returnValue( $provider ) ); |
|
121 | - $provider->expects( $this->once() )->method( 'updateSync' )->will( $this->returnValue( $item ) ); |
|
122 | - $provider->expects( $this->once() )->method( 'isImplemented' )->will( $this->returnValue( true ) ); |
|
123 | - $provider->expects( $this->once() )->method( 'query' ); |
|
118 | + $request->expects($this->once())->method('getQueryParams')->will($this->returnValue(['code' => 'unitcode'])); |
|
119 | + $response->expects($this->once())->method('createStreamFromString')->will($this->returnValue($stream)); |
|
120 | + $manager->expects($this->once())->method('getProvider')->will($this->returnValue($provider)); |
|
121 | + $provider->expects($this->once())->method('updateSync')->will($this->returnValue($item)); |
|
122 | + $provider->expects($this->once())->method('isImplemented')->will($this->returnValue(true)); |
|
123 | + $provider->expects($this->once())->method('query'); |
|
124 | 124 | |
125 | - $this->object->updateSync( $request, $response, [] ); |
|
125 | + $this->object->updateSync($request, $response, []); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
129 | 129 | public function testGetServices() |
130 | 130 | { |
131 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
132 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
131 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
132 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
133 | 133 | |
134 | - $services = $this->object->getServices( 'delivery', $basket ); |
|
135 | - $this->assertGreaterThan( 0, count( $services ) ); |
|
134 | + $services = $this->object->getServices('delivery', $basket); |
|
135 | + $this->assertGreaterThan(0, count($services)); |
|
136 | 136 | |
137 | - foreach( $services as $service ) { |
|
138 | - $this->assertInstanceOf( '\\Aimeos\\MShop\\Service\\Item\\Iface', $service ); |
|
137 | + foreach ($services as $service) { |
|
138 | + $this->assertInstanceOf('\\Aimeos\\MShop\\Service\\Item\\Iface', $service); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
@@ -143,83 +143,83 @@ discard block |
||
143 | 143 | public function testGetServiceAttributes() |
144 | 144 | { |
145 | 145 | $service = $this->getServiceItem(); |
146 | - $attributes = $this->object->getServiceAttributes( 'delivery', $service->getId(), self::$basket ); |
|
146 | + $attributes = $this->object->getServiceAttributes('delivery', $service->getId(), self::$basket); |
|
147 | 147 | |
148 | - $this->assertEquals( 0, count( $attributes ) ); |
|
148 | + $this->assertEquals(0, count($attributes)); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
152 | 152 | public function testGetServiceAttributesCache() |
153 | 153 | { |
154 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
155 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
154 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
155 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
156 | 156 | |
157 | - $services = $this->object->getServices( 'delivery', $basket ); |
|
157 | + $services = $this->object->getServices('delivery', $basket); |
|
158 | 158 | |
159 | - if( ( $service = reset( $services ) ) === false ) { |
|
160 | - throw new \RuntimeException( 'No service item found' ); |
|
159 | + if (($service = reset($services)) === false) { |
|
160 | + throw new \RuntimeException('No service item found'); |
|
161 | 161 | } |
162 | 162 | |
163 | - $attributes = $this->object->getServiceAttributes( 'delivery', $service->getId(), self::$basket ); |
|
163 | + $attributes = $this->object->getServiceAttributes('delivery', $service->getId(), self::$basket); |
|
164 | 164 | |
165 | - $this->assertEquals( 0, count( $attributes ) ); |
|
165 | + $this->assertEquals(0, count($attributes)); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
169 | 169 | public function testGetServiceAttributesNoItems() |
170 | 170 | { |
171 | - $this->setExpectedException( '\\Aimeos\\MShop\\Exception' ); |
|
172 | - $this->object->getServiceAttributes( 'invalid', -1, self::$basket ); |
|
171 | + $this->setExpectedException('\\Aimeos\\MShop\\Exception'); |
|
172 | + $this->object->getServiceAttributes('invalid', -1, self::$basket); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | |
176 | 176 | public function testGetServicePrice() |
177 | 177 | { |
178 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
179 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
178 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
179 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
180 | 180 | |
181 | 181 | $service = $this->getServiceItem(); |
182 | - $price = $this->object->getServicePrice( 'delivery', $service->getId(), $basket ); |
|
182 | + $price = $this->object->getServicePrice('delivery', $service->getId(), $basket); |
|
183 | 183 | |
184 | - $this->assertEquals( '12.95', $price->getValue() ); |
|
185 | - $this->assertEquals( '1.99', $price->getCosts() ); |
|
184 | + $this->assertEquals('12.95', $price->getValue()); |
|
185 | + $this->assertEquals('1.99', $price->getCosts()); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | |
189 | 189 | public function testGetServicePriceCache() |
190 | 190 | { |
191 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
192 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
191 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
192 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
193 | 193 | |
194 | - $services = $this->object->getServices( 'delivery', $basket ); |
|
194 | + $services = $this->object->getServices('delivery', $basket); |
|
195 | 195 | |
196 | - if( ( $service = reset( $services ) ) === false ) { |
|
197 | - throw new \RuntimeException( 'No service item found' ); |
|
196 | + if (($service = reset($services)) === false) { |
|
197 | + throw new \RuntimeException('No service item found'); |
|
198 | 198 | } |
199 | 199 | |
200 | - $price = $this->object->getServicePrice( 'delivery', $service->getId(), $basket ); |
|
200 | + $price = $this->object->getServicePrice('delivery', $service->getId(), $basket); |
|
201 | 201 | |
202 | - $this->assertEquals( '12.95', $price->getValue() ); |
|
203 | - $this->assertEquals( '1.99', $price->getCosts() ); |
|
202 | + $this->assertEquals('12.95', $price->getValue()); |
|
203 | + $this->assertEquals('1.99', $price->getCosts()); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | |
207 | 207 | public function testGetServicePriceNoItems() |
208 | 208 | { |
209 | - $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
210 | - $basket = $orderManager->getSubManager( 'base' )->createItem(); |
|
209 | + $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
210 | + $basket = $orderManager->getSubManager('base')->createItem(); |
|
211 | 211 | |
212 | - $this->setExpectedException( '\\Aimeos\\MShop\\Exception' ); |
|
213 | - $this->object->getServicePrice( 'invalid', -1, $basket ); |
|
212 | + $this->setExpectedException('\\Aimeos\\MShop\\Exception'); |
|
213 | + $this->object->getServicePrice('invalid', -1, $basket); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | |
217 | 217 | public function testCheckServiceAttributes() |
218 | 218 | { |
219 | 219 | $service = $this->getServiceItem(); |
220 | - $attributes = $this->object->checkServiceAttributes( 'delivery', $service->getId(), [] ); |
|
220 | + $attributes = $this->object->checkServiceAttributes('delivery', $service->getId(), []); |
|
221 | 221 | |
222 | - $this->assertEquals( [], $attributes ); |
|
222 | + $this->assertEquals([], $attributes); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | protected function getServiceItem() |
230 | 230 | { |
231 | - $manager = \Aimeos\MShop\Service\Manager\Factory::createManager( \TestHelperFrontend::getContext() ); |
|
232 | - return $manager->findItem( 'unitcode' ); |
|
231 | + $manager = \Aimeos\MShop\Service\Manager\Factory::createManager(\TestHelperFrontend::getContext()); |
|
232 | + return $manager->findItem('unitcode'); |
|
233 | 233 | } |
234 | 234 | } |