Completed
Push — master ( 7164bc...d21ec6 )
by Aimeos
02:07
created
controller/frontend/src/Controller/Frontend/Basket/Iface.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -150,7 +150,6 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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\Manager\Base\Base::PARTS_ALL, $default = true );
72
+	public function load($id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true);
73 73
 
74 74
 
75 75
 	/**
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available
90 90
 	 * @return void
91 91
 	 */
92
-	public function addProduct( $prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [],
92
+	public function addProduct($prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [],
93 93
 		array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [],
94
-		$stocktype = 'default' );
94
+		$stocktype = 'default');
95 95
 
96 96
 
97 97
 	/**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @param integer $position Position number (key) of the order product item
101 101
 	 * @return void
102 102
 	 */
103
-	public function deleteProduct( $position );
103
+	public function deleteProduct($position);
104 104
 
105 105
 
106 106
 	/**
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED
112 112
 	 * @return void
113 113
 	 */
114
-	public function editProduct( $position, $quantity, array $configAttributeCodes = [] );
114
+	public function editProduct($position, $quantity, array $configAttributeCodes = []);
115 115
 
116 116
 
117 117
 	/**
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed
122 122
 	 * @return void
123 123
 	 */
124
-	public function addCoupon( $code );
124
+	public function addCoupon($code);
125 125
 
126 126
 
127 127
 	/**
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid
132 132
 	 * @return void
133 133
 	 */
134
-	public function deleteCoupon( $code );
134
+	public function deleteCoupon($code);
135 135
 
136 136
 
137 137
 	/**
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * 	if one of the keys is invalid when using an array with key/value pairs
144 144
 	 * @return void
145 145
 	 */
146
-	public function setAddress( $type, $value );
146
+	public function setAddress($type, $value);
147 147
 
148 148
 
149 149
 	/**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * 	entered by the customer when choosing one of the delivery or payment options
156 156
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached
157 157
 	 */
158
-	public function addService( $type, $id, array $attributes = [] );
158
+	public function addService($type, $id, array $attributes = []);
159 159
 
160 160
 
161 161
 	/**
@@ -163,5 +163,5 @@  discard block
 block discarded – undo
163 163
 	 *
164 164
 	 * @param string $type Service type code like 'payment' or 'delivery'
165 165
 	 */
166
-	public function deleteService( $type );
166
+	public function deleteService($type);
167 167
 }
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Basket/Base.php 2 patches
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -225,8 +225,7 @@  discard block
 block discarded – undo
225 225
 			{
226 226
 				$this->setAddress( $type, $item->toArray() );
227 227
 				$basket->deleteAddress( $type );
228
-			}
229
-			catch( \Exception $e )
228
+			} catch( \Exception $e )
230 229
 			{
231 230
 				$logger = $this->getContext()->getLogger();
232 231
 				$str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s';
@@ -255,8 +254,7 @@  discard block
 block discarded – undo
255 254
 			{
256 255
 				$this->addCoupon( $code );
257 256
 				$basket->deleteCoupon( $code, true );
258
-			}
259
-			catch( \Exception $e )
257
+			} catch( \Exception $e )
260 258
 			{
261 259
 				$logger = $this->getContext()->getLogger();
262 260
 				$str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s';
@@ -305,8 +303,7 @@  discard block
 block discarded – undo
305 303
 				);
306 304
 
307 305
 				$basket->deleteProduct( $pos );
308
-			}
309
-			catch( \Exception $e )
306
+			} catch( \Exception $e )
310 307
 			{
311 308
 				$code = $product->getProductCode();
312 309
 				$logger = $this->getContext()->getLogger();
@@ -344,8 +341,7 @@  discard block
 block discarded – undo
344 341
 
345 342
 					$this->addService( $type, $item->getServiceId(), $attributes );
346 343
 					$basket->deleteService( $type );
347
-				}
348
-				catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically
344
+				} catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically
349 345
 			}
350 346
 		}
351 347
 
Please login to merge, or discard this patch.
Spacing   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -31,50 +31,50 @@  discard block
 block discarded – undo
31 31
 	 * @param integer $quantity New product quantity
32 32
 	 * @return \Aimeos\MShop\Price\Item\Iface Price item with calculated price
33 33
 	 */
34
-	protected function calcPrice( \Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity )
34
+	protected function calcPrice(\Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity)
35 35
 	{
36 36
 		$context = $this->getContext();
37 37
 
38
-		if( empty( $prices ) )
38
+		if (empty($prices))
39 39
 		{
40
-			$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
41
-			$prices = $manager->getItem( $product->getProductId(), array( 'price' ) )->getRefItems( 'price', 'default' );
40
+			$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
41
+			$prices = $manager->getItem($product->getProductId(), array('price'))->getRefItems('price', 'default');
42 42
 		}
43 43
 
44 44
 
45
-		$priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' );
46
-		$price = $priceManager->getLowestPrice( $prices, $quantity );
45
+		$priceManager = \Aimeos\MShop\Factory::createManager($context, 'price');
46
+		$price = $priceManager->getLowestPrice($prices, $quantity);
47 47
 
48 48
 		// customers can pay what they would like to pay
49
-		if( ( $attr = $product->getAttributeItem( 'price', 'custom' ) ) !== null )
49
+		if (($attr = $product->getAttributeItem('price', 'custom')) !== null)
50 50
 		{
51 51
 			$amount = $attr->getValue();
52 52
 
53
-			if( preg_match( '/^[0-9]*(\.[0-9]+)?$/', $amount ) !== 1 || ((double) $amount) < 0.01 ) {
54
-				throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid price value "%1$s"', $amount ) );
53
+			if (preg_match('/^[0-9]*(\.[0-9]+)?$/', $amount) !== 1 || ((double) $amount) < 0.01) {
54
+				throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid price value "%1$s"', $amount));
55 55
 			}
56 56
 
57
-			$price->setValue( $amount );
57
+			$price->setValue($amount);
58 58
 		}
59 59
 
60 60
 		$orderAttributes = $product->getAttributes();
61
-		$attrItems = $this->getAttributeItems( $orderAttributes );
61
+		$attrItems = $this->getAttributeItems($orderAttributes);
62 62
 
63 63
 		// add prices of (optional) attributes
64
-		foreach( $orderAttributes as $orderAttrItem )
64
+		foreach ($orderAttributes as $orderAttrItem)
65 65
 		{
66 66
 			$attrId = $orderAttrItem->getAttributeId();
67 67
 
68
-			if( isset( $attrItems[$attrId] )
69
-				&& ( $prices = $attrItems[$attrId]->getRefItems( 'price', 'default' ) ) !== []
68
+			if (isset($attrItems[$attrId])
69
+				&& ($prices = $attrItems[$attrId]->getRefItems('price', 'default')) !== []
70 70
 			) {
71
-				$attrPrice = $priceManager->getLowestPrice( $prices, $orderAttrItem->getQuantity() );
72
-				$price->addItem( $attrPrice, $orderAttrItem->getQuantity() );
71
+				$attrPrice = $priceManager->getLowestPrice($prices, $orderAttrItem->getQuantity());
72
+				$price->addItem($attrPrice, $orderAttrItem->getQuantity());
73 73
 			}
74 74
 		}
75 75
 
76 76
 		// remove product rebate of original price in favor to rebates granted for the order
77
-		$price->setRebate( '0.00' );
77
+		$price->setRebate('0.00');
78 78
 
79 79
 		return $price;
80 80
 	}
@@ -88,42 +88,42 @@  discard block
 block discarded – undo
88 88
 	 * @param array $refMap Associative list of list type codes as keys and lists of reference IDs as values
89 89
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated
90 90
 	 */
91
-	protected function checkListRef( $prodId, $domain, array $refMap )
91
+	protected function checkListRef($prodId, $domain, array $refMap)
92 92
 	{
93
-		if( empty( $refMap ) ) {
93
+		if (empty($refMap)) {
94 94
 			return;
95 95
 		}
96 96
 
97
-		$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
98
-		$search = $productManager->createSearch( true );
97
+		$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
98
+		$search = $productManager->createSearch(true);
99 99
 
100 100
 		$expr = array(
101
-			$search->compare( '==', 'product.id', $prodId ),
101
+			$search->compare('==', 'product.id', $prodId),
102 102
 			$search->getConditions(),
103 103
 		);
104 104
 
105
-		foreach( $refMap as $listType => $refIds )
105
+		foreach ($refMap as $listType => $refIds)
106 106
 		{
107
-			if( empty( $refIds ) ) {
107
+			if (empty($refIds)) {
108 108
 				continue;
109 109
 			}
110 110
 
111
-			foreach( $refIds as $key => $refId ) {
111
+			foreach ($refIds as $key => $refId) {
112 112
 				$refIds[$key] = (string) $refId;
113 113
 			}
114 114
 
115
-			$param = array( $domain, $this->getProductListTypeItem( $domain, $listType )->getId(), $refIds );
116
-			$cmpfunc = $search->createFunction( 'product.contains', $param );
115
+			$param = array($domain, $this->getProductListTypeItem($domain, $listType)->getId(), $refIds);
116
+			$cmpfunc = $search->createFunction('product.contains', $param);
117 117
 
118
-			$expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) );
118
+			$expr[] = $search->compare('==', $cmpfunc, count($refIds));
119 119
 		}
120 120
 
121
-		$search->setConditions( $search->combine( '&&', $expr ) );
121
+		$search->setConditions($search->combine('&&', $expr));
122 122
 
123
-		if( count( $productManager->searchItems( $search, [] ) ) === 0 )
123
+		if (count($productManager->searchItems($search, [])) === 0)
124 124
 		{
125
-			$msg = sprintf( 'Invalid "%1$s" references for product with ID %2$s', $domain, json_encode( $prodId ) );
126
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
125
+			$msg = sprintf('Invalid "%1$s" references for product with ID %2$s', $domain, json_encode($prodId));
126
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
127 127
 		}
128 128
 	}
129 129
 
@@ -138,34 +138,34 @@  discard block
 block discarded – undo
138 138
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated
139 139
 	 * @deprecated Use checkListRef() instead
140 140
 	 */
141
-	protected function checkReferences( $prodId, $domain, $listTypeId, array $refIds )
141
+	protected function checkReferences($prodId, $domain, $listTypeId, array $refIds)
142 142
 	{
143
-		$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
144
-		$search = $productManager->createSearch( true );
143
+		$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
144
+		$search = $productManager->createSearch(true);
145 145
 
146 146
 		$expr = array(
147
-			$search->compare( '==', 'product.id', $prodId ),
147
+			$search->compare('==', 'product.id', $prodId),
148 148
 			$search->getConditions(),
149 149
 		);
150 150
 
151
-		if( count( $refIds ) > 0 )
151
+		if (count($refIds) > 0)
152 152
 		{
153
-			foreach( $refIds as $key => $refId ) {
153
+			foreach ($refIds as $key => $refId) {
154 154
 				$refIds[$key] = (string) $refId;
155 155
 			}
156 156
 
157
-			$param = array( $domain, $listTypeId, $refIds );
158
-			$cmpfunc = $search->createFunction( 'product.contains', $param );
157
+			$param = array($domain, $listTypeId, $refIds);
158
+			$cmpfunc = $search->createFunction('product.contains', $param);
159 159
 
160
-			$expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) );
160
+			$expr[] = $search->compare('==', $cmpfunc, count($refIds));
161 161
 		}
162 162
 
163
-		$search->setConditions( $search->combine( '&&', $expr ) );
163
+		$search->setConditions($search->combine('&&', $expr));
164 164
 
165
-		if( count( $productManager->searchItems( $search, [] ) ) === 0 )
165
+		if (count($productManager->searchItems($search, [])) === 0)
166 166
 		{
167
-			$msg = sprintf( 'Invalid "%1$s" references for product with ID %2$s', $domain, json_encode( $prodId ) );
168
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
167
+			$msg = sprintf('Invalid "%1$s" references for product with ID %2$s', $domain, json_encode($prodId));
168
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
169 169
 		}
170 170
 	}
171 171
 
@@ -175,41 +175,41 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @param string $type Basket type
177 177
 	 */
178
-	protected function checkLocale( $type )
178
+	protected function checkLocale($type)
179 179
 	{
180 180
 		$errors = [];
181 181
 		$context = $this->getContext();
182 182
 		$session = $context->getSession();
183 183
 		$locale = $this->get()->getLocale();
184 184
 
185
-		$localeStr = $session->get( 'aimeos/basket/locale' );
185
+		$localeStr = $session->get('aimeos/basket/locale');
186 186
 		$localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId();
187 187
 
188
-		if( $localeStr !== null && $localeStr !== $localeKey )
188
+		if ($localeStr !== null && $localeStr !== $localeKey)
189 189
 		{
190
-			$locParts = explode( '|', $localeStr );
191
-			$locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' );
192
-			$locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' );
193
-			$locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' );
190
+			$locParts = explode('|', $localeStr);
191
+			$locSite = (isset($locParts[0]) ? $locParts[0] : '');
192
+			$locLanguage = (isset($locParts[1]) ? $locParts[1] : '');
193
+			$locCurrency = (isset($locParts[2]) ? $locParts[2] : '');
194 194
 
195
-			$localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' );
196
-			$locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false );
195
+			$localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale');
196
+			$locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false);
197 197
 
198 198
 			$context = clone $context;
199
-			$context->setLocale( $locale );
199
+			$context->setLocale($locale);
200 200
 
201
-			$manager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' );
202
-			$basket = $manager->getSession( $type );
201
+			$manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base');
202
+			$basket = $manager->getSession($type);
203 203
 
204
-			$this->copyAddresses( $basket, $errors, $localeKey );
205
-			$this->copyServices( $basket, $errors );
206
-			$this->copyProducts( $basket, $errors, $localeKey );
207
-			$this->copyCoupons( $basket, $errors, $localeKey );
204
+			$this->copyAddresses($basket, $errors, $localeKey);
205
+			$this->copyServices($basket, $errors);
206
+			$this->copyProducts($basket, $errors, $localeKey);
207
+			$this->copyCoupons($basket, $errors, $localeKey);
208 208
 
209
-			$manager->setSession( $basket, $type );
209
+			$manager->setSession($basket, $type);
210 210
 		}
211 211
 
212
-		$session->set( 'aimeos/basket/locale', $localeKey );
212
+		$session->set('aimeos/basket/locale', $localeKey);
213 213
 	}
