Completed
Push — master ( b46c0d...fe698d )
by Aimeos
06:27
created
controller/frontend/tests/Controller/Frontend/Basket/StandardTest.php 1 patch
Spacing   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -19,277 +19,277 @@  discard block
 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
-		$this->object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
24
+		$this->object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context);
25 25
 	}
26 26
 
27 27
 
28 28
 	protected function tearDown()
29 29
 	{
30 30
 		$this->object->clear();
31
-		$this->context->getSession()->set( 'aimeos', array() );
31
+		$this->context->getSession()->set('aimeos', array());
32 32
 
33
-		unset( $this->object, $this->testItem );
33
+		unset($this->object, $this->testItem);
34 34
 	}
35 35
 
36 36
 
37 37
 	public function testAddDeleteProduct()
38 38
 	{
39 39
 		$basket = $this->object->get();
40
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' );
40
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC');
41 41
 
42
-		$this->object->addProduct( $item->getId(), 2, array(), array(), array(), array(), array(), 'default' );
43
-		$item2 = $this->object->get()->getProduct( 0 );
44
-		$this->object->deleteProduct( 0 );
42
+		$this->object->addProduct($item->getId(), 2, array(), array(), array(), array(), array(), 'default');
43
+		$item2 = $this->object->get()->getProduct(0);
44
+		$this->object->deleteProduct(0);
45 45
 
46
-		$this->assertEquals( 0, count( $basket->getProducts() ) );
47
-		$this->assertEquals( 'CNC', $item2->getProductCode() );
46
+		$this->assertEquals(0, count($basket->getProducts()));
47
+		$this->assertEquals('CNC', $item2->getProductCode());
48 48
 	}
49 49
 
50 50
 
51 51
 	public function testAddProductCustomAttribute()
52 52
 	{
53
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
53
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
54 54
 
55 55
 		$search = $attributeManager->createSearch();
56 56
 		$expr = array(
57
-			$search->compare( '==', 'attribute.code', 'custom' ),
58
-			$search->compare( '==', 'attribute.type.code', 'date' ),
57
+			$search->compare('==', 'attribute.code', 'custom'),
58
+			$search->compare('==', 'attribute.type.code', 'date'),
59 59
 		);
60
-		$search->setConditions( $search->combine( '&&', $expr ) );
60
+		$search->setConditions($search->combine('&&', $expr));
61 61
 
62
-		$attributes = $attributeManager->searchItems( $search );
62
+		$attributes = $attributeManager->searchItems($search);
63 63
 
64
-		if( ( $attrItem = reset( $attributes ) ) === false ) {
65
-			throw new \RuntimeException( 'Attribute not found' );
64
+		if (($attrItem = reset($attributes)) === false) {
65
+			throw new \RuntimeException('Attribute not found');
66 66
 		}
67 67
 
68
-		$attrValues = array( $attrItem->getId() => '2000-01-01' );
68
+		$attrValues = array($attrItem->getId() => '2000-01-01');
69 69
 
70
-		$this->object->addProduct( $this->testItem->getId(), 1, array(), array(), array(), array(), $attrValues );
70
+		$this->object->addProduct($this->testItem->getId(), 1, array(), array(), array(), array(), $attrValues);
71 71
 		$basket = $this->object->get();
72 72
 
73
-		$this->assertEquals( 1, count( $basket->getProducts() ) );
74
-		$this->assertEquals( '2000-01-01', $basket->getProduct( 0 )->getAttribute( 'date', 'custom' ) );
73
+		$this->assertEquals(1, count($basket->getProducts()));
74
+		$this->assertEquals('2000-01-01', $basket->getProduct(0)->getAttribute('date', 'custom'));
75 75
 	}
76 76
 
77 77
 
78 78
 	public function testAddProductAttributeNotAssigned()
79 79
 	{
80
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
80
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
81 81
 
82 82
 		$search = $attributeManager->createSearch();
83 83
 		$expr = array(
84
-			$search->compare( '==', 'attribute.code', '30' ),
85
-			$search->compare( '==', 'attribute.type.code', 'width' ),
84
+			$search->compare('==', 'attribute.code', '30'),
85
+			$search->compare('==', 'attribute.type.code', 'width'),
86 86
 		);
87
-		$search->setConditions( $search->combine( '&&', $expr ) );
87
+		$search->setConditions($search->combine('&&', $expr));
88 88
 
89
-		$attribute = $attributeManager->searchItems( $search );
89
+		$attribute = $attributeManager->searchItems($search);
90 90
 
91
-		if( empty( $attribute ) ) {
92
-			throw new \RuntimeException( 'Attribute not found' );
91
+		if (empty($attribute)) {
92
+			throw new \RuntimeException('Attribute not found');
93 93
 		}
94 94
 
95
-		$hiddenAttrIds = array_keys( $attribute );
96
-		$configAttrIds = array_keys( $attribute );
95
+		$hiddenAttrIds = array_keys($attribute);
96
+		$configAttrIds = array_keys($attribute);
97 97
 
98
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
99
-		$this->object->addProduct( $this->testItem->getId(), 1, array(), array(), $configAttrIds, $hiddenAttrIds );
98
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
99
+		$this->object->addProduct($this->testItem->getId(), 1, array(), array(), $configAttrIds, $hiddenAttrIds);
100 100
 	}
101 101
 
102 102
 
103 103
 	public function testAddProductNegativeQuantityException()
104 104
 	{
105
-		$this->setExpectedException( '\\Aimeos\\MShop\\Order\\Exception' );
106
-		$this->object->addProduct( $this->testItem->getId(), -1 );
105
+		$this->setExpectedException('\\Aimeos\\MShop\\Order\\Exception');
106
+		$this->object->addProduct($this->testItem->getId(), -1);
107 107
 	}
108 108
 
109 109
 
110 110
 	public function testAddProductNoPriceException()
111 111
 	{
112
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'MNOP' );
112
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('MNOP');
113 113
 
114
-		$this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' );
115
-		$this->object->addProduct( $item->getId(), 1 );
114
+		$this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception');
115
+		$this->object->addProduct($item->getId(), 1);
116 116
 	}
117 117
 
118 118
 
119 119
 	public function testAddProductConfigAttributeException()
120 120
 	{
121
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
122
-		$this->object->addProduct( $this->testItem->getId(), 1, array(), array(), array( -1 ) );
121
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
122
+		$this->object->addProduct($this->testItem->getId(), 1, array(), array(), array( -1 ));
123 123
 	}
124 124
 
125 125
 
126 126
 	public function testAddProductLowQuantityPriceException()
127 127
 	{
128
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' );
128
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL');
129 129
 
130
-		$this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' );
131
-		$this->object->addProduct( $item->getId(), 1 );
130
+		$this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception');
131
+		$this->object->addProduct($item->getId(), 1);
132 132
 	}
133 133
 
134 134
 
135 135
 	public function testAddProductHigherQuantities()
136 136
 	{
137
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' );
137
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL');
138 138
 
139
-		$this->object->addProduct( $item->getId(), 2, array(), array(), array(), array(), array(), 'unit_type3' );
139
+		$this->object->addProduct($item->getId(), 2, array(), array(), array(), array(), array(), 'unit_type3');
140 140
 
141
-		$this->assertEquals( 2, $this->object->get()->getProduct( 0 )->getQuantity() );
142
-		$this->assertEquals( 'IJKL', $this->object->get()->getProduct( 0 )->getProductCode() );
141
+		$this->assertEquals(2, $this->object->get()->getProduct(0)->getQuantity());
142
+		$this->assertEquals('IJKL', $this->object->get()->getProduct(0)->getProductCode());
143 143
 	}
144 144
 
145 145
 
146 146
 	public function testDeleteProductFlagError()
147 147
 	{
148
-		$this->object->addProduct( $this->testItem->getId(), 2 );
148
+		$this->object->addProduct($this->testItem->getId(), 2);
149 149
 
150
-		$item = $this->object->get()->getProduct( 0 );
151
-		$item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE );
150
+		$item = $this->object->get()->getProduct(0);
151
+		$item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE);
152 152
 
153
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
154
-		$this->object->deleteProduct( 0 );
153
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
154
+		$this->object->deleteProduct(0);
155 155
 	}
156 156
 
157 157
 
158 158
 	public function testEditProduct()
159 159
 	{
160
-		$this->object->addProduct( $this->testItem->getId(), 1 );
160
+		$this->object->addProduct($this->testItem->getId(), 1);
161 161
 
162
-		$item = $this->object->get()->getProduct( 0 );
163
-		$this->assertEquals( 1, $item->getQuantity() );
162
+		$item = $this->object->get()->getProduct(0);
163
+		$this->assertEquals(1, $item->getQuantity());
164 164
 
165
-		$this->object->editProduct( 0, 4 );
165
+		$this->object->editProduct(0, 4);
166 166
 
167
-		$item = $this->object->get()->getProduct( 0 );
168
-		$this->assertEquals( 4, $item->getQuantity() );
169
-		$this->assertEquals( 'U:TESTP', $item->getProductCode() );
167
+		$item = $this->object->get()->getProduct(0);
168
+		$this->assertEquals(4, $item->getQuantity());
169
+		$this->assertEquals('U:TESTP', $item->getProductCode());
170 170
 	}
171 171
 
172 172
 
173 173
 	public function testEditProductAttributes()
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
 		$conditions = array(
179
-			$search->compare( '==', 'attribute.domain', 'product' ),
180
-			$search->combine( '||', array(
181
-				$search->combine( '&&', array(
182
-					$search->compare( '==', 'attribute.code', 'xs' ),
183
-					$search->compare( '==', 'attribute.type.code', 'size' ),
184
-				) ),
185
-				$search->combine( '&&', array(
186
-					$search->compare( '==', 'attribute.code', 'white' ),
187
-					$search->compare( '==', 'attribute.type.code', 'color' ),
188
-				) ),
189
-			) )
179
+			$search->compare('==', 'attribute.domain', 'product'),
180
+			$search->combine('||', array(
181
+				$search->combine('&&', array(
182
+					$search->compare('==', 'attribute.code', 'xs'),
183
+					$search->compare('==', 'attribute.type.code', 'size'),
184
+				)),
185
+				$search->combine('&&', array(
186
+					$search->compare('==', 'attribute.code', 'white'),
187
+					$search->compare('==', 'attribute.type.code', 'color'),
188
+				)),
189
+			))
190 190
 		);
191
-		$search->setConditions( $search->combine( '&&', $conditions ) );
192
-		$attributes = $attributeManager->searchItems( $search );
191
+		$search->setConditions($search->combine('&&', $conditions));
192
+		$attributes = $attributeManager->searchItems($search);
193 193
 
194
-		if( ( $attribute = reset( $attributes ) ) === false ) {
195
-			throw new \RuntimeException( 'No attributes available' );
194
+		if (($attribute = reset($attributes)) === false) {
195
+			throw new \RuntimeException('No attributes available');
196 196
 		}
197 197
 
198 198
 
199
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' );
199
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP');
200 200
 
201
-		$this->object->addProduct( $item->getId(), 1, array(), array(), array_keys( $attributes ) );
202
-		$this->object->editProduct( 0, 4 );
201
+		$this->object->addProduct($item->getId(), 1, array(), array(), array_keys($attributes));
202
+		$this->object->editProduct(0, 4);
203 203
 
204
-		$item = $this->object->get()->getProduct( 0 );
205
-		$this->assertEquals( 2, count( $item->getAttributes() ) );
206
-		$this->assertEquals( 4, $item->getQuantity() );
204
+		$item = $this->object->get()->getProduct(0);
205
+		$this->assertEquals(2, count($item->getAttributes()));
206
+		$this->assertEquals(4, $item->getQuantity());
207 207
 
208 208
 
209
-		$this->object->editProduct( 0, 3, array(), array( $attribute->getType() ) );
209
+		$this->object->editProduct(0, 3, array(), array($attribute->getType()));
210 210
 
211
-		$item = $this->object->get()->getProduct( 0 );
212
-		$this->assertEquals( 3, $item->getQuantity() );
213
-		$this->assertEquals( 1, count( $item->getAttributes() ) );
214
-		$this->assertEquals( 'U:TESTP', $item->getProductCode() );
211
+		$item = $this->object->get()->getProduct(0);
212
+		$this->assertEquals(3, $item->getQuantity());
213
+		$this->assertEquals(1, count($item->getAttributes()));
214
+		$this->assertEquals('U:TESTP', $item->getProductCode());
215 215
 	}
