@@ -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; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
27 | 27 | * @since 2017.04 |
28 | 28 | */ |
29 | - public function addItem( array $values ); |
|
29 | + public function addItem(array $values); |
|
30 | 30 | |
31 | 31 | |
32 | 32 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
36 | 36 | * @since 2017.04 |
37 | 37 | */ |
38 | - public function createItem( array $values = [] ); |
|
38 | + public function createItem(array $values = []); |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param string $id Unique customer ID |
45 | 45 | * @since 2017.04 |
46 | 46 | */ |
47 | - public function deleteItem( $id ); |
|
47 | + public function deleteItem($id); |
|
48 | 48 | |
49 | 49 | |
50 | 50 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
56 | 56 | * @since 2017.04 |
57 | 57 | */ |
58 | - public function editItem( $id, array $values ); |
|
58 | + public function editItem($id, array $values); |
|
59 | 59 | |
60 | 60 | |
61 | 61 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
67 | 67 | * @since 2017.04 |
68 | 68 | */ |
69 | - public function getItem( $id = null, array $domains = [] ); |
|
69 | + public function getItem($id = null, array $domains = []); |
|
70 | 70 | |
71 | 71 | |
72 | 72 | /** |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
80 | 80 | * @since 2017.04 |
81 | 81 | */ |
82 | - public function findItem( $code, array $domains = [] ); |
|
82 | + public function findItem($code, array $domains = []); |
|
83 | 83 | |
84 | 84 | |
85 | 85 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item including the generated ID |
90 | 90 | * @since 2017.04 |
91 | 91 | */ |
92 | - public function saveItem( \Aimeos\MShop\Customer\Item\Iface $item ); |
|
92 | + public function saveItem(\Aimeos\MShop\Customer\Item\Iface $item); |
|
93 | 93 | |
94 | 94 | |
95 | 95 | /** |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return \Aimeos\MShop\Customer\Item\Iface Customer address item |
100 | 100 | * @since 2017.04 |
101 | 101 | */ |
102 | - public function addAddressItem( array $values ); |
|
102 | + public function addAddressItem(array $values); |
|
103 | 103 | |
104 | 104 | |
105 | 105 | /** |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
109 | 109 | * @since 2017.04 |
110 | 110 | */ |
111 | - public function createAddressItem( array $values = [] ); |
|
111 | + public function createAddressItem(array $values = []); |
|
112 | 112 | |
113 | 113 | |
114 | 114 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param string $id Unique customer address ID |
118 | 118 | * @since 2017.04 |
119 | 119 | */ |
120 | - public function deleteAddressItem( $id ); |
|
120 | + public function deleteAddressItem($id); |
|
121 | 121 | |
122 | 122 | |
123 | 123 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return \Aimeos\MShop\Customer\Item\Iface Customer address item |
129 | 129 | * @since 2017.04 |
130 | 130 | */ |
131 | - public function editAddressItem( $id, array $values ); |
|
131 | + public function editAddressItem($id, array $values); |
|
132 | 132 | |
133 | 133 | |
134 | 134 | /** |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
139 | 139 | * @since 2017.04 |
140 | 140 | */ |
141 | - public function getAddressItem( $id ); |
|
141 | + public function getAddressItem($id); |
|
142 | 142 | |
143 | 143 | |
144 | 144 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item including the generated ID |
149 | 149 | * @since 2017.04 |
150 | 150 | */ |
151 | - public function saveAddressItem( \Aimeos\MShop\Customer\Item\Address\Iface $item ); |
|
151 | + public function saveAddressItem(\Aimeos\MShop\Customer\Item\Address\Iface $item); |
|
152 | 152 | |
153 | 153 | /** |
154 | 154 | * Creates and returns a new list item object |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item |
158 | 158 | * @since 2017.06 |
159 | 159 | */ |
160 | - public function addListItem( array $values ); |
|
160 | + public function addListItem(array $values); |
|
161 | 161 | |
162 | 162 | /** |
163 | 163 | * Returns a new customer lists filter criteria object |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @param string $id Unique customer address ID |
174 | 174 | * @since 2017.06 |
175 | 175 | */ |
176 | - public function deleteListItem( $id ); |
|
176 | + public function deleteListItem($id); |
|
177 | 177 | |
178 | 178 | /** |
179 | 179 | * Saves a modified customer lists item object |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item |
184 | 184 | * @since 2017.06 |
185 | 185 | */ |
186 | - public function editListItem( $id, array $values ); |
|
186 | + public function editListItem($id, array $values); |
|
187 | 187 | |
188 | 188 | /** |
189 | 189 | * Returns the customer item for the given customer ID |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
193 | 193 | * @since 2017.06 |
194 | 194 | */ |
195 | - public function getListItem( $id ); |
|
195 | + public function getListItem($id); |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Returns the customer lists items filtered by the given criteria |
@@ -202,5 +202,5 @@ discard block |
||
202 | 202 | * @return \Aimeos\MShop\Common\Item\Lists\Iface[] Customer list items |
203 | 203 | * @since 2017.06 |
204 | 204 | */ |
205 | - public function searchListItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null ); |
|
205 | + public function searchListItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null); |
|
206 | 206 | } |
@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | public static function bootstrap() |
16 | 16 | { |
17 | 17 | self::getAimeos(); |
18 | - \Aimeos\MShop\Factory::setCache( false ); |
|
19 | - \Aimeos\Controller\Frontend\Factory::setCache( false ); |
|
18 | + \Aimeos\MShop\Factory::setCache(false); |
|
19 | + \Aimeos\Controller\Frontend\Factory::setCache(false); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | - public static function getContext( $site = 'unittest' ) |
|
23 | + public static function getContext($site = 'unittest') |
|
24 | 24 | { |
25 | - if( !isset( self::$context[$site] ) ) { |
|
26 | - self::$context[$site] = self::createContext( $site ); |
|
25 | + if (!isset(self::$context[$site])) { |
|
26 | + self::$context[$site] = self::createContext($site); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | return clone self::$context[$site]; |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | |
33 | 33 | private static function getAimeos() |
34 | 34 | { |
35 | - if( !isset( self::$aimeos ) ) |
|
35 | + if (!isset(self::$aimeos)) |
|
36 | 36 | { |
37 | 37 | require_once 'Bootstrap.php'; |
38 | - spl_autoload_register( 'Aimeos\\Bootstrap::autoload' ); |
|
38 | + spl_autoload_register('Aimeos\\Bootstrap::autoload'); |
|
39 | 39 | |
40 | - $extdir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ); |
|
41 | - self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), true ); |
|
40 | + $extdir = dirname(dirname(dirname(dirname(dirname(__FILE__))))); |
|
41 | + self::$aimeos = new \Aimeos\Bootstrap(array($extdir), true); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | return self::$aimeos; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * @param string $site |
50 | 50 | */ |
51 | - private static function createContext( $site ) |
|
51 | + private static function createContext($site) |
|
52 | 52 | { |
53 | 53 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
54 | 54 | $aimeos = self::getAimeos(); |
@@ -58,38 +58,38 @@ discard block |
||
58 | 58 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
59 | 59 | $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser'; |
60 | 60 | |
61 | - $conf = new \Aimeos\MW\Config\PHPArray( [], $paths ); |
|
62 | - $conf = new \Aimeos\MW\Config\Decorator\Memory( $conf ); |
|
63 | - $conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file ); |
|
64 | - $ctx->setConfig( $conf ); |
|
61 | + $conf = new \Aimeos\MW\Config\PHPArray([], $paths); |
|
62 | + $conf = new \Aimeos\MW\Config\Decorator\Memory($conf); |
|
63 | + $conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file); |
|
64 | + $ctx->setConfig($conf); |
|
65 | 65 | |
66 | 66 | |
67 | - $dbm = new \Aimeos\MW\DB\Manager\PDO( $conf ); |
|
68 | - $ctx->setDatabaseManager( $dbm ); |
|
67 | + $dbm = new \Aimeos\MW\DB\Manager\PDO($conf); |
|
68 | + $ctx->setDatabaseManager($dbm); |
|
69 | 69 | |
70 | 70 | |
71 | - $mq = new \Aimeos\MW\MQueue\Manager\Standard( $conf ); |
|
72 | - $ctx->setMessageQueueManager( $mq ); |
|
71 | + $mq = new \Aimeos\MW\MQueue\Manager\Standard($conf); |
|
72 | + $ctx->setMessageQueueManager($mq); |
|
73 | 73 | |
74 | 74 | |
75 | - $logger = new \Aimeos\MW\Logger\File( 'unittest.log', \Aimeos\MW\Logger\Base::DEBUG ); |
|
76 | - $ctx->setLogger( $logger ); |
|
75 | + $logger = new \Aimeos\MW\Logger\File('unittest.log', \Aimeos\MW\Logger\Base::DEBUG); |
|
76 | + $ctx->setLogger($logger); |
|
77 | 77 | |
78 | 78 | |
79 | - $i18n = new \Aimeos\MW\Translation\None( 'de' ); |
|
80 | - $ctx->setI18n( array( 'de' => $i18n ) ); |
|
79 | + $i18n = new \Aimeos\MW\Translation\None('de'); |
|
80 | + $ctx->setI18n(array('de' => $i18n)); |
|
81 | 81 | |
82 | 82 | |
83 | 83 | $session = new \Aimeos\MW\Session\None(); |
84 | - $ctx->setSession( $session ); |
|
84 | + $ctx->setSession($session); |
|
85 | 85 | |
86 | 86 | |
87 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $ctx ); |
|
88 | - $locale = $localeManager->bootstrap( $site, '', '', false ); |
|
89 | - $ctx->setLocale( $locale ); |
|
87 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); |
|
88 | + $locale = $localeManager->bootstrap($site, '', '', false); |
|
89 | + $ctx->setLocale($locale); |
|
90 | 90 | |
91 | 91 | |
92 | - $ctx->setEditor( 'core:controller/frontend' ); |
|
92 | + $ctx->setEditor('core:controller/frontend'); |
|
93 | 93 | |
94 | 94 | return $ctx; |
95 | 95 | } |
@@ -18,121 +18,121 @@ discard block |
||
18 | 18 | protected function setUp() |
19 | 19 | { |
20 | 20 | $this->context = \TestHelperFrontend::getContext(); |
21 | - $this->object = new \Aimeos\Controller\Frontend\Customer\Standard( $this->context ); |
|
21 | + $this->object = new \Aimeos\Controller\Frontend\Customer\Standard($this->context); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
25 | 25 | protected function tearDown() |
26 | 26 | { |
27 | - unset( $this->context, $this->object ); |
|
27 | + unset($this->context, $this->object); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
31 | 31 | public function testAddEditSaveDeleteItem() |
32 | 32 | { |
33 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' ); |
|
34 | - $id = $manager->findItem( 'UTC001' )->getId(); |
|
33 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer'); |
|
34 | + $id = $manager->findItem('UTC001')->getId(); |
|
35 | 35 | |
36 | - $this->context->setUserId( $id ); |
|
37 | - $item = $this->object->addItem( ['customer.code' => 'unittest-ctnl', 'customer.status' => 1] ); |
|
38 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item ); |
|
36 | + $this->context->setUserId($id); |
|
37 | + $item = $this->object->addItem(['customer.code' => 'unittest-ctnl', 'customer.status' => 1]); |
|
38 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $item); |
|
39 | 39 | |
40 | - $this->context->setUserId( $item->getId() ); |
|
41 | - $item = $this->object->editItem( $item->getId(), ['customer.code' => 'unittest-ctnl2'] ); |
|
42 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item ); |
|
40 | + $this->context->setUserId($item->getId()); |
|
41 | + $item = $this->object->editItem($item->getId(), ['customer.code' => 'unittest-ctnl2']); |
|
42 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $item); |
|
43 | 43 | |
44 | - $item->setStatus( 0 ); |
|
45 | - $item = $this->object->saveItem( $item ); |
|
46 | - $this->assertEquals( 0, $item->getStatus() ); |
|
44 | + $item->setStatus(0); |
|
45 | + $item = $this->object->saveItem($item); |
|
46 | + $this->assertEquals(0, $item->getStatus()); |
|
47 | 47 | |
48 | - $this->object->deleteItem( $item->getId() ); |
|
48 | + $this->object->deleteItem($item->getId()); |
|
49 | 49 | |
50 | - $this->setExpectedException( '\Aimeos\MShop\Exception' ); |
|
51 | - $manager->findItem( 'unittest-ctnl' ); |
|
50 | + $this->setExpectedException('\Aimeos\MShop\Exception'); |
|
51 | + $manager->findItem('unittest-ctnl'); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | public function testAddExistingItem() |
56 | 56 | { |
57 | - $item = $this->object->addItem( ['customer.code' => 'UTC001'] ); |
|
58 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item ); |
|
57 | + $item = $this->object->addItem(['customer.code' => 'UTC001']); |
|
58 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $item); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | 62 | public function testCreateItem() |
63 | 63 | { |
64 | 64 | $result = $this->object->createItem(); |
65 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result ); |
|
65 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $result); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | 69 | public function testGetItem() |
70 | 70 | { |
71 | - $id = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' )->getId(); |
|
72 | - $this->context->setUserId( $id ); |
|
71 | + $id = \Aimeos\MShop\Factory::createManager($this->context, 'customer')->findItem('UTC001')->getId(); |
|
72 | + $this->context->setUserId($id); |
|
73 | 73 | |
74 | - $result = $this->object->getItem( $id, ['customer/address', 'text'] ); |
|
74 | + $result = $this->object->getItem($id, ['customer/address', 'text']); |
|
75 | 75 | |
76 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result ); |
|
77 | - $this->assertEquals( 1, count( $result->getRefItems( 'text' ) ) ); |
|
78 | - $this->assertEquals( 1, count( $result->getAddressItems() ) ); |
|
76 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $result); |
|
77 | + $this->assertEquals(1, count($result->getRefItems('text'))); |
|
78 | + $this->assertEquals(1, count($result->getAddressItems())); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
82 | 82 | public function testFindItem() |
83 | 83 | { |
84 | - $result = $this->object->findItem( 'UTC001' ); |
|
85 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result ); |
|
84 | + $result = $this->object->findItem('UTC001'); |
|
85 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $result); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
89 | 89 | public function testAddEditSaveDeleteAddressItem() |
90 | 90 | { |
91 | - $customer = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' ); |
|
92 | - $this->context->setUserId( $customer->getId() ); |
|
91 | + $customer = \Aimeos\MShop\Factory::createManager($this->context, 'customer')->findItem('UTC001'); |
|
92 | + $this->context->setUserId($customer->getId()); |
|
93 | 93 | |
94 | - $item = $this->object->addAddressItem( ['customer.address.lastname' => 'unittest-ctnl'] ); |
|
95 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $item ); |
|
94 | + $item = $this->object->addAddressItem(['customer.address.lastname' => 'unittest-ctnl']); |
|
95 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $item); |
|
96 | 96 | |
97 | - $item = $this->object->editAddressItem( $item->getId(), ['customer.address.lastname' => 'unittest-ctnl2'] ); |
|
98 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $item ); |
|
97 | + $item = $this->object->editAddressItem($item->getId(), ['customer.address.lastname' => 'unittest-ctnl2']); |
|
98 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $item); |
|
99 | 99 | |
100 | - $item->setLastName( 'test' ); |
|
101 | - $this->object->saveAddressItem( $item ); |
|
102 | - $this->assertEquals( 'test', $item->getLastName() ); |
|
100 | + $item->setLastName('test'); |
|
101 | + $this->object->saveAddressItem($item); |
|
102 | + $this->assertEquals('test', $item->getLastName()); |
|
103 | 103 | |
104 | - $this->object->deleteAddressItem( $item->getId() ); |
|
104 | + $this->object->deleteAddressItem($item->getId()); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
108 | 108 | public function testCreateAddressItem() |
109 | 109 | { |
110 | 110 | $result = $this->object->createAddressItem(); |
111 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $result ); |
|
111 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $result); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | public function testGetAddressItem() |
116 | 116 | { |
117 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer/address' ); |
|
117 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer/address'); |
|
118 | 118 | $search = $manager->createSearch(); |
119 | - $search->setSlice( 0, 1 ); |
|
120 | - $result = $manager->searchItems( $search ); |
|
119 | + $search->setSlice(0, 1); |
|
120 | + $result = $manager->searchItems($search); |
|
121 | 121 | |
122 | - if( ( $item = reset( $result ) ) === false ) { |
|
123 | - throw new \RuntimeException( 'No customer address available' ); |
|
122 | + if (($item = reset($result)) === false) { |
|
123 | + throw new \RuntimeException('No customer address available'); |
|
124 | 124 | } |
125 | 125 | |
126 | - $this->context->setUserId( $item->getParentId() ); |
|
127 | - $result = $this->object->getAddressItem( $item->getId() ); |
|
128 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $result ); |
|
126 | + $this->context->setUserId($item->getParentId()); |
|
127 | + $result = $this->object->getAddressItem($item->getId()); |
|
128 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $result); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
132 | 132 | public function testAddEditDeleteListItem() |
133 | 133 | { |
134 | - $customer = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' ); |
|
135 | - $this->context->setUserId( $customer->getId() ); |
|
134 | + $customer = \Aimeos\MShop\Factory::createManager($this->context, 'customer')->findItem('UTC001'); |
|
135 | + $this->context->setUserId($customer->getId()); |
|
136 | 136 | |
137 | 137 | $values = [ |
138 | 138 | 'customer.lists.type' => 'favorite', |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | 'customer.lists.refid' => '-1' |
141 | 141 | ]; |
142 | 142 | |
143 | - $item = $this->object->addListItem( $values ); |
|
144 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $item ); |
|
143 | + $item = $this->object->addListItem($values); |
|
144 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $item); |
|
145 | 145 | |
146 | 146 | $values = [ |
147 | 147 | 'customer.lists.type' => 'favorite', |
@@ -149,46 +149,46 @@ discard block |
||
149 | 149 | 'customer.lists.refid' => '-2' |
150 | 150 | ]; |
151 | 151 | |
152 | - $item = $this->object->editListItem( $item->getId(), $values ); |
|
153 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $item ); |
|
152 | + $item = $this->object->editListItem($item->getId(), $values); |
|
153 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $item); |
|
154 | 154 | |
155 | - $this->object->deleteListItem( $item->getId() ); |
|
155 | + $this->object->deleteListItem($item->getId()); |
|
156 | 156 | |
157 | - $this->setExpectedException( '\Aimeos\MShop\Exception' ); |
|
158 | - $this->object->getListItem( $item->getId() ); |
|
157 | + $this->setExpectedException('\Aimeos\MShop\Exception'); |
|
158 | + $this->object->getListItem($item->getId()); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | |
162 | 162 | public function testGetListItem() |
163 | 163 | { |
164 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer/lists' ); |
|
164 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer/lists'); |
|
165 | 165 | $search = $manager->createSearch(); |
166 | - $search->setSlice( 0, 1 ); |
|
167 | - $result = $manager->searchItems( $search ); |
|
166 | + $search->setSlice(0, 1); |
|
167 | + $result = $manager->searchItems($search); |
|
168 | 168 | |
169 | - if( ( $item = reset( $result ) ) === false ) { |
|
170 | - throw new \RuntimeException( 'No customer lists item available' ); |
|
169 | + if (($item = reset($result)) === false) { |
|
170 | + throw new \RuntimeException('No customer lists item available'); |
|
171 | 171 | } |
172 | 172 | |
173 | - $this->context->setUserId( $item->getParentId() ); |
|
174 | - $result = $this->object->getListItem( $item->getId() ); |
|
175 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $result ); |
|
173 | + $this->context->setUserId($item->getParentId()); |
|
174 | + $result = $this->object->getListItem($item->getId()); |
|
175 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $result); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
179 | 179 | public function testSearchListItem() |
180 | 180 | { |
181 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' ); |
|
182 | - $customer = $manager->findItem( 'UTC001' ); |
|
183 | - $this->context->setUserId( $customer->getId() ); |
|
181 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer'); |
|
182 | + $customer = $manager->findItem('UTC001'); |
|
183 | + $this->context->setUserId($customer->getId()); |
|
184 | 184 | |
185 | 185 | $filter = $this->object->createListsFilter(); |
186 | - $result = $this->object->searchListItems( $filter ); |
|
186 | + $result = $this->object->searchListItems($filter); |
|
187 | 187 | |
188 | - foreach( $result as $item ) |
|
188 | + foreach ($result as $item) |
|
189 | 189 | { |
190 | - $this->assertEquals( $customer->getId(), $item->getParentId() ); |
|
191 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $item ); |
|
190 | + $this->assertEquals($customer->getId(), $item->getParentId()); |
|
191 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $item); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
@@ -180,8 +180,7 @@ discard block |
||
180 | 180 | { |
181 | 181 | $search = $manager->createSearch(); |
182 | 182 | $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
183 | - } |
|
184 | - else |
|
183 | + } else |
|
185 | 184 | { |
186 | 185 | $search = $manager->createSearch( true ); |
187 | 186 | } |
@@ -275,8 +274,7 @@ discard block |
||
275 | 274 | { |
276 | 275 | $search = $manager->createSearch(); |
277 | 276 | $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
278 | - } |
|
279 | - else |
|
277 | + } else |
|
280 | 278 | { |
281 | 279 | $search = $manager->createSearch( true ); |
282 | 280 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * Returns the given search filter with the conditions attached for filtering by suppliers. |
124 | 124 | * |
125 | 125 | * @param \Aimeos\MW\Criteria\Iface $filter Criteria object used for product search |
126 | - * @param array $supIds List of supplier IDs for faceted search |
|
126 | + * @param integer[] $supIds List of supplier IDs for faceted search |
|
127 | 127 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
128 | 128 | * @since 2018.07 |
129 | 129 | */ |
@@ -334,6 +334,7 @@ discard block |
||
334 | 334 | * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
335 | 335 | * @param string[] $domains Domain names of items that are associated with the products and that should be fetched too |
336 | 336 | * @param integer &$total Parameter where the total number of found products will be stored in |
337 | + * @param integer $total |
|
337 | 338 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
338 | 339 | * @since 2017.03 |
339 | 340 | */ |
@@ -31,38 +31,38 @@ discard block |
||
31 | 31 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
32 | 32 | * @since 2017.03 |
33 | 33 | */ |
34 | - public function addFilterAttribute( \Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds ) |
|
34 | + public function addFilterAttribute(\Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds) |
|
35 | 35 | { |
36 | - if( ( $attrIds = $this->validateIds( $attrIds ) ) !== [] ) |
|
36 | + if (($attrIds = $this->validateIds($attrIds)) !== []) |
|
37 | 37 | { |
38 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $attrIds ) ); |
|
38 | + $func = $filter->createFunction('index.attributeaggregate', array($attrIds)); |
|
39 | 39 | $expr = array( |
40 | - $filter->compare( '==', $func, count( $attrIds ) ), |
|
40 | + $filter->compare('==', $func, count($attrIds)), |
|
41 | 41 | $filter->getConditions(), |
42 | 42 | ); |
43 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
43 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
44 | 44 | } |
45 | 45 | |
46 | - if( ( $optIds = $this->validateIds( $optIds ) ) !== [] ) |
|
46 | + if (($optIds = $this->validateIds($optIds)) !== []) |
|
47 | 47 | { |
48 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $optIds ) ); |
|
48 | + $func = $filter->createFunction('index.attributeaggregate', array($optIds)); |
|
49 | 49 | $expr = array( |
50 | - $filter->compare( '>', $func, 0 ), |
|
50 | + $filter->compare('>', $func, 0), |
|
51 | 51 | $filter->getConditions(), |
52 | 52 | ); |
53 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
53 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
54 | 54 | } |
55 | 55 | |
56 | - foreach( $oneIds as $type => $list ) |
|
56 | + foreach ($oneIds as $type => $list) |
|
57 | 57 | { |
58 | - if( ( $list = $this->validateIds( (array) $list ) ) !== [] ) |
|
58 | + if (($list = $this->validateIds((array) $list)) !== []) |
|
59 | 59 | { |
60 | - $func = $filter->createFunction( 'index.attributeaggregate', array( $list ) ); |
|
60 | + $func = $filter->createFunction('index.attributeaggregate', array($list)); |
|
61 | 61 | $expr = array( |
62 | - $filter->compare( '>', $func, 0 ), |
|
62 | + $filter->compare('>', $func, 0), |
|
63 | 63 | $filter->getConditions(), |
64 | 64 | ); |
65 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
65 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
@@ -82,38 +82,38 @@ discard block |
||
82 | 82 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
83 | 83 | * @since 2017.03 |
84 | 84 | */ |
85 | - public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId, |
|
86 | - $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default' ) |
|
85 | + public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId, |
|
86 | + $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default') |
|
87 | 87 | { |
88 | - $catIds = ( !is_array( $catId ) ? explode( ',', $catId ) : $catId ); |
|
88 | + $catIds = (!is_array($catId) ? explode(',', $catId) : $catId); |
|
89 | 89 | |
90 | - if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ) |
|
90 | + if ($level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE) |
|
91 | 91 | { |
92 | 92 | $list = []; |
93 | - $cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'catalog' ); |
|
93 | + $cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog'); |
|
94 | 94 | |
95 | - foreach( $catIds as $catId ) |
|
95 | + foreach ($catIds as $catId) |
|
96 | 96 | { |
97 | - $tree = $cntl->getTree( $catId, [], $level ); |
|
98 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $tree ) ); |
|
97 | + $tree = $cntl->getTree($catId, [], $level); |
|
98 | + $list = array_merge($list, $this->getCatalogIdsFromTree($tree)); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | $catIds = $list; |
102 | 102 | } |
103 | 103 | |
104 | - $expr = array( $filter->compare( '==', 'index.catalog.id', array_unique( $catIds ) ) ); |
|
104 | + $expr = array($filter->compare('==', 'index.catalog.id', array_unique($catIds))); |
|
105 | 105 | $expr[] = $filter->getConditions(); |
106 | 106 | |
107 | - if( $sort === 'relevance' ) |
|
107 | + if ($sort === 'relevance') |
|
108 | 108 | { |
109 | - $cmpfunc = $filter->createFunction( 'index.catalog.position', array( $listtype, $catIds ) ); |
|
110 | - $expr[] = $filter->compare( '>=', $cmpfunc, 0 ); |
|
109 | + $cmpfunc = $filter->createFunction('index.catalog.position', array($listtype, $catIds)); |
|
110 | + $expr[] = $filter->compare('>=', $cmpfunc, 0); |
|
111 | 111 | |
112 | - $sortfunc = $filter->createFunction( 'sort:index.catalog.position', array( $listtype, $catIds ) ); |
|
113 | - $filter->setSortations( [$filter->sort( $direction, $sortfunc ), $filter->sort( '+', 'product.id' )] ); |
|
112 | + $sortfunc = $filter->createFunction('sort:index.catalog.position', array($listtype, $catIds)); |
|
113 | + $filter->setSortations([$filter->sort($direction, $sortfunc), $filter->sort('+', 'product.id')]); |
|
114 | 114 | } |
115 | 115 | |
116 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
116 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
117 | 117 | |
118 | 118 | return $filter; |
119 | 119 | } |
@@ -127,16 +127,16 @@ discard block |
||
127 | 127 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
128 | 128 | * @since 2018.07 |
129 | 129 | */ |
130 | - public function addFilterSupplier( \Aimeos\MW\Criteria\Iface $filter, array $supIds ) |
|
130 | + public function addFilterSupplier(\Aimeos\MW\Criteria\Iface $filter, array $supIds) |
|
131 | 131 | { |
132 | - if( !empty( $supIds ) ) |
|
132 | + if (!empty($supIds)) |
|
133 | 133 | { |
134 | - $supIds = $this->validateIds( $supIds ); |
|
134 | + $supIds = $this->validateIds($supIds); |
|
135 | 135 | $expr = array( |
136 | - $filter->compare( '==', 'index.supplier.id', $supIds ), |
|
136 | + $filter->compare('==', 'index.supplier.id', $supIds), |
|
137 | 137 | $filter->getConditions(), |
138 | 138 | ); |
139 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
139 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | return $filter; |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
155 | 155 | * @since 2017.03 |
156 | 156 | */ |
157 | - public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default' ) |
|
157 | + public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default') |
|
158 | 158 | { |
159 | 159 | $langid = $this->getContext()->getLocale()->getLanguageId(); |
160 | - $cmpfunc = $filter->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) ); |
|
161 | - $expr = array( $filter->compare( '>', $cmpfunc, 0 ), $filter->getConditions() ); |
|
160 | + $cmpfunc = $filter->createFunction('index.text.relevance', array($listtype, $langid, $input)); |
|
161 | + $expr = array($filter->compare('>', $cmpfunc, 0), $filter->getConditions()); |
|
162 | 162 | |
163 | - return $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
163 | + return $filter->setConditions($filter->combine('&&', $expr)); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | * @return array Associative list of key values as key and the product count for this key as value |
173 | 173 | * @since 2017.03 |
174 | 174 | */ |
175 | - public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key ) |
|
175 | + public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key) |
|
176 | 176 | { |
177 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->aggregate( $filter, $key ); |
|
177 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->aggregate($filter, $key); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -189,11 +189,11 @@ discard block |
||
189 | 189 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
190 | 190 | * @since 2017.03 |
191 | 191 | */ |
192 | - public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' ) |
|
192 | + public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default') |
|
193 | 193 | { |
194 | 194 | $sortations = []; |
195 | 195 | $context = $this->getContext(); |
196 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'index' ); |
|
196 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'index'); |
|
197 | 197 | |
198 | 198 | |
199 | 199 | /** controller/frontend/product/ignore-dates |
@@ -208,55 +208,55 @@ discard block |
||
208 | 208 | * @since 2017.10 |
209 | 209 | * @category Developer |
210 | 210 | */ |
211 | - if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) ) |
|
211 | + if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false)) |
|
212 | 212 | { |
213 | 213 | $search = $manager->createSearch(); |
214 | - $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
|
214 | + $search->setConditions($search->compare('>', 'product.status', 0)); |
|
215 | 215 | } |
216 | 216 | else |
217 | 217 | { |
218 | - $search = $manager->createSearch( true ); |
|
218 | + $search = $manager->createSearch(true); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | |
222 | - $expr = array( $search->compare( '!=', 'index.catalog.id', null ) ); |
|
222 | + $expr = array($search->compare('!=', 'index.catalog.id', null)); |
|
223 | 223 | |
224 | - switch( $sort ) |
|
224 | + switch ($sort) |
|
225 | 225 | { |
226 | 226 | case 'code': |
227 | - $sortations[] = $search->sort( $direction, 'product.code' ); |
|
227 | + $sortations[] = $search->sort($direction, 'product.code'); |
|
228 | 228 | break; |
229 | 229 | |
230 | 230 | case 'ctime': |
231 | - $sortations[] = $search->sort( $direction, 'product.ctime' ); |
|
231 | + $sortations[] = $search->sort($direction, 'product.ctime'); |
|
232 | 232 | break; |
233 | 233 | |
234 | 234 | case 'name': |
235 | 235 | $langid = $context->getLocale()->getLanguageId(); |
236 | 236 | |
237 | - $cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) ); |
|
238 | - $expr[] = $search->compare( '>=', $cmpfunc, '' ); |
|
237 | + $cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product')); |
|
238 | + $expr[] = $search->compare('>=', $cmpfunc, ''); |
|
239 | 239 | |
240 | - $sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) ); |
|
241 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
240 | + $sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name')); |
|
241 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
242 | 242 | break; |
243 | 243 | |
244 | 244 | case 'price': |
245 | 245 | $currencyid = $context->getLocale()->getCurrencyId(); |
246 | 246 | |
247 | - $cmpfunc = $search->createFunction( 'index.price.value', array( $listtype, $currencyid, 'default' ) ); |
|
248 | - $expr[] = $search->compare( '>=', $cmpfunc, '0.00' ); |
|
247 | + $cmpfunc = $search->createFunction('index.price.value', array($listtype, $currencyid, 'default')); |
|
248 | + $expr[] = $search->compare('>=', $cmpfunc, '0.00'); |
|
249 | 249 | |
250 | - $sortfunc = $search->createFunction( 'sort:index.price.value', array( $listtype, $currencyid, 'default' ) ); |
|
251 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
250 | + $sortfunc = $search->createFunction('sort:index.price.value', array($listtype, $currencyid, 'default')); |
|
251 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
252 | 252 | break; |
253 | 253 | } |
254 | 254 | |
255 | 255 | $expr[] = $search->getConditions(); |
256 | 256 | |
257 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
258 | - $search->setSortations( $sortations ); |
|
259 | - $search->setSlice( $start, $size ); |
|
257 | + $search->setConditions($search->combine('&&', $expr)); |
|
258 | + $search->setSortations($sortations); |
|
259 | + $search->setSlice($start, $size); |
|
260 | 260 | |
261 | 261 | return $search; |
262 | 262 | } |
@@ -270,15 +270,15 @@ discard block |
||
270 | 270 | * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items |
271 | 271 | * @since 2017.03 |
272 | 272 | */ |
273 | - public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) ) |
|
273 | + public function getItem($productId, array $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text')) |
|
274 | 274 | { |
275 | - $items = $this->getItems( [$productId], $domains ); |
|
275 | + $items = $this->getItems([$productId], $domains); |
|
276 | 276 | |
277 | - if( ( $item = reset( $items ) ) !== false ) { |
|
277 | + if (($item = reset($items)) !== false) { |
|
278 | 278 | return $item; |
279 | 279 | } |
280 | 280 | |
281 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Product item with ID "%1$s" not found', $productId ) ); |
|
281 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Product item with ID "%1$s" not found', $productId)); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -290,10 +290,10 @@ discard block |
||
290 | 290 | * @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values |
291 | 291 | * @since 2017.03 |
292 | 292 | */ |
293 | - public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) ) |
|
293 | + public function getItems(array $productIds, array $domains = array('media', 'price', 'text')) |
|
294 | 294 | { |
295 | 295 | $context = $this->getContext(); |
296 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
296 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
297 | 297 | |
298 | 298 | /** controller/frontend/order/ignore-dates |
299 | 299 | * Ignore start and end dates of products |
@@ -307,25 +307,25 @@ discard block |
||
307 | 307 | * @since 2017.08 |
308 | 308 | * @category Developer |
309 | 309 | */ |
310 | - if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) ) |
|
310 | + if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false)) |
|
311 | 311 | { |
312 | 312 | $search = $manager->createSearch(); |
313 | - $search->setConditions( $search->compare( '>', 'product.status', 0 ) ); |
|
313 | + $search->setConditions($search->compare('>', 'product.status', 0)); |
|
314 | 314 | } |
315 | 315 | else |
316 | 316 | { |
317 | - $search = $manager->createSearch( true ); |
|
317 | + $search = $manager->createSearch(true); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | $expr = array( |
321 | - $search->compare( '==', 'product.id', $productIds ), |
|
321 | + $search->compare('==', 'product.id', $productIds), |
|
322 | 322 | $search->getConditions(), |
323 | 323 | ); |
324 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
325 | - $search->setSortations( [$search->sort( '+', 'product.type.position' )] ); |
|
326 | - $search->setSlice( 0, count( $productIds ) ); |
|
324 | + $search->setConditions($search->combine('&&', $expr)); |
|
325 | + $search->setSortations([$search->sort('+', 'product.type.position')]); |
|
326 | + $search->setSlice(0, count($productIds)); |
|
327 | 327 | |
328 | - return $manager->searchItems( $search, $domains ); |
|
328 | + return $manager->searchItems($search, $domains); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
339 | 339 | * @since 2017.03 |
340 | 340 | */ |
341 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
341 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null) |
|
342 | 342 | { |
343 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total ); |
|
343 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->searchItems($filter, $domains, $total); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -350,16 +350,16 @@ discard block |
||
350 | 350 | * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children |
351 | 351 | * @return array List of catalog IDs |
352 | 352 | */ |
353 | - protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item ) |
|
353 | + protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item) |
|
354 | 354 | { |
355 | - if( $item->getStatus() < 1 ) { |
|
355 | + if ($item->getStatus() < 1) { |
|
356 | 356 | return []; |
357 | 357 | } |
358 | 358 | |
359 | - $list = [ $item->getId() ]; |
|
359 | + $list = [$item->getId()]; |
|
360 | 360 | |
361 | - foreach( $item->getChildren() as $child ) { |
|
362 | - $list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) ); |
|
361 | + foreach ($item->getChildren() as $child) { |
|
362 | + $list = array_merge($list, $this->getCatalogIdsFromTree($child)); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | return $list; |
@@ -372,13 +372,13 @@ discard block |
||
372 | 372 | * @param array $ids List of IDs to validate |
373 | 373 | * @return array List of validated IDs |
374 | 374 | */ |
375 | - protected function validateIds( array $ids ) |
|
375 | + protected function validateIds(array $ids) |
|
376 | 376 | { |
377 | 377 | $list = []; |
378 | 378 | |
379 | - foreach( $ids as $id ) |
|
379 | + foreach ($ids as $id) |
|
380 | 380 | { |
381 | - if( $id != '' ) { |
|
381 | + if ($id != '') { |
|
382 | 382 | $list[] = (int) $id; |
383 | 383 | } |
384 | 384 | } |
@@ -431,17 +431,14 @@ |
||
431 | 431 | { |
432 | 432 | $address->copyFrom( $value ); |
433 | 433 | $this->get()->setAddress( $address, $type ); |
434 | - } |
|
435 | - else if( is_array( $value ) ) |
|
434 | + } else if( is_array( $value ) ) |
|
436 | 435 | { |
437 | 436 | $this->setAddressFromArray( $address, $value ); |
438 | 437 | $this->get()->setAddress( $address, $type ); |
439 | - } |
|
440 | - else if( $value === null ) |
|
438 | + } else if( $value === null ) |
|
441 | 439 | { |
442 | 440 | $this->get()->deleteAddress( $type ); |
443 | - } |
|
444 | - else |
|
441 | + } else |
|
445 | 442 | { |
446 | 443 | $msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid value for address type "%1$s"' ); |
447 | 444 | throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $type ) ); |
@@ -150,7 +150,6 @@ |
||
150 | 150 | * Adds the delivery/payment service item based on the service ID. |
151 | 151 | * |
152 | 152 | * @param string $type Service type code like 'payment' or 'delivery' |
153 | - * @param string $id|null Unique ID of the service item or null to remove it |
|
154 | 153 | * @param array $attributes Associative list of key/value pairs containing the attributes selected or |
155 | 154 | * entered by the customer when choosing one of the delivery or payment options |
156 | 155 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | * @param \Aimeos\MShop\Context\Item\Iface $context Object storing the required instances for manaing databases |
34 | 34 | * connections, logger, session, etc. |
35 | 35 | */ |
36 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
36 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
37 | 37 | { |
38 | - parent::__construct( $context ); |
|
38 | + parent::__construct($context); |
|
39 | 39 | |
40 | - $this->domainManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
40 | + $this->domainManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function clear() |
50 | 50 | { |
51 | 51 | $this->baskets[$this->type] = $this->domainManager->createItem(); |
52 | - $this->domainManager->setSession( $this->baskets[$this->type], $this->type ); |
|
52 | + $this->domainManager->setSession($this->baskets[$this->type], $this->type); |
|
53 | 53 | |
54 | 54 | return $this; |
55 | 55 | } |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function get() |
64 | 64 | { |
65 | - if( !isset( $this->baskets[$this->type] ) ) |
|
65 | + if (!isset($this->baskets[$this->type])) |
|
66 | 66 | { |
67 | - $this->baskets[$this->type] = $this->domainManager->getSession( $this->type ); |
|
68 | - $this->checkLocale( $this->baskets[$this->type]->getLocale(), $this->type ); |
|
67 | + $this->baskets[$this->type] = $this->domainManager->getSession($this->type); |
|
68 | + $this->checkLocale($this->baskets[$this->type]->getLocale(), $this->type); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | return $this->baskets[$this->type]; |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function save() |
81 | 81 | { |
82 | - if( isset( $this->baskets[$this->type] ) && $this->baskets[$this->type]->isModified() ) { |
|
83 | - $this->domainManager->setSession( $this->baskets[$this->type], $this->type ); |
|
82 | + if (isset($this->baskets[$this->type]) && $this->baskets[$this->type]->isModified()) { |
|
83 | + $this->domainManager->setSession($this->baskets[$this->type], $this->type); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $this; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string $type Basket type |
94 | 94 | * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object |
95 | 95 | */ |
96 | - public function setType( $type ) |
|
96 | + public function setType($type) |
|
97 | 97 | { |
98 | 98 | $this->type = $type; |
99 | 99 | return $this; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @category Developer |
128 | 128 | * @see controller/frontend/basket/limit-seconds |
129 | 129 | */ |
130 | - $count = $config->get( 'controller/frontend/basket/limit-count', 5 ); |
|
130 | + $count = $config->get('controller/frontend/basket/limit-count', 5); |
|
131 | 131 | |
132 | 132 | /** controller/frontend/basket/limit-seconds |
133 | 133 | * Order limitation time frame in seconds |
@@ -145,33 +145,33 @@ discard block |
||
145 | 145 | * @category Developer |
146 | 146 | * @see controller/frontend/basket/limit-count |
147 | 147 | */ |
148 | - $seconds = $config->get( 'controller/frontend/basket/limit-seconds', 300 ); |
|
148 | + $seconds = $config->get('controller/frontend/basket/limit-seconds', 300); |
|
149 | 149 | |
150 | 150 | $search = $this->domainManager->createSearch(); |
151 | 151 | $expr = [ |
152 | - $search->compare( '==', 'order.base.editor', $context->getEditor() ), |
|
153 | - $search->compare( '>=', 'order.base.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), |
|
152 | + $search->compare('==', 'order.base.editor', $context->getEditor()), |
|
153 | + $search->compare('>=', 'order.base.ctime', date('Y-m-d H:i:s', time() - $seconds)), |
|
154 | 154 | ]; |
155 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
156 | - $search->setSlice( 0, 0 ); |
|
155 | + $search->setConditions($search->combine('&&', $expr)); |
|
156 | + $search->setSlice(0, 0); |
|
157 | 157 | |
158 | - $this->domainManager->searchItems( $search, [], $total ); |
|
158 | + $this->domainManager->searchItems($search, [], $total); |
|
159 | 159 | |
160 | - if( $total > $count ) |
|
160 | + if ($total > $count) |
|
161 | 161 | { |
162 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Temporary order limit reached' ); |
|
163 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
162 | + $msg = $context->getI18n()->dt('controller/frontend', 'Temporary order limit reached'); |
|
163 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
167 | 167 | $basket = $this->get()->finish(); |
168 | - $basket->setCustomerId( (string) $context->getUserId() ); |
|
168 | + $basket->setCustomerId((string) $context->getUserId()); |
|
169 | 169 | |
170 | 170 | $this->domainManager->begin(); |
171 | - $this->domainManager->store( $basket ); |
|
171 | + $this->domainManager->store($basket); |
|
172 | 172 | $this->domainManager->commit(); |
173 | 173 | |
174 | - $this->createSubscriptions( $basket ); |
|
174 | + $this->createSubscriptions($basket); |
|
175 | 175 | |
176 | 176 | return $basket; |
177 | 177 | } |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | * @param boolean $default True to add default criteria (user logged in), false if not |
186 | 186 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
187 | 187 | */ |
188 | - public function load( $id, $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL, $default = true ) |
|
188 | + public function load($id, $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL, $default = true) |
|
189 | 189 | { |
190 | - return $this->domainManager->load( $id, $parts, false, $default ); |
|
190 | + return $this->domainManager->load($id, $parts, false, $default); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -206,34 +206,34 @@ discard block |
||
206 | 206 | * @param string $stocktype Unique code of the stock type to deliver the products from |
207 | 207 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
208 | 208 | */ |
209 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
210 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ) |
|
209 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
210 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []) |
|
211 | 211 | { |
212 | 212 | $attributeMap = [ |
213 | - 'custom' => array_keys( $customAttributeValues ), |
|
214 | - 'config' => array_keys( $configAttributeIds ), |
|
213 | + 'custom' => array_keys($customAttributeValues), |
|
214 | + 'config' => array_keys($configAttributeIds), |
|
215 | 215 | ]; |
216 | - $this->checkListRef( $prodid, 'attribute', $attributeMap ); |
|
216 | + $this->checkListRef($prodid, 'attribute', $attributeMap); |
|
217 | 217 | |
218 | 218 | |
219 | 219 | $context = $this->getContext(); |
220 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
220 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
221 | 221 | |
222 | - $productItem = $productManager->getItem( $prodid, ['attribute', 'media', 'supplier', 'price', 'product', 'text'], true ); |
|
223 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
224 | - $hidden = $productItem->getRefItems( 'attribute', null, 'hidden' ); |
|
222 | + $productItem = $productManager->getItem($prodid, ['attribute', 'media', 'supplier', 'price', 'product', 'text'], true); |
|
223 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
224 | + $hidden = $productItem->getRefItems('attribute', null, 'hidden'); |
|
225 | 225 | |
226 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
227 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
226 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
227 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
228 | 228 | |
229 | - $custAttr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ); |
|
230 | - $confAttr = $this->getOrderProductAttributes( 'config', array_keys( $configAttributeIds ), [], $configAttributeIds ); |
|
231 | - $attr = array_merge( $custAttr, $confAttr, $this->getOrderProductAttributes( 'hidden', array_keys( $hidden ) ) ); |
|
229 | + $custAttr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues); |
|
230 | + $confAttr = $this->getOrderProductAttributes('config', array_keys($configAttributeIds), [], $configAttributeIds); |
|
231 | + $attr = array_merge($custAttr, $confAttr, $this->getOrderProductAttributes('hidden', array_keys($hidden))); |
|
232 | 232 | |
233 | - $orderBaseProductItem->setAttributes( $attr ); |
|
234 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
233 | + $orderBaseProductItem->setAttributes($attr); |
|
234 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
235 | 235 | |
236 | - $this->get()->addProduct( $orderBaseProductItem ); |
|
236 | + $this->get()->addProduct($orderBaseProductItem); |
|
237 | 237 | $this->save(); |
238 | 238 | } |
239 | 239 | |
@@ -243,17 +243,17 @@ discard block |
||
243 | 243 | * |
244 | 244 | * @param integer $position Position number (key) of the order product item |
245 | 245 | */ |
246 | - public function deleteProduct( $position ) |
|
246 | + public function deleteProduct($position) |
|
247 | 247 | { |
248 | - $product = $this->get()->getProduct( $position ); |
|
248 | + $product = $this->get()->getProduct($position); |
|
249 | 249 | |
250 | - if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
250 | + if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
251 | 251 | { |
252 | - $msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Basket item at position "%1$d" cannot be deleted manually' ); |
|
253 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $position ) ); |
|
252 | + $msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Basket item at position "%1$d" cannot be deleted manually'); |
|
253 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $position)); |
|
254 | 254 | } |
255 | 255 | |
256 | - $this->get()->deleteProduct( $position ); |
|
256 | + $this->get()->deleteProduct($position); |
|
257 | 257 | $this->save(); |
258 | 258 | } |
259 | 259 | |
@@ -265,32 +265,32 @@ discard block |
||
265 | 265 | * @param integer $quantity New quantiy of the product item |
266 | 266 | * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED |
267 | 267 | */ |
268 | - public function editProduct( $position, $quantity, array $configAttributeCodes = [] ) |
|
268 | + public function editProduct($position, $quantity, array $configAttributeCodes = []) |
|
269 | 269 | { |
270 | - $product = $this->get()->getProduct( $position ); |
|
270 | + $product = $this->get()->getProduct($position); |
|
271 | 271 | |
272 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
272 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
273 | 273 | { |
274 | - $msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Basket item at position "%1$d" cannot be changed' ); |
|
275 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $position ) ); |
|
274 | + $msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Basket item at position "%1$d" cannot be changed'); |
|
275 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $position)); |
|
276 | 276 | } |
277 | 277 | |
278 | - $product->setQuantity( $quantity ); |
|
278 | + $product->setQuantity($quantity); |
|
279 | 279 | |
280 | 280 | $attributes = $product->getAttributes(); |
281 | - foreach( $attributes as $key => $attribute ) |
|
281 | + foreach ($attributes as $key => $attribute) |
|
282 | 282 | { |
283 | - if( in_array( $attribute->getCode(), $configAttributeCodes ) ) { |
|
284 | - unset( $attributes[$key] ); |
|
283 | + if (in_array($attribute->getCode(), $configAttributeCodes)) { |
|
284 | + unset($attributes[$key]); |
|
285 | 285 | } |
286 | 286 | } |
287 | - $product->setAttributes( $attributes ); |
|
287 | + $product->setAttributes($attributes); |
|
288 | 288 | |
289 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
290 | - $productItem = $manager->findItem( $product->getProductCode(), array( 'price', 'text' ), true ); |
|
291 | - $product->setPrice( $this->calcPrice( $product, $productItem->getRefItems( 'price', 'default' ), $quantity ) ); |
|
289 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
290 | + $productItem = $manager->findItem($product->getProductCode(), array('price', 'text'), true); |
|
291 | + $product->setPrice($this->calcPrice($product, $productItem->getRefItems('price', 'default'), $quantity)); |
|
292 | 292 | |
293 | - $this->get()->editProduct( $product, $position ); |
|
293 | + $this->get()->editProduct($product, $position); |
|
294 | 294 | |
295 | 295 | $this->save(); |
296 | 296 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @param string $code Coupon code entered by the user |
303 | 303 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
304 | 304 | */ |
305 | - public function addCoupon( $code ) |
|
305 | + public function addCoupon($code) |
|
306 | 306 | { |
307 | 307 | $context = $this->getContext(); |
308 | 308 | |
@@ -322,39 +322,39 @@ discard block |
||
322 | 322 | * @category User |
323 | 323 | * @category Developer |
324 | 324 | */ |
325 | - $allowed = $context->getConfig()->get( 'controller/frontend/basket/standard/coupon/allowed', 1 ); |
|
325 | + $allowed = $context->getConfig()->get('controller/frontend/basket/standard/coupon/allowed', 1); |
|
326 | 326 | |
327 | - if( $allowed <= count( $this->get()->getCoupons() ) ) |
|
327 | + if ($allowed <= count($this->get()->getCoupons())) |
|
328 | 328 | { |
329 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Number of coupon codes exceeds the limit' ); |
|
330 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
329 | + $msg = $context->getI18n()->dt('controller/frontend', 'Number of coupon codes exceeds the limit'); |
|
330 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | |
334 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'coupon' ); |
|
334 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'coupon'); |
|
335 | 335 | |
336 | 336 | $search = $manager->createSearch(); |
337 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
338 | - $search->setSlice( 0, 1 ); |
|
337 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
338 | + $search->setSlice(0, 1); |
|
339 | 339 | |
340 | - $result = $manager->searchItems( $search ); |
|
340 | + $result = $manager->searchItems($search); |
|
341 | 341 | |
342 | - if( ( $item = reset( $result ) ) === false ) |
|
342 | + if (($item = reset($result)) === false) |
|
343 | 343 | { |
344 | - $msg = sprintf( $context->getI18n()->dt( 'controller/frontend', 'Coupon code "%1$s" is invalid or not available any more' ), $code ); |
|
345 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
344 | + $msg = sprintf($context->getI18n()->dt('controller/frontend', 'Coupon code "%1$s" is invalid or not available any more'), $code); |
|
345 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
349 | - $provider = $manager->getProvider( $item, $code ); |
|
349 | + $provider = $manager->getProvider($item, $code); |
|
350 | 350 | |
351 | - if( $provider->isAvailable( $this->get() ) !== true ) |
|
351 | + if ($provider->isAvailable($this->get()) !== true) |
|
352 | 352 | { |
353 | - $msg = sprintf( $context->getI18n()->dt( 'controller/frontend', 'Requirements for coupon code "%1$s" aren\'t met' ), $code ); |
|
354 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
353 | + $msg = sprintf($context->getI18n()->dt('controller/frontend', 'Requirements for coupon code "%1$s" aren\'t met'), $code); |
|
354 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
355 | 355 | } |
356 | 356 | |
357 | - $provider->addCoupon( $this->get() ); |
|
357 | + $provider->addCoupon($this->get()); |
|
358 | 358 | $this->save(); |
359 | 359 | } |
360 | 360 | |
@@ -365,24 +365,24 @@ discard block |
||
365 | 365 | * @param string $code Coupon code entered by the user |
366 | 366 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
367 | 367 | */ |
368 | - public function deleteCoupon( $code ) |
|
368 | + public function deleteCoupon($code) |
|
369 | 369 | { |
370 | 370 | $context = $this->getContext(); |
371 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'coupon' ); |
|
371 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'coupon'); |
|
372 | 372 | |
373 | 373 | $search = $manager->createSearch(); |
374 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
375 | - $search->setSlice( 0, 1 ); |
|
374 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
375 | + $search->setSlice(0, 1); |
|
376 | 376 | |
377 | - $result = $manager->searchItems( $search ); |
|
377 | + $result = $manager->searchItems($search); |
|
378 | 378 | |
379 | - if( ( $item = reset( $result ) ) === false ) |
|
379 | + if (($item = reset($result)) === false) |
|
380 | 380 | { |
381 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Coupon code "%1$s" is invalid' ); |
|
382 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $code ) ); |
|
381 | + $msg = $context->getI18n()->dt('controller/frontend', 'Coupon code "%1$s" is invalid'); |
|
382 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $code)); |
|
383 | 383 | } |
384 | 384 | |
385 | - $manager->getProvider( $item, $code )->deleteCoupon( $this->get() ); |
|
385 | + $manager->getProvider($item, $code)->deleteCoupon($this->get()); |
|
386 | 386 | $this->save(); |
387 | 387 | } |
388 | 388 | |
@@ -395,30 +395,30 @@ discard block |
||
395 | 395 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of |
396 | 396 | * if one of the keys is invalid when using an array with key/value pairs |
397 | 397 | */ |
398 | - public function setAddress( $type, $value ) |
|
398 | + public function setAddress($type, $value) |
|
399 | 399 | { |
400 | 400 | $context = $this->getContext(); |
401 | - $address = \Aimeos\MShop\Factory::createManager( $context, 'order/base/address' )->createItem(); |
|
402 | - $address->setType( $type ); |
|
401 | + $address = \Aimeos\MShop\Factory::createManager($context, 'order/base/address')->createItem(); |
|
402 | + $address->setType($type); |
|
403 | 403 | |
404 | - if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface ) |
|
404 | + if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface) |
|
405 | 405 | { |
406 | - $address->copyFrom( $value ); |
|
407 | - $this->get()->setAddress( $address, $type ); |
|
406 | + $address->copyFrom($value); |
|
407 | + $this->get()->setAddress($address, $type); |
|
408 | 408 | } |
409 | - else if( is_array( $value ) ) |
|
409 | + else if (is_array($value)) |
|
410 | 410 | { |
411 | - $this->setAddressFromArray( $address, $value ); |
|
412 | - $this->get()->setAddress( $address, $type ); |
|
411 | + $this->setAddressFromArray($address, $value); |
|
412 | + $this->get()->setAddress($address, $type); |
|
413 | 413 | } |
414 | - else if( $value === null ) |
|
414 | + else if ($value === null) |
|
415 | 415 | { |
416 | - $this->get()->deleteAddress( $type ); |
|
416 | + $this->get()->deleteAddress($type); |
|
417 | 417 | } |
418 | 418 | else |
419 | 419 | { |
420 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid value for address type "%1$s"' ); |
|
421 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $type ) ); |
|
420 | + $msg = $context->getI18n()->dt('controller/frontend', 'Invalid value for address type "%1$s"'); |
|
421 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $type)); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | $this->save(); |
@@ -434,42 +434,42 @@ discard block |
||
434 | 434 | * entered by the customer when choosing one of the delivery or payment options |
435 | 435 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
436 | 436 | */ |
437 | - public function addService( $type, $id, array $attributes = [] ) |
|
437 | + public function addService($type, $id, array $attributes = []) |
|
438 | 438 | { |
439 | 439 | $context = $this->getContext(); |
440 | 440 | |
441 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
442 | - $serviceItem = $serviceManager->getItem( $id, array( 'media', 'price', 'text' ) ); |
|
441 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
442 | + $serviceItem = $serviceManager->getItem($id, array('media', 'price', 'text')); |
|
443 | 443 | |
444 | - $provider = $serviceManager->getProvider( $serviceItem, $serviceItem->getType() ); |
|
445 | - $result = $provider->checkConfigFE( $attributes ); |
|
446 | - $unknown = array_diff_key( $attributes, $result ); |
|
444 | + $provider = $serviceManager->getProvider($serviceItem, $serviceItem->getType()); |
|
445 | + $result = $provider->checkConfigFE($attributes); |
|
446 | + $unknown = array_diff_key($attributes, $result); |
|
447 | 447 | |
448 | - if( count( $unknown ) > 0 ) |
|
448 | + if (count($unknown) > 0) |
|
449 | 449 | { |
450 | - $msg = $context->getI18n()->dt( 'controller/frontend', 'Unknown attributes "%1$s"' ); |
|
451 | - $msg = sprintf( $msg, implode( '","', array_keys( $unknown ) ) ); |
|
452 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
450 | + $msg = $context->getI18n()->dt('controller/frontend', 'Unknown attributes "%1$s"'); |
|
451 | + $msg = sprintf($msg, implode('","', array_keys($unknown))); |
|
452 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
453 | 453 | } |
454 | 454 | |
455 | - foreach( $result as $key => $value ) |
|
455 | + foreach ($result as $key => $value) |
|
456 | 456 | { |
457 | - if( $value !== null ) { |
|
458 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $value ); |
|
457 | + if ($value !== null) { |
|
458 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($value); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
462 | - $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' ); |
|
462 | + $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service'); |
|
463 | 463 | $orderServiceItem = $orderBaseServiceManager->createItem(); |
464 | - $orderServiceItem->copyFrom( $serviceItem ); |
|
464 | + $orderServiceItem->copyFrom($serviceItem); |
|
465 | 465 | |
466 | 466 | // remove service rebate of original price |
467 | - $price = $provider->calcPrice( $this->get() )->setRebate( '0.00' ); |
|
468 | - $orderServiceItem->setPrice( $price ); |
|
467 | + $price = $provider->calcPrice($this->get())->setRebate('0.00'); |
|
468 | + $orderServiceItem->setPrice($price); |
|
469 | 469 | |
470 | - $provider->setConfigFE( $orderServiceItem, $attributes ); |
|
470 | + $provider->setConfigFE($orderServiceItem, $attributes); |
|
471 | 471 | |
472 | - $this->get()->addService( $orderServiceItem, $type ); |
|
472 | + $this->get()->addService($orderServiceItem, $type); |
|
473 | 473 | $this->save(); |
474 | 474 | } |
475 | 475 | |
@@ -479,9 +479,9 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @param string $type Service type code like 'payment' or 'delivery' |
481 | 481 | */ |
482 | - public function deleteService( $type ) |
|
482 | + public function deleteService($type) |
|
483 | 483 | { |
484 | - $this->get()->deleteService( $type ); |
|
484 | + $this->get()->deleteService($type); |
|
485 | 485 | $this->save(); |
486 | 486 | } |
487 | 487 | |
@@ -494,18 +494,18 @@ discard block |
||
494 | 494 | * an address item. |
495 | 495 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
496 | 496 | */ |
497 | - protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map ) |
|
497 | + protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map) |
|
498 | 498 | { |
499 | - foreach( $map as $key => $value ) { |
|
500 | - $map[$key] = strip_tags( $value ); // prevent XSS |
|
499 | + foreach ($map as $key => $value) { |
|
500 | + $map[$key] = strip_tags($value); // prevent XSS |
|
501 | 501 | } |
502 | 502 | |
503 | - $errors = $address->fromArray( $map ); |
|
503 | + $errors = $address->fromArray($map); |
|
504 | 504 | |
505 | - if( count( $errors ) > 0 ) |
|
505 | + if (count($errors) > 0) |
|
506 | 506 | { |
507 | - $msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Invalid address properties, please check your input' ); |
|
508 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors ); |
|
507 | + $msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Invalid address properties, please check your input'); |
|
508 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors); |
|
509 | 509 | } |
510 | 510 | } |
511 | 511 | } |
@@ -150,7 +150,6 @@ |
||
150 | 150 | * Adds the delivery/payment service item based on the service ID. |
151 | 151 | * |
152 | 152 | * @param string $type Service type code like 'payment' or 'delivery' |
153 | - * @param string $id|null Unique ID of the service item or null to remove it |
|
154 | 153 | * @param array $attributes Associative list of key/value pairs containing the attributes selected or |
155 | 154 | * entered by the customer when choosing one of the delivery or payment options |
156 | 155 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param string $type Basket type |
51 | 51 | * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object |
52 | 52 | */ |
53 | - public function setType( $type ); |
|
53 | + public function setType($type); |
|
54 | 54 | |
55 | 55 | |
56 | 56 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param boolean $default True to add default criteria (user logged in), false if not |
70 | 70 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
71 | 71 | */ |
72 | - public function load( $id, $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL, $default = true ); |
|
72 | + public function load($id, $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL, $default = true); |
|
73 | 73 | |
74 | 74 | |
75 | 75 | /** |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
89 | 89 | * @return void |
90 | 90 | */ |
91 | - public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
92 | - array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] ); |
|
91 | + public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [], |
|
92 | + array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []); |
|
93 | 93 | |
94 | 94 | |
95 | 95 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param integer $position Position number (key) of the order product item |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - public function deleteProduct( $position ); |
|
101 | + public function deleteProduct($position); |
|
102 | 102 | |
103 | 103 | |
104 | 104 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED |
110 | 110 | * @return void |
111 | 111 | */ |
112 | - public function editProduct( $position, $quantity, array $configAttributeCodes = [] ); |
|
112 | + public function editProduct($position, $quantity, array $configAttributeCodes = []); |
|
113 | 113 | |
114 | 114 | |
115 | 115 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
120 | 120 | * @return void |
121 | 121 | */ |
122 | - public function addCoupon( $code ); |
|
122 | + public function addCoupon($code); |
|
123 | 123 | |
124 | 124 | |
125 | 125 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
130 | 130 | * @return void |
131 | 131 | */ |
132 | - public function deleteCoupon( $code ); |
|
132 | + public function deleteCoupon($code); |
|
133 | 133 | |
134 | 134 | |
135 | 135 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * if one of the keys is invalid when using an array with key/value pairs |
142 | 142 | * @return void |
143 | 143 | */ |
144 | - public function setAddress( $type, $value ); |
|
144 | + public function setAddress($type, $value); |
|
145 | 145 | |
146 | 146 | |
147 | 147 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * entered by the customer when choosing one of the delivery or payment options |
154 | 154 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
155 | 155 | */ |
156 | - public function addService( $type, $id, array $attributes = [] ); |
|
156 | + public function addService($type, $id, array $attributes = []); |
|
157 | 157 | |
158 | 158 | |
159 | 159 | /** |
@@ -161,5 +161,5 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @param string $type Service type code like 'payment' or 'delivery' |
163 | 163 | */ |
164 | - public function deleteService( $type ); |
|
164 | + public function deleteService($type); |
|
165 | 165 | } |
@@ -20,54 +20,54 @@ discard block |
||
20 | 20 | { |
21 | 21 | $this->context = \TestHelperFrontend::getContext(); |
22 | 22 | |
23 | - $this->stub = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
23 | + $this->stub = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
24 | 24 | ->disableOriginalConstructor() |
25 | 25 | ->getMock(); |
26 | 26 | |
27 | - $this->object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Decorator\Base' ) |
|
28 | - ->setConstructorArgs( [$this->stub, $this->context] ) |
|
27 | + $this->object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Decorator\Base') |
|
28 | + ->setConstructorArgs([$this->stub, $this->context]) |
|
29 | 29 | ->getMockForAbstractClass(); |
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | 33 | protected function tearDown() |
34 | 34 | { |
35 | - unset( $this->context, $this->object, $this->stub ); |
|
35 | + unset($this->context, $this->object, $this->stub); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | 39 | public function testConstructException() |
40 | 40 | { |
41 | - $stub = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Iface' )->getMock(); |
|
41 | + $stub = $this->getMockBuilder('\Aimeos\Controller\Frontend\Iface')->getMock(); |
|
42 | 42 | |
43 | - $this->setExpectedException( '\Aimeos\Controller\Frontend\Exception' ); |
|
43 | + $this->setExpectedException('\Aimeos\Controller\Frontend\Exception'); |
|
44 | 44 | |
45 | - $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Decorator\Base' ) |
|
46 | - ->setConstructorArgs( [$stub, $this->context] ) |
|
45 | + $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Decorator\Base') |
|
46 | + ->setConstructorArgs([$stub, $this->context]) |
|
47 | 47 | ->getMockForAbstractClass(); |
48 | 48 | } |
49 | 49 | |
50 | 50 | |
51 | 51 | public function testCall() |
52 | 52 | { |
53 | - $stub = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
53 | + $stub = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
54 | 54 | ->disableOriginalConstructor() |
55 | - ->setMethods( ['invalid'] ) |
|
55 | + ->setMethods(['invalid']) |
|
56 | 56 | ->getMock(); |
57 | 57 | |
58 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Decorator\Base' ) |
|
59 | - ->setConstructorArgs( [$stub, $this->context] ) |
|
58 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Decorator\Base') |
|
59 | + ->setConstructorArgs([$stub, $this->context]) |
|
60 | 60 | ->getMockForAbstractClass(); |
61 | 61 | |
62 | - $stub->expects( $this->once() )->method( 'invalid' )->will( $this->returnValue( true ) ); |
|
62 | + $stub->expects($this->once())->method('invalid')->will($this->returnValue(true)); |
|
63 | 63 | |
64 | - $this->assertTrue( $object->invalid() ); |
|
64 | + $this->assertTrue($object->invalid()); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | 68 | public function testClear() |
69 | 69 | { |
70 | - $this->stub->expects( $this->once() )->method( 'clear' ); |
|
70 | + $this->stub->expects($this->once())->method('clear'); |
|
71 | 71 | |
72 | 72 | $this->object->clear(); |
73 | 73 | } |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | public function testGet() |
77 | 77 | { |
78 | 78 | $context = \TestHelperFrontend::getContext(); |
79 | - $order = \Aimeos\MShop\Factory::createManager( $context, 'order/base' )->createItem(); |
|
79 | + $order = \Aimeos\MShop\Factory::createManager($context, 'order/base')->createItem(); |
|
80 | 80 | |
81 | - $this->stub->expects( $this->once() )->method( 'get' ) |
|
82 | - ->will( $this->returnValue( $order ) ); |
|
81 | + $this->stub->expects($this->once())->method('get') |
|
82 | + ->will($this->returnValue($order)); |
|
83 | 83 | |
84 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get() ); |
|
84 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get()); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
88 | 88 | public function testSave() |
89 | 89 | { |
90 | - $this->stub->expects( $this->once() )->method( 'save' ); |
|
90 | + $this->stub->expects($this->once())->method('save'); |
|
91 | 91 | |
92 | 92 | $this->object->save(); |
93 | 93 | } |
@@ -95,15 +95,15 @@ discard block |
||
95 | 95 | |
96 | 96 | public function testSetType() |
97 | 97 | { |
98 | - $this->stub->expects( $this->once() )->method( 'setType' ); |
|
98 | + $this->stub->expects($this->once())->method('setType'); |
|
99 | 99 | |
100 | - $this->object->setType( 'test' ); |
|
100 | + $this->object->setType('test'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
104 | 104 | public function testStore() |
105 | 105 | { |
106 | - $this->stub->expects( $this->once() )->method( 'store' ); |
|
106 | + $this->stub->expects($this->once())->method('store'); |
|
107 | 107 | |
108 | 108 | $this->object->store(); |
109 | 109 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | public function testLoad() |
113 | 113 | { |
114 | - $this->stub->expects( $this->once() )->method( 'load' ); |
|
114 | + $this->stub->expects($this->once())->method('load'); |
|
115 | 115 | |
116 | 116 | $this->object->load( -1 ); |
117 | 117 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | public function testAddProduct() |
121 | 121 | { |
122 | - $this->stub->expects( $this->once() )->method( 'addProduct' ); |
|
122 | + $this->stub->expects($this->once())->method('addProduct'); |
|
123 | 123 | |
124 | 124 | $this->object->addProduct( -1 ); |
125 | 125 | } |
@@ -127,73 +127,73 @@ discard block |
||
127 | 127 | |
128 | 128 | public function testDeleteProduct() |
129 | 129 | { |
130 | - $this->stub->expects( $this->once() )->method( 'deleteProduct' ); |
|
130 | + $this->stub->expects($this->once())->method('deleteProduct'); |
|
131 | 131 | |
132 | - $this->object->deleteProduct( 0 ); |
|
132 | + $this->object->deleteProduct(0); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
136 | 136 | public function testEditProduct() |
137 | 137 | { |
138 | - $this->stub->expects( $this->once() )->method( 'editProduct' ); |
|
138 | + $this->stub->expects($this->once())->method('editProduct'); |
|
139 | 139 | |
140 | - $this->object->editProduct( 0, 1 ); |
|
140 | + $this->object->editProduct(0, 1); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
144 | 144 | public function testAddCoupon() |
145 | 145 | { |
146 | - $this->stub->expects( $this->once() )->method( 'addCoupon' ); |
|
146 | + $this->stub->expects($this->once())->method('addCoupon'); |
|
147 | 147 | |
148 | - $this->object->addCoupon( 'test' ); |
|
148 | + $this->object->addCoupon('test'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
152 | 152 | public function testDeleteCoupon() |
153 | 153 | { |
154 | - $this->stub->expects( $this->once() )->method( 'deleteCoupon' ); |
|
154 | + $this->stub->expects($this->once())->method('deleteCoupon'); |
|
155 | 155 | |
156 | - $this->object->deleteCoupon( 'test' ); |
|
156 | + $this->object->deleteCoupon('test'); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
160 | 160 | public function testSetAddress() |
161 | 161 | { |
162 | - $this->stub->expects( $this->once() )->method( 'setAddress' ); |
|
162 | + $this->stub->expects($this->once())->method('setAddress'); |
|
163 | 163 | |
164 | - $this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null ); |
|
164 | + $this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
168 | 168 | public function testAddService() |
169 | 169 | { |
170 | - $this->stub->expects( $this->once() )->method( 'addService' ); |
|
170 | + $this->stub->expects($this->once())->method('addService'); |
|
171 | 171 | |
172 | - $this->object->addService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT, -1 ); |
|
172 | + $this->object->addService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT, -1); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | |
176 | 176 | public function testDeleteService() |
177 | 177 | { |
178 | - $this->stub->expects( $this->once() )->method( 'deleteService' ); |
|
178 | + $this->stub->expects($this->once())->method('deleteService'); |
|
179 | 179 | |
180 | - $this->object->deleteService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT ); |
|
180 | + $this->object->deleteService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | |
184 | 184 | public function testGetController() |
185 | 185 | { |
186 | - $result = $this->access( 'getController' )->invokeArgs( $this->object, [] ); |
|
186 | + $result = $this->access('getController')->invokeArgs($this->object, []); |
|
187 | 187 | |
188 | - $this->assertSame( $this->stub, $result ); |
|
188 | + $this->assertSame($this->stub, $result); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | |
192 | - protected function access( $name ) |
|
192 | + protected function access($name) |
|
193 | 193 | { |
194 | - $class = new \ReflectionClass( '\Aimeos\Controller\Frontend\Basket\Decorator\Base' ); |
|
195 | - $method = $class->getMethod( $name ); |
|
196 | - $method->setAccessible( true ); |
|
194 | + $class = new \ReflectionClass('\Aimeos\Controller\Frontend\Basket\Decorator\Base'); |
|
195 | + $method = $class->getMethod($name); |
|
196 | + $method->setAccessible(true); |
|
197 | 197 | |
198 | 198 | return $method; |
199 | 199 | } |