214 214
 
215 215
 
@@ -221,20 +221,20 @@  discard block
 block discarded – undo
221 221
 	 * @param string $localeKey Unique identifier of the site, language and currency
222 222
 	 * @return array Associative list of errors occured
223 223
 	 */
224
-	protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
224
+	protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
225 225
 	{
226
-		foreach( $basket->getAddresses() as $type => $item )
226
+		foreach ($basket->getAddresses() as $type => $item)
227 227
 		{
228 228
 			try
229 229
 			{
230
-				$this->setAddress( $type, $item->toArray() );
231
-				$basket->deleteAddress( $type );
230
+				$this->setAddress($type, $item->toArray());
231
+				$basket->deleteAddress($type);
232 232
 			}
233
-			catch( \Exception $e )
233
+			catch (\Exception $e)
234 234
 			{
235 235
 				$logger = $this->getContext()->getLogger();
236 236
 				$str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s';
237
-				$logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
237
+				$logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
238 238
 				$errors['address'][$type] = $e->getMessage();
239 239
 			}
240 240
 		}
@@ -251,20 +251,20 @@  discard block
 block discarded – undo
251 251
 	 * @param string $localeKey Unique identifier of the site, language and currency
252 252
 	 * @return array Associative list of errors occured
253 253
 	 */
254
-	protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
254
+	protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
255 255
 	{
256
-		foreach( $basket->getCoupons() as $code => $list )
256
+		foreach ($basket->getCoupons() as $code => $list)
257 257
 		{
258 258
 			try
259 259
 			{
260
-				$this->addCoupon( $code );
261
-				$basket->deleteCoupon( $code, true );
260
+				$this->addCoupon($code);
261
+				$basket->deleteCoupon($code, true);
262 262
 			}
263
-			catch( \Exception $e )
263
+			catch (\Exception $e)
264 264
 			{
265 265
 				$logger = $this->getContext()->getLogger();
266 266
 				$str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s';
267
-				$logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
267
+				$logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
268 268
 				$errors['coupon'][$code] = $e->getMessage();
269 269
 			}
270 270
 		}
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
 	 * @param string $localeKey Unique identifier of the site, language and currency
282 282
 	 * @return array Associative list of errors occured
283 283
 	 */
284
-	protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
284
+	protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
285 285
 	{
286
-		foreach( $basket->getProducts() as $pos => $product )
286
+		foreach ($basket->getProducts() as $pos => $product)
287 287
 		{
288
-			if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) {
288
+			if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) {
289 289
 				continue;
290 290
 			}
291 291
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 			{
294 294
 				$attrIds = [];
295 295
 
296
-				foreach( $product->getAttributes() as $attrItem ) {
296
+				foreach ($product->getAttributes() as $attrItem) {
297 297
 					$attrIds[$attrItem->getType()][] = $attrItem->getAttributeId();
298 298
 				}
299 299
 
@@ -301,23 +301,23 @@  discard block
 block discarded – undo
301 301
 					$product->getProductId(),
302 302
 					$product->getQuantity(),
303 303
 					[],
304
-					$this->getValue( $attrIds, 'variant', [] ),
305
-					$this->getValue( $attrIds, 'config', [] ),
306
-					$this->getValue( $attrIds, 'hidden', [] ),
307
-					$this->getValue( $attrIds, 'custom', [] ),
304
+					$this->getValue($attrIds, 'variant', []),
305
+					$this->getValue($attrIds, 'config', []),
306
+					$this->getValue($attrIds, 'hidden', []),
307
+					$this->getValue($attrIds, 'custom', []),
308 308
 					$product->getStockType()
309 309
 				);
310 310
 
311
-				$basket->deleteProduct( $pos );
311
+				$basket->deleteProduct($pos);
312 312
 			}
313
-			catch( \Exception $e )
313
+			catch (\Exception $e)
314 314
 			{
315 315
 				$code = $product->getProductCode();
316 316
 				$logger = $this->getContext()->getLogger();
317 317
 				$errors['product'][$pos] = $e->getMessage();
318 318
 
319 319
 				$str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s';
320
-				$logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
320
+				$logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
321 321
 			}
322 322
 		}
323 323
 
@@ -332,24 +332,24 @@  discard block
 block discarded – undo
332 332
 	 * @param array $errors Associative list of previous errors
333 333
 	 * @return array Associative list of errors occured
334 334
 	 */
335
-	protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors )
335
+	protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors)
336 336
 	{
337
-		foreach( $basket->getServices() as $type => $list )
337
+		foreach ($basket->getServices() as $type => $list)
338 338
 		{
339
-			foreach( $list as $item )
339
+			foreach ($list as $item)
340 340
 			{
341 341
 				try
342 342
 				{
343 343
 					$attributes = [];
344 344
 
345
-					foreach( $item->getAttributes() as $attrItem ) {
345
+					foreach ($item->getAttributes() as $attrItem) {
346 346
 						$attributes[$attrItem->getCode()] = $attrItem->getValue();
347 347
 					}
348 348
 
349
-					$this->addService( $type, $item->getServiceId(), $attributes );
350
-					$basket->deleteService( $type );
349
+					$this->addService($type, $item->getServiceId(), $attributes);
350
+					$basket->deleteService($type);
351 351
 				}
352
-				catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically
352
+				catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically
353 353
 			}
354 354
 		}
355 355
 
@@ -369,36 +369,36 @@  discard block
 block discarded – undo
369 369
 	 * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface
370 370
 	 * @deprecated Use getOrderProductAttributes(), checkReferences() and calcPrice() instead
371 371
 	 */
372
-	protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity,
373
-			array $attributeIds, $type, array $attributeValues = [] )
372
+	protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity,
373
+			array $attributeIds, $type, array $attributeValues = [])
374 374
 	{
375
-		if( empty( $attributeIds ) ) {
375
+		if (empty($attributeIds)) {
376 376
 			return [];
377 377
 		}
378 378
 
379
-		$attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId();
380
-		$this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds );
379
+		$attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId();
380
+		$this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds);
381 381
 