216 216
 
217 217
 
218 218
 	public function testEditProductFlagError()
219 219
 	{
220
-		$this->object->addProduct( $this->testItem->getId(), 2 );
220
+		$this->object->addProduct($this->testItem->getId(), 2);
221 221
 
222
-		$item = $this->object->get()->getProduct( 0 );
223
-		$item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE );
222
+		$item = $this->object->get()->getProduct(0);
223
+		$item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE);
224 224
 
225
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
226
-		$this->object->editProduct( 0, 4 );
225
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
226
+		$this->object->editProduct(0, 4);
227 227
 	}
228 228
 
229 229
 
230 230
 	public function testAddCoupon()
231 231
 	{
232
-		$this->object->addProduct( $this->testItem->getId(), 2 );
233
-		$this->object->addCoupon( 'GHIJ' );
232
+		$this->object->addProduct($this->testItem->getId(), 2);
233
+		$this->object->addCoupon('GHIJ');
234 234
 
235 235
 		$basket = $this->object->get();
236 236
 
237
-		$this->assertEquals( 1, count( $basket->getCoupons() ) );
237
+		$this->assertEquals(1, count($basket->getCoupons()));
238 238
 	}
239 239
 
240 240
 
241 241
 	public function testAddCouponInvalidCode()
242 242
 	{
243
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
244
-		$this->object->addCoupon( 'invalid' );
243
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
244
+		$this->object->addCoupon('invalid');
245 245
 	}
246 246
 
247 247
 
248 248
 	public function testAddCouponMissingRequirements()
249 249
 	{
250
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
251
-		$this->object->addCoupon( 'OPQR' );
250
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
251
+		$this->object->addCoupon('OPQR');
252 252
 	}
253 253
 
254 254
 
255 255
 	public function testDeleteCoupon()
256 256
 	{
257
-		$this->object->addProduct( $this->testItem->getId(), 2 );
258
-		$this->object->addCoupon( '90AB' );
259
-		$this->object->deleteCoupon( '90AB' );
257
+		$this->object->addProduct($this->testItem->getId(), 2);
258
+		$this->object->addCoupon('90AB');
259
+		$this->object->deleteCoupon('90AB');
260 260
 
261 261
 		$basket = $this->object->get();
262 262
 
263
-		$this->assertEquals( 0, count( $basket->getCoupons() ) );
263
+		$this->assertEquals(0, count($basket->getCoupons()));
264 264
 	}
265 265
 
266 266
 
267 267
 	public function testClear()
268 268
 	{
269
-		$this->object->addProduct( $this->testItem->getId(), 2 );
269
+		$this->object->addProduct($this->testItem->getId(), 2);
270 270
 		$this->object->clear();
271 271
 
272
-		$this->assertEquals( 0, count( $this->object->get()->getProducts() ) );
272
+		$this->assertEquals(0, count($this->object->get()->getProducts()));
273 273
 	}
274 274
 
275 275
 
276 276
 	public function testSetAddressDelete()
277 277
 	{
278
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null );
278
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null);
279 279
 
280
-		$this->setExpectedException( '\Aimeos\MShop\Order\Exception' );
281
-		$this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
280
+		$this->setExpectedException('\Aimeos\MShop\Order\Exception');
281
+		$this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT);
282 282
 	}
283 283
 
284 284
 
285 285
 	public function testSetBillingAddressByItem()
286 286
 	{
287
-		$item = $this->getAddress( 'Example company' );
287
+		$item = $this->getAddress('Example company');
288 288
 
289
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item );
289
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item);
290 290
 
291
-		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
292
-		$this->assertEquals( 'Example company', $address->getCompany() );
291
+		$address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT);
292
+		$this->assertEquals('Example company', $address->getCompany());
293 293
 	}
294 294
 
295 295
 
@@ -317,37 +317,37 @@  discard block
 block discarded – undo
317 317
 			'order.base.address.flag' => 0,
318 318
 		);
319 319
 
320
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture );
320
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture);
321 321
 
322
-		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
323
-		$this->assertEquals( 'Example company', $address->getCompany() );
324
-		$this->assertEquals( 'Dr.', $address->getTitle() );
325
-		$this->assertEquals( 'firstunit', $address->getFirstname() );
322
+		$address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT);
323
+		$this->assertEquals('Example company', $address->getCompany());
324
+		$this->assertEquals('Dr.', $address->getTitle());
325
+		$this->assertEquals('firstunit', $address->getFirstname());
326 326
 	}
327 327
 
328 328
 
329 329
 	public function testSetBillingAddressByArrayError()
330 330
 	{
331
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
332
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array( 'error' => false ) );
331
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
332
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array('error' => false));
333 333
 	}
334 334
 
335 335
 
336 336
 	public function testSetBillingAddressParameterError()
337 337
 	{
338
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
339
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error' );
338
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
339
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error');
340 340
 	}
341 341
 
342 342
 
343 343
 	public function testSetDeliveryAddressByItem()
344 344
 	{
345
-		$item = $this->getAddress( 'Example company' );
345
+		$item = $this->getAddress('Example company');
346 346
 
347
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item );
347
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item);
348 348
 
349
-		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY );
350
-		$this->assertEquals( 'Example company', $address->getCompany() );
349
+		$address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY);
350
+		$this->assertEquals('Example company', $address->getCompany());
351 351
 	}
352 352
 
353 353
 
@@ -374,119 +374,119 @@  discard block
 block discarded – undo
374 374
 			'order.base.address.website' => 'www.example.com',
375 375
 			'order.base.address.flag' => 0,
376 376
 		);
377
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture );
377
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture);
378 378
 
379
-		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY );
380
-		$this->assertEquals( 'Example company', $address->getCompany() );
381
-		$this->assertEquals( 'Dr.', $address->getTitle() );
382
-		$this->assertEquals( 'firstunit', $address->getFirstname() );
379
+		$address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY);
380
+		$this->assertEquals('Example company', $address->getCompany());
381
+		$this->assertEquals('Dr.', $address->getTitle());
382
+		$this->assertEquals('firstunit', $address->getFirstname());
383 383
 	}
384 384
 
385 385
 
386 386
 	public function testSetDeliveryAddressByArrayError()
387 387
 	{
388
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
389
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array( 'error' => false ) );
388
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
389
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array('error' => false));
390 390
 	}
391 391
 
392 392
 
393 393
 	public function testSetDeliveryAddressTypeError()
394 394
 	{
395
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
396
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error' );
395
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
396
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error');
397 397
 	}
398 398
 
399 399
 
400 400
 	public function testSetServicePayment()
401 401
 	{
402
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' );
403
-		$service = $manager->findItem( 'unitpaymentcode', array(), 'service', 'payment' );
402
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'service');
403
+		$service = $manager->findItem('unitpaymentcode', array(), 'service', 'payment');
404 404
 
405
-		$this->object->setService( 'payment', $service->getId(), array() );
406
-		$this->assertEquals( 'unitpaymentcode', $this->object->get()->getService( 'payment' )->getCode() );
405
+		$this->object->setService('payment', $service->getId(), array());
406
+		$this->assertEquals('unitpaymentcode', $this->object->get()->getService('payment')->getCode());
407 407
 
408
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
409
-		$this->object->setService( 'payment', $service->getId(), array( 'prepay' => true ) );
408
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
409
+		$this->object->setService('payment', $service->getId(), array('prepay' => true));
410 410
 	}
411 411
 
412 412
 
413 413
 	public function testSetDeliveryOption()
414 414
 	{
415
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' );
416
-		$service = $manager->findItem( 'unitcode', array(), 'service', 'delivery' );
415
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'service');
416
+		$service = $manager->findItem('unitcode', array(), 'service', 'delivery');
417 417
 
418
-		$this->object->setService( 'delivery', $service->getId(), array() );
419
-		$this->assertEquals( 'unitcode', $this->object->get()->getService( 'delivery' )->getCode() );
418
+		$this->object->setService('delivery', $service->getId(), array());
419
+		$this->assertEquals('unitcode', $this->object->get()->getService('delivery')->getCode());
420 420
 
421
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
422
-		$this->object->setService( 'delivery', $service->getId(), array( 'fast shipping' => true, 'air shipping' => false ) );
421
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
422
+		$this->object->setService('delivery', $service->getId(), array('fast shipping' => true, 'air shipping' => false));
423 423
 	}
424 424
 
425 425
 
426 426
 	public function testCheckLocale()
427 427
 	{
428
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' );
429
-		$payment = $manager->findItem( 'unitpaymentcode', array(), 'service', 'payment' );
430
-		$delivery = $manager->findItem( 'unitcode', array(), 'service', 'delivery' );
428
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'service');
429
+		$payment = $manager->findItem('unitpaymentcode', array(), 'service', 'payment');
430
+		$delivery = $manager->findItem('unitcode', array(), 'service', 'delivery');
431 431
 
432
-		$this->object->addProduct( $this->testItem->getId(), 2 );
433
-		$this->object->addCoupon( 'OPQR' );
432
+		$this->object->addProduct($this->testItem->getId(), 2);
433
+		$this->object->addCoupon('OPQR');
434 434
 
435
-		$this->object->setService( 'payment', $payment->getId() );
436
-		$this->object->setService( 'delivery', $delivery->getId() );
435
+		$this->object->setService('payment', $payment->getId());
436
+		$this->object->setService('delivery', $delivery->getId());
437 437
 
438 438
 		$basket = $this->object->get();
439 439
 		$price = $basket->getPrice();
440 440
 
441
-		foreach( $basket->getProducts() as $product )
441
+		foreach ($basket->getProducts() as $product)
442 442
 		{
443
-			$this->assertEquals( 2, $product->getQuantity() );
444
-			$product->getPrice()->setCurrencyId( 'CHF' );
443
+			$this->assertEquals(2, $product->getQuantity());
444
+			$product->getPrice()->setCurrencyId('CHF');
445 445
 		}
446 446
 
447
-		$basket->getService( 'delivery' )->getPrice()->setCurrencyId( 'CHF' );
448
-		$basket->getService( 'payment' )->getPrice()->setCurrencyId( 'CHF' );
449
-		$basket->getLocale()->setCurrencyId( 'CHF' );
450
-		$price->setCurrencyId( 'CHF' );
447
+		$basket->getService('delivery')->getPrice()->setCurrencyId('CHF');
448
+		$basket->getService('payment')->getPrice()->setCurrencyId('CHF');
449
+		$basket->getLocale()->setCurrencyId('CHF');
450
+		$price->setCurrencyId('CHF');
451 451
 
452
-		$this->context->getLocale()->setCurrencyId( 'CHF' );
453
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress( 'Example company' ) );
452
+		$this->context->getLocale()->setCurrencyId('CHF');
453
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress('Example company'));
454 454
 
455
-		$this->context->getSession()->set( 'aimeos/basket/currency', 'CHF' );
456
-		$this->context->getLocale()->setCurrencyId( 'EUR' );
455
+		$this->context->getSession()->set('aimeos/basket/currency', 'CHF');
456
+		$this->context->getLocale()->setCurrencyId('EUR');
457 457
 
458
-		$this->context->getSession()->set( 'aimeos/basket/content-unittest-en-EUR-', null );
458
+		$this->context->getSession()->set('aimeos/basket/content-unittest-en-EUR-', null);
459 459
 
460
-		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
460
+		$object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context);
461 461
 		$basket = $object->get();
462 462
 
463
-		foreach( $basket->getProducts() as $product )
463
+		foreach ($basket->getProducts() as $product)
464 464
 		{
465
-			$this->assertEquals( 'EUR', $product->getPrice()->getCurrencyId() );
466
-			$this->assertEquals( 2, $product->getQuantity() );
465
+			$this->assertEquals('EUR', $product->getPrice()->getCurrencyId());
466
+			$this->assertEquals(2, $product->getQuantity());
467 467
 		}
468 468
 
469
-		$this->assertEquals( 'EUR', $basket->getService( 'payment' )->getPrice()->getCurrencyId() );
470
-		$this->assertEquals( 'EUR', $basket->getService( 'delivery' )->getPrice()->getCurrencyId() );
471
-		$this->assertEquals( 'EUR', $basket->getLocale()->getCurrencyId() );
472
-		$this->assertEquals( 'EUR', $basket->getPrice()->getCurrencyId() );
469
+		$this->assertEquals('EUR', $basket->getService('payment')->getPrice()->getCurrencyId());
470
+		$this->assertEquals('EUR', $basket->getService('delivery')->getPrice()->getCurrencyId());
471
+		$this->assertEquals('EUR', $basket->getLocale()->getCurrencyId());
472
+		$this->assertEquals('EUR', $basket->getPrice()->getCurrencyId());
473 473
 	}