382 382
 		$list = [];
383 383
 		$context = $this->getContext();
384 384
 
385
-		$priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' );
386
-		$orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' );
385
+		$priceManager = \Aimeos\MShop\Factory::createManager($context, 'price');
386
+		$orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute');
387 387
 
388
-		foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem )
388
+		foreach ($this->getAttributes($attributeIds) as $id => $attrItem)
389 389
 		{
390
-			$prices = $attrItem->getRefItems( 'price', 'default', 'default' );
390
+			$prices = $attrItem->getRefItems('price', 'default', 'default');
391 391
 
392
-			if( !empty( $prices ) ) {
393
-				$price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) );
392
+			if (!empty($prices)) {
393
+				$price->addItem($priceManager->getLowestPrice($prices, $quantity));
394 394
 			}
395 395
 
396 396
 			$item = $orderProductAttributeManager->createItem();
397
-			$item->copyFrom( $attrItem );
398
-			$item->setType( $type );
397
+			$item->copyFrom($attrItem);
398
+			$item->setType($type);
399 399
 
400
-			if( isset( $attributeValues[$id] ) ) {
401
-				$item->setValue( $attributeValues[$id] );
400
+			if (isset($attributeValues[$id])) {
401
+				$item->setValue($attributeValues[$id]);
402 402
 			}
403 403
 
404 404
 			$list[] = $item;
@@ -416,31 +416,31 @@  discard block
 block discarded – undo
416 416
 	 * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface
417 417
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one
418 418
 	 */
419
-	protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) )
419
+	protected function getAttributes(array $attributeIds, array $domains = array('price', 'text'))
420 420
 	{
421
-		if( empty( $attributeIds ) ) {
421
+		if (empty($attributeIds)) {
422 422
 			return [];
423 423
 		}
424 424
 
425
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
425
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
426 426
 
427
-		$search = $attributeManager->createSearch( true );
427
+		$search = $attributeManager->createSearch(true);
428 428
 		$expr = array(
429
-			$search->compare( '==', 'attribute.id', $attributeIds ),
429
+			$search->compare('==', 'attribute.id', $attributeIds),
430 430
 			$search->getConditions(),
431 431
 		);
432
-		$search->setConditions( $search->combine( '&&', $expr ) );
433
-		$search->setSlice( 0, 0x7fffffff );
432
+		$search->setConditions($search->combine('&&', $expr));
433
+		$search->setSlice(0, 0x7fffffff);
434 434
 
435
-		$attrItems = $attributeManager->searchItems( $search, $domains );
435
+		$attrItems = $attributeManager->searchItems($search, $domains);
436 436
 
437
-		if( count( $attrItems ) !== count( $attributeIds ) )
437
+		if (count($attrItems) !== count($attributeIds))
438 438
 		{
439
-			$expected = implode( ',', $attributeIds );
440
-			$actual = implode( ',', array_keys( $attrItems ) );
441
-			$msg = sprintf( 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected );
439
+			$expected = implode(',', $attributeIds);
440
+			$actual = implode(',', array_keys($attrItems));
441
+			$msg = sprintf('Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected);
442 442
 
443
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
443
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
444 444
 		}
445 445
 
446 446
 		return $attrItems;
@@ -453,31 +453,31 @@  discard block
 block discarded – undo
453 453
 	 * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items
454 454
 	 * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values
455 455
 	 */
456
-	protected function getAttributeItems( array $orderAttributes )
456
+	protected function getAttributeItems(array $orderAttributes)
457 457
 	{
458
-		if( empty( $orderAttributes ) ) {
458
+		if (empty($orderAttributes)) {
459 459
 			return [];
460 460
 		}
461 461
 
462
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
463
-		$search = $attributeManager->createSearch( true );
462
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
463
+		$search = $attributeManager->createSearch(true);
464 464
 		$expr = [];
465 465
 
466
-		foreach( $orderAttributes as $item )
466
+		foreach ($orderAttributes as $item)
467 467
 		{
468 468
 			$tmp = array(
469
-				$search->compare( '==', 'attribute.domain', 'product' ),
470
-				$search->compare( '==', 'attribute.code', $item->getValue() ),
471
-				$search->compare( '==', 'attribute.type.domain', 'product' ),
472
-				$search->compare( '==', 'attribute.type.code', $item->getCode() ),
473
-				$search->compare( '>', 'attribute.type.status', 0 ),
469
+				$search->compare('==', 'attribute.domain', 'product'),
470
+				$search->compare('==', 'attribute.code', $item->getValue()),
471
+				$search->compare('==', 'attribute.type.domain', 'product'),
472
+				$search->compare('==', 'attribute.type.code', $item->getCode()),
473
+				$search->compare('>', 'attribute.type.status', 0),
474 474
 				$search->getConditions(),
475 475
 			);
476
-			$expr[] = $search->combine( '&&', $tmp );
476
+			$expr[] = $search->combine('&&', $tmp);
477 477
 		}
478 478
 
479
-		$search->setConditions( $search->combine( '||', $expr ) );
480
-		return $attributeManager->searchItems( $search, array( 'price' ) );
479
+		$search->setConditions($search->combine('||', $expr));
480
+		return $attributeManager->searchItems($search, array('price'));
481 481
 	}
482 482
 
483 483
 
@@ -492,23 +492,23 @@  discard block
 block discarded – undo
492 492
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception
493 493
 	 * @deprecated Use getItem() or findItem() instead
494 494
 	 */
495
-	protected function getDomainItem( $domain, $key, $value, array $ref )
495
+	protected function getDomainItem($domain, $key, $value, array $ref)
496 496
 	{
497
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain );
497
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain);
498 498
 
499
-		$search = $manager->createSearch( true );
499
+		$search = $manager->createSearch(true);
500 500
 		$expr = array(
501
-			$search->compare( '==', $key, $value ),
501
+			$search->compare('==', $key, $value),
502 502
 			$search->getConditions(),
503 503
 		);
504
-		$search->setConditions( $search->combine( '&&', $expr ) );
504
+		$search->setConditions($search->combine('&&', $expr));
505 505
 
506
-		$result = $manager->searchItems( $search, $ref );
506
+		$result = $manager->searchItems($search, $ref);
507 507
 
508
-		if( ( $item = reset( $result ) ) === false )
508
+		if (($item = reset($result)) === false)
509 509
 		{
510
-			$msg = sprintf( 'No item for "%1$s" (%2$s) found', $value, $key );
511
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
510
+			$msg = sprintf('No item for "%1$s" (%2$s) found', $value, $key);
511
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
512 512
 		}
513 513
 
514 514
 		return $item;
@@ -524,24 +524,24 @@  discard block
 block discarded – undo
524 524
 	 * @param array $quantities Associative list of attribute IDs as keys and their quantities as values
525 525
 	 * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface
526 526
 	 */
527
-	protected function getOrderProductAttributes( $type, array $ids, array $values = [], array $quantities = [] )
527
+	protected function getOrderProductAttributes($type, array $ids, array $values = [], array $quantities = [])
528 528
 	{
529
-		if( empty( $ids ) ) {
529
+		if (empty($ids)) {
530 530
 			return [];
531 531
 		}
532 532
 
533 533
 		$list = [];
534
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' );
534
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute');
535 535
 
536
-		foreach( $this->getAttributes( $ids ) as $id => $attrItem )
536
+		foreach ($this->getAttributes($ids) as $id => $attrItem)
537 537
 		{
538 538
 			$item = $manager->createItem();
539
-			$item->copyFrom( $attrItem );
540
-			$item->setType( $type );
541
-			$item->setQuantity( isset( $quantities[$id] ) ? $quantities[$id] : 1 );
539
+			$item->copyFrom($attrItem);
540
+			$item->setType($type);
541
+			$item->setQuantity(isset($quantities[$id]) ? $quantities[$id] : 1);
542 542
 
543
-			if( isset( $values[$id] ) ) {
544
-				$item->setValue( $values[$id] );
543
+			if (isset($values[$id])) {
544
+				$item->setValue($values[$id]);
545 545
 			}
546 546
 
547 547
 			$list[] = $item;
@@ -558,21 +558,21 @@  discard block
 block discarded – undo
558 558
 	 * @param string $code Code of the list type
559 559
 	 * @return \Aimeos\MShop\Common\Item\Type\Iface List type item
560 560
 	 */
561
-	protected function getProductListTypeItem( $domain, $code )
561
+	protected function getProductListTypeItem($domain, $code)
562 562
 	{
563
-		if( empty( $this->listTypeItems ) )
563
+		if (empty($this->listTypeItems))
564 564
 		{
565
-			$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists/type' );
565
+			$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists/type');
566 566
 
567
-			foreach( $manager->searchItems( $manager->createSearch( true ) ) as $item ) {
568
-				$this->listTypeItems[ $item->getDomain() ][ $item->getCode() ] = $item;
567
+			foreach ($manager->searchItems($manager->createSearch(true)) as $item) {
568
+				$this->listTypeItems[$item->getDomain()][$item->getCode()] = $item;
569 569
 			}
570 570
 		}
571 571
 
572
-		if( !isset( $this->listTypeItems[$domain][$code] ) )
572
+		if (!isset($this->listTypeItems[$domain][$code]))
573 573
 		{
574
-			$msg = sprintf( 'List type for domain "%1$s" and code "%2$s" not found', $domain, $code );
575
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
574
+			$msg = sprintf('List type for domain "%1$s" and code "%2$s" not found', $domain, $code);
575
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
576 576
 		}
577 577
 
578 578
 		return $this->listTypeItems[$domain][$code];
@@ -587,43 +587,43 @@  discard block
 block discarded – undo
587 587
 	 * @param array $domains Names of the domain items that should be fetched too
588 588
 	 * @return array List of products matching the given attributes
589 589
 	 */
590
-	protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds,
591
-			array $domains = array( 'attribute', 'media', 'price', 'text' ) )
590
+	protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds,
591
+			array $domains = array('attribute', 'media', 'price', 'text'))
592 592
 	{
593 593
 		$subProductIds = [];
594
-		foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) {
594
+		foreach ($productItem->getRefItems('product', 'default', 'default') as $item) {
595 595
 			$subProductIds[] = $item->getId();
596 596
 		}
597 597
 
598
-		if( count( $subProductIds ) === 0 ) {
598
+		if (count($subProductIds) === 0) {
599 599
 			return [];
600 600
 		}
601 601
 
602
-		$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
603
-		$search = $productManager->createSearch( true );
602
+		$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
603
+		$search = $productManager->createSearch(true);
604 604
 
605 605
 		$expr = array(
606
-			$search->compare( '==', 'product.id', $subProductIds ),
606
+			$search->compare('==', 'product.id', $subProductIds),
607 607
 			$search->getConditions(),
608 608
 		);
609 609
 
610
-		if( count( $variantAttributeIds ) > 0 )
610
+		if (count($variantAttributeIds) > 0)
611 611
 		{
612
-			foreach( $variantAttributeIds as $key => $id ) {
612
+			foreach ($variantAttributeIds as $key => $id) {
613 613
 				$variantAttributeIds[$key] = (string) $id;
614 614
 			}
615 615
 
616
-			$listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' );
616
+			$listTypeItem = $this->getProductListTypeItem('attribute', 'variant');
617 617
 
618
-			$param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds );
619
-			$cmpfunc = $search->createFunction( 'product.contains', $param );
618
+			$param = array('attribute', $listTypeItem->getId(), $variantAttributeIds);
619
+			$cmpfunc = $search->createFunction('product.contains', $param);
620 620
 
621
-			$expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) );
621
+			$expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds));
622 622
 		}
623 623
 
624
-		$search->setConditions( $search->combine( '&&', $expr ) );
624
+		$search->setConditions($search->combine('&&', $expr));
625 625
 
626
-		return $productManager->searchItems( $search, $domains );
626
+		return $productManager->searchItems($search, $domains);
627 627
 	}
628 628
 
629 629
 
@@ -635,9 +635,9 @@  discard block
 block discarded – undo
635 635
 	 * @param mixed $default Default value if no value is available for the given name
636 636
 	 * @return mixed Value from the array or default value
637 637
 	 */
638
-	protected function getValue( array $values, $name, $default = null )
638
+	protected function getValue(array $values, $name, $default = null)
639 639
 	{
640
-		if( isset( $values[$name] ) ) {
640
+		if (isset($values[$name])) {
641 641
 			return $values[$name];
642 642
 		}
643 643
 
Please login to merge, or discard this patch.
controller/frontend/tests/Controller/Frontend/Basket/Decorator/BaseTest.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -20,54 +20,54 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
frontend/tests/Controller/Frontend/Basket/Decorator/SelectTest.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -19,217 +19,217 @@
 block discarded – undo
19 19
 	protected function setUp()
20 20
 	{
21 21
 		$this->context = \TestHelperFrontend::getContext();
22
-		$this->testItem = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' );
22
+		$this->testItem = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP');
23 23
 
24
-		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
25
-		$this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Select( $object, $this->context );
24
+		$object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context);
25
+		$this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Select($object, $this->context);
26 26
 	}
27 27
 
28 28
 
29 29
 	protected function tearDown()
30 30
 	{
31 31
 		$this->object->clear();
32
-		$this->context->getSession()->set( 'aimeos', [] );
32
+		$this->context->getSession()->set('aimeos', []);
33 33
 
34
-		unset( $this->object );
34
+		unset($this->object);
35 35
 	}
36 36
 
37 37
 
38 38
 	public function testAddDeleteProduct()
39 39
 	{
40 40
 		$basket = $this->object->get();
41
-		$this->object->addProduct( $this->testItem->getId(), 2 );
41
+		$this->object->addProduct($this->testItem->getId(), 2);
42 42
 
43
-		$this->assertEquals( 1, count( $basket->getProducts() ) );
44
-		$this->assertEquals( 2, $basket->getProduct( 0 )->getQuantity() );
45
-		$this->assertEquals( 'U:TESTPSUB01', $basket->getProduct( 0 )->getProductCode() );
43
+		$this->assertEquals(1, count($basket->getProducts()));
44
+		$this->assertEquals(2, $basket->getProduct(0)->getQuantity());
45
+		$this->assertEquals('U:TESTPSUB01', $basket->getProduct(0)->getProductCode());
46 46
 	}
47 47
 
48 48
 
49 49
 	public function testAddProductNoSelection()
50 50
 	{
51
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' );
51
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC');
52 52
 
53
-		$this->object->addProduct( $item->getId(), 1 );
53
+		$this->object->addProduct($item->getId(), 1);
54 54
 
55
-		$this->assertEquals( 1, count( $this->object->get()->getProducts() ) );
56
-		$this->assertEquals( 'CNC', $this->object->get()->getProduct( 0 )->getProductCode() );
57
-		$this->assertEquals( 0, count( $this->object->get()->getProduct( 0 )->getProducts() ) );
55
+		$this->assertEquals(1, count($this->object->get()->getProducts()));
56
+		$this->assertEquals('CNC', $this->object->get()->getProduct(0)->getProductCode());
57
+		$this->assertEquals(0, count($this->object->get()->getProduct(0)->getProducts()));
58 58
 	}
59 59
 
60 60
 
61 61
 	public function testAddProductVariant()
62 62
 	{
63
-		$attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( \TestHelperFrontend::getContext() );
63
+		$attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager(\TestHelperFrontend::getContext());
64 64
 
65 65
 		$search = $attributeManager->createSearch();
66
-		$search->setConditions( $search->compare( '==', 'attribute.code', array( 'xs', 'white' ) ) );
66
+		$search->setConditions($search->compare('==', 'attribute.code', array('xs', 'white')));
67 67
 
68
-		$attributes = $attributeManager->searchItems( $search );
68
+		$attributes = $attributeManager->searchItems($search);
69 69
 
70
-		if( count( $attributes ) === 0 ) {
71
-			throw new \RuntimeException( 'Attributes not found' );
70
+		if (count($attributes) === 0) {
71
+			throw new \RuntimeException('Attributes not found');
72 72
 		}
73 73
 
74 74
 
75
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' );
75
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC');
76 76
 
77
-		$this->object->addProduct( $item->getId(), 1, [], array_keys( $attributes ), [], [], [], 'default' );
77
+		$this->object->addProduct($item->getId(), 1, [], array_keys($attributes), [], [], [], 'default');
78 78
 
79
-		$this->assertEquals( 1, count( $this->object->get()->getProducts() ) );
80
-		$this->assertEquals( 'CNC', $this->object->get()->getProduct( 0 )->getProductCode() );
79
+		$this->assertEquals(1, count($this->object->get()->getProducts()));
80
+		$this->assertEquals('CNC', $this->object->get()->getProduct(0)->getProductCode());
81 81
 	}
82 82
 
83 83
 
84 84
 	public function testAddProductVariantIncomplete()
85 85
 	{
86
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
86
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
87 87
 
88 88
 		$search = $attributeManager->createSearch();
89 89
 		$expr = array(
90
-			$search->compare( '==', 'attribute.domain', 'product' ),
91
-			$search->compare( '==', 'attribute.code', '30' ),
92
-			$search->compare( '==', 'attribute.type.code', 'length' ),
90
+			$search->compare('==', 'attribute.domain', 'product'),
91
+			$search->compare('==', 'attribute.code', '30'),
92
+			$search->compare('==', 'attribute.type.code', 'length'),
93 93
 		);
94
-		$search->setConditions( $search->combine( '&&', $expr ) );
94
+		$search->setConditions($search->combine('&&', $expr));
95 95
 
96
-		$attributes = $attributeManager->searchItems( $search );
96
+		$attributes = $attributeManager->searchItems($search);
97 97
 
98
-		if( count( $attributes ) === 0 ) {
99
-			throw new \RuntimeException( 'Attributes not found' );
98
+		if (count($attributes) === 0) {
99
+			throw new \RuntimeException('Attributes not found');
100 100
 		}
101 101
 
102 102
 
103
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TEST' );
103
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TEST');
104 104
 
105
-		$this->object->addProduct( $item->getId(), 1, [], array_keys( $attributes ) );
105
+		$this->object->addProduct($item->getId(), 1, [], array_keys($attributes));
106 106
 
107
-		$this->assertEquals( 1, count( $this->object->get()->getProducts() ) );
108
-		$this->assertEquals( 'U:TESTSUB02', $this->object->get()->getProduct( 0 )->getProductCode() );
109
-		$this->assertEquals( 2, count( $this->object->get()->getProduct( 0 )->getAttributes() ) );
107
+		$this->assertEquals(1, count($this->object->get()->getProducts()));
108
+		$this->assertEquals('U:TESTSUB02', $this->object->get()->getProduct(0)->getProductCode());
109
+		$this->assertEquals(2, count($this->object->get()->getProduct(0)->getAttributes()));
110 110
 	}
111 111
 
112 112
 
113 113
 	public function testAddProductVariantNonUnique()
114 114
 	{
115
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
115
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
116 116
 
117 117
 		$search = $attributeManager->createSearch();
118 118
 		$expr = array(
119
-			$search->compare( '==', 'attribute.domain', 'product' ),
120
-			$search->compare( '==', 'attribute.code', '30' ),
121
-			$search->compare( '==', 'attribute.type.code', 'width' ),
119
+			$search->compare('==', 'attribute.domain', 'product'),
120
+			$search->compare('==', 'attribute.code', '30'),
121
+			$search->compare('==', 'attribute.type.code', 'width'),
122 122
 		);
123
-		$search->setConditions( $search->combine( '&&', $expr ) );
123
+		$search->setConditions($search->combine('&&', $expr));
124 124
 
125
-		$attributes = $attributeManager->searchItems( $search );
125
+		$attributes = $attributeManager->searchItems($search);
126 126
 
127
-		if( count( $attributes ) === 0 ) {
128
-			throw new \RuntimeException( 'Attributes not found' );
127
+		if (count($attributes) === 0) {
128
+			throw new \RuntimeException('Attributes not found');
129 129
 		}
130 130
 
131 131
 
132
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TEST' );
132
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TEST');
133 133
 
134
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
135
-		$this->object->addProduct( $item->getId(), 1, [], array_keys( $attributes ) );
134
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
135
+		$this->object->addProduct($item->getId(), 1, [], array_keys($attributes));
136 136
 	}
137 137
 
138 138
 
139 139
 	public function testAddProductVariantNotRequired()
140 140
 	{
141
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
141
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
142 142
 
143 143
 		$search = $attributeManager->createSearch();
144
-		$search->setConditions( $search->compare( '==', 'attribute.code', 'xs' ) );
144
+		$search->setConditions($search->compare('==', 'attribute.code', 'xs'));
145 145
 
146
-		$attributes = $attributeManager->searchItems( $search );
146
+		$attributes = $attributeManager->searchItems($search);
147 147
 
148
-		if( count( $attributes ) === 0 ) {
149
-			throw new \RuntimeException( 'Attribute not found' );
148
+		if (count($attributes) === 0) {
149
+			throw new \RuntimeException('Attribute not found');
150 150
 		}
151 151
 
152
-		$options = array( 'variant' => false );
152
+		$options = array('variant' => false);
153 153
 
154
-		$this->object->addProduct( $this->testItem->getId(), 1, $options, array_keys( $attributes ) );
154
+		$this->object->addProduct($this->testItem->getId(), 1, $options, array_keys($attributes));
155 155
 
156
-		$this->assertEquals( 1, count( $this->object->get()->getProducts() ) );
157
-		$this->assertEquals( 'U:TESTP', $this->object->get()->getProduct( 0 )->getProductCode() );
156
+		$this->assertEquals(1, count($this->object->get()->getProducts()));
157
+		$this->assertEquals('U:TESTP', $this->object->get()->getProduct(0)->getProductCode());
158 158
 	}
159 159
 
160 160
 
161 161
 	public function testAddProductEmptySelectionException()
162 162
 	{
163
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:noSel' );
163
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:noSel');
164 164
 
165
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
166
-		$this->object->addProduct( $item->getId(), 1 );
165
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
166
+		$this->object->addProduct($item->getId(), 1);
167 167
 	}
168 168
 
169 169
 
170 170
 	public function testAddProductSelectionWithPricelessItem()
171 171
 	{
172
-		$this->object->addProduct( $this->testItem->getId(), 1 );
172
+		$this->object->addProduct($this->testItem->getId(), 1);
173 173
 
174
-		$this->assertEquals( 'U:TESTPSUB01', $this->object->get()->getProduct( 0 )->getProductCode() );
174
+		$this->assertEquals('U:TESTPSUB01', $this->object->get()->getProduct(0)->getProductCode());
175 175
 	}
176 176
 
177 177
 
178 178
 	public function testAddProductConfigAttribute()
179 179
 	{
180
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
180
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
181 181
 
182 182
 		$search = $attributeManager->createSearch();
183
-		$search->setConditions( $search->compare( '==', 'attribute.code', 'xs' ) );
183
+		$search->setConditions($search->compare('==', 'attribute.code', 'xs'));
184 184
 
185
-		$attributes = $attributeManager->searchItems( $search );
185
+		$attributes = $attributeManager->searchItems($search);
186 186
 
187
-		if( ( $attribute = reset( $attributes ) ) === false ) {
188
-			throw new \RuntimeException( 'Attribute not found' );
187
+		if (($attribute = reset($attributes)) === false) {
188
+			throw new \RuntimeException('Attribute not found');
189 189
 		}
190 190
 
191
-		$this->object->addProduct( $this->testItem->getId(), 1, [], [], [$attribute->getId() => 1] );
191
+		$this->object->addProduct($this->testItem->getId(), 1, [], [], [$attribute->getId() => 1]);
192 192
 		$basket = $this->object->get();
193 193
 
194
-		$this->assertEquals( 1, count( $basket->getProducts() ) );
195
-		$this->assertEquals( 'U:TESTPSUB01', $basket->getProduct( 0 )->getProductCode() );
196
-		$this->assertEquals( 'xs', $basket->getProduct( 0 )->getAttribute( 'size', 'config' ) );
194
+		$this->assertEquals(1, count($basket->getProducts()));
195
+		$this->assertEquals('U:TESTPSUB01', $basket->getProduct(0)->getProductCode());
196
+		$this->assertEquals('xs', $basket->getProduct(0)->getAttribute('size', 'config'));
197 197
 	}
198 198
 
199 199
 
200 200
 	public function testAddProductHiddenAttribute()
201 201
 	{
202
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
202
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
203 203
 
204 204
 		$search = $attributeManager->createSearch();
205 205
 		$expr = array(
206
-			$search->compare( '==', 'attribute.code', '29' ),
207
-			$search->compare( '==', 'attribute.type.code', 'width' ),
206
+			$search->compare('==', 'attribute.code', '29'),
207
+			$search->compare('==', 'attribute.type.code', 'width'),
208 208
 		);
209
-		$search->setConditions( $search->combine( '&&', $expr ) );
209
+		$search->setConditions($search->combine('&&', $expr));
210 210
 
211
-		$attributes = $attributeManager->searchItems( $search );
211
+		$attributes = $attributeManager->searchItems($search);
212 212
 
213
-		if( empty( $attributes ) ) {
214
-			throw new \RuntimeException( 'Attribute not found' );
213
+		if (empty($attributes)) {
214
+			throw new \RuntimeException('Attribute not found');
215 215
 		}
216 216
 
217
-		$this->object->addProduct( $this->testItem->getId(), 1, [], [], [], array_keys( $attributes ) );
217
+		$this->object->addProduct($this->testItem->getId(), 1, [], [], [], array_keys($attributes));
218 218
 
219 219
 		$basket = $this->object->get();
220
-		$this->assertEquals( 1, count( $basket->getProducts() ) );
220
+		$this->assertEquals(1, count($basket->getProducts()));
221 221
 
222
-		$product = $basket->getProduct( 0 );
223
-		$this->assertEquals( 'U:TESTPSUB01', $product->getProductCode() );
222
+		$product = $basket->getProduct(0);
223
+		$this->assertEquals('U:TESTPSUB01', $product->getProductCode());
224 224
 
225 225
 		$attributes = $product->getAttributes();
226
-		$this->assertEquals( 1, count( $attributes ) );
226
+		$this->assertEquals(1, count($attributes));
227 227
 
228
-		if( ( $attribute = reset( $attributes ) ) === false ) {
229
-			throw new \RuntimeException( 'No attribute' );
228
+		if (($attribute = reset($attributes)) === false) {
229
+			throw new \RuntimeException('No attribute');
230 230
 		}
231 231
 
232
-		$this->assertEquals( 'hidden', $attribute->getType() );
233
-		$this->assertEquals( '29', $product->getAttribute( 'width', 'hidden' ) );
232
+		$this->assertEquals('hidden', $attribute->getType());
233
+		$this->assertEquals('29', $product->getAttribute('width', 'hidden'));
234 234
 	}
235 235
 }
Please login to merge, or discard this patch.
controller/frontend/tests/Controller/Frontend/Basket/StandardTest.php 1 patch
Spacing   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -19,112 +19,112 @@  discard block
 block discarded – undo
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,338 +132,338 @@  discard block
 block discarded – undo
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 testAddProductCustomPrice()
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', 'custom' ),
180
-			$search->compare( '==', 'attribute.type.code', 'price' ),
179
+			$search->compare('==', 'attribute.code', 'custom'),
180
+			$search->compare('==', 'attribute.type.code', 'price'),
181 181
 		);
182
-		$search->setConditions( $search->combine( '&&', $expr ) );
182
+		$search->setConditions($search->combine('&&', $expr));
183 183
 
184
-		$attributes = $attributeManager->searchItems( $search );
184
+		$attributes = $attributeManager->searchItems($search);
185 185
 
186
-		if( ( $attrItem = reset( $attributes ) ) === false ) {
187
-			throw new \RuntimeException( 'Attribute not found' );
186
+		if (($attrItem = reset($attributes)) === false) {
187
+			throw new \RuntimeException('Attribute not found');
188 188
 		}
189 189
 
190
-		$attrValues = array( $attrItem->getId() => '0.01' );
190
+		$attrValues = array($attrItem->getId() => '0.01');
191 191
 
192
-		$this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues );
192
+		$this->object->addProduct(self::$testItem->getId(), 1, [], [], [], [], $attrValues);
193 193
 		$basket = $this->object->get();
194 194
 
195
-		$this->assertEquals( 1, count( $basket->getProducts() ) );
196
-		$this->assertEquals( '0.01', $basket->getProduct( 0 )->getPrice()->getValue() );
195
+		$this->assertEquals(1, count($basket->getProducts()));
196
+		$this->assertEquals('0.01', $basket->getProduct(0)->getPrice()->getValue());
197 197
 	}
198 198
 
199 199
 
200 200
 	public function testAddProductCustomPriceException()
201 201
 	{
202
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
202
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
203 203
 
204 204
 		$search = $attributeManager->createSearch();
205 205
 		$expr = array(
206
-			$search->compare( '==', 'attribute.code', 'custom' ),
207
-			$search->compare( '==', 'attribute.type.code', 'price' ),
206
+			$search->compare('==', 'attribute.code', 'custom'),
207
+			$search->compare('==', 'attribute.type.code', 'price'),
208 208
 		);
209
-		$search->setConditions( $search->combine( '&&', $expr ) );
209
+		$search->setConditions($search->combine('&&', $expr));
210 210
 
211
-		$attributes = $attributeManager->searchItems( $search );
211
+		$attributes = $attributeManager->searchItems($search);
212 212
 
213
-		if( ( $attrItem = reset( $attributes ) ) === false ) {
214
-			throw new \RuntimeException( 'Attribute not found' );
213
+		if (($attrItem = reset($attributes)) === false) {
214
+			throw new \RuntimeException('Attribute not found');
215 215
 		}
216 216
 
217
-		$attrValues = array( $attrItem->getId() => ',' );
217
+		$attrValues = array($attrItem->getId() => ',');
218 218
 
219
-		$this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' );
220
-		$this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues );
219
+		$this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception');
220
+		$this->object->addProduct(self::$testItem->getId(), 1, [], [], [], [], $attrValues);
221 221
 	}
222 222
 
223 223
 
224 224
 	public function testAddProductAttributePrice()
225 225
 	{
226
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
226
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
227 227
 
228 228
 		$search = $attributeManager->createSearch();
229 229
 		$expr = array(
230
-			$search->compare( '==', 'attribute.code', 'xs' ),
231
-			$search->compare( '==', 'attribute.type.code', 'size' ),
230
+			$search->compare('==', 'attribute.code', 'xs'),
231
+			$search->compare('==', 'attribute.type.code', 'size'),
232 232
 		);
233
-		$search->setConditions( $search->combine( '&&', $expr ) );
233
+		$search->setConditions($search->combine('&&', $expr));
234 234
 
235
-		$attributes = $attributeManager->searchItems( $search );
235
+		$attributes = $attributeManager->searchItems($search);
236 236
 
237
-		if( ( $attribute = reset( $attributes ) ) === false ) {
238
-			throw new \RuntimeException( 'Attribute not found' );
237
+		if (($attribute = reset($attributes)) === false) {
238
+			throw new \RuntimeException('Attribute not found');
239 239
 		}
240 240
 
241
-		$this->object->addProduct( self::$testItem->getId(), 1, [], [], [$attribute->getId() => 2] );
241
+		$this->object->addProduct(self::$testItem->getId(), 1, [], [], [$attribute->getId() => 2]);
242 242
 
243
-		$this->assertEquals( '43.90', $this->object->get()->getPrice()->getValue() );
243
+		$this->assertEquals('43.90', $this->object->get()->getPrice()->getValue());
244 244
 	}
245 245
 
246 246
 
247 247
 	public function testAddProductAttributeNotAssigned()
248 248
 	{
249
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
249
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
250 250
 
251 251
 		$search = $attributeManager->createSearch();
252 252
 		$expr = array(
253
-			$search->compare( '==', 'attribute.code', '30' ),
254
-			$search->compare( '==', 'attribute.type.code', 'width' ),
253
+			$search->compare('==', 'attribute.code', '30'),
254
+			$search->compare('==', 'attribute.type.code', 'width'),
255 255
 		);
256
-		$search->setConditions( $search->combine( '&&', $expr ) );
256
+		$search->setConditions($search->combine('&&', $expr));
257 257
 
258
-		$attribute = $attributeManager->searchItems( $search );
258
+		$attribute = $attributeManager->searchItems($search);
259 259
 
260
-		if( empty( $attribute ) ) {
261
-			throw new \RuntimeException( 'Attribute not found' );
260
+		if (empty($attribute)) {
261
+			throw new \RuntimeException('Attribute not found');
262 262
 		}
263 263
 
264
-		$hiddenAttrIds = array_keys( $attribute );
265
-		$configAttrIds = array_keys( $attribute );
264
+		$hiddenAttrIds = array_keys($attribute);
265
+		$configAttrIds = array_keys($attribute);
266 266
 
267
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
268
-		$this->object->addProduct( self::$testItem->getId(), 1, [], [], $configAttrIds, $hiddenAttrIds );
267
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
268
+		$this->object->addProduct(self::$testItem->getId(), 1, [], [], $configAttrIds, $hiddenAttrIds);
269 269
 	}
270 270
 
271 271
 
272 272
 	public function testAddProductNegativeQuantityException()
273 273
 	{
274
-		$this->setExpectedException( '\\Aimeos\\MShop\\Order\\Exception' );
275
-		$this->object->addProduct( self::$testItem->getId(), -1 );
274
+		$this->setExpectedException('\\Aimeos\\MShop\\Order\\Exception');
275
+		$this->object->addProduct(self::$testItem->getId(), -1);
276 276
 	}
277 277
 
278 278
 
279 279
 	public function testAddProductNoPriceException()
280 280
 	{
281
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'MNOP' );
281
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('MNOP');
282 282
 
283
-		$this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' );
284
-		$this->object->addProduct( $item->getId(), 1 );
283
+		$this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception');
284
+		$this->object->addProduct($item->getId(), 1);
285 285
 	}
286 286
 
287 287
 
288 288
 	public function testAddProductConfigAttributeException()
289 289
 	{
290
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
291
-		$this->object->addProduct( self::$testItem->getId(), 1, [], [], array( -1 ) );
290
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
291
+		$this->object->addProduct(self::$testItem->getId(), 1, [], [], array( -1 ));
292 292
 	}
293 293
 
294 294
 
295 295
 	public function testAddProductLowQuantityPriceException()
296 296
 	{
297
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' );
297
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL');
298 298
 
299
-		$this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' );
300
-		$this->object->addProduct( $item->getId(), 1 );
299
+		$this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception');
300
+		$this->object->addProduct($item->getId(), 1);
301 301
 	}
302 302
 
303 303
 
304 304
 	public function testAddProductHigherQuantities()
305 305
 	{
306
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' );
306
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL');
307 307
 
308
-		$this->object->addProduct( $item->getId(), 2, [], [], [], [], [], 'unit_type3' );
308
+		$this->object->addProduct($item->getId(), 2, [], [], [], [], [], 'unit_type3');
309 309
 
310
-		$this->assertEquals( 2, $this->object->get()->getProduct( 0 )->getQuantity() );
311
-		$this->assertEquals( 'IJKL', $this->object->get()->getProduct( 0 )->getProductCode() );
310
+		$this->assertEquals(2, $this->object->get()->getProduct(0)->getQuantity());
311
+		$this->assertEquals('IJKL', $this->object->get()->getProduct(0)->getProductCode());
312 312
 	}
313 313
 
314 314
 
315 315
 	public function testDeleteProductFlagError()
316 316
 	{
317
-		$this->object->addProduct( self::$testItem->getId(), 2 );
317
+		$this->object->addProduct(self::$testItem->getId(), 2);
318 318
 
319
-		$item = $this->object->get()->getProduct( 0 );
320
-		$item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE );
319
+		$item = $this->object->get()->getProduct(0);
320
+		$item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE);
321 321
 
322
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
323
-		$this->object->deleteProduct( 0 );
322
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
323
+		$this->object->deleteProduct(0);
324 324
 	}
325 325
 
326 326
 
327 327
 	public function testEditProduct()
328 328
 	{
329
-		$this->object->addProduct( self::$testItem->getId(), 1 );
329
+		$this->object->addProduct(self::$testItem->getId(), 1);
330 330
 
331
-		$item = $this->object->get()->getProduct( 0 );
332
-		$this->assertEquals( 1, $item->getQuantity() );
331
+		$item = $this->object->get()->getProduct(0);
332
+		$this->assertEquals(1, $item->getQuantity());
333 333
 
334
-		$this->object->editProduct( 0, 4 );
334
+		$this->object->editProduct(0, 4);
335 335
 
336
-		$item = $this->object->get()->getProduct( 0 );
337
-		$this->assertEquals( 4, $item->getQuantity() );
338
-		$this->assertEquals( 'U:TESTP', $item->getProductCode() );
336
+		$item = $this->object->get()->getProduct(0);
337
+		$this->assertEquals(4, $item->getQuantity());
338
+		$this->assertEquals('U:TESTP', $item->getProductCode());
339 339
 	}
340 340
 
341 341
 
342 342
 	public function testEditProductAttributes()
343 343
 	{
344 344
 		$configAttrIds = [];
345
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
345
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
346 346
 
347 347
 		$search = $attributeManager->createSearch();
348 348
 		$conditions = array(
349
-			$search->compare( '==', 'attribute.domain', 'product' ),
350
-			$search->combine( '||', array(
351
-				$search->combine( '&&', array(
352
-					$search->compare( '==', 'attribute.code', 'xs' ),
353
-					$search->compare( '==', 'attribute.type.code', 'size' ),
354
-				) ),
355
-				$search->combine( '&&', array(
356
-					$search->compare( '==', 'attribute.code', 'white' ),
357
-					$search->compare( '==', 'attribute.type.code', 'color' ),
358
-				) ),
359
-			) )
349
+			$search->compare('==', 'attribute.domain', 'product'),
350
+			$search->combine('||', array(
351
+				$search->combine('&&', array(
352
+					$search->compare('==', 'attribute.code', 'xs'),
353
+					$search->compare('==', 'attribute.type.code', 'size'),
354
+				)),
355
+				$search->combine('&&', array(
356
+					$search->compare('==', 'attribute.code', 'white'),
357
+					$search->compare('==', 'attribute.type.code', 'color'),
358
+				)),
359
+			))
360 360
 		);
361
-		$search->setConditions( $search->combine( '&&', $conditions ) );
362
-		$attributes = $attributeManager->searchItems( $search );
361
+		$search->setConditions($search->combine('&&', $conditions));
362
+		$attributes = $attributeManager->searchItems($search);
363 363
 
364
-		if( empty( $attributes ) ) {
365
-			throw new \RuntimeException( 'No attributes available' );
364
+		if (empty($attributes)) {
365
+			throw new \RuntimeException('No attributes available');
366 366
 		}
367 367
 
368
-		foreach( $attributes as $id => $attribute ) {
368
+		foreach ($attributes as $id => $attribute) {
369 369
 			$configAttrIds[$id] = 1;
370 370
 		}
371 371
 
372
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' );
372
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP');
373 373
 
374
-		$this->object->addProduct( $item->getId(), 1, [], [], $configAttrIds );
375
-		$this->object->editProduct( 0, 4 );
374
+		$this->object->addProduct($item->getId(), 1, [], [], $configAttrIds);
375
+		$this->object->editProduct(0, 4);
376 376
 
377
-		$item = $this->object->get()->getProduct( 0 );
378
-		$this->assertEquals( 2, count( $item->getAttributes() ) );
379
-		$this->assertEquals( 4, $item->getQuantity() );
377
+		$item = $this->object->get()->getProduct(0);
378
+		$this->assertEquals(2, count($item->getAttributes()));
379
+		$this->assertEquals(4, $item->getQuantity());
380 380
 
381 381
 
382
-		$this->object->editProduct( 0, 3, [], array( reset( $attributes )->getType() ) );
382
+		$this->object->editProduct(0, 3, [], array(reset($attributes)->getType()));
383 383
 
384
-		$item = $this->object->get()->getProduct( 0 );
385
-		$this->assertEquals( 3, $item->getQuantity() );
386
-		$this->assertEquals( 1, count( $item->getAttributes() ) );
387
-		$this->assertEquals( 'U:TESTP', $item->getProductCode() );
384
+		$item = $this->object->get()->getProduct(0);
385
+		$this->assertEquals(3, $item->getQuantity());
386
+		$this->assertEquals(1, count($item->getAttributes()));
387
+		$this->assertEquals('U:TESTP', $item->getProductCode());
388 388
 	}
389 389
 
390 390
 
391 391
 	public function testEditProductFlagError()
392 392
 	{
393
-		$this->object->addProduct( self::$testItem->getId(), 2 );
393
+		$this->object->addProduct(self::$testItem->getId(), 2);
394 394
 
395
-		$item = $this->object->get()->getProduct( 0 );
396
-		$item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE );
395
+		$item = $this->object->get()->getProduct(0);
396
+		$item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE);
397 397
 
398
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
399
-		$this->object->editProduct( 0, 4 );
398
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
399
+		$this->object->editProduct(0, 4);
400 400
 	}
401 401
 
402 402
 
403 403
 	public function testAddCoupon()
404 404
 	{
405
-		$this->object->addProduct( self::$testItem->getId(), 2 );
406
-		$this->object->addCoupon( 'GHIJ' );
405
+		$this->object->addProduct(self::$testItem->getId(), 2);
406
+		$this->object->addCoupon('GHIJ');
407 407
 
408 408
 		$basket = $this->object->get();
409 409
 
410
-		$this->assertEquals( 1, count( $basket->getCoupons() ) );
410
+		$this->assertEquals(1, count($basket->getCoupons()));
411 411
 	}
412 412
 
413 413
 
414 414
 	public function testAddCouponExceedCount()
415 415
 	{
416
-		$this->object->addProduct( self::$testItem->getId(), 2 );
417
-		$this->object->addCoupon( 'GHIJ' );
416
+		$this->object->addProduct(self::$testItem->getId(), 2);
417
+		$this->object->addCoupon('GHIJ');
418 418
 
419
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
420
-		$this->object->addCoupon( 'GHIJ' );
419
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
420
+		$this->object->addCoupon('GHIJ');
421 421
 	}
422 422
 
423 423
 
424 424
 	public function testAddCouponInvalidCode()
425 425
 	{
426
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
427
-		$this->object->addCoupon( 'invalid' );
426
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
427
+		$this->object->addCoupon('invalid');
428 428
 	}
429 429
 
430 430
 
431 431
 	public function testAddCouponMissingRequirements()
432 432
 	{
433
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
434
-		$this->object->addCoupon( 'OPQR' );
433
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
434
+		$this->object->addCoupon('OPQR');
435 435
 	}
436 436
 
437 437
 
438 438
 	public function testDeleteCoupon()
439 439
 	{
440
-		$this->object->addProduct( self::$testItem->getId(), 2 );
441
-		$this->object->addCoupon( '90AB' );
442
-		$this->object->deleteCoupon( '90AB' );
440
+		$this->object->addProduct(self::$testItem->getId(), 2);
441
+		$this->object->addCoupon('90AB');
442
+		$this->object->deleteCoupon('90AB');
443 443
 
444 444
 		$basket = $this->object->get();
445 445
 
446
-		$this->assertEquals( 0, count( $basket->getCoupons() ) );
446
+		$this->assertEquals(0, count($basket->getCoupons()));
447 447
 	}
448 448
 
449 449
 
450 450
 	public function testSetAddressDelete()
451 451
 	{
452
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null );
452
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null);
453 453
 
454
-		$this->setExpectedException( '\Aimeos\MShop\Order\Exception' );
455
-		$this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
454
+		$this->setExpectedException('\Aimeos\MShop\Order\Exception');
455
+		$this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT);
456 456
 	}
457 457
 
458 458
 
459 459
 	public function testSetBillingAddressByItem()
460 460
 	{
461
-		$item = $this->getAddress( 'Example company' );
461
+		$item = $this->getAddress('Example company');
462 462
 
463
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item );
463
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item);
464 464
 
465
-		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
466
-		$this->assertEquals( 'Example company', $address->getCompany() );
465
+		$address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT);
466
+		$this->assertEquals('Example company', $address->getCompany());
467 467
 	}
468 468
 
469 469
 
@@ -491,37 +491,37 @@  discard block
 block discarded – undo
491 491
 			'order.base.address.flag' => 0,
492 492
 		);
493 493
 
494
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture );
494
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture);
495 495
 