474 474
 
475 475
 
476 476
 	/**
477 477
 	 * @param string $company
478 478
 	 */
479
-	protected function getAddress( $company )
479
+	protected function getAddress($company)
480 480
 	{
481
-		$customer = \Aimeos\MShop\Customer\Manager\Factory::createManager( \TestHelperFrontend::getContext(), 'Standard' );
482
-		$addressManager = $customer->getSubManager( 'address', 'Standard' );
481
+		$customer = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelperFrontend::getContext(), 'Standard');
482
+		$addressManager = $customer->getSubManager('address', 'Standard');
483 483
 
484 484
 		$search = $addressManager->createSearch();
485
-		$search->setConditions( $search->compare( '==', 'customer.address.company', $company ) );
486
-		$items = $addressManager->searchItems( $search );
485
+		$search->setConditions($search->compare('==', 'customer.address.company', $company));
486
+		$items = $addressManager->searchItems($search);
487 487
 
488
-		if( ( $item = reset( $items ) ) === false ) {
489
-			throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) );
488
+		if (($item = reset($items)) === false) {
489
+			throw new \RuntimeException(sprintf('No address item with company "%1$s" found', $company));
490 490
 		}
491 491
 
492 492
 		return $item;
Please login to merge, or discard this patch.
frontend/tests/Controller/Frontend/Basket/Decorator/SelectTest.php 1 patch
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -13,205 +13,205 @@
 block discarded – undo
13 13
 	protected function setUp()
14 14
 	{
15 15
 		$this->context = \TestHelperFrontend::getContext();
16
-		$this->testItem = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' );
16
+		$this->testItem = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP');
17 17
 
18
-		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
19
-		$this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Select( $object, $this->context );
18
+		$object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context);
19
+		$this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Select($object, $this->context);
20 20
 	}
21 21
 
22 22
 
23 23
 	protected function tearDown()
24 24
 	{
25 25
 		$this->object->clear();
26
-		$this->context->getSession()->set( 'aimeos', array() );
26
+		$this->context->getSession()->set('aimeos', array());
27 27
 
28
-		unset( $this->object );
28
+		unset($this->object);
29 29
 	}
30 30
 
31 31
 
32 32
 	public function testAddDeleteProduct()
33 33
 	{
34 34
 		$basket = $this->object->get();
35
-		$this->object->addProduct( $this->testItem->getId(), 2 );
35
+		$this->object->addProduct($this->testItem->getId(), 2);
36 36
 
37
-		$this->assertEquals( 1, count( $basket->getProducts() ) );
38
-		$this->assertEquals( 2, $basket->getProduct( 0 )->getQuantity() );
39
-		$this->assertEquals( 'U:TESTPSUB01', $basket->getProduct( 0 )->getProductCode() );
37
+		$this->assertEquals(1, count($basket->getProducts()));
38
+		$this->assertEquals(2, $basket->getProduct(0)->getQuantity());
39
+		$this->assertEquals('U:TESTPSUB01', $basket->getProduct(0)->getProductCode());
40 40
 	}
41 41
 
42 42
 
43 43
 	public function testAddProductVariant()
44 44
 	{
45
-		$attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( \TestHelperFrontend::getContext() );
45
+		$attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager(\TestHelperFrontend::getContext());
46 46
 
47 47
 		$search = $attributeManager->createSearch();
48
-		$search->setConditions( $search->compare( '==', 'attribute.code', array( 'xs', 'white' ) ) );
48
+		$search->setConditions($search->compare('==', 'attribute.code', array('xs', 'white')));
49 49
 
50
-		$attributes = $attributeManager->searchItems( $search );
50
+		$attributes = $attributeManager->searchItems($search);
51 51
 
52
-		if( count( $attributes ) === 0 ) {
53
-			throw new \RuntimeException( 'Attributes not found' );
52
+		if (count($attributes) === 0) {
53
+			throw new \RuntimeException('Attributes not found');
54 54
 		}
55 55
 
56 56
 
57
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' );
57
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC');
58 58
 
59
-		$this->object->addProduct( $item->getId(), 1, array(), array_keys( $attributes ), array(), array(), array(), 'default' );
59
+		$this->object->addProduct($item->getId(), 1, array(), array_keys($attributes), array(), array(), array(), 'default');
60 60
 
61
-		$this->assertEquals( 1, count( $this->object->get()->getProducts() ) );
62
-		$this->assertEquals( 'CNC', $this->object->get()->getProduct( 0 )->getProductCode() );
61
+		$this->assertEquals(1, count($this->object->get()->getProducts()));
62
+		$this->assertEquals('CNC', $this->object->get()->getProduct(0)->getProductCode());
63 63
 	}
64 64
 
65 65
 
66 66
 	public function testAddProductVariantIncomplete()
67 67
 	{
68
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
68
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
69 69
 
70 70
 		$search = $attributeManager->createSearch();
71 71
 		$expr = array(
72
-			$search->compare( '==', 'attribute.domain', 'product' ),
73
-			$search->compare( '==', 'attribute.code', '30' ),
74
-			$search->compare( '==', 'attribute.type.code', 'length' ),
72
+			$search->compare('==', 'attribute.domain', 'product'),
73
+			$search->compare('==', 'attribute.code', '30'),
74
+			$search->compare('==', 'attribute.type.code', 'length'),
75 75
 		);
76
-		$search->setConditions( $search->combine( '&&', $expr ) );
76
+		$search->setConditions($search->combine('&&', $expr));
77 77
 
78
-		$attributes = $attributeManager->searchItems( $search );
78
+		$attributes = $attributeManager->searchItems($search);
79 79
 
80
-		if( count( $attributes ) === 0 ) {
81
-			throw new \RuntimeException( 'Attributes not found' );
80
+		if (count($attributes) === 0) {
81
+			throw new \RuntimeException('Attributes not found');
82 82
 		}
83 83
 
84 84
 
85
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TEST' );
85
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TEST');
86 86
 
87
-		$this->object->addProduct( $item->getId(), 1, array(), array_keys( $attributes ) );
87
+		$this->object->addProduct($item->getId(), 1, array(), array_keys($attributes));
88 88
 
89
-		$this->assertEquals( 1, count( $this->object->get()->getProducts() ) );
90
-		$this->assertEquals( 'U:TESTSUB02', $this->object->get()->getProduct( 0 )->getProductCode() );
91
-		$this->assertEquals( 2, count( $this->object->get()->getProduct( 0 )->getAttributes() ) );
89
+		$this->assertEquals(1, count($this->object->get()->getProducts()));
90
+		$this->assertEquals('U:TESTSUB02', $this->object->get()->getProduct(0)->getProductCode());
91
+		$this->assertEquals(2, count($this->object->get()->getProduct(0)->getAttributes()));
92 92
 	}
93 93
 
94 94
 
95 95
 	public function testAddProductVariantNonUnique()
96 96
 	{
97
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
97
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
98 98
 
99 99
 		$search = $attributeManager->createSearch();
100 100
 		$expr = array(
101
-			$search->compare( '==', 'attribute.domain', 'product' ),
102
-			$search->compare( '==', 'attribute.code', '30' ),
103
-			$search->compare( '==', 'attribute.type.code', 'width' ),
101
+			$search->compare('==', 'attribute.domain', 'product'),
102
+			$search->compare('==', 'attribute.code', '30'),
103
+			$search->compare('==', 'attribute.type.code', 'width'),
104 104
 		);
105
-		$search->setConditions( $search->combine( '&&', $expr ) );
105
+		$search->setConditions($search->combine('&&', $expr));
106 106
 
107
-		$attributes = $attributeManager->searchItems( $search );
107
+		$attributes = $attributeManager->searchItems($search);
108 108
 
109
-		if( count( $attributes ) === 0 ) {
110
-			throw new \RuntimeException( 'Attributes not found' );
109
+		if (count($attributes) === 0) {
110
+			throw new \RuntimeException('Attributes not found');
111 111
 		}
112 112
 
113 113
 
114
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TEST' );
114
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TEST');
115 115
 
116
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
117
-		$this->object->addProduct( $item->getId(), 1, array(), array_keys( $attributes ) );
116
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
117
+		$this->object->addProduct($item->getId(), 1, array(), array_keys($attributes));
118 118
 	}
119 119
 
120 120
 
121 121
 	public function testAddProductVariantNotRequired()
122 122
 	{
123
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
123
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
124 124
 
125 125
 		$search = $attributeManager->createSearch();
126
-		$search->setConditions( $search->compare( '==', 'attribute.code', 'xs' ) );
126
+		$search->setConditions($search->compare('==', 'attribute.code', 'xs'));
127 127
 
128
-		$attributes = $attributeManager->searchItems( $search );
128
+		$attributes = $attributeManager->searchItems($search);
129 129
 
130
-		if( count( $attributes ) === 0 ) {
131
-			throw new \RuntimeException( 'Attribute not found' );
130
+		if (count($attributes) === 0) {
131
+			throw new \RuntimeException('Attribute not found');
132 132
 		}
133 133
 
134
-		$options = array( 'variant' => false );
134
+		$options = array('variant' => false);
135 135
 
136
-		$this->object->addProduct( $this->testItem->getId(), 1, $options, array_keys( $attributes ) );
136
+		$this->object->addProduct($this->testItem->getId(), 1, $options, array_keys($attributes));
137 137
 
138
-		$this->assertEquals( 1, count( $this->object->get()->getProducts() ) );
139
-		$this->assertEquals( 'U:TESTP', $this->object->get()->getProduct( 0 )->getProductCode() );
138
+		$this->assertEquals(1, count($this->object->get()->getProducts()));
139
+		$this->assertEquals('U:TESTP', $this->object->get()->getProduct(0)->getProductCode());
140 140
 	}
141 141
 
142 142
 
143 143
 	public function testAddProductEmptySelectionException()
144 144
 	{
145
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:noSel' );
145
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:noSel');
146 146
 
147
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
148
-		$this->object->addProduct( $item->getId(), 1 );
147
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
148
+		$this->object->addProduct($item->getId(), 1);
149 149
 	}
150 150
 
151 151
 
152 152
 	public function testAddProductSelectionWithPricelessItem()
153 153
 	{
154
-		$this->object->addProduct( $this->testItem->getId(), 1 );
154
+		$this->object->addProduct($this->testItem->getId(), 1);
155 155
 
156
-		$this->assertEquals( 'U:TESTPSUB01', $this->object->get()->getProduct( 0 )->getProductCode() );
156
+		$this->assertEquals('U:TESTPSUB01', $this->object->get()->getProduct(0)->getProductCode());
157 157
 	}
158 158
 
159 159
 
160 160
 	public function testAddProductConfigAttribute()
161 161
 	{
162
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
162
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
163 163
 
164 164
 		$search = $attributeManager->createSearch();
165
-		$search->setConditions( $search->compare( '==', 'attribute.code', 'xs' ) );
165
+		$search->setConditions($search->compare('==', 'attribute.code', 'xs'));
166 166
 
167
-		$attributes = $attributeManager->searchItems( $search );
167
+		$attributes = $attributeManager->searchItems($search);
168 168
 
169
-		if( empty( $attributes ) ) {
170
-			throw new \RuntimeException( 'Attribute not found' );
169
+		if (empty($attributes)) {
170
+			throw new \RuntimeException('Attribute not found');
171 171
 		}
172 172
 
173
-		$this->object->addProduct( $this->testItem->getId(), 1, array(), array(), array_keys( $attributes ) );
173
+		$this->object->addProduct($this->testItem->getId(), 1, array(), array(), array_keys($attributes));
174 174
 		$basket = $this->object->get();
175 175
 
176
-		$this->assertEquals( 1, count( $basket->getProducts() ) );
177
-		$this->assertEquals( 'U:TESTPSUB01', $basket->getProduct( 0 )->getProductCode() );
178
-		$this->assertEquals( 'xs', $basket->getProduct( 0 )->getAttribute( 'size', 'config' ) );
176
+		$this->assertEquals(1, count($basket->getProducts()));
177
+		$this->assertEquals('U:TESTPSUB01', $basket->getProduct(0)->getProductCode());
178
+		$this->assertEquals('xs', $basket->getProduct(0)->getAttribute('size', 'config'));
179 179
 	}
180 180
 
181 181
 
182 182
 	public function testAddProductHiddenAttribute()
183 183
 	{
184
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
184
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
185 185
 
186 186
 		$search = $attributeManager->createSearch();
187 187
 		$expr = array(
188
-			$search->compare( '==', 'attribute.code', '29' ),
189
-			$search->compare( '==', 'attribute.type.code', 'width' ),
188
+			$search->compare('==', 'attribute.code', '29'),
189
+			$search->compare('==', 'attribute.type.code', 'width'),
190 190
 		);
191
-		$search->setConditions( $search->combine( '&&', $expr ) );
191
+		$search->setConditions($search->combine('&&', $expr));
192 192
 
193
-		$attributes = $attributeManager->searchItems( $search );
193
+		$attributes = $attributeManager->searchItems($search);
194 194
 
195
-		if( empty( $attributes ) ) {
196
-			throw new \RuntimeException( 'Attribute not found' );
195
+		if (empty($attributes)) {
196
+			throw new \RuntimeException('Attribute not found');
197 197
 		}
198 198
 
199
-		$this->object->addProduct( $this->testItem->getId(), 1, array(), array(), array(), array_keys( $attributes ) );
199
+		$this->object->addProduct($this->testItem->getId(), 1, array(), array(), array(), array_keys($attributes));
200 200
 
201 201
 		$basket = $this->object->get();
202
-		$this->assertEquals( 1, count( $basket->getProducts() ) );
202
+		$this->assertEquals(1, count($basket->getProducts()));
203 203
 
204
-		$product = $basket->getProduct( 0 );
205
-		$this->assertEquals( 'U:TESTPSUB01', $product->getProductCode() );
204
+		$product = $basket->getProduct(0);
205
+		$this->assertEquals('U:TESTPSUB01', $product->getProductCode());
206 206
 
207 207
 		$attributes = $product->getAttributes();
208
-		$this->assertEquals( 1, count( $attributes ) );
208
+		$this->assertEquals(1, count($attributes));
209 209
 
210
-		if( ( $attribute = reset( $attributes ) ) === false ) {
211
-			throw new \RuntimeException( 'No attribute' );
210
+		if (($attribute = reset($attributes)) === false) {
211
+			throw new \RuntimeException('No attribute');
212 212
 		}
213 213
 
214
-		$this->assertEquals( 'hidden', $attribute->getType() );
215
-		$this->assertEquals( '29', $product->getAttribute( 'width', 'hidden' ) );
214
+		$this->assertEquals('hidden', $attribute->getType());
215
+		$this->assertEquals('29', $product->getAttribute('width', 'hidden'));
216 216
 	}
217 217
 }
Please login to merge, or discard this patch.
frontend/tests/Controller/Frontend/Basket/Decorator/BundleTest.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,28 +12,28 @@
 block discarded – undo
12 12
 	protected function setUp()
13 13
 	{
14 14
 		$this->context = \TestHelperFrontend::getContext();
15
-		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
16
-		$this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Bundle( $object, $this->context );
15
+		$object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context);
16
+		$this->object = new \Aimeos\Controller\Frontend\Basket\Decorator\Bundle($object, $this->context);
17 17
 	}
18 18
 
19 19
 
20 20
 	protected function tearDown()
21 21
 	{
22 22
 		$this->object->clear();
23
-		$this->context->getSession()->set( 'aimeos', array() );
23
+		$this->context->getSession()->set('aimeos', array());
24 24
 
25
-		unset( $this->object );
25
+		unset($this->object);
26 26
 	}
27 27
 
28 28
 
29 29
 	public function testAddProductBundle()
30 30
 	{
31
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:BUNDLE' );
31
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:BUNDLE');
32 32
 
33
-		$this->object->addProduct( $item->getId(), 1 );
33
+		$this->object->addProduct($item->getId(), 1);
34 34
 
35
-		$this->assertEquals( 1, count( $this->object->get()->getProducts() ) );
36
-		$this->assertEquals( 'U:BUNDLE', $this->object->get()->getProduct( 0 )->getProductCode() );
37
-		$this->assertEquals( 2, count( $this->object->get()->getProduct( 0 )->getProducts() ) );
35
+		$this->assertEquals(1, count($this->object->get()->getProducts()));
36
+		$this->assertEquals('U:BUNDLE', $this->object->get()->getProduct(0)->getProductCode());
37
+		$this->assertEquals(2, count($this->object->get()->getProduct(0)->getProducts()));
38 38
 	}
39 39
 }
Please login to merge, or discard this patch.
controller/frontend/tests/Controller/Frontend/Common/Decorator/Example.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 class Example
22 22
 	implements \Aimeos\Controller\Frontend\Common\Decorator\Iface
23 23
 {
24
-	public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context )
24
+	public function __construct(\Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context)
25 25
 	{
26 26
 	}
27 27
 }
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Basket/Decorator/Base.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param \Aimeos\Controller\Frontend\Iface $controller Controller object
32 32
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects
33 33
 	 */
34
-	public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context )
34
+	public function __construct(\Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context)
35 35
 	{
36 36
 		$this->context = $context;
37 37
 		$this->controller = $controller;
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
 	 * @return mixed Returns the value of the called method
47 47
 	 * @throws \Aimeos\Controller\Frontend\Exception If method call failed
48 48
 	 */
49
-	public function __call( $name, array $param )
49
+	public function __call($name, array $param)
50 50
 	{
51
-		return call_user_func_array( array( $this->controller, $name ), $param );
51
+		return call_user_func_array(array($this->controller, $name), $param);
52 52
 	}
53 53
 
54 54
 
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available
104 104
 	 * @return void
105 105
 	 */
106
-	public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(),
106
+	public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(),
107 107
 		array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(),
108
-		$stocktype = 'default' )
108
+		$stocktype = 'default')
109 109
 	{
110 110
 		$this->getController()->addProduct(
111 111
 			$prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds,
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 	 * @param integer $position Position number (key) of the order product item
121 121
 	 * @return void
122 122
 	 */
123
-	public function deleteProduct( $position )
123
+	public function deleteProduct($position)
124 124
 	{
125
-		$this->getController()->deleteProduct( $position );
125
+		$this->getController()->deleteProduct($position);
126 126
 	}
127 127
 
128 128
 
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
 	 * @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED
136 136
 	 * @return void
137 137
 	 */
138
-	public function editProduct( $position, $quantity, array $options = array(), array $configAttributeCodes = array() )
138
+	public function editProduct($position, $quantity, array $options = array(), array $configAttributeCodes = array())
139 139
 	{
140
-		$this->getController()->editProduct( $position, $quantity, $options, $configAttributeCodes );
140
+		$this->getController()->editProduct($position, $quantity, $options, $configAttributeCodes);
141 141
 	}
142 142
 
143 143
 
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed
149 149
 	 * @return void
150 150
 	 */
151
-	public function addCoupon( $code )
151
+	public function addCoupon($code)
152 152
 	{
153
-		$this->getController()->addCoupon( $code );
153
+		$this->getController()->addCoupon($code);
154 154
 	}
155 155
 
156 156
 
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid
162 162
 	 * @return void
163 163
 	 */
164
-	public function deleteCoupon( $code )
164
+	public function deleteCoupon($code)
165 165
 	{
166
-		$this->getController()->deleteCoupon( $code );
166
+		$this->getController()->deleteCoupon($code);
167 167
 	}
168 168
 
169 169
 
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 	 * 	if one of the keys is invalid when using an array with key/value pairs
177 177
 	 * @return void
178 178
 	 */
179
-	public function setAddress( $type, $value )
179
+	public function setAddress($type, $value)
180 180
 	{
181
-		$this->getController()->setAddress( $type, $value );
181
+		$this->getController()->setAddress($type, $value);
182 182
 	}
183 183
 
184 184
 
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached
193 193
 	 * @return void
194 194
 	 */
195
-	public function setService( $type, $id, array $attributes = array() )
195
+	public function setService($type, $id, array $attributes = array())
196 196
 	{
197
-		$this->getController()->setService( $type, $id, $attributes );
197
+		$this->getController()->setService($type, $id, $attributes);
198 198
 	}
199 199
 
200 200
 
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Basket/Decorator/Bundle.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -41,15 +41,15 @@  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(), array $variantAttributeIds = array(),
44
+	public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(),
45 45
 		array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(),
46
-		$stocktype = 'default' )
46
+		$stocktype = 'default')
47 47
 	{
48 48
 		$context = $this->getContext();
49
-		$productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
50
-		$productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ) );
49
+		$productManager = \Aimeos\MShop\Factory::createManager($context, 'product');
50
+		$productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'));
51 51
 