496
-		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
497
-		$this->assertEquals( 'Example company', $address->getCompany() );
498
-		$this->assertEquals( 'Dr.', $address->getTitle() );
499
-		$this->assertEquals( 'firstunit', $address->getFirstname() );
496
+		$address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT);
497
+		$this->assertEquals('Example company', $address->getCompany());
498
+		$this->assertEquals('Dr.', $address->getTitle());
499
+		$this->assertEquals('firstunit', $address->getFirstname());
500 500
 	}
501 501
 
502 502
 
503 503
 	public function testSetBillingAddressByArrayError()
504 504
 	{
505
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
506
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array( 'error' => false ) );
505
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
506
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array('error' => false));
507 507
 	}
508 508
 
509 509
 
510 510
 	public function testSetBillingAddressParameterError()
511 511
 	{
512
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
513
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error' );
512
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
513
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error');
514 514
 	}
515 515
 
516 516
 
517 517
 	public function testSetDeliveryAddressByItem()
518 518
 	{
519
-		$item = $this->getAddress( 'Example company' );
519
+		$item = $this->getAddress('Example company');
520 520
 
521
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item );
521
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item);
522 522
 
523
-		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY );
524
-		$this->assertEquals( 'Example company', $address->getCompany() );
523
+		$address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY);
524
+		$this->assertEquals('Example company', $address->getCompany());
525 525
 	}
526 526
 
527 527
 
@@ -548,121 +548,121 @@  discard block
 block discarded – undo
548 548
 			'order.base.address.website' => 'www.example.com',
549 549
 			'order.base.address.flag' => 0,
550 550
 		);
551
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture );
551
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture);
552 552
 
553
-		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY );
554
-		$this->assertEquals( 'Example company', $address->getCompany() );
555
-		$this->assertEquals( 'Dr.', $address->getTitle() );
556
-		$this->assertEquals( 'firstunit', $address->getFirstname() );
553
+		$address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY);
554
+		$this->assertEquals('Example company', $address->getCompany());
555
+		$this->assertEquals('Dr.', $address->getTitle());
556
+		$this->assertEquals('firstunit', $address->getFirstname());
557 557
 	}
558 558
 
559 559
 
560 560
 	public function testSetDeliveryAddressByArrayError()
561 561
 	{
562
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
563
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array( 'error' => false ) );
562
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
563
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array('error' => false));
564 564
 	}
565 565
 
566 566
 
567 567
 	public function testSetDeliveryAddressTypeError()
568 568
 	{
569
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
570
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error' );
569
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
570
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error');
571 571
 	}
572 572
 
573 573
 
574 574
 	public function testSetServicePayment()
575 575
 	{
576
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' );
577
-		$service = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' );
576
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'service');
577
+		$service = $manager->findItem('unitpaymentcode', [], 'service', 'payment');
578 578
 