52
-		if( $productItem->getType() !== 'bundle' )
52
+		if ($productItem->getType() !== 'bundle')
53 53
 		{
54 54
 			return $this->getController()->addProduct(
55 55
 				$prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds,
@@ -57,28 +57,28 @@  discard block
 block discarded – undo
57 57
 			);
58 58
 		}
59 59
 
60
-		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem();
61
-		$orderBaseProductItem->copyFrom( $productItem );
62
-		$orderBaseProductItem->setQuantity( $quantity );
63
-		$orderBaseProductItem->setStockType( $stocktype );
60
+		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem();
61
+		$orderBaseProductItem->copyFrom($productItem);
62
+		$orderBaseProductItem->setQuantity($quantity);
63
+		$orderBaseProductItem->setStockType($stocktype);
64 64
 
65
-		$prices = $productItem->getRefItems( 'price', 'default', 'default' );
66
-		$this->addBundleProducts( $orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype );
65
+		$prices = $productItem->getRefItems('price', 'default', 'default');
66
+		$this->addBundleProducts($orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype);
67 67
 
68
-		$priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' );
69
-		$price = $priceManager->getLowestPrice( $prices, $quantity );
68
+		$priceManager = \Aimeos\MShop\Factory::createManager($context, 'price');
69
+		$price = $priceManager->getLowestPrice($prices, $quantity);
70 70
 
71
-		$attr = $this->createOrderProductAttributes( $price, $prodid, $quantity, $configAttributeIds, 'config' );
72
-		$attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $hiddenAttributeIds, 'hidden' ) );
73
-		$attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, array_keys( $customAttributeValues ), 'custom', $customAttributeValues ) );
71
+		$attr = $this->createOrderProductAttributes($price, $prodid, $quantity, $configAttributeIds, 'config');
72
+		$attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $hiddenAttributeIds, 'hidden'));
73
+		$attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, array_keys($customAttributeValues), 'custom', $customAttributeValues));
74 74
 
75 75
 		// remove product rebate of original price in favor to rebates granted for the order
76
-		$price->setRebate( '0.00' );
76
+		$price->setRebate('0.00');
77 77
 
78
-		$orderBaseProductItem->setPrice( $price );
79
-		$orderBaseProductItem->setAttributes( $attr );
78
+		$orderBaseProductItem->setPrice($price);
79
+		$orderBaseProductItem->setAttributes($attr);
80 80
 
81
-		$this->getController()->get()->addProduct( $orderBaseProductItem );
81
+		$this->getController()->get()->addProduct($orderBaseProductItem);
82 82
 		$this->getController()->save();
83 83
 	}
84 84
 
@@ -91,43 +91,43 @@  discard block
 block discarded – undo
91 91
 	 * @param array $variantAttributeIds List of product variant attribute IDs
92 92
 	 * @param string $stocktype
93 93
 	 */
94
-	protected function addBundleProducts( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem,
95
-		\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype )
94
+	protected function addBundleProducts(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem,
95
+		\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype)
96 96
 	{
97 97
 		$quantity = $orderBaseProductItem->getQuantity();
98 98
 		$products = $subProductIds = $orderProducts = array();
99
-		$orderProductManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product' );
99
+		$orderProductManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product');
100 100
 
101
-		foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item ) {
101
+		foreach ($productItem->getRefItems('product', null, 'default') as $item) {
102 102
 			$subProductIds[] = $item->getId();
103 103
 		}
104 104
 
105
-		if( count( $subProductIds ) > 0 )
105
+		if (count($subProductIds) > 0)
106 106
 		{
107
-			$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
107
+			$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
108 108
 
109
-			$search = $productManager->createSearch( true );
109
+			$search = $productManager->createSearch(true);
110 110
 			$expr = array(
111
-				$search->compare( '==', 'product.id', $subProductIds ),
111
+				$search->compare('==', 'product.id', $subProductIds),
112 112
 				$search->getConditions(),
113 113
 			);
114
-			$search->setConditions( $search->combine( '&&', $expr ) );
114
+			$search->setConditions($search->combine('&&', $expr));
115 115
 
116
-			$products = $productManager->searchItems( $search, array( 'attribute', 'media', 'price', 'text' ) );
116
+			$products = $productManager->searchItems($search, array('attribute', 'media', 'price', 'text'));
117 117
 		}
118 118
 
119
-		foreach( $products as $product )
119
+		foreach ($products as $product)
120 120
 		{
121
-			$prices = $product->getRefItems( 'price', 'default', 'default' );
121
+			$prices = $product->getRefItems('price', 'default', 'default');
122 122
 
123 123
 			$orderProduct = $orderProductManager->createItem();
124
-			$orderProduct->copyFrom( $product );
125
-			$orderProduct->setStockType( $stocktype );
126
-			$orderProduct->setPrice( $this->calcPrice( $orderProduct, $prices, $quantity ) );
124
+			$orderProduct->copyFrom($product);
125
+			$orderProduct->setStockType($stocktype);
126
+			$orderProduct->setPrice($this->calcPrice($orderProduct, $prices, $quantity));
127 127
 
128 128
 			$orderProducts[] = $orderProduct;
129 129
 		}
130 130
 
131
-		$orderBaseProductItem->setProducts( $orderProducts );
131
+		$orderBaseProductItem->setProducts($orderProducts);
132 132
 	}
133 133
 }
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Basket/Decorator/Select.php 2 patches
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -41,15 +41,15 @@  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(), array $variantAttributeIds = array(),
44
+	public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(),
45 45
 		array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(),
46
-		$stocktype = 'default' )
46
+		$stocktype = 'default')
47 47
 	{
48 48
 		$context = $this->getContext();
49
-		$productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
50
-		$productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ) );
49
+		$productManager = \Aimeos\MShop\Factory::createManager($context, 'product');
50
+		$productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'));
51 51
 
52
-		if( $productItem->getType() !== 'select' )
52
+		if ($productItem->getType() !== 'select')
53 53
 		{
54 54
 			return $this->getController()->addProduct(
55 55
 				$prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds,
@@ -57,28 +57,28 @@  discard block
 block discarded – undo
57 57
 			);
58 58
 		}
59 59
 
60
-		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem();
61
-		$orderBaseProductItem->copyFrom( $productItem );
62
-		$orderBaseProductItem->setQuantity( $quantity );
63
-		$orderBaseProductItem->setStockType( $stocktype );
60
+		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem();
61
+		$orderBaseProductItem->copyFrom($productItem);
62
+		$orderBaseProductItem->setQuantity($quantity);
63
+		$orderBaseProductItem->setStockType($stocktype);
64 64
 
65
-		$prices = $productItem->getRefItems( 'price', 'default', 'default' );
66
-		$attr = $this->getVariantDetails( $orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options );
65
+		$prices = $productItem->getRefItems('price', 'default', 'default');
66
+		$attr = $this->getVariantDetails($orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options);
67 67
 
68
-		$priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' );
69
-		$price = $priceManager->getLowestPrice( $prices, $quantity );
68
+		$priceManager = \Aimeos\MShop\Factory::createManager($context, 'price');
69
+		$price = $priceManager->getLowestPrice($prices, $quantity);
70 70
 
71
-		$attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $configAttributeIds, 'config' ) );
72
-		$attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $hiddenAttributeIds, 'hidden' ) );
73
-		$attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, array_keys( $customAttributeValues ), 'custom', $customAttributeValues ) );
71
+		$attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $configAttributeIds, 'config'));
72
+		$attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $hiddenAttributeIds, 'hidden'));
73
+		$attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, array_keys($customAttributeValues), 'custom', $customAttributeValues));
74 74
 
75 75
 		// remove product rebate of original price in favor to rebates granted for the order
76
-		$price->setRebate( '0.00' );
76
+		$price->setRebate('0.00');
77 77
 
78
-		$orderBaseProductItem->setPrice( $price );
79
-		$orderBaseProductItem->setAttributes( $attr );
78
+		$orderBaseProductItem->setPrice($price);
79
+		$orderBaseProductItem->setAttributes($attr);
80 80
 
81
-		$this->getController()->get()->addProduct( $orderBaseProductItem );
81
+		$this->getController()->get()->addProduct($orderBaseProductItem);
82 82
 		$this->getController()->save();
83 83
 	}
84 84
 
@@ -94,50 +94,50 @@  discard block
 block discarded – undo
94 94
 	 * @return \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface[] List of order product attributes
95 95
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If no product variant is found
96 96
 	 */
97
-	protected function getVariantDetails( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem,
98
-		\Aimeos\MShop\Product\Item\Iface &$productItem, array &$prices, array $variantAttributeIds, array $options )
97
+	protected function getVariantDetails(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem,
98
+		\Aimeos\MShop\Product\Item\Iface & $productItem, array &$prices, array $variantAttributeIds, array $options)
99 99
 	{
100 100
 		$attr = array();
101
-		$productItems = $this->getProductVariants( $productItem, $variantAttributeIds );
101
+		$productItems = $this->getProductVariants($productItem, $variantAttributeIds);
102 102
 
103
-		if( count( $productItems ) > 1 )
103
+		if (count($productItems) > 1)
104 104
 		{
105
-			$msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() );
106
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
105
+			$msg = sprintf('No unique article found for selected attributes and product ID "%1$s"', $productItem->getId());
106
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
107 107
 		}
108
-		else if( ( $result = reset( $productItems ) ) !== false ) // count == 1
108
+		else if (($result = reset($productItems)) !== false) // count == 1
109 109
 		{
110 110
 			$productItem = $result;
111
-			$orderBaseProductItem->setProductCode( $productItem->getCode() );
111
+			$orderBaseProductItem->setProductCode($productItem->getCode());
112 112
 
113
-			$subprices = $productItem->getRefItems( 'price', 'default', 'default' );
113
+			$subprices = $productItem->getRefItems('price', 'default', 'default');
114 114
 
115
-			if( !empty( $subprices ) ) {
115
+			if (!empty($subprices)) {
116 116
 				$prices = $subprices;
117 117
 			}
118 118
 
119
-			$submedia = $productItem->getRefItems( 'media', 'default', 'default' );
119
+			$submedia = $productItem->getRefItems('media', 'default', 'default');
120 120
 
121
-			if( ( $mediaItem = reset( $submedia ) ) !== false ) {
122
-				$orderBaseProductItem->setMediaUrl( $mediaItem->getPreview() );
121
+			if (($mediaItem = reset($submedia)) !== false) {
122
+				$orderBaseProductItem->setMediaUrl($mediaItem->getPreview());
123 123
 			}
124 124
 
125
-			$orderProductAttrManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' );
126
-			$variantAttributes = $productItem->getRefItems( 'attribute', null, 'variant' );
125
+			$orderProductAttrManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute');
126
+			$variantAttributes = $productItem->getRefItems('attribute', null, 'variant');
127 127
 
128
-			foreach( $this->getAttributes( array_keys( $variantAttributes ), array( 'text' ) ) as $attrItem )
128
+			foreach ($this->getAttributes(array_keys($variantAttributes), array('text')) as $attrItem)
129 129
 			{
130 130
 				$orderAttributeItem = $orderProductAttrManager->createItem();
131
-				$orderAttributeItem->copyFrom( $attrItem );
132
-				$orderAttributeItem->setType( 'variant' );
131
+				$orderAttributeItem->copyFrom($attrItem);
132
+				$orderAttributeItem->setType('variant');
133 133
 
134 134
 				$attr[] = $orderAttributeItem;
135 135
 			}
136 136
 		}
137
-		else if( !isset( $options['variant'] ) || $options['variant'] != false ) // count == 0
137
+		else if (!isset($options['variant']) || $options['variant'] != false) // count == 0
138 138
 		{
139
-			$msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() );
140
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
139
+			$msg = sprintf('No article found for selected attributes and product ID "%1$s"', $productItem->getId());
140
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
141 141
 		}
142 142
 
143 143
 		return $attr;
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -104,10 +104,11 @@  discard block
 block discarded – undo
104 104
 		{
105 105
 			$msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() );
106 106
 			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
107
-		}
108
-		else if( ( $result = reset( $productItems ) ) !== false ) // count == 1
107
+		} else if( ( $result = reset( $productItems ) ) !== false ) {
108
+			// count == 1
109 109
 		{
110 110
 			$productItem = $result;
111
+		}
111 112
 			$orderBaseProductItem->setProductCode( $productItem->getCode() );
112 113
 
113 114
 			$subprices = $productItem->getRefItems( 'price', 'default', 'default' );
@@ -133,10 +134,11 @@  discard block
 block discarded – undo
133 134
 
134 135
 				$attr[] = $orderAttributeItem;
135 136
 			}
136
-		}
137
-		else if( !isset( $options['variant'] ) || $options['variant'] != false ) // count == 0
137
+		} else if( !isset( $options['variant'] ) || $options['variant'] != false ) {
138
+			// count == 0
138 139
 		{
139 140
 			$msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() );
141
+		}
140 142
 			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
141 143
 		}
142 144
 
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Basket/Base.php 1 patch
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -31,32 +31,32 @@  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
-		$priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' );
45
-		$price = $priceManager->getLowestPrice( $prices, $quantity );
44
+		$priceManager = \Aimeos\MShop\Factory::createManager($context, 'price');
45
+		$price = $priceManager->getLowestPrice($prices, $quantity);
46 46
 
47
-		foreach( $this->getAttributeItems( $product->getAttributes() ) as $attrItem )
47
+		foreach ($this->getAttributeItems($product->getAttributes()) as $attrItem)
48 48
 		{
49
-			$prices = $attrItem->getRefItems( 'price', 'default' );
49
+			$prices = $attrItem->getRefItems('price', 'default');
50 50
 
51
-			if( count( $prices ) > 0 )
51
+			if (count($prices) > 0)
52 52
 			{
53
-				$attrPrice = $priceManager->getLowestPrice( $prices, $quantity );
54
-				$price->addItem( $attrPrice );
53
+				$attrPrice = $priceManager->getLowestPrice($prices, $quantity);
54
+				$price->addItem($attrPrice);
55 55
 			}
56 56
 		}
57 57
 
58 58
 		// remove product rebate of original price in favor to rebates granted for the order
59
-		$price->setRebate( '0.00' );
59
+		$price->setRebate('0.00');
60 60
 
61 61
 		return $price;
62 62
 	}
@@ -71,34 +71,34 @@  discard block
 block discarded – undo
71 71
 	 * @param array $refIds List of IDs that must be associated to the product
72 72
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated
73 73
 	 */
74
-	protected function checkReferences( $prodId, $domain, $listTypeId, array $refIds )
74
+	protected function checkReferences($prodId, $domain, $listTypeId, array $refIds)
75 75
 	{
76
-		$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
77
-		$search = $productManager->createSearch( true );
76
+		$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
77
+		$search = $productManager->createSearch(true);
78 78
 
79 79
 		$expr = array(
80
-			$search->compare( '==', 'product.id', $prodId ),
80
+			$search->compare('==', 'product.id', $prodId),
81 81
 			$search->getConditions(),
82 82
 		);
83 83
 
84
-		if( count( $refIds ) > 0 )
84
+		if (count($refIds) > 0)
85 85
 		{
86
-			foreach( $refIds as $key => $refId ) {
86
+			foreach ($refIds as $key => $refId) {
87 87
 				$refIds[$key] = (string) $refId;
88 88
 			}
89 89
 
90
-			$param = array( $domain, $listTypeId, $refIds );
91
-			$cmpfunc = $search->createFunction( 'product.contains', $param );
90
+			$param = array($domain, $listTypeId, $refIds);
91
+			$cmpfunc = $search->createFunction('product.contains', $param);
92 92
 
93
-			$expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) );
93
+			$expr[] = $search->compare('==', $cmpfunc, count($refIds));
94 94
 		}
95 95
 
96
-		$search->setConditions( $search->combine( '&&', $expr ) );
96
+		$search->setConditions($search->combine('&&', $expr));
97 97
 
98
-		if( count( $productManager->searchItems( $search, array() ) ) === 0 )
98
+		if (count($productManager->searchItems($search, array())) === 0)
99 99
 		{
100
-			$msg = sprintf( 'Invalid "%1$s" references for product with ID "%2$s"', $domain, $prodId );
101
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
100
+			$msg = sprintf('Invalid "%1$s" references for product with ID "%2$s"', $domain, $prodId);
101
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
102 102
 		}