579
-		$this->object->addService( 'payment', $service->getId(), [] );
580
-		$item = $this->object->get()->getService( 'payment', 'unitpaymentcode' )->getCode();
581
-		$this->assertEquals( 'unitpaymentcode', $item );
579
+		$this->object->addService('payment', $service->getId(), []);
580
+		$item = $this->object->get()->getService('payment', 'unitpaymentcode')->getCode();
581
+		$this->assertEquals('unitpaymentcode', $item);
582 582
 
583
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
584
-		$this->object->addService( 'payment', $service->getId(), array( 'prepay' => true ) );
583
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
584
+		$this->object->addService('payment', $service->getId(), array('prepay' => true));
585 585
 	}
586 586
 
587 587
 
588 588
 	public function testSetDeliveryOption()
589 589
 	{
590
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' );
591
-		$service = $manager->findItem( 'unitcode', [], 'service', 'delivery' );
590
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'service');
591
+		$service = $manager->findItem('unitcode', [], 'service', 'delivery');
592 592
 
593
-		$this->object->addService( 'delivery', $service->getId(), [] );
594
-		$item = $this->object->get()->getService( 'delivery', 'unitcode' );
595
-		$this->assertEquals( 'unitcode', $item->getCode() );
593
+		$this->object->addService('delivery', $service->getId(), []);
594
+		$item = $this->object->get()->getService('delivery', 'unitcode');
595
+		$this->assertEquals('unitcode', $item->getCode());
596 596
 