103 103
 	}
104 104
 
@@ -113,34 +113,34 @@  discard block
 block discarded – undo
113 113
 		$session = $context->getSession();
114 114
 		$locale = $this->get()->getLocale();
115 115
 
116
-		$localeStr = $session->get( 'aimeos/basket/locale' );
116
+		$localeStr = $session->get('aimeos/basket/locale');
117 117
 		$localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId();
118 118
 
119
-		if( $localeStr !== null && $localeStr !== $localeKey )
119
+		if ($localeStr !== null && $localeStr !== $localeKey)
120 120
 		{
121
-			$locParts = explode( '|', $localeStr );
122
-			$locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' );
123
-			$locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' );
124
-			$locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' );
121
+			$locParts = explode('|', $localeStr);
122
+			$locSite = (isset($locParts[0]) ? $locParts[0] : '');
123
+			$locLanguage = (isset($locParts[1]) ? $locParts[1] : '');
124
+			$locCurrency = (isset($locParts[2]) ? $locParts[2] : '');
125 125
 
126
-			$localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' );
127
-			$locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false );
126
+			$localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale');
127
+			$locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false);
128 128
 
129 129
 			$context = clone $context;
130
-			$context->setLocale( $locale );
130
+			$context->setLocale($locale);
131 131
 
132
-			$manager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' );
132
+			$manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base');
133 133
 			$basket = $manager->getSession();
134 134
 
135
-			$this->copyAddresses( $basket, $errors, $localeKey );
136
-			$this->copyServices( $basket, $errors );
137
-			$this->copyProducts( $basket, $errors, $localeKey );
138
-			$this->copyCoupons( $basket, $errors, $localeKey );
135
+			$this->copyAddresses($basket, $errors, $localeKey);
136
+			$this->copyServices($basket, $errors);
137
+			$this->copyProducts($basket, $errors, $localeKey);
138
+			$this->copyCoupons($basket, $errors, $localeKey);
139 139
 
140
-			$manager->setSession( $basket );
140
+			$manager->setSession($basket);
141 141
 		}
142 142
 
143
-		$session->set( 'aimeos/basket/locale', $localeKey );
143
+		$session->set('aimeos/basket/locale', $localeKey);
144 144
 	}
145 145
 
146 146
 
@@ -152,20 +152,20 @@  discard block
 block discarded – undo
152 152
 	 * @param string $localeKey Unique identifier of the site, language and currency
153 153
 	 * @return array Associative list of errors occured
154 154
 	 */
155
-	protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
155
+	protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
156 156
 	{
157
-		foreach( $basket->getAddresses() as $type => $item )
157
+		foreach ($basket->getAddresses() as $type => $item)
158 158
 		{
159 159
 			try
160 160
 			{
161
-				$this->setAddress( $type, $item->toArray() );
162
-				$basket->deleteAddress( $type );
161
+				$this->setAddress($type, $item->toArray());
162
+				$basket->deleteAddress($type);
163 163
 			}
164
-			catch( \Exception $e )
164
+			catch (\Exception $e)
165 165
 			{
166 166
 				$logger = $this->getContext()->getLogger();
167 167
 				$str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s';
168
-				$logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
168
+				$logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
169 169
 				$errors['address'][$type] = $e->getMessage();
170 170
 			}
171 171
 		}
@@ -182,20 +182,20 @@  discard block
 block discarded – undo
182 182
 	 * @param string $localeKey Unique identifier of the site, language and currency
183 183
 	 * @return array Associative list of errors occured
184 184
 	 */
185
-	protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
185
+	protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
186 186
 	{
187
-		foreach( $basket->getCoupons() as $code => $list )
187
+		foreach ($basket->getCoupons() as $code => $list)
188 188
 		{
189 189
 			try
190 190
 			{
191
-				$this->addCoupon( $code );
192
-				$basket->deleteCoupon( $code, true );
191
+				$this->addCoupon($code);
192
+				$basket->deleteCoupon($code, true);
193 193
 			}
194
-			catch( \Exception $e )
194
+			catch (\Exception $e)
195 195
 			{
196 196
 				$logger = $this->getContext()->getLogger();
197 197
 				$str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s';
198
-				$logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
198
+				$logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
199 199
 				$errors['coupon'][$code] = $e->getMessage();
200 200
 			}
201 201
 		}
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
 	 * @param string $localeKey Unique identifier of the site, language and currency
213 213
 	 * @return array Associative list of errors occured
214 214
 	 */
215
-	protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
215
+	protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
216 216
 	{
217
-		foreach( $basket->getProducts() as $pos => $product )
217
+		foreach ($basket->getProducts() as $pos => $product)
218 218
 		{
219
-			if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) {
219
+			if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) {
220 220
 				continue;
221 221
 			}
222 222
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 			{
225 225
 				$attrIds = array();
226 226
 
227
-				foreach( $product->getAttributes() as $attrItem ) {
227
+				foreach ($product->getAttributes() as $attrItem) {
228 228
 					$attrIds[$attrItem->getType()][] = $attrItem->getAttributeId();
229 229
 				}
230 230
 
@@ -232,21 +232,21 @@  discard block
 block discarded – undo
232 232
 						$product->getProductId(),
233 233
 						$product->getQuantity(),
234 234
 						array(),
235
-						$this->getValue( $attrIds, 'variant', array() ),
236
-						$this->getValue( $attrIds, 'config', array() ),
237
-						$this->getValue( $attrIds, 'hidden', array() ),
238
-						$this->getValue( $attrIds, 'custom', array() ),
235
+						$this->getValue($attrIds, 'variant', array()),
236
+						$this->getValue($attrIds, 'config', array()),
237
+						$this->getValue($attrIds, 'hidden', array()),
238
+						$this->getValue($attrIds, 'custom', array()),
239 239
 						$product->getStockType()
240 240
 				);
241 241
 
242
-				$basket->deleteProduct( $pos );
242
+				$basket->deleteProduct($pos);
243 243
 			}
244
-			catch( \Exception $e )
244
+			catch (\Exception $e)
245 245
 			{
246 246
 				$code = $product->getProductCode();
247 247
 				$logger = $this->getContext()->getLogger();
248 248
 				$str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s';
249
-				$logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
249
+				$logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
250 250
 				$errors['product'][$pos] = $e->getMessage();
251 251
 			}
252 252
 		}
@@ -262,22 +262,22 @@  discard block
 block discarded – undo
262 262
 	 * @param array $errors Associative list of previous errors
263 263
 	 * @return array Associative list of errors occured
264 264
 	 */
265
-	protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors )
265
+	protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors)
266 266
 	{
267
-		foreach( $basket->getServices() as $type => $item )
267
+		foreach ($basket->getServices() as $type => $item)
268 268
 		{
269 269
 			try
270 270
 			{
271 271
 				$attributes = array();
272 272
 
273
-				foreach( $item->getAttributes() as $attrItem ) {
273
+				foreach ($item->getAttributes() as $attrItem) {
274 274
 					$attributes[$attrItem->getCode()] = $attrItem->getValue();
275 275
 				}
276 276
 
277
-				$this->setService( $type, $item->getServiceId(), $attributes );
278
-				$basket->deleteService( $type );
277
+				$this->setService($type, $item->getServiceId(), $attributes);
278
+				$basket->deleteService($type);
279 279
 			}
280
-			catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically
280
+			catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically
281 281
 		}
282 282
 
283 283
 		return $errors;
@@ -295,36 +295,36 @@  discard block
 block discarded – undo
295 295
 	 * @param array $attributeValues Associative list of attribute IDs as keys and their codes as values
296 296
 	 * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface
297 297
 	 */
298
-	protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity,
299
-			array $attributeIds, $type, array $attributeValues = array() )
298
+	protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity,
299
+			array $attributeIds, $type, array $attributeValues = array())
300 300
 	{
301
-		if( empty( $attributeIds ) ) {
301
+		if (empty($attributeIds)) {
302 302
 			return array();
303 303
 		}
304 304
 
305
-		$attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId();
306
-		$this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds );
305
+		$attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId();
306
+		$this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds);
307 307
 
308 308
 		$list = array();
309 309
 		$context = $this->getContext();
310 310
 
311
-		$priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' );
312
-		$orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' );
311
+		$priceManager = \Aimeos\MShop\Factory::createManager($context, 'price');
312
+		$orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute');
313 313
 
314
-		foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem )
314
+		foreach ($this->getAttributes($attributeIds) as $id => $attrItem)
315 315
 		{
316
-			$prices = $attrItem->getRefItems( 'price', 'default', 'default' );
316
+			$prices = $attrItem->getRefItems('price', 'default', 'default');
317 317
 
318
-			if( !empty( $prices ) ) {
319
-				$price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) );
318
+			if (!empty($prices)) {
319
+				$price->addItem($priceManager->getLowestPrice($prices, $quantity));
320 320
 			}
321 321
 
322 322
 			$item = $orderProductAttributeManager->createItem();
323
-			$item->copyFrom( $attrItem );
324
-			$item->setType( $type );
323
+			$item->copyFrom($attrItem);
324
+			$item->setType($type);
325 325
 
326
-			if( isset( $attributeValues[$id] ) ) {
327
-				$item->setValue( $attributeValues[$id] );
326
+			if (isset($attributeValues[$id])) {
327
+				$item->setValue($attributeValues[$id]);
328 328
 			}
329 329
 
330 330
 			$list[] = $item;
@@ -342,31 +342,31 @@  discard block
 block discarded – undo
342 342
 	 * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface
343 343
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one
344 344
 	 */
345
-	protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) )
345
+	protected function getAttributes(array $attributeIds, array $domains = array('price', 'text'))
346 346
 	{
347
-		if( empty( $attributeIds ) ) {
347
+		if (empty($attributeIds)) {
348 348
 			return array();
349 349
 		}
350 350
 
351
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
351
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
352 352
 
353
-		$search = $attributeManager->createSearch( true );
353
+		$search = $attributeManager->createSearch(true);
354 354
 		$expr = array(
355
-				$search->compare( '==', 'attribute.id', $attributeIds ),
355
+				$search->compare('==', 'attribute.id', $attributeIds),
356 356
 				$search->getConditions(),
357 357
 		);
358
-		$search->setConditions( $search->combine( '&&', $expr ) );
359
-		$search->setSlice( 0, 0x7fffffff );
358
+		$search->setConditions($search->combine('&&', $expr));
359
+		$search->setSlice(0, 0x7fffffff);
360 360
 
361
-		$attrItems = $attributeManager->searchItems( $search, $domains );
361
+		$attrItems = $attributeManager->searchItems($search, $domains);
362 362
 
363
-		if( count( $attrItems ) !== count( $attributeIds ) )
363
+		if (count($attrItems) !== count($attributeIds))
364 364
 		{
365
-			$expected = implode( ',', $attributeIds );
366
-			$actual = implode( ',', array_keys( $attrItems ) );
367
-			$msg = sprintf( 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected );
365
+			$expected = implode(',', $attributeIds);
366
+			$actual = implode(',', array_keys($attrItems));
367
+			$msg = sprintf('Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected);
368 368
 
369
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
369
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
370 370
 		}
371 371
 
372 372
 		return $attrItems;
@@ -379,31 +379,31 @@  discard block
 block discarded – undo
379 379
 	 * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items
380 380
 	 * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values
381 381
 	 */
382
-	protected function getAttributeItems( array $orderAttributes )
382
+	protected function getAttributeItems(array $orderAttributes)
383 383
 	{
384
-		if( empty( $orderAttributes ) ) {
384
+		if (empty($orderAttributes)) {
385 385
 			return array();
386 386
 		}
387 387
 
388
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
389
-		$search = $attributeManager->createSearch( true );
388
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
389
+		$search = $attributeManager->createSearch(true);
390 390
 		$expr = array();
391 391
 
392
-		foreach( $orderAttributes as $item )
392
+		foreach ($orderAttributes as $item)
393 393
 		{
394 394
 			$tmp = array(
395
-				$search->compare( '==', 'attribute.domain', 'product' ),
396
-				$search->compare( '==', 'attribute.code', $item->getValue() ),
397
-				$search->compare( '==', 'attribute.type.domain', 'product' ),
398
-				$search->compare( '==', 'attribute.type.code', $item->getCode() ),
399
-				$search->compare( '>', 'attribute.type.status', 0 ),
395
+				$search->compare('==', 'attribute.domain', 'product'),
396
+				$search->compare('==', 'attribute.code', $item->getValue()),
397
+				$search->compare('==', 'attribute.type.domain', 'product'),
398
+				$search->compare('==', 'attribute.type.code', $item->getCode()),
399
+				$search->compare('>', 'attribute.type.status', 0),
400 400
 				$search->getConditions(),
401 401
 			);
402
-			$expr[] = $search->combine( '&&', $tmp );
402
+			$expr[] = $search->combine('&&', $tmp);
403 403
 		}
404 404
 
405
-		$search->setConditions( $search->combine( '||', $expr ) );
406
-		return $attributeManager->searchItems( $search, array( 'price' ) );
405
+		$search->setConditions($search->combine('||', $expr));
406
+		return $attributeManager->searchItems($search, array('price'));
407 407
 	}
408 408
 
409 409
 
@@ -417,23 +417,23 @@  discard block
 block discarded – undo
417 417
 	 * @return \Aimeos\MShop\Common\Item\Iface Domain item object
418 418
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception
419 419
 	 */
420
-	protected function getDomainItem( $domain, $key, $value, array $ref )
420
+	protected function getDomainItem($domain, $key, $value, array $ref)
421 421
 	{
422
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain );
422
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain);
423 423
 
424
-		$search = $manager->createSearch( true );
424
+		$search = $manager->createSearch(true);
425 425
 		$expr = array(
426
-				$search->compare( '==', $key, $value ),
426
+				$search->compare('==', $key, $value),
427 427
 				$search->getConditions(),
428 428
 		);
429
-		$search->setConditions( $search->combine( '&&', $expr ) );
429
+		$search->setConditions($search->combine('&&', $expr));
430 430
 
431
-		$result = $manager->searchItems( $search, $ref );
431
+		$result = $manager->searchItems($search, $ref);
432 432
 
433
-		if( ( $item = reset( $result ) ) === false )
433
+		if (($item = reset($result)) === false)
434 434
 		{
435
-			$msg = sprintf( 'No item for "%1$s" (%2$s) found', $value, $key );
436
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
435
+			$msg = sprintf('No item for "%1$s" (%2$s) found', $value, $key);
436
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
437 437
 		}
438 438
 
439 439
 		return $item;
@@ -447,26 +447,26 @@  discard block
 block discarded – undo
447 447
 	 * @param string $code Code of the list type
448 448
 	 * @return \Aimeos\MShop\Common\Item\Type\Iface List type item
449 449
 	 */
450
-	protected function getProductListTypeItem( $domain, $code )
450
+	protected function getProductListTypeItem($domain, $code)
451 451
 	{
452
-		if( !isset( $this->listTypeAttributes[$domain][$code] ) )
452
+		if (!isset($this->listTypeAttributes[$domain][$code]))
453 453
 		{
454
-			$listTypeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists/type' );
454
+			$listTypeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists/type');
455 455
 
456
-			$listTypeSearch = $listTypeManager->createSearch( true );
456
+			$listTypeSearch = $listTypeManager->createSearch(true);
457 457
 			$expr = array(
458
-				$listTypeSearch->compare( '==', 'product.lists.type.domain', $domain ),
459
-				$listTypeSearch->compare( '==', 'product.lists.type.code', $code ),
458
+				$listTypeSearch->compare('==', 'product.lists.type.domain', $domain),
459
+				$listTypeSearch->compare('==', 'product.lists.type.code', $code),
460 460
 				$listTypeSearch->getConditions(),
461 461
 			);
462
-			$listTypeSearch->setConditions( $listTypeSearch->combine( '&&', $expr ) );
462
+			$listTypeSearch->setConditions($listTypeSearch->combine('&&', $expr));
463 463
 
464
-			$listTypeItems = $listTypeManager->searchItems( $listTypeSearch );
464
+			$listTypeItems = $listTypeManager->searchItems($listTypeSearch);
465 465
 
466
-			if( ( $listTypeItem = reset( $listTypeItems ) ) === false )
466
+			if (($listTypeItem = reset($listTypeItems)) === false)
467 467
 			{
468
-				$msg = sprintf( 'List type for domain "%1$s" and code "%2$s" not found', $domain, $code );
469
-				throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
468
+				$msg = sprintf('List type for domain "%1$s" and code "%2$s" not found', $domain, $code);
469
+				throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
470 470
 			}
471 471
 
472 472
 			$this->listTypeAttributes[$domain][$code] = $listTypeItem;
@@ -484,43 +484,43 @@  discard block
 block discarded – undo
484 484
 	 * @param array $domains Names of the domain items that should be fetched too
485 485
 	 * @return array List of products matching the given attributes
486 486
 	 */
487
-	protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds,
488
-			array $domains = array( 'attribute', 'media', 'price', 'text' ) )
487
+	protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds,
488
+			array $domains = array('attribute', 'media', 'price', 'text'))
489 489
 	{
490 490
 		$subProductIds = array();
491
-		foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) {
491
+		foreach ($productItem->getRefItems('product', 'default', 'default') as $item) {
492 492
 			$subProductIds[] = $item->getId();
493 493
 		}
494 494
 
495
-		if( count( $subProductIds ) === 0 ) {
495
+		if (count($subProductIds) === 0) {
496 496
 			return array();
497 497
 		}
498 498
 
499
-		$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
500
-		$search = $productManager->createSearch( true );
499
+		$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
500
+		$search = $productManager->createSearch(true);
501 501
 
502 502
 		$expr = array(
503
-			$search->compare( '==', 'product.id', $subProductIds ),
503
+			$search->compare('==', 'product.id', $subProductIds),
504 504
 			$search->getConditions(),
505 505
 		);
506 506
 
507
-		if( count( $variantAttributeIds ) > 0 )
507
+		if (count($variantAttributeIds) > 0)
508 508
 		{
509
-			foreach( $variantAttributeIds as $key => $id ) {
509
+			foreach ($variantAttributeIds as $key => $id) {
510 510
 				$variantAttributeIds[$key] = (string) $id;
511 511
 			}
512 512
 
513
-			$listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' );
513
+			$listTypeItem = $this->getProductListTypeItem('attribute', 'variant');
514 514
 
515
-			$param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds );
516
-			$cmpfunc = $search->createFunction( 'product.contains', $param );
515
+			$param = array('attribute', $listTypeItem->getId(), $variantAttributeIds);
516
+			$cmpfunc = $search->createFunction('product.contains', $param);
517 517
 
518
-			$expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) );
518
+			$expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds));
519 519
 		}
520 520
 
521
-		$search->setConditions( $search->combine( '&&', $expr ) );
521
+		$search->setConditions($search->combine('&&', $expr));
522 522
 
523
-		return $productManager->searchItems( $search, $domains );
523
+		return $productManager->searchItems($search, $domains);
524 524
 	}
525 525
 
526 526
 
@@ -532,9 +532,9 @@  discard block
 block discarded – undo
532 532
 	 * @param mixed $default Default value if no value is available for the given name
533 533
 	 * @return mixed Value from the array or default value
534 534
 	 */
535
-	protected function getValue( array $values, $name, $default = null )
535
+	protected function getValue(array $values, $name, $default = null)
536 536
 	{
537
-		if( isset( $values[$name] ) ) {
537
+		if (isset($values[$name])) {
538 538
 			return $values[$name];
539 539
 		}
540 540
 
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Basket/Standard.php 2 patches
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Object storing the required instances for manaing databases
33 33
 	 *  connections, logger, session, etc.
34 34
 	 */
35
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context )
35
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context)
36 36
 	{
37
-		parent::__construct( $context );
37
+		parent::__construct($context);
38 38
 
39
-		$this->domainManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' );
39
+		$this->domainManager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
40 40
 		$this->basket = $this->domainManager->getSession();
41 41
 
42 42
 		$this->checkLocale();
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	public function clear()
50 50
 	{
51 51
 		$this->basket = $this->domainManager->createItem();
52
-		$this->domainManager->setSession( $this->basket );
52
+		$this->domainManager->setSession($this->basket);
53 53
 	}
54 54
 
55 55
 
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function save()
71 71
 	{
72
-		if( $this->basket->isModified() ) {
73
-			$this->domainManager->setSession( $this->basket );
72
+		if ($this->basket->isModified()) {
73
+			$this->domainManager->setSession($this->basket);
74 74
 		}
75 75
 	}
76 76
 
@@ -95,38 +95,38 @@  discard block
 block discarded – undo
95 95
 	 * @param string $stocktype Unique code of the stock type to deliver the products from
96 96
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available
97 97
 	 */
98
-	public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(),
98
+	public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(),
99 99
 		array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(),
100
-		$stocktype = 'default' )
100
+		$stocktype = 'default')
101 101
 	{
102 102
 		$context = $this->getContext();
103
-		$productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
104
-		$productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ) );
103
+		$productManager = \Aimeos\MShop\Factory::createManager($context, 'product');
104
+		$productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'));
105 105
 
106
-		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem();
107
-		$orderBaseProductItem->copyFrom( $productItem );
108
-		$orderBaseProductItem->setQuantity( $quantity );
109
-		$orderBaseProductItem->setStockType( $stocktype );
106
+		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem();
107
+		$orderBaseProductItem->copyFrom($productItem);
108
+		$orderBaseProductItem->setQuantity($quantity);
109
+		$orderBaseProductItem->setStockType($stocktype);
110 110
 
111 111
 		$attr = array();
112
-		$prices = $productItem->getRefItems( 'price', 'default', 'default' );
112
+		$prices = $productItem->getRefItems('price', 'default', 'default');
113 113
 
114
-		$priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' );
115
-		$price = $priceManager->getLowestPrice( $prices, $quantity );
114
+		$priceManager = \Aimeos\MShop\Factory::createManager($context, 'price');
115
+		$price = $priceManager->getLowestPrice($prices, $quantity);
116 116
 
117
-		$attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $configAttributeIds, 'config' ) );
118
-		$attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $hiddenAttributeIds, 'hidden' ) );
119
-		$attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, array_keys( $customAttributeValues ), 'custom', $customAttributeValues ) );
117
+		$attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $configAttributeIds, 'config'));
118
+		$attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $hiddenAttributeIds, 'hidden'));
119
+		$attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, array_keys($customAttributeValues), 'custom', $customAttributeValues));
120 120
 
121 121
 		// remove product rebate of original price in favor to rebates granted for the order
122
-		$price->setRebate( '0.00' );
122
+		$price->setRebate('0.00');
123 123
 
124
-		$orderBaseProductItem->setPrice( $price );
125
-		$orderBaseProductItem->setAttributes( $attr );
124
+		$orderBaseProductItem->setPrice($price);
125
+		$orderBaseProductItem->setAttributes($attr);
126 126
 
127
-		$this->basket->addProduct( $orderBaseProductItem );
127
+		$this->basket->addProduct($orderBaseProductItem);
128 128
 
129
-		$this->domainManager->setSession( $this->basket );
129
+		$this->domainManager->setSession($this->basket);
130 130
 	}
131 131
 
132 132
 
@@ -135,18 +135,18 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param integer $position Position number (key) of the order product item
137 137
 	 */
138
-	public function deleteProduct( $position )
138
+	public function deleteProduct($position)
139 139
 	{
140
-		$product = $this->basket->getProduct( $position );
140
+		$product = $this->basket->getProduct($position);
141 141
 
142
-		if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE )
142
+		if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE)
143 143
 		{
144
-			$msg = sprintf( 'Basket item at position "%1$d" cannot be deleted manually', $position );
145
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
144
+			$msg = sprintf('Basket item at position "%1$d" cannot be deleted manually', $position);
145
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
146 146
 		}
147 147
 
148
-		$this->basket->deleteProduct( $position );
149
-		$this->domainManager->setSession( $this->basket );
148
+		$this->basket->deleteProduct($position);
149
+		$this->domainManager->setSession($this->basket);
150 150
 	}
151 151
 
152 152
 
@@ -159,36 +159,36 @@  discard block
 block discarded – undo
159 159
 	 * 	The 'stock'=>false option allows adding products without being in stock.
160 160
 	 * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED
161 161
 	 */