597
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
598
-		$this->object->addService( 'delivery', $service->getId(), array( 'fast shipping' => true, 'air shipping' => false ) );
597
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
598
+		$this->object->addService('delivery', $service->getId(), array('fast shipping' => true, 'air shipping' => false));
599 599
 	}
600 600
 
601 601
 
602 602
 	public function testCheckLocale()
603 603
 	{
604
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' );
605
-		$payment = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' );
606
-		$delivery = $manager->findItem( 'unitcode', [], 'service', 'delivery' );
604
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'service');
605
+		$payment = $manager->findItem('unitpaymentcode', [], 'service', 'payment');
606
+		$delivery = $manager->findItem('unitcode', [], 'service', 'delivery');
607 607
 
608
-		$this->object->addProduct( self::$testItem->getId(), 2 );
609
-		$this->object->addCoupon( 'OPQR' );
608
+		$this->object->addProduct(self::$testItem->getId(), 2);
609
+		$this->object->addCoupon('OPQR');
610 610
 
611
-		$this->object->addService( 'payment', $payment->getId() );
612
-		$this->object->addService( 'delivery', $delivery->getId() );
611
+		$this->object->addService('payment', $payment->getId());
612
+		$this->object->addService('delivery', $delivery->getId());
613 613
 
614 614
 		$basket = $this->object->get();