162
-	public function editProduct( $position, $quantity, array $options = array(),
163
-		array $configAttributeCodes = array() )
162
+	public function editProduct($position, $quantity, array $options = array(),
163
+		array $configAttributeCodes = array())
164 164
 	{
165
-		$product = $this->basket->getProduct( $position );
165
+		$product = $this->basket->getProduct($position);
166 166
 
167
-		if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE )
167
+		if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE)
168 168
 		{
169
-			$msg = sprintf( 'Basket item at position "%1$d" cannot be changed', $position );
170
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
169
+			$msg = sprintf('Basket item at position "%1$d" cannot be changed', $position);
170
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
171 171
 		}
172 172
 
173
-		$product->setQuantity( $quantity );
173
+		$product->setQuantity($quantity);
174 174
 
175 175
 		$attributes = $product->getAttributes();
176
-		foreach( $attributes as $key => $attribute )
176
+		foreach ($attributes as $key => $attribute)
177 177
 		{
178
-			if( in_array( $attribute->getCode(), $configAttributeCodes ) ) {
179
-				unset( $attributes[$key] );
178
+			if (in_array($attribute->getCode(), $configAttributeCodes)) {
179
+				unset($attributes[$key]);
180 180
 			}
181 181
 		}
182
-		$product->setAttributes( $attributes );
182
+		$product->setAttributes($attributes);
183 183
 
184
-		$productItem = $this->getDomainItem( 'product', 'product.code', $product->getProductCode(), array( 'price', 'text' ) );
185
-		$prices = $productItem->getRefItems( 'price', 'default' );
186
-		$product->setPrice( $this->calcPrice( $product, $prices, $quantity ) );
184
+		$productItem = $this->getDomainItem('product', 'product.code', $product->getProductCode(), array('price', 'text'));
185
+		$prices = $productItem->getRefItems('price', 'default');
186
+		$product->setPrice($this->calcPrice($product, $prices, $quantity));
187 187
 
188
-		$this->basket->deleteProduct( $position );
189
-		$this->basket->addProduct( $product, $position );
188
+		$this->basket->deleteProduct($position);
189
+		$this->basket->addProduct($product, $position);
190 190
 
191
-		$this->domainManager->setSession( $this->basket );
191
+		$this->domainManager->setSession($this->basket);
192 192
 	}
193 193
 
194 194
 
@@ -198,50 +198,50 @@  discard block
 block discarded – undo
198 198
 	 * @param string $code Coupon code entered by the user
199 199
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed
200 200
 	 */
201
-	public function addCoupon( $code )
201
+	public function addCoupon($code)
202 202
 	{
203
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' );
204
-		$codeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' );
203
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon');
204
+		$codeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code');
205 205
 
206 206
 
207
-		$search = $codeManager->createSearch( true );
207
+		$search = $codeManager->createSearch(true);
208 208
 		$expr = array(
209
-			$search->compare( '==', 'coupon.code.code', $code ),
209
+			$search->compare('==', 'coupon.code.code', $code),
210 210
 			$search->getConditions(),
211 211
 		);
212
-		$search->setConditions( $search->combine( '&&', $expr ) );
213
-		$search->setSlice( 0, 1 );
212
+		$search->setConditions($search->combine('&&', $expr));
213
+		$search->setSlice(0, 1);
214 214
 
215
-		$result = $codeManager->searchItems( $search );
215
+		$result = $codeManager->searchItems($search);
216 216
 
217
-		if( ( $codeItem = reset( $result ) ) === false ) {
218
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid or not available any more', $code ) );
217
+		if (($codeItem = reset($result)) === false) {
218
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid or not available any more', $code));
219 219
 		}
220 220
 
221 221
 
222
-		$search = $manager->createSearch( true );
222
+		$search = $manager->createSearch(true);
223 223
 		$expr = array(
224
-			$search->compare( '==', 'coupon.id', $codeItem->getParentId() ),
224
+			$search->compare('==', 'coupon.id', $codeItem->getParentId()),
225 225
 			$search->getConditions(),
226 226
 		);
227
-		$search->setConditions( $search->combine( '&&', $expr ) );
228
-		$search->setSlice( 0, 1 );
227
+		$search->setConditions($search->combine('&&', $expr));
228
+		$search->setSlice(0, 1);
229 229
 
230
-		$result = $manager->searchItems( $search );
230
+		$result = $manager->searchItems($search);
231 231
 
232
-		if( ( $item = reset( $result ) ) === false ) {
233
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon for code "%1$s" is not available any more', $code ) );
232
+		if (($item = reset($result)) === false) {
233
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon for code "%1$s" is not available any more', $code));
234 234
 		}
235 235
 
236 236
 
237
-		$provider = $manager->getProvider( $item, $code );
237
+		$provider = $manager->getProvider($item, $code);
238 238
 
239
-		if( $provider->isAvailable( $this->basket ) !== true ) {
240
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Requirements for coupon code "%1$s" aren\'t met', $code ) );
239
+		if ($provider->isAvailable($this->basket) !== true) {
240
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Requirements for coupon code "%1$s" aren\'t met', $code));
241 241
 		}
242 242
 
243
-		$provider->addCoupon( $this->basket );
244
-		$this->domainManager->setSession( $this->basket );
243
+		$provider->addCoupon($this->basket);
244
+		$this->domainManager->setSession($this->basket);
245 245
 	}
246 246
 
247 247
 
@@ -251,22 +251,22 @@  discard block
 block discarded – undo
251 251
 	 * @param string $code Coupon code entered by the user
252 252
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid
253 253
 	 */
254
-	public function deleteCoupon( $code )
254
+	public function deleteCoupon($code)
255 255
 	{
256
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' );
256
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon');
257 257
 
258 258
 		$search = $manager->createSearch();
259
-		$search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) );
260
-		$search->setSlice( 0, 1 );
259
+		$search->setConditions($search->compare('==', 'coupon.code.code', $code));
260
+		$search->setSlice(0, 1);
261 261
 
262
-		$result = $manager->searchItems( $search );
262
+		$result = $manager->searchItems($search);
263 263
 
264
-		if( ( $item = reset( $result ) ) === false ) {
265
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid', $code ) );
264
+		if (($item = reset($result)) === false) {
265
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid', $code));
266 266
 		}
267 267
 
268
-		$manager->getProvider( $item, $code )->deleteCoupon( $this->basket );
269
-		$this->domainManager->setSession( $this->basket );
268
+		$manager->getProvider($item, $code)->deleteCoupon($this->basket);
269
+		$this->domainManager->setSession($this->basket);
270 270
 	}
271 271
 
272 272
 
@@ -278,31 +278,31 @@  discard block
 block discarded – undo
278 278
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of
279 279
 	 * 	if one of the keys is invalid when using an array with key/value pairs
280 280
 	 */
281
-	public function setAddress( $type, $value )
281
+	public function setAddress($type, $value)
282 282
 	{
283
-		$address = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/address' )->createItem();
284
-		$address->setType( $type );
283
+		$address = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/address')->createItem();
284
+		$address->setType($type);
285 285
 
286
-		if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface )
286
+		if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface)
287 287
 		{
288
-			$address->copyFrom( $value );
289
-			$this->basket->setAddress( $address, $type );
288
+			$address->copyFrom($value);
289
+			$this->basket->setAddress($address, $type);
290 290
 		}
291
-		else if( is_array( $value ) )
291
+		else if (is_array($value))
292 292
 		{
293
-			$this->setAddressFromArray( $address, $value );
294
-			$this->basket->setAddress( $address, $type );
293
+			$this->setAddressFromArray($address, $value);
294
+			$this->basket->setAddress($address, $type);
295 295
 		}
296
-		else if( $value === null )
296
+		else if ($value === null)
297 297
 		{
298
-			$this->basket->deleteAddress( $type );
298
+			$this->basket->deleteAddress($type);
299 299
 		}
300 300
 		else
301 301
 		{
302
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) );
302
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid value for address type "%1$s"', $type));
303 303
 		}
304 304
 
305
-		$this->domainManager->setSession( $this->basket );
305
+		$this->domainManager->setSession($this->basket);
306 306
 	}
307 307
 
308 308
 
@@ -315,43 +315,43 @@  discard block
 block discarded – undo
315 315
 	 * 	entered by the customer when choosing one of the delivery or payment options
316 316
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached
317 317
 	 */
318
-	public function setService( $type, $id, array $attributes = array() )
318
+	public function setService($type, $id, array $attributes = array())
319 319
 	{
320 320
 		$context = $this->getContext();
321 321
 
322
-		$serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' );
323
-		$serviceItem = $this->getDomainItem( 'service', 'service.id', $id, array( 'media', 'price', 'text' ) );
322
+		$serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service');
323
+		$serviceItem = $this->getDomainItem('service', 'service.id', $id, array('media', 'price', 'text'));
324 324
 
325
-		$provider = $serviceManager->getProvider( $serviceItem );
326
-		$result = $provider->checkConfigFE( $attributes );
327
-		$unknown = array_diff_key( $attributes, $result );
325
+		$provider = $serviceManager->getProvider($serviceItem);
326
+		$result = $provider->checkConfigFE($attributes);
327
+		$unknown = array_diff_key($attributes, $result);
328 328
 
329
-		if( count( $unknown ) > 0 )
329
+		if (count($unknown) > 0)
330 330
 		{
331
-			$msg = sprintf( 'Unknown attributes "%1$s"', implode( '","', array_keys( $unknown ) ) );
332
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
331
+			$msg = sprintf('Unknown attributes "%1$s"', implode('","', array_keys($unknown)));
332
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
333 333
 		}
334 334
 
335
-		foreach( $result as $key => $value )
335
+		foreach ($result as $key => $value)
336 336
 		{
337
-			if( $value !== null ) {
338
-				throw new \Aimeos\Controller\Frontend\Basket\Exception( $value );
337
+			if ($value !== null) {
338
+				throw new \Aimeos\Controller\Frontend\Basket\Exception($value);
339 339
 			}
340 340
 		}
341 341
 
342
-		$orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' );
342
+		$orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service');
343 343
 		$orderServiceItem = $orderBaseServiceManager->createItem();
344
-		$orderServiceItem->copyFrom( $serviceItem );
344
+		$orderServiceItem->copyFrom($serviceItem);
345 345
 
346
-		$price = $provider->calcPrice( $this->basket );
346
+		$price = $provider->calcPrice($this->basket);
347 347
 		// remove service rebate of original price
348
-		$price->setRebate( '0.00' );
349
-		$orderServiceItem->setPrice( $price );
348
+		$price->setRebate('0.00');
349
+		$orderServiceItem->setPrice($price);
350 350
 
351
-		$provider->setConfigFE( $orderServiceItem, $attributes );
351
+		$provider->setConfigFE($orderServiceItem, $attributes);
352 352
 
353
-		$this->basket->setService( $orderServiceItem, $type );
354
-		$this->domainManager->setSession( $this->basket );
353
+		$this->basket->setService($orderServiceItem, $type);
354
+		$this->domainManager->setSession($this->basket);
355 355
 	}
356 356
 
357 357
 
@@ -363,18 +363,18 @@  discard block
 block discarded – undo
363 363
 	 * 	an address item.
364 364
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception
365 365
 	 */
366
-	protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map )
366
+	protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map)
367 367
 	{
368
-		foreach( $map as $key => $value ) {
369
-			$map[$key] = strip_tags( $value ); // prevent XSS
368
+		foreach ($map as $key => $value) {
369
+			$map[$key] = strip_tags($value); // prevent XSS
370 370
 		}
371 371
 
372
-		$errors = $address->fromArray( $map );
372
+		$errors = $address->fromArray($map);
373 373
 
374
-		if( count( $errors ) > 0 )
374
+		if (count($errors) > 0)
375 375
 		{
376
-			$msg = sprintf( 'Invalid address properties, please check your input' );
377
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors );
376
+			$msg = sprintf('Invalid address properties, please check your input');
377
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors);
378 378
 		}
379 379
 	}
380 380
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -287,17 +287,14 @@
 block discarded – undo
287 287
 		{
288 288
 			$address->copyFrom( $value );
289 289
 			$this->basket->setAddress( $address, $type );
290
-		}
291
-		else if( is_array( $value ) )
290
+		} else if( is_array( $value ) )
292 291
 		{
293 292
 			$this->setAddressFromArray( $address, $value );
294 293
 			$this->basket->setAddress( $address, $type );
295
-		}
296
-		else if( $value === null )
294
+		} else if( $value === null )
297 295
 		{
298 296
 			$this->basket->deleteAddress( $type );
299
-		}
300
-		else
297
+		} else
301 298
 		{
302 299
 			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) );
303 300
 		}
Please login to merge, or discard this patch.