615 615
 		$price = $basket->getPrice();
616 616
 
617
-		foreach( $basket->getProducts() as $product )
617
+		foreach ($basket->getProducts() as $product)
618 618
 		{
619
-			$this->assertEquals( 2, $product->getQuantity() );
620
-			$product->getPrice()->setCurrencyId( 'CHF' );
619
+			$this->assertEquals(2, $product->getQuantity());
620
+			$product->getPrice()->setCurrencyId('CHF');
621 621
 		}
622 622
 
623
-		$basket->getService( 'delivery', 'unitcode' )->getPrice()->setCurrencyId( 'CHF' );
624
-		$basket->getService( 'payment', 'unitpaymentcode' )->getPrice()->setCurrencyId( 'CHF' );
625
-		$basket->getLocale()->setCurrencyId( 'CHF' );
626
-		$price->setCurrencyId( 'CHF' );
623
+		$basket->getService('delivery', 'unitcode')->getPrice()->setCurrencyId('CHF');
624
+		$basket->getService('payment', 'unitpaymentcode')->getPrice()->setCurrencyId('CHF');
625
+		$basket->getLocale()->setCurrencyId('CHF');
626
+		$price->setCurrencyId('CHF');
627 627
 
628
-		$this->context->getLocale()->setCurrencyId( 'CHF' );
629
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress( 'Example company' ) );
628
+		$this->context->getLocale()->setCurrencyId('CHF');
629
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress('Example company'));
630 630
 
631
-		$this->context->getSession()->set( 'aimeos/basket/currency', 'CHF' );
632
-		$this->context->getLocale()->setCurrencyId( 'EUR' );
631
+		$this->context->getSession()->set('aimeos/basket/currency', 'CHF');
632
+		$this->context->getLocale()->setCurrencyId('EUR');
633 633
 
634
-		$this->context->getSession()->set( 'aimeos/basket/content-unittest-en-EUR-', null );
634
+		$this->context->getSession()->set('aimeos/basket/content-unittest-en-EUR-', null);
635 635
 
636
-		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
636
+		$object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context);
637 637
 		$basket = $object->get();
638 638
 
639
-		foreach( $basket->getProducts() as $product )
639
+		foreach ($basket->getProducts() as $product)
640 640
 		{
641
-			$this->assertEquals( 'EUR', $product->getPrice()->getCurrencyId() );
642
-			$this->assertEquals( 2, $product->getQuantity() );
641
+			$this->assertEquals('EUR', $product->getPrice()->getCurrencyId());
642
+			$this->assertEquals(2, $product->getQuantity());
643 643
 		}
644 644
 
645
-		$this->assertEquals( 'EUR', $basket->getService( 'payment', 'unitpaymentcode' )->getPrice()->getCurrencyId() );
646
-		$this->assertEquals( 'EUR', $basket->getService( 'delivery', 'unitcode' )->getPrice()->getCurrencyId() );
647
-		$this->assertEquals( 'EUR', $basket->getLocale()->getCurrencyId() );
648
-		$this->assertEquals( 'EUR', $basket->getPrice()->getCurrencyId() );
645
+		$this->assertEquals('EUR', $basket->getService('payment', 'unitpaymentcode')->getPrice()->getCurrencyId());
646
+		$this->assertEquals('EUR', $basket->getService('delivery', 'unitcode')->getPrice()->getCurrencyId());
647
+		$this->assertEquals('EUR', $basket->getLocale()->getCurrencyId());
648
+		$this->assertEquals('EUR', $basket->getPrice()->getCurrencyId());
649 649
 	}
650 650
 
651 651
 
652 652
 	/**
653 653
 	 * @param string $company
654 654
 	 */
655
-	protected function getAddress( $company )
655
+	protected function getAddress($company)
656 656
 	{
657
-		$customer = \Aimeos\MShop\Customer\Manager\Factory::createManager( \TestHelperFrontend::getContext(), 'Standard' );
658
-		$addressManager = $customer->getSubManager( 'address', 'Standard' );
657
+		$customer = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelperFrontend::getContext(), 'Standard');
658
+		$addressManager = $customer->getSubManager('address', 'Standard');
659 659
 
660 660
 		$search = $addressManager->createSearch();
661
-		$search->setConditions( $search->compare( '==', 'customer.address.company', $company ) );
662
-		$items = $addressManager->searchItems( $search );
661
+		$search->setConditions($search->compare('==', 'customer.address.company', $company));
662
+		$items = $addressManager->searchItems($search);
663 663
 
664
-		if( ( $item = reset( $items ) ) === false ) {
665
-			throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) );
664
+		if (($item = reset($items)) === false) {
665
+			throw new \RuntimeException(sprintf('No address item with company "%1$s" found', $company));
666 666
 		}
667 667
 
668 668
 		return $item;
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Basket/Decorator/Bundle.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
 	 * @param string $stocktype Unique code of the stock type to deliver the products from
42 42
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available
43 43
 	 */
44
-	public function addProduct( $prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [],
44
+	public function addProduct($prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [],
45 45
 		array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [],
46
-		$stocktype = 'default' )
46
+		$stocktype = 'default')
47 47
 	{
48 48
 		$context = $this->getContext();
49
-		$productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
49
+		$productManager = \Aimeos\MShop\Factory::createManager($context, 'product');
50 50
 
51
-		if( $productManager->getItem( $prodid, [], true )->getType() !== 'bundle' )
51
+		if ($productManager->getItem($prodid, [], true)->getType() !== 'bundle')
52 52
 		{
53 53
 			return $this->getController()->addProduct(
54 54
 				$prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds,
@@ -57,29 +57,29 @@  discard block
 block discarded – undo
57 57
 		}
58 58
 
59 59
 		$attributeMap = [
60
-			'custom' => array_keys( $customAttributeValues ),
61
-			'config' => array_keys( $configAttributeIds ),
60
+			'custom' => array_keys($customAttributeValues),
61
+			'config' => array_keys($configAttributeIds),
62 62
 			'hidden' => $hiddenAttributeIds,
63 63
 		];
64
-		$this->checkListRef( $prodid, 'attribute', $attributeMap );
64
+		$this->checkListRef($prodid, 'attribute', $attributeMap);
65 65
 
66 66
 
67
-		$productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true );
68
-		$prices = $productItem->getRefItems( 'price', 'default', 'default' );
67
+		$productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true);
68
+		$prices = $productItem->getRefItems('price', 'default', 'default');
69 69
 
70
-		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem();
71
-		$orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype );
70
+		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem();
71
+		$orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype);
72 72
 
73
-		$this->addBundleProducts( $orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype );
73
+		$this->addBundleProducts($orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype);
74 74
 
75
-		$attr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues );
76
-		$attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', array_keys( $configAttributeIds ), [], $configAttributeIds ) );
77
-		$attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) );
75
+		$attr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues);
76
+		$attr = array_merge($attr, $this->getOrderProductAttributes('config', array_keys($configAttributeIds), [], $configAttributeIds));
77
+		$attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds));
78 78
 
79
-		$orderBaseProductItem->setAttributes( $attr );
80
-		$orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) );
79
+		$orderBaseProductItem->setAttributes($attr);
80
+		$orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity));
81 81
 
82
-		$this->getController()->get()->addProduct( $orderBaseProductItem );
82
+		$this->getController()->get()->addProduct($orderBaseProductItem);
83 83
 		$this->getController()->save();
84 84
 	}
85 85
 
@@ -92,43 +92,43 @@  discard block
 block discarded – undo
92 92
 	 * @param array $variantAttributeIds List of product variant attribute IDs
93 93
 	 * @param string $stocktype
94 94
 	 */
95
-	protected function addBundleProducts( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem,
96
-		\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype )
95
+	protected function addBundleProducts(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem,
96
+		\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype)
97 97
 	{
98 98
 		$quantity = $orderBaseProductItem->getQuantity();
99 99
 		$products = $subProductIds = $orderProducts = [];
100
-		$orderProductManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product' );
100
+		$orderProductManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product');
101 101
 
102
-		foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item ) {
102
+		foreach ($productItem->getRefItems('product', null, 'default') as $item) {
103 103
 			$subProductIds[] = $item->getId();
104 104
 		}
105 105
 
106
-		if( count( $subProductIds ) > 0 )
106
+		if (count($subProductIds) > 0)
107 107
 		{
108
-			$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
108
+			$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
109 109
 
110
-			$search = $productManager->createSearch( true );
110
+			$search = $productManager->createSearch(true);
111 111
 			$expr = array(
112
-				$search->compare( '==', 'product.id', $subProductIds ),
112
+				$search->compare('==', 'product.id', $subProductIds),
113 113
 				$search->getConditions(),
114 114
 			);
115
-			$search->setConditions( $search->combine( '&&', $expr ) );
115
+			$search->setConditions($search->combine('&&', $expr));
116 116
 
117
-			$products = $productManager->searchItems( $search, array( 'attribute', 'media', 'price', 'text' ) );
117
+			$products = $productManager->searchItems($search, array('attribute', 'media', 'price', 'text'));
118 118
 		}
119 119
 
120
-		foreach( $products as $product )
120
+		foreach ($products as $product)
121 121
 		{
122
-			$prices = $product->getRefItems( 'price', 'default', 'default' );
122
+			$prices = $product->getRefItems('price', 'default', 'default');
123 123
 
124 124
 			$orderProduct = $orderProductManager->createItem();
125
-			$orderProduct->copyFrom( $product );
126
-			$orderProduct->setStockType( $stocktype );
127
-			$orderProduct->setPrice( $this->calcPrice( $orderProduct, $prices, $quantity ) );
125
+			$orderProduct->copyFrom($product);
126
+			$orderProduct->setStockType($stocktype);
127
+			$orderProduct->setPrice($this->calcPrice($orderProduct, $prices, $quantity));
128 128
 
129 129
 			$orderProducts[] = $orderProduct;
130 130
 		}
131 131
 
132
-		$orderBaseProductItem->setProducts( $orderProducts );
132
+		$orderBaseProductItem->setProducts($orderProducts);
133 133
 	}
134 134
 }
Please login to merge, or discard this patch.