Completed
Push — master ( 7e7dfb...1f41d8 )
by Aimeos
01:49
created
controller/frontend/tests/Controller/Frontend/Basket/StandardTest.php 1 patch
Spacing   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -19,112 +19,112 @@  discard block
 block discarded – undo
19 19
 	public static function setUpBeforeClass()
20 20
 	{
21 21
 		$context = \TestHelperFrontend::getContext();
22
-		self::$testItem = \Aimeos\MShop\Factory::createManager( $context, 'product' )->findItem( 'U:TESTP' );
22
+		self::$testItem = \Aimeos\MShop\Factory::createManager($context, 'product')->findItem('U:TESTP');
23 23
 	}
24 24
 
25 25
 
26 26
 	protected function setUp()
27 27
 	{
28
-		\Aimeos\MShop\Factory::setCache( true );
28
+		\Aimeos\MShop\Factory::setCache(true);
29 29
 
30 30
 		$this->context = \TestHelperFrontend::getContext();
31
-		$this->object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
31
+		$this->object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context);
32 32
 	}
33 33
 
34 34
 
35 35
 	protected function tearDown()
36 36
 	{
37
-		\Aimeos\MShop\Factory::setCache( false );
37
+		\Aimeos\MShop\Factory::setCache(false);
38 38
 		\Aimeos\MShop\Factory::clear();
39 39
 
40 40
 		$this->object->clear();
41
-		$this->context->getSession()->set( 'aimeos', [] );
41
+		$this->context->getSession()->set('aimeos', []);
42 42
 
43
-		unset( $this->context, $this->object );
43
+		unset($this->context, $this->object);
44 44
 	}
45 45
 
46 46
 
47 47
 	public function testClear()
48 48
 	{
49
-		$this->object->addProduct( self::$testItem->getId(), 2 );
49
+		$this->object->addProduct(self::$testItem->getId(), 2);
50 50
 		$this->object->clear();
51 51
 
52
-		$this->assertEquals( 0, count( $this->object->get()->getProducts() ) );
52
+		$this->assertEquals(0, count($this->object->get()->getProducts()));
53 53
 	}
54 54
 
55 55
 
56 56
 	public function testGet()
57 57
 	{
58
-		$this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get() );
58
+		$this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get());
59 59
 	}
60 60
 
61 61
 
62 62
 	public function testSave()
63 63
 	{
64
-		$stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' )
65
-			->setConstructorArgs( [$this->context] )
66
-			->setMethods( ['setSession'] )
64
+		$stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard')
65
+			->setConstructorArgs([$this->context])
66
+			->setMethods(['setSession'])
67 67
 			->getMock();
68 68
 
69
-		\Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub );
69
+		\Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub);
70 70
 
71
-		$stub->expects( $this->exactly( 2 ) )->method( 'setSession' );
71
+		$stub->expects($this->exactly(2))->method('setSession');
72 72
 
73
-		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
74
-		$object->addProduct( self::$testItem->getId(), 2 );
73
+		$object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context);
74
+		$object->addProduct(self::$testItem->getId(), 2);
75 75
 		$object->save();
76 76
 	}
77 77
 
78 78
 
79 79
 	public function testSetType()
80 80
 	{
81
-		$this->assertInstanceOf( '\Aimeos\Controller\Frontend\Basket\Iface', $this->object->setType( 'test' ) );
81
+		$this->assertInstanceOf('\Aimeos\Controller\Frontend\Basket\Iface', $this->object->setType('test'));
82 82
 	}
83 83
 
84 84
 
85 85
 	public function testStore()
86 86
 	{
87
-		$stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' )
88
-			->setConstructorArgs( [$this->context] )
89
-			->setMethods( ['store'] )
87
+		$stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard')
88
+			->setConstructorArgs([$this->context])
89
+			->setMethods(['store'])
90 90
 			->getMock();
91 91
 
92
-		\Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub );
92
+		\Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub);
93 93
 
94
-		$stub->expects( $this->once() )->method( 'store' );
94
+		$stub->expects($this->once())->method('store');
95 95
 
96
-		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
96
+		$object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context);
97 97
 		$object->store();
98 98
 	}
99 99
 
100 100
 
101 101
 	public function testStoreLimit()
102 102
 	{
103
-		$this->context->setEditor( 'core:unittest' );
103
+		$this->context->setEditor('core:unittest');
104 104
 		$config = $this->context->getConfig();
105
-		$config->set( 'controller/frontend/basket/limit-count', 0 );
106
-		$config->set( 'controller/frontend/basket/limit-seconds', 86400 * 365 );
105
+		$config->set('controller/frontend/basket/limit-count', 0);
106
+		$config->set('controller/frontend/basket/limit-seconds', 86400 * 365);
107 107
 
108
-		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
108
+		$object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context);
109 109
 
110
-		$this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' );
110
+		$this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception');
111 111
 		$object->store();
112 112
 	}
113 113
 
114 114
 
115 115
 	public function testLoad()
116 116
 	{
117
-		$stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' )
118
-			->setConstructorArgs( [$this->context] )
119
-			->setMethods( ['load'] )
117
+		$stub = $this->getMockBuilder('\Aimeos\MShop\Order\Manager\Base\Standard')
118
+			->setConstructorArgs([$this->context])
119
+			->setMethods(['load'])
120 120
 			->getMock();
121 121
 
122
-		\Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub );
122
+		\Aimeos\MShop\Factory::injectManager($this->context, 'order/base', $stub);
123 123
 
124
-		$stub->expects( $this->once() )->method( 'load' )
125
-			->will( $this->returnValue( $stub->createItem() ) );
124
+		$stub->expects($this->once())->method('load')
125
+			->will($this->returnValue($stub->createItem()));
126 126
 
127
-		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
127
+		$object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context);
128 128
 		$object->load( -1 );
129 129
 	}
130 130
 
@@ -132,338 +132,338 @@  discard block
 block discarded – undo
132 132
 	public function testAddDeleteProduct()
133 133
 	{
134 134
 		$basket = $this->object->get();
135
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' );
135
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC');
136 136
 
137
-		$this->object->addProduct( $item->getId(), 2, 'default', [], [], [], [] );
138
-		$item2 = $this->object->get()->getProduct( 0 );
139
-		$this->object->deleteProduct( 0 );
137
+		$this->object->addProduct($item->getId(), 2, 'default', [], [], [], []);
138
+		$item2 = $this->object->get()->getProduct(0);
139
+		$this->object->deleteProduct(0);
140 140
 
141
-		$this->assertEquals( 0, count( $basket->getProducts() ) );
142
-		$this->assertEquals( 'CNC', $item2->getProductCode() );
141
+		$this->assertEquals(0, count($basket->getProducts()));
142
+		$this->assertEquals('CNC', $item2->getProductCode());
143 143
 	}
144 144
 
145 145
 
146 146
 	public function testAddProductCustomAttribute()
147 147
 	{
148
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
148
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
149 149
 
150 150
 		$search = $attributeManager->createSearch();
151 151
 		$expr = array(
152
-			$search->compare( '==', 'attribute.code', 'custom' ),
153
-			$search->compare( '==', 'attribute.type.code', 'date' ),
152
+			$search->compare('==', 'attribute.code', 'custom'),
153
+			$search->compare('==', 'attribute.type.code', 'date'),
154 154
 		);
155
-		$search->setConditions( $search->combine( '&&', $expr ) );
155
+		$search->setConditions($search->combine('&&', $expr));
156 156
 
157
-		$attributes = $attributeManager->searchItems( $search );
157
+		$attributes = $attributeManager->searchItems($search);
158 158
 
159
-		if( ( $attrItem = reset( $attributes ) ) === false ) {
160
-			throw new \RuntimeException( 'Attribute not found' );
159
+		if (($attrItem = reset($attributes)) === false) {
160
+			throw new \RuntimeException('Attribute not found');
161 161
 		}
162 162
 
163
-		$attrValues = array( $attrItem->getId() => '2000-01-01' );
163
+		$attrValues = array($attrItem->getId() => '2000-01-01');
164 164
 
165
-		$this->object->addProduct( self::$testItem->getId(), 1, 'default', [], [], [], $attrValues );
165
+		$this->object->addProduct(self::$testItem->getId(), 1, 'default', [], [], [], $attrValues);
166 166
 		$basket = $this->object->get();
167 167
 
168
-		$this->assertEquals( 1, count( $basket->getProducts() ) );
169
-		$this->assertEquals( '2000-01-01', $basket->getProduct( 0 )->getAttribute( 'date', 'custom' ) );
168
+		$this->assertEquals(1, count($basket->getProducts()));
169
+		$this->assertEquals('2000-01-01', $basket->getProduct(0)->getAttribute('date', 'custom'));
170 170
 	}
171 171
 
172 172
 
173 173
 	public function testAddProductCustomPrice()
174 174
 	{
175
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
175
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
176 176
 
177 177
 		$search = $attributeManager->createSearch();
178 178
 		$expr = array(
179
-			$search->compare( '==', 'attribute.code', 'custom' ),
180
-			$search->compare( '==', 'attribute.type.code', 'price' ),
179
+			$search->compare('==', 'attribute.code', 'custom'),
180
+			$search->compare('==', 'attribute.type.code', 'price'),
181 181
 		);
182
-		$search->setConditions( $search->combine( '&&', $expr ) );
182
+		$search->setConditions($search->combine('&&', $expr));
183 183
 
184
-		$attributes = $attributeManager->searchItems( $search );
184
+		$attributes = $attributeManager->searchItems($search);
185 185
 
186
-		if( ( $attrItem = reset( $attributes ) ) === false ) {
187
-			throw new \RuntimeException( 'Attribute not found' );
186
+		if (($attrItem = reset($attributes)) === false) {
187
+			throw new \RuntimeException('Attribute not found');
188 188
 		}
189 189
 
190
-		$attrValues = array( $attrItem->getId() => '0.01' );
190
+		$attrValues = array($attrItem->getId() => '0.01');
191 191
 
192
-		$this->object->addProduct( self::$testItem->getId(), 1, 'default', [], [], [], $attrValues );
192
+		$this->object->addProduct(self::$testItem->getId(), 1, 'default', [], [], [], $attrValues);
193 193
 		$basket = $this->object->get();
194 194
 
195
-		$this->assertEquals( 1, count( $basket->getProducts() ) );
196
-		$this->assertEquals( '0.01', $basket->getProduct( 0 )->getPrice()->getValue() );
195
+		$this->assertEquals(1, count($basket->getProducts()));
196
+		$this->assertEquals('0.01', $basket->getProduct(0)->getPrice()->getValue());
197 197
 	}
198 198
 
199 199
 
200 200
 	public function testAddProductCustomPriceException()
201 201
 	{
202
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
202
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
203 203
 
204 204
 		$search = $attributeManager->createSearch();
205 205
 		$expr = array(
206
-			$search->compare( '==', 'attribute.code', 'custom' ),
207
-			$search->compare( '==', 'attribute.type.code', 'price' ),
206
+			$search->compare('==', 'attribute.code', 'custom'),
207
+			$search->compare('==', 'attribute.type.code', 'price'),
208 208
 		);
209
-		$search->setConditions( $search->combine( '&&', $expr ) );
209
+		$search->setConditions($search->combine('&&', $expr));
210 210
 
211
-		$attributes = $attributeManager->searchItems( $search );
211
+		$attributes = $attributeManager->searchItems($search);
212 212
 
213
-		if( ( $attrItem = reset( $attributes ) ) === false ) {
214
-			throw new \RuntimeException( 'Attribute not found' );
213
+		if (($attrItem = reset($attributes)) === false) {
214
+			throw new \RuntimeException('Attribute not found');
215 215
 		}
216 216
 
217
-		$attrValues = array( $attrItem->getId() => ',' );
217
+		$attrValues = array($attrItem->getId() => ',');
218 218
 
219
-		$this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' );
220
-		$this->object->addProduct( self::$testItem->getId(), 1, 'default', [], [], [], $attrValues );
219
+		$this->setExpectedException('\Aimeos\Controller\Frontend\Basket\Exception');
220
+		$this->object->addProduct(self::$testItem->getId(), 1, 'default', [], [], [], $attrValues);
221 221
 	}
222 222
 
223 223
 
224 224
 	public function testAddProductAttributePrice()
225 225
 	{
226
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
226
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
227 227
 
228 228
 		$search = $attributeManager->createSearch();
229 229
 		$expr = array(
230
-			$search->compare( '==', 'attribute.code', 'xs' ),
231
-			$search->compare( '==', 'attribute.type.code', 'size' ),
230
+			$search->compare('==', 'attribute.code', 'xs'),
231
+			$search->compare('==', 'attribute.type.code', 'size'),
232 232
 		);
233
-		$search->setConditions( $search->combine( '&&', $expr ) );
233
+		$search->setConditions($search->combine('&&', $expr));
234 234
 
235
-		$attributes = $attributeManager->searchItems( $search );
235
+		$attributes = $attributeManager->searchItems($search);
236 236
 
237
-		if( ( $attribute = reset( $attributes ) ) === false ) {
238
-			throw new \RuntimeException( 'Attribute not found' );
237
+		if (($attribute = reset($attributes)) === false) {
238
+			throw new \RuntimeException('Attribute not found');
239 239
 		}
240 240
 
241
-		$this->object->addProduct( self::$testItem->getId(), 1, 'default', [], [$attribute->getId() => 2] );
241
+		$this->object->addProduct(self::$testItem->getId(), 1, 'default', [], [$attribute->getId() => 2]);
242 242
 
243
-		$this->assertEquals( '43.90', $this->object->get()->getPrice()->getValue() );
243
+		$this->assertEquals('43.90', $this->object->get()->getPrice()->getValue());
244 244
 	}
245 245
 
246 246
 
247 247
 	public function testAddProductAttributeNotAssigned()
248 248
 	{
249
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
249
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
250 250
 
251 251
 		$search = $attributeManager->createSearch();
252 252
 		$expr = array(
253
-			$search->compare( '==', 'attribute.code', '30' ),
254
-			$search->compare( '==', 'attribute.type.code', 'width' ),
253
+			$search->compare('==', 'attribute.code', '30'),
254
+			$search->compare('==', 'attribute.type.code', 'width'),
255 255
 		);
256
-		$search->setConditions( $search->combine( '&&', $expr ) );
256
+		$search->setConditions($search->combine('&&', $expr));
257 257
 
258
-		$attribute = $attributeManager->searchItems( $search );
258
+		$attribute = $attributeManager->searchItems($search);
259 259
 
260
-		if( empty( $attribute ) ) {
261
-			throw new \RuntimeException( 'Attribute not found' );
260
+		if (empty($attribute)) {
261
+			throw new \RuntimeException('Attribute not found');
262 262
 		}
263 263
 
264
-		$hiddenAttrIds = array_keys( $attribute );
265
-		$configAttrIds = array_keys( $attribute );
264
+		$hiddenAttrIds = array_keys($attribute);
265
+		$configAttrIds = array_keys($attribute);
266 266
 
267
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
268
-		$this->object->addProduct( self::$testItem->getId(), 1, 'default', [], $configAttrIds, $hiddenAttrIds );
267
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
268
+		$this->object->addProduct(self::$testItem->getId(), 1, 'default', [], $configAttrIds, $hiddenAttrIds);
269 269
 	}
270 270
 
271 271
 
272 272
 	public function testAddProductNegativeQuantityException()
273 273
 	{
274
-		$this->setExpectedException( '\\Aimeos\\MShop\\Order\\Exception' );
275
-		$this->object->addProduct( self::$testItem->getId(), -1 );
274
+		$this->setExpectedException('\\Aimeos\\MShop\\Order\\Exception');
275
+		$this->object->addProduct(self::$testItem->getId(), -1);
276 276
 	}
277 277
 
278 278
 
279 279
 	public function testAddProductNoPriceException()
280 280
 	{
281
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'MNOP' );
281
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('MNOP');
282 282
 
283
-		$this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' );
284
-		$this->object->addProduct( $item->getId(), 1 );
283
+		$this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception');
284
+		$this->object->addProduct($item->getId(), 1);
285 285
 	}
286 286
 
287 287
 
288 288
 	public function testAddProductConfigAttributeException()
289 289
 	{
290
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
291
-		$this->object->addProduct( self::$testItem->getId(), 1, 'default', [], array( -1 ) );
290
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
291
+		$this->object->addProduct(self::$testItem->getId(), 1, 'default', [], array( -1 ));
292 292
 	}
293 293
 
294 294
 
295 295
 	public function testAddProductLowQuantityPriceException()
296 296
 	{
297
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' );
297
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL');
298 298
 
299
-		$this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' );
300
-		$this->object->addProduct( $item->getId(), 1 );
299
+		$this->setExpectedException('\\Aimeos\\MShop\\Price\\Exception');
300
+		$this->object->addProduct($item->getId(), 1);
301 301
 	}
302 302
 
303 303
 
304 304
 	public function testAddProductHigherQuantities()
305 305
 	{
306
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' );
306
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('IJKL');
307 307
 
308
-		$this->object->addProduct( $item->getId(), 2, 'default', [], [], [], [], 'unit_type3' );
308
+		$this->object->addProduct($item->getId(), 2, 'default', [], [], [], [], 'unit_type3');
309 309
 
310
-		$this->assertEquals( 2, $this->object->get()->getProduct( 0 )->getQuantity() );
311
-		$this->assertEquals( 'IJKL', $this->object->get()->getProduct( 0 )->getProductCode() );
310
+		$this->assertEquals(2, $this->object->get()->getProduct(0)->getQuantity());
311
+		$this->assertEquals('IJKL', $this->object->get()->getProduct(0)->getProductCode());
312 312
 	}
313 313
 
314 314
 
315 315
 	public function testDeleteProductFlagError()
316 316
 	{
317
-		$this->object->addProduct( self::$testItem->getId(), 2 );
317
+		$this->object->addProduct(self::$testItem->getId(), 2);
318 318
 
319
-		$item = $this->object->get()->getProduct( 0 );
320
-		$item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE );
319
+		$item = $this->object->get()->getProduct(0);
320
+		$item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE);
321 321
 
322
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
323
-		$this->object->deleteProduct( 0 );
322
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
323
+		$this->object->deleteProduct(0);
324 324
 	}
325 325
 
326 326
 
327 327
 	public function testEditProduct()
328 328
 	{
329
-		$this->object->addProduct( self::$testItem->getId(), 1 );
329
+		$this->object->addProduct(self::$testItem->getId(), 1);
330 330
 
331
-		$item = $this->object->get()->getProduct( 0 );
332
-		$this->assertEquals( 1, $item->getQuantity() );
331
+		$item = $this->object->get()->getProduct(0);
332
+		$this->assertEquals(1, $item->getQuantity());
333 333
 
334
-		$this->object->editProduct( 0, 4 );
334
+		$this->object->editProduct(0, 4);
335 335
 
336
-		$item = $this->object->get()->getProduct( 0 );
337
-		$this->assertEquals( 4, $item->getQuantity() );
338
-		$this->assertEquals( 'U:TESTP', $item->getProductCode() );
336
+		$item = $this->object->get()->getProduct(0);
337
+		$this->assertEquals(4, $item->getQuantity());
338
+		$this->assertEquals('U:TESTP', $item->getProductCode());
339 339
 	}
340 340
 
341 341
 
342 342
 	public function testEditProductAttributes()
343 343
 	{
344 344
 		$configAttrIds = [];
345
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
345
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->context, 'attribute');
346 346
 
347 347
 		$search = $attributeManager->createSearch();
348 348
 		$conditions = array(
349
-			$search->compare( '==', 'attribute.domain', 'product' ),
350
-			$search->combine( '||', array(
351
-				$search->combine( '&&', array(
352
-					$search->compare( '==', 'attribute.code', 'xs' ),
353
-					$search->compare( '==', 'attribute.type.code', 'size' ),
354
-				) ),
355
-				$search->combine( '&&', array(
356
-					$search->compare( '==', 'attribute.code', 'white' ),
357
-					$search->compare( '==', 'attribute.type.code', 'color' ),
358
-				) ),
359
-			) )
349
+			$search->compare('==', 'attribute.domain', 'product'),
350
+			$search->combine('||', array(
351
+				$search->combine('&&', array(
352
+					$search->compare('==', 'attribute.code', 'xs'),
353
+					$search->compare('==', 'attribute.type.code', 'size'),
354
+				)),
355
+				$search->combine('&&', array(
356
+					$search->compare('==', 'attribute.code', 'white'),
357
+					$search->compare('==', 'attribute.type.code', 'color'),
358
+				)),
359
+			))
360 360
 		);
361
-		$search->setConditions( $search->combine( '&&', $conditions ) );
362
-		$attributes = $attributeManager->searchItems( $search );
361
+		$search->setConditions($search->combine('&&', $conditions));
362
+		$attributes = $attributeManager->searchItems($search);
363 363
 
364
-		if( empty( $attributes ) ) {
365
-			throw new \RuntimeException( 'No attributes available' );
364
+		if (empty($attributes)) {
365
+			throw new \RuntimeException('No attributes available');
366 366
 		}
367 367
 
368
-		foreach( $attributes as $id => $attribute ) {
368
+		foreach ($attributes as $id => $attribute) {
369 369
 			$configAttrIds[$id] = 1;
370 370
 		}
371 371
 
372
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' );
372
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('U:TESTP');
373 373
 
374
-		$this->object->addProduct( $item->getId(), 1, 'default', [], $configAttrIds );
375
-		$this->object->editProduct( 0, 4 );
374
+		$this->object->addProduct($item->getId(), 1, 'default', [], $configAttrIds);
375
+		$this->object->editProduct(0, 4);
376 376
 
377
-		$item = $this->object->get()->getProduct( 0 );
378
-		$this->assertEquals( 3, count( $item->getAttributes() ) );
379
-		$this->assertEquals( 4, $item->getQuantity() );
377
+		$item = $this->object->get()->getProduct(0);
378
+		$this->assertEquals(3, count($item->getAttributes()));
379
+		$this->assertEquals(4, $item->getQuantity());
380 380
 
381 381
 
382
-		$this->object->editProduct( 0, 3, array( reset( $attributes )->getType() ) );
382
+		$this->object->editProduct(0, 3, array(reset($attributes)->getType()));
383 383
 
384
-		$item = $this->object->get()->getProduct( 0 );
385
-		$this->assertEquals( 3, $item->getQuantity() );
386
-		$this->assertEquals( 2, count( $item->getAttributes() ) );
387
-		$this->assertEquals( 'U:TESTP', $item->getProductCode() );
384
+		$item = $this->object->get()->getProduct(0);
385
+		$this->assertEquals(3, $item->getQuantity());
386
+		$this->assertEquals(2, count($item->getAttributes()));
387
+		$this->assertEquals('U:TESTP', $item->getProductCode());
388 388
 	}
389 389
 
390 390
 
391 391
 	public function testEditProductFlagError()
392 392
 	{
393
-		$this->object->addProduct( self::$testItem->getId(), 2 );
393
+		$this->object->addProduct(self::$testItem->getId(), 2);
394 394
 
395
-		$item = $this->object->get()->getProduct( 0 );
396
-		$item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE );
395
+		$item = $this->object->get()->getProduct(0);
396
+		$item->setFlags(\Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE);
397 397
 
398
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
399
-		$this->object->editProduct( 0, 4 );
398
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
399
+		$this->object->editProduct(0, 4);
400 400
 	}
401 401
 
402 402
 
403 403
 	public function testAddCoupon()
404 404
 	{
405
-		$this->object->addProduct( self::$testItem->getId(), 2 );
406
-		$this->object->addCoupon( 'GHIJ' );
405
+		$this->object->addProduct(self::$testItem->getId(), 2);
406
+		$this->object->addCoupon('GHIJ');
407 407
 
408 408
 		$basket = $this->object->get();
409 409
 
410
-		$this->assertEquals( 1, count( $basket->getCoupons() ) );
410
+		$this->assertEquals(1, count($basket->getCoupons()));
411 411
 	}
412 412
 
413 413
 
414 414
 	public function testAddCouponExceedCount()
415 415
 	{
416
-		$this->object->addProduct( self::$testItem->getId(), 2 );
417
-		$this->object->addCoupon( 'GHIJ' );
416
+		$this->object->addProduct(self::$testItem->getId(), 2);
417
+		$this->object->addCoupon('GHIJ');
418 418
 
419
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
420
-		$this->object->addCoupon( 'GHIJ' );
419
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
420
+		$this->object->addCoupon('GHIJ');
421 421
 	}
422 422
 
423 423
 
424 424
 	public function testAddCouponInvalidCode()
425 425
 	{
426
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
427
-		$this->object->addCoupon( 'invalid' );
426
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
427
+		$this->object->addCoupon('invalid');
428 428
 	}
429 429
 
430 430
 
431 431
 	public function testAddCouponMissingRequirements()
432 432
 	{
433
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
434
-		$this->object->addCoupon( 'OPQR' );
433
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
434
+		$this->object->addCoupon('OPQR');
435 435
 	}
436 436
 
437 437
 
438 438
 	public function testDeleteCoupon()
439 439
 	{
440
-		$this->object->addProduct( self::$testItem->getId(), 2 );
441
-		$this->object->addCoupon( '90AB' );
442
-		$this->object->deleteCoupon( '90AB' );
440
+		$this->object->addProduct(self::$testItem->getId(), 2);
441
+		$this->object->addCoupon('90AB');
442
+		$this->object->deleteCoupon('90AB');
443 443
 
444 444
 		$basket = $this->object->get();
445 445
 
446
-		$this->assertEquals( 0, count( $basket->getCoupons() ) );
446
+		$this->assertEquals(0, count($basket->getCoupons()));
447 447
 	}
448 448
 
449 449
 
450 450
 	public function testSetAddressDelete()
451 451
 	{
452
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null );
452
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null);
453 453
 
454
-		$this->setExpectedException( '\Aimeos\MShop\Order\Exception' );
455
-		$this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
454
+		$this->setExpectedException('\Aimeos\MShop\Order\Exception');
455
+		$this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT);
456 456
 	}
457 457
 
458 458
 
459 459
 	public function testSetBillingAddressByItem()
460 460
 	{
461
-		$item = $this->getAddress( 'Example company' );
461
+		$item = $this->getAddress('Example company');
462 462
 
463
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item );
463
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item);
464 464
 
465
-		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
466
-		$this->assertEquals( 'Example company', $address->getCompany() );
465
+		$address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT);
466
+		$this->assertEquals('Example company', $address->getCompany());
467 467
 	}
468 468
 
469 469
 
@@ -491,37 +491,37 @@  discard block
 block discarded – undo
491 491
 			'order.base.address.flag' => 0,
492 492
 		);
493 493
 
494
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture );
494
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture);
495 495
 
496
-		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
497
-		$this->assertEquals( 'Example company', $address->getCompany() );
498
-		$this->assertEquals( 'Dr.', $address->getTitle() );
499
-		$this->assertEquals( 'firstunit', $address->getFirstname() );
496
+		$address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT);
497
+		$this->assertEquals('Example company', $address->getCompany());
498
+		$this->assertEquals('Dr.', $address->getTitle());
499
+		$this->assertEquals('firstunit', $address->getFirstname());
500 500
 	}
501 501
 
502 502
 
503 503
 	public function testSetBillingAddressByArrayError()
504 504
 	{
505
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
506
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array( 'error' => false ) );
505
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
506
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array('error' => false));
507 507
 	}
508 508
 
509 509
 
510 510
 	public function testSetBillingAddressParameterError()
511 511
 	{
512
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
513
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error' );
512
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
513
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error');
514 514
 	}
515 515
 
516 516
 
517 517
 	public function testSetDeliveryAddressByItem()
518 518
 	{
519
-		$item = $this->getAddress( 'Example company' );
519
+		$item = $this->getAddress('Example company');
520 520
 
521
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item );
521
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item);
522 522
 
523
-		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY );
524
-		$this->assertEquals( 'Example company', $address->getCompany() );
523
+		$address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY);
524
+		$this->assertEquals('Example company', $address->getCompany());
525 525
 	}
526 526
 
527 527
 
@@ -548,121 +548,121 @@  discard block
 block discarded – undo
548 548
 			'order.base.address.website' => 'www.example.com',
549 549
 			'order.base.address.flag' => 0,
550 550
 		);
551
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture );
551
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture);
552 552
 
553
-		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY );
554
-		$this->assertEquals( 'Example company', $address->getCompany() );
555
-		$this->assertEquals( 'Dr.', $address->getTitle() );
556
-		$this->assertEquals( 'firstunit', $address->getFirstname() );
553
+		$address = $this->object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY);
554
+		$this->assertEquals('Example company', $address->getCompany());
555
+		$this->assertEquals('Dr.', $address->getTitle());
556
+		$this->assertEquals('firstunit', $address->getFirstname());
557 557
 	}
558 558
 
559 559
 
560 560
 	public function testSetDeliveryAddressByArrayError()
561 561
 	{
562
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
563
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array( 'error' => false ) );
562
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
563
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array('error' => false));
564 564
 	}
565 565
 
566 566
 
567 567
 	public function testSetDeliveryAddressTypeError()
568 568
 	{
569
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
570
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error' );
569
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
570
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error');
571 571
 	}
572 572
 
573 573
 
574 574
 	public function testSetServicePayment()
575 575
 	{
576
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' );
577
-		$service = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' );
576
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'service');
577
+		$service = $manager->findItem('unitpaymentcode', [], 'service', 'payment');
578 578
 
579
-		$this->object->addService( 'payment', $service->getId(), [] );
580
-		$item = $this->object->get()->getService( 'payment', 'unitpaymentcode' )->getCode();
581
-		$this->assertEquals( 'unitpaymentcode', $item );
579
+		$this->object->addService('payment', $service->getId(), []);
580
+		$item = $this->object->get()->getService('payment', 'unitpaymentcode')->getCode();
581
+		$this->assertEquals('unitpaymentcode', $item);
582 582
 
583
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
584
-		$this->object->addService( 'payment', $service->getId(), array( 'prepay' => true ) );
583
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
584
+		$this->object->addService('payment', $service->getId(), array('prepay' => true));
585 585
 	}
586 586
 
587 587
 
588 588
 	public function testSetDeliveryOption()
589 589
 	{
590
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' );
591
-		$service = $manager->findItem( 'unitcode', [], 'service', 'delivery' );
590
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'service');
591
+		$service = $manager->findItem('unitcode', [], 'service', 'delivery');
592 592
 
593
-		$this->object->addService( 'delivery', $service->getId(), [] );
594
-		$item = $this->object->get()->getService( 'delivery', 'unitcode' );
595
-		$this->assertEquals( 'unitcode', $item->getCode() );
593
+		$this->object->addService('delivery', $service->getId(), []);
594
+		$item = $this->object->get()->getService('delivery', 'unitcode');
595
+		$this->assertEquals('unitcode', $item->getCode());
596 596
 
597
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
598
-		$this->object->addService( 'delivery', $service->getId(), array( 'fast shipping' => true, 'air shipping' => false ) );
597
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Basket\\Exception');
598
+		$this->object->addService('delivery', $service->getId(), array('fast shipping' => true, 'air shipping' => false));
599 599
 	}
600 600
 
601 601
 
602 602
 	public function testCheckLocale()
603 603
 	{
604
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' );
605
-		$payment = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' );
606
-		$delivery = $manager->findItem( 'unitcode', [], 'service', 'delivery' );
604
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'service');
605
+		$payment = $manager->findItem('unitpaymentcode', [], 'service', 'payment');
606
+		$delivery = $manager->findItem('unitcode', [], 'service', 'delivery');
607 607
 
608
-		$this->object->addProduct( self::$testItem->getId(), 2 );
609
-		$this->object->addCoupon( 'OPQR' );
608
+		$this->object->addProduct(self::$testItem->getId(), 2);
609
+		$this->object->addCoupon('OPQR');
610 610
 
611
-		$this->object->addService( 'payment', $payment->getId() );
612
-		$this->object->addService( 'delivery', $delivery->getId() );
611
+		$this->object->addService('payment', $payment->getId());
612
+		$this->object->addService('delivery', $delivery->getId());
613 613
 
614 614
 		$basket = $this->object->get();
615 615
 		$price = $basket->getPrice();
616 616
 
617
-		foreach( $basket->getProducts() as $product )
617
+		foreach ($basket->getProducts() as $product)
618 618
 		{
619
-			$this->assertEquals( 2, $product->getQuantity() );
620
-			$product->getPrice()->setCurrencyId( 'CHF' );
619
+			$this->assertEquals(2, $product->getQuantity());
620
+			$product->getPrice()->setCurrencyId('CHF');
621 621
 		}
622 622
 
623
-		$basket->getService( 'delivery', 'unitcode' )->getPrice()->setCurrencyId( 'CHF' );
624
-		$basket->getService( 'payment', 'unitpaymentcode' )->getPrice()->setCurrencyId( 'CHF' );
625
-		$basket->getLocale()->setCurrencyId( 'CHF' );
626
-		$price->setCurrencyId( 'CHF' );
623
+		$basket->getService('delivery', 'unitcode')->getPrice()->setCurrencyId('CHF');
624
+		$basket->getService('payment', 'unitpaymentcode')->getPrice()->setCurrencyId('CHF');
625
+		$basket->getLocale()->setCurrencyId('CHF');
626
+		$price->setCurrencyId('CHF');
627 627
 
628
-		$this->context->getLocale()->setCurrencyId( 'CHF' );
629
-		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress( 'Example company' ) );
628
+		$this->context->getLocale()->setCurrencyId('CHF');
629
+		$this->object->setAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress('Example company'));
630 630
 
631
-		$this->context->getSession()->set( 'aimeos/basket/currency', 'CHF' );
632
-		$this->context->getLocale()->setCurrencyId( 'EUR' );
631
+		$this->context->getSession()->set('aimeos/basket/currency', 'CHF');
632
+		$this->context->getLocale()->setCurrencyId('EUR');
633 633
 
634
-		$this->context->getSession()->set( 'aimeos/basket/content-unittest-en-EUR-', null );
634
+		$this->context->getSession()->set('aimeos/basket/content-unittest-en-EUR-', null);
635 635
 
636
-		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
636
+		$object = new \Aimeos\Controller\Frontend\Basket\Standard($this->context);
637 637
 		$basket = $object->get();
638 638
 
639
-		foreach( $basket->getProducts() as $product )
639
+		foreach ($basket->getProducts() as $product)
640 640
 		{
641
-			$this->assertEquals( 'EUR', $product->getPrice()->getCurrencyId() );
642
-			$this->assertEquals( 2, $product->getQuantity() );
641
+			$this->assertEquals('EUR', $product->getPrice()->getCurrencyId());
642
+			$this->assertEquals(2, $product->getQuantity());
643 643
 		}
644 644
 
645
-		$this->assertEquals( 'EUR', $basket->getService( 'payment', 'unitpaymentcode' )->getPrice()->getCurrencyId() );
646
-		$this->assertEquals( 'EUR', $basket->getService( 'delivery', 'unitcode' )->getPrice()->getCurrencyId() );
647
-		$this->assertEquals( 'EUR', $basket->getLocale()->getCurrencyId() );
648
-		$this->assertEquals( 'EUR', $basket->getPrice()->getCurrencyId() );
645
+		$this->assertEquals('EUR', $basket->getService('payment', 'unitpaymentcode')->getPrice()->getCurrencyId());
646
+		$this->assertEquals('EUR', $basket->getService('delivery', 'unitcode')->getPrice()->getCurrencyId());
647
+		$this->assertEquals('EUR', $basket->getLocale()->getCurrencyId());
648
+		$this->assertEquals('EUR', $basket->getPrice()->getCurrencyId());
649 649
 	}
650 650
 
651 651
 
652 652
 	/**
653 653
 	 * @param string $company
654 654
 	 */
655
-	protected function getAddress( $company )
655
+	protected function getAddress($company)
656 656
 	{
657
-		$customer = \Aimeos\MShop\Customer\Manager\Factory::createManager( \TestHelperFrontend::getContext(), 'Standard' );
658
-		$addressManager = $customer->getSubManager( 'address', 'Standard' );
657
+		$customer = \Aimeos\MShop\Customer\Manager\Factory::createManager(\TestHelperFrontend::getContext(), 'Standard');
658
+		$addressManager = $customer->getSubManager('address', 'Standard');
659 659
 
660 660
 		$search = $addressManager->createSearch();
661
-		$search->setConditions( $search->compare( '==', 'customer.address.company', $company ) );
662
-		$items = $addressManager->searchItems( $search );
661
+		$search->setConditions($search->compare('==', 'customer.address.company', $company));
662
+		$items = $addressManager->searchItems($search);
663 663
 
664
-		if( ( $item = reset( $items ) ) === false ) {
665
-			throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) );
664
+		if (($item = reset($items)) === false) {
665
+			throw new \RuntimeException(sprintf('No address item with company "%1$s" found', $company));
666 666
 		}
667 667
 
668 668
 		return $item;
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Stock/Standard.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
30 30
 	 * @since 2017.03
31 31
 	 */
32
-	public function addFilterCodes( \Aimeos\MW\Criteria\Iface $filter, array $codes )
32
+	public function addFilterCodes(\Aimeos\MW\Criteria\Iface $filter, array $codes)
33 33
 	{
34 34
 		$expr = [
35
-			$filter->compare( '==', 'stock.productcode', $codes ),
35
+			$filter->compare('==', 'stock.productcode', $codes),
36 36
 			$filter->getConditions(),
37 37
 		];
38
-		$filter->setConditions( $filter->combine( '&&', $expr ) );
38
+		$filter->setConditions($filter->combine('&&', $expr));
39 39
 
40 40
 		return $filter;
41 41
 	}
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
50 50
 	 * @since 2017.03
51 51
 	 */
52
-	public function addFilterTypes( \Aimeos\MW\Criteria\Iface $filter, array $codes )
52
+	public function addFilterTypes(\Aimeos\MW\Criteria\Iface $filter, array $codes)
53 53
 	{
54
-		if( !empty( $codes ) )
54
+		if (!empty($codes))
55 55
 		{
56 56
 			$expr = [
57
-				$filter->compare( '==', 'stock.type.code', $codes ),
57
+				$filter->compare('==', 'stock.type.code', $codes),
58 58
 				$filter->getConditions(),
59 59
 			];
60
-			$filter->setConditions( $filter->combine( '&&', $expr ) );
60
+			$filter->setConditions($filter->combine('&&', $expr));
61 61
 		}
62 62
 
63 63
 		return $filter;
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public function createFilter()
75 75
 	{
76
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'stock' );
77
-		$search = $manager->createSearch( true );
76
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'stock');
77
+		$search = $manager->createSearch(true);
78 78
 
79
-		return $search->setSortations( [$search->sort( '+', 'stock.type.position' )] );
79
+		return $search->setSortations([$search->sort('+', 'stock.type.position')]);
80 80
 	}
81 81
 
82 82
 
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 	 * @return \Aimeos\MShop\Stock\Item\Iface Stock item including the referenced domains items
88 88
 	 * @since 2017.03
89 89
 	 */
90
-	public function getItem( $id )
90
+	public function getItem($id)
91 91
 	{
92
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'stock' )->getItem( $id, [], true );
92
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'stock')->getItem($id, [], true);
93 93
 	}
94 94
 
95 95
 
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	 * @return array Ordered list of stock items implementing \Aimeos\MShop\Stock\Item\Iface
102 102
 	 * @since 2017.03
103 103
 	 */
104
-	public function searchItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null )
104
+	public function searchItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null)
105 105
 	{
106
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'stock' )->searchItems( $filter, [], $total );
106
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'stock')->searchItems($filter, [], $total);
107 107
 	}
108 108
 }
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Service/Standard.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
 	 * @param string[] $attributes List of attribute codes as keys and strings entered by the customer as value
36 36
 	 * @return string[] List of attributes codes as keys and error messages as values for invalid or missing values
37 37
 	 */
38
-	public function checkAttributes( $serviceId, array $attributes )
38
+	public function checkAttributes($serviceId, array $attributes)
39 39
 	{
40
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service' );
40
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service');
41 41
 
42
-		$item = $manager->getItem( $serviceId, [], true );
43
-		$provider = $manager->getProvider( $item, $item->getType() );
42
+		$item = $manager->getItem($serviceId, [], true);
43
+		$provider = $manager->getProvider($item, $item->getType());
44 44
 
45
-		return array_filter( $provider->checkConfigFE( $attributes ) );
45
+		return array_filter($provider->checkConfigFE($attributes));
46 46
 	}
47 47
 
48 48
 
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 	 * @param string[] $ref List of domain names whose items should be fetched too
54 54
 	 * @return \Aimeos\MShop\Service\Provider\Iface Service provider object
55 55
 	 */
56
-	public function getProvider( $serviceId, $ref = ['media', 'price', 'text'] )
56
+	public function getProvider($serviceId, $ref = ['media', 'price', 'text'])
57 57
 	{
58
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service' );
59
-		$item = $manager->getItem( $serviceId, $ref, true );
58
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service');
59
+		$item = $manager->getItem($serviceId, $ref, true);
60 60
 
61
-		return $manager->getProvider( $item, $item->getType() );
61
+		return $manager->getProvider($item, $item->getType());
62 62
 	}
63 63
 
64 64
 
@@ -69,26 +69,26 @@  discard block
 block discarded – undo
69 69
 	 * @param string[] $ref List of domain names whose items should be fetched too
70 70
 	 * @return \Aimeos\MShop\Service\Provider\Iface[] List of service IDs as keys and service provider objects as values
71 71
 	 */
72
-	public function getProviders( $type = null, $ref = ['media', 'price', 'text'] )
72
+	public function getProviders($type = null, $ref = ['media', 'price', 'text'])
73 73
 	{
74 74
 		$list = [];
75
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service' );
75
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service');
76 76
 
77
-		$search = $manager->createSearch( true );
78
-		$search->setSortations( [$search->sort( '+', 'service.type.position' ), $search->sort( '+', 'service.position' )] );
77
+		$search = $manager->createSearch(true);
78
+		$search->setSortations([$search->sort('+', 'service.type.position'), $search->sort('+', 'service.position')]);
79 79
 
80
-		if( $type != null )
80
+		if ($type != null)
81 81
 		{
82 82
 			$expr = array(
83 83
 				$search->getConditions(),
84
-				$search->compare( '==', 'service.type.code', $type ),
85
-				$search->compare( '==', 'service.type.domain', 'service' ),
84
+				$search->compare('==', 'service.type.code', $type),
85
+				$search->compare('==', 'service.type.domain', 'service'),
86 86
 			);
87
-			$search->setConditions( $search->combine( '&&', $expr ) );
87
+			$search->setConditions($search->combine('&&', $expr));
88 88
 		}
89 89
 
90
-		foreach( $manager->searchItems( $search, $ref ) as $id => $item ) {
91
-			$list[$id] = $manager->getProvider( $item, $item->getType() );
90
+		foreach ($manager->searchItems($search, $ref) as $id => $item) {
91
+			$list[$id] = $manager->getProvider($item, $item->getType());
92 92
 		}
93 93
 
94 94
 		return $list;
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
 	 * @return \Aimeos\MShop\Common\Item\Helper\Form\Iface|null Form object with URL, parameters, etc.
107 107
 	 * 	or null if no form data is required
108 108
 	 */
109
-	public function process( \Aimeos\MShop\Order\Item\Iface $orderItem, $serviceId, array $urls, array $params )
109
+	public function process(\Aimeos\MShop\Order\Item\Iface $orderItem, $serviceId, array $urls, array $params)
110 110
 	{
111
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service' );
112
-		$item = $manager->getItem( $serviceId, [], true );
111
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service');
112
+		$item = $manager->getItem($serviceId, [], true);
113 113
 
114
-		$provider = $manager->getProvider( $item, $item->getType() );
115
-		$provider->injectGlobalConfigBE( $urls );
114
+		$provider = $manager->getProvider($item, $item->getType());
115
+		$provider->injectGlobalConfigBE($urls);
116 116
 
117
-		return $provider->process( $orderItem, $params );
117
+		return $provider->process($orderItem, $params);
118 118
 	}
119 119
 
120 120
 
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
 	 * @param string $code Unique code of the service used for the current order
127 127
 	 * @return \Psr\Http\Message\ResponseInterface Response object
128 128
 	 */
129
-	public function updatePush( ServerRequestInterface $request, ResponseInterface $response, $code )
129
+	public function updatePush(ServerRequestInterface $request, ResponseInterface $response, $code)
130 130
 	{
131
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'service' );
132
-		$item = $manager->findItem( $code );
131
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'service');
132
+		$item = $manager->findItem($code);
133 133
 
134
-		$provider = $manager->getProvider( $item, $item->getType() );
134
+		$provider = $manager->getProvider($item, $item->getType());
135 135
 
136
-		return $provider->updatePush( $request, $response );
136
+		return $provider->updatePush($request, $response);
137 137
 	}
138 138
 
139 139
 
@@ -145,24 +145,24 @@  discard block
 block discarded – undo
145 145
 	 * @param string $orderid ID of the order whose payment status should be updated
146 146
 	 * @return \Aimeos\MShop\Order\Item\Iface $orderItem Order item that has been updated
147 147
 	 */
148
-	public function updateSync( ServerRequestInterface $request, $code, $orderid )
148
+	public function updateSync(ServerRequestInterface $request, $code, $orderid)
149 149
 	{
150 150
 		$context = $this->getContext();
151
-		$orderManager = \Aimeos\MShop\Factory::createManager( $context, 'order' );
152
-		$serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' );
151
+		$orderManager = \Aimeos\MShop\Factory::createManager($context, 'order');
152
+		$serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service');
153 153
 
154
-		$orderItem = $orderManager->getItem( $orderid );
155
-		$serviceItem = $serviceManager->findItem( $code );
154
+		$orderItem = $orderManager->getItem($orderid);
155
+		$serviceItem = $serviceManager->findItem($code);
156 156
 
157
-		$provider = $serviceManager->getProvider( $serviceItem, $serviceItem->getType() );
157
+		$provider = $serviceManager->getProvider($serviceItem, $serviceItem->getType());
158 158
 
159 159
 
160
-		if( ( $orderItem = $provider->updateSync( $request, $orderItem ) ) !== null )
160
+		if (($orderItem = $provider->updateSync($request, $orderItem)) !== null)
161 161
 		{
162
-			if( $orderItem->getPaymentStatus() === \Aimeos\MShop\Order\Item\Base::PAY_UNFINISHED
163
-				&& $provider->isImplemented( \Aimeos\MShop\Service\Provider\Payment\Base::FEAT_QUERY )
162
+			if ($orderItem->getPaymentStatus() === \Aimeos\MShop\Order\Item\Base::PAY_UNFINISHED
163
+				&& $provider->isImplemented(\Aimeos\MShop\Service\Provider\Payment\Base::FEAT_QUERY)
164 164
 			) {
165
-				$provider->query( $orderItem );
165
+				$provider->query($orderItem);
166 166
 			}
167 167
 		}
168 168
 
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Attribute/Standard.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
30 30
 	 * @since 2017.03
31 31
 	 */
32
-	public function addFilterTypes( \Aimeos\MW\Criteria\Iface $filter, array $codes )
32
+	public function addFilterTypes(\Aimeos\MW\Criteria\Iface $filter, array $codes)
33 33
 	{
34
-		if( !empty( $codes ) )
34
+		if (!empty($codes))
35 35
 		{
36 36
 			$expr = [
37
-				$filter->compare( '==', 'attribute.type.code', $codes ),
37
+				$filter->compare('==', 'attribute.type.code', $codes),
38 38
 				$filter->getConditions(),
39 39
 			];
40
-			$filter->setConditions( $filter->combine( '&&', $expr ) );
40
+			$filter->setConditions($filter->combine('&&', $expr));
41 41
 		}
42 42
 
43 43
 		return $filter;
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function createFilter()
55 55
 	{
56
-		$filter = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' )->createSearch( true );
56
+		$filter = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute')->createSearch(true);
57 57
 
58 58
 		$expr = array(
59
-			$filter->compare( '==', 'attribute.domain', 'product' ),
59
+			$filter->compare('==', 'attribute.domain', 'product'),
60 60
 			$filter->getConditions(),
61 61
 		);
62 62
 
63
-		$filter->setConditions( $filter->combine( '&&', $expr ) );
64
-		$filter->setSortations( [$filter->sort( '+', 'attribute.type.position' ), $filter->sort( '+', 'attribute.position' )] );
63
+		$filter->setConditions($filter->combine('&&', $expr));
64
+		$filter->setSortations([$filter->sort('+', 'attribute.type.position'), $filter->sort('+', 'attribute.position')]);
65 65
 
66 66
 		return $filter;
67 67
 	}
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 	 * @return \Aimeos\MShop\Attribute\Item\Iface Attribute item including the referenced domains items
76 76
 	 * @since 2017.03
77 77
 	 */
78
-	public function getItem( $id, array $domains = array( 'media', 'price', 'text' ) )
78
+	public function getItem($id, array $domains = array('media', 'price', 'text'))
79 79
 	{
80
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' )->getItem( $id, $domains, true );
80
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute')->getItem($id, $domains, true);
81 81
 	}
82 82
 
83 83
 
@@ -89,20 +89,20 @@  discard block
 block discarded – undo
89 89
 	 * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute item including the referenced domains items
90 90
 	 * @since 2017.03
91 91
 	 */
92
-	public function getItems( array $ids, array $domains = array( 'media', 'price', 'text' ) )
92
+	public function getItems(array $ids, array $domains = array('media', 'price', 'text'))
93 93
 	{
94
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
94
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
95 95
 
96
-		$filter = $manager->createSearch( true );
96
+		$filter = $manager->createSearch(true);
97 97
 		$expr = [
98
-			$filter->compare( '==', 'attribute.domain', 'product' ),
99
-			$filter->compare( '==', 'attribute.id', $ids ),
98
+			$filter->compare('==', 'attribute.domain', 'product'),
99
+			$filter->compare('==', 'attribute.id', $ids),
100 100
 			$filter->getConditions(),
101 101
 		];
102
-		$filter->setConditions( $filter->combine( '&&', $expr ) );
103
-		$filter->setSortations( [$filter->sort( '+', 'attribute.type.position' ), $filter->sort( '+', 'attribute.position' )] );
102
+		$filter->setConditions($filter->combine('&&', $expr));
103
+		$filter->setSortations([$filter->sort('+', 'attribute.type.position'), $filter->sort('+', 'attribute.position')]);
104 104
 
105
-		return $manager->searchItems( $filter, $domains );
105
+		return $manager->searchItems($filter, $domains);
106 106
 	}
107 107
 
108 108
 
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 * @return array Ordered list of attribute items implementing \Aimeos\MShop\Attribute\Item\Iface
116 116
 	 * @since 2017.03
117 117
 	 */
118
-	public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null )
118
+	public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null)
119 119
 	{
120
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' )->searchItems( $filter, $domains, $total );
120
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute')->searchItems($filter, $domains, $total);
121 121
 	}
122 122
 }
Please login to merge, or discard this patch.
controller/frontend/tests/Controller/Frontend/Stock/StandardTest.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 
17 17
 	protected function setUp()
18 18
 	{
19
-		$this->object = new \Aimeos\Controller\Frontend\Stock\Standard( \TestHelperFrontend::getContext() );
19
+		$this->object = new \Aimeos\Controller\Frontend\Stock\Standard(\TestHelperFrontend::getContext());
20 20
 	}
21 21
 
22 22
 
23 23
 	protected function tearDown()
24 24
 	{
25
-		unset( $this->object );
25
+		unset($this->object);
26 26
 	}
27 27
 
28 28
 
@@ -30,66 +30,66 @@  discard block
 block discarded – undo
30 30
 	{
31 31
 		$filter = $this->object->createFilter();
32 32
 
33
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
34
-		$this->assertEquals( 1, count( $filter->getSortations() ) );
35
-		$this->assertEquals( 0, $filter->getSliceStart() );
36
-		$this->assertEquals( 100, $filter->getSliceSize() );
33
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
34
+		$this->assertEquals(1, count($filter->getSortations()));
35
+		$this->assertEquals(0, $filter->getSliceStart());
36
+		$this->assertEquals(100, $filter->getSliceSize());
37 37
 	}
38 38
 
39 39
 
40 40
 	public function testAddFilterCodes()
41 41
 	{
42 42
 		$filter = $this->object->createFilter();
43
-		$filter = $this->object->addFilterCodes( $filter, ['CNC', 'CNE'] );
43
+		$filter = $this->object->addFilterCodes($filter, ['CNC', 'CNE']);
44 44
 
45 45
 		$list = $filter->getConditions()->getExpressions();
46 46
 
47
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
48
-			throw new \RuntimeException( 'Wrong expression' );
47
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
48
+			throw new \RuntimeException('Wrong expression');
49 49
 		}
50 50
 
51
-		$this->assertEquals( 'stock.productcode', $list[0]->getName() );
52
-		$this->assertEquals( 2, count( $list[0]->getValue() ) );
51
+		$this->assertEquals('stock.productcode', $list[0]->getName());
52
+		$this->assertEquals(2, count($list[0]->getValue()));
53 53
 	}
54 54
 
55 55
 
56 56
 	public function testAddFilterTypes()
57 57
 	{
58 58
 		$filter = $this->object->createFilter();
59
-		$filter = $this->object->addFilterTypes( $filter, ['default'] );
59
+		$filter = $this->object->addFilterTypes($filter, ['default']);
60 60
 
61 61
 		$list = $filter->getConditions()->getExpressions();
62 62
 
63
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
64
-			throw new \RuntimeException( 'Wrong expression' );
63
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
64
+			throw new \RuntimeException('Wrong expression');
65 65
 		}
66 66
 
67
-		$this->assertEquals( 'stock.type.code', $list[0]->getName() );
68
-		$this->assertEquals( 1, count( $list[0]->getValue() ) );
67
+		$this->assertEquals('stock.type.code', $list[0]->getName());
68
+		$this->assertEquals(1, count($list[0]->getValue()));
69 69
 	}
70 70
 
71 71
 
72 72
 	public function testGetItem()
73 73
 	{
74 74
 		$context = \TestHelperFrontend::getContext();
75
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'stock' );
76
-		$id = $manager->findItem( 'CNC', [], 'product', 'default' )->getId();
75
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'stock');
76
+		$id = $manager->findItem('CNC', [], 'product', 'default')->getId();
77 77
 
78
-		$result = $this->object->getItem( $id );
78
+		$result = $this->object->getItem($id);
79 79
 
80
-		$this->assertInstanceOf( '\Aimeos\MShop\Stock\Item\Iface', $result );
80
+		$this->assertInstanceOf('\Aimeos\MShop\Stock\Item\Iface', $result);
81 81
 	}
82 82
 
83 83
 
84 84
 	public function testSearchItems()
85 85
 	{
86 86
 		$filter = $this->object->createFilter();
87
-		$filter = $this->object->addFilterCodes( $filter, ['CNC', 'CNE'] );
87
+		$filter = $this->object->addFilterCodes($filter, ['CNC', 'CNE']);
88 88
 
89 89
 		$total = 0;
90
-		$results = $this->object->searchItems( $filter, $total );
90
+		$results = $this->object->searchItems($filter, $total);
91 91
 
92
-		$this->assertEquals( 2, $total );
93
-		$this->assertEquals( 2, count( $results ) );
92
+		$this->assertEquals(2, $total);
93
+		$this->assertEquals(2, count($results));
94 94
 	}
95 95
 }
Please login to merge, or discard this patch.
controller/frontend/tests/Controller/Frontend/Attribute/StandardTest.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 
17 17
 	protected function setUp()
18 18
 	{
19
-		$this->object = new \Aimeos\Controller\Frontend\Attribute\Standard( \TestHelperFrontend::getContext() );
19
+		$this->object = new \Aimeos\Controller\Frontend\Attribute\Standard(\TestHelperFrontend::getContext());
20 20
 	}
21 21
 
22 22
 
23 23
 	protected function tearDown()
24 24
 	{
25
-		unset( $this->object );
25
+		unset($this->object);
26 26
 	}
27 27
 
28 28
 
@@ -30,57 +30,57 @@  discard block
 block discarded – undo
30 30
 	{
31 31
 		$filter = $this->object->createFilter();
32 32
 
33
-		$this->assertInstanceOf( '\\Aimeos\\MW\\Criteria\\Iface', $filter );
34
-		$this->assertEquals( 2, count( $filter->getSortations() ) );
35
-		$this->assertEquals( 0, $filter->getSliceStart() );
36
-		$this->assertEquals( 100, $filter->getSliceSize() );
33
+		$this->assertInstanceOf('\\Aimeos\\MW\\Criteria\\Iface', $filter);
34
+		$this->assertEquals(2, count($filter->getSortations()));
35
+		$this->assertEquals(0, $filter->getSliceStart());
36
+		$this->assertEquals(100, $filter->getSliceSize());
37 37
 	}
38 38
 
39 39
 
40 40
 	public function testAddFilterTypes()
41 41
 	{
42 42
 		$filter = $this->object->createFilter();
43
-		$filter = $this->object->addFilterTypes( $filter, ['size'] );
43
+		$filter = $this->object->addFilterTypes($filter, ['size']);
44 44
 
45 45
 		$list = $filter->getConditions()->getExpressions();
46 46
 
47
-		if( !isset( $list[0] ) || !( $list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface ) ) {
48
-			throw new \RuntimeException( 'Wrong expression' );
47
+		if (!isset($list[0]) || !($list[0] instanceof \Aimeos\MW\Criteria\Expression\Compare\Iface)) {
48
+			throw new \RuntimeException('Wrong expression');
49 49
 		}
50 50
 
51
-		$this->assertEquals( 'attribute.type.code', $list[0]->getName() );
52
-		$this->assertEquals( 1, count( $list[0]->getValue() ) );
51
+		$this->assertEquals('attribute.type.code', $list[0]->getName());
52
+		$this->assertEquals(1, count($list[0]->getValue()));
53 53
 	}
54 54
 
55 55
 
56 56
 	public function testGetItem()
57 57
 	{
58 58
 		$context = \TestHelperFrontend::getContext();
59
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'attribute' );
60
-		$id = $manager->findItem( 'xs', [], 'product', 'size' )->getId();
59
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'attribute');
60
+		$id = $manager->findItem('xs', [], 'product', 'size')->getId();
61 61
 
62
-		$result = $this->object->getItem( $id, ['text'] );
62
+		$result = $this->object->getItem($id, ['text']);
63 63
 
64
-		$this->assertInstanceOf( '\Aimeos\MShop\Attribute\Item\Iface', $result );
65
-		$this->assertEquals( 3, count( $result->getRefItems( 'text' ) ) );
64
+		$this->assertInstanceOf('\Aimeos\MShop\Attribute\Item\Iface', $result);
65
+		$this->assertEquals(3, count($result->getRefItems('text')));
66 66
 	}
67 67
 
68 68
 
69 69
 	public function testGetItems()
70 70
 	{
71 71
 		$context = \TestHelperFrontend::getContext();
72
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'attribute' );
73
-		$id = $manager->findItem( 'xs', [], 'product', 'size' )->getId();
72
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'attribute');
73
+		$id = $manager->findItem('xs', [], 'product', 'size')->getId();
74 74
 
75
-		$result = $this->object->getItems( [$id], ['text'] );
75
+		$result = $this->object->getItems([$id], ['text']);
76 76
 
77
-		$this->assertInternalType( 'array', $result );
78
-		$this->assertEquals( 1, count( $result ) );
77
+		$this->assertInternalType('array', $result);
78
+		$this->assertEquals(1, count($result));
79 79
 
80
-		foreach( $result as $attrItem )
80
+		foreach ($result as $attrItem)
81 81
 		{
82
-			$this->assertInstanceOf( '\Aimeos\MShop\Attribute\Item\Iface', $attrItem );
83
-			$this->assertEquals( 3, count( $attrItem->getRefItems( 'text' ) ) );
82
+			$this->assertInstanceOf('\Aimeos\MShop\Attribute\Item\Iface', $attrItem);
83
+			$this->assertEquals(3, count($attrItem->getRefItems('text')));
84 84
 		}
85 85
 	}
86 86
 
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 	public function testSearchItems()
89 89
 	{
90 90
 		$filter = $this->object->createFilter();
91
-		$filter = $this->object->addFilterTypes( $filter, ['size'] );
91
+		$filter = $this->object->addFilterTypes($filter, ['size']);
92 92
 
93 93
 		$total = 0;
94
-		$results = $this->object->searchItems( $filter, ['text'], $total );
94
+		$results = $this->object->searchItems($filter, ['text'], $total);
95 95
 
96
-		$this->assertEquals( 6, $total );
97
-		$this->assertEquals( 6, count( $results ) );
96
+		$this->assertEquals(6, $total);
97
+		$this->assertEquals(6, count($results));
98 98
 	}
99 99
 }
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Common/Factory/Base.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param string $classname Full name of the class for which the object should be returned
32 32
 	 * @param \Aimeos\Controller\Frontend\Iface|null $controller Frontend controller object
33 33
 	 */
34
-	public static function injectController( $classname, \Aimeos\Controller\Frontend\Iface $controller = null )
34
+	public static function injectController($classname, \Aimeos\Controller\Frontend\Iface $controller = null)
35 35
 	{
36 36
 		self::$objects[$classname] = $controller;
37 37
 	}
@@ -46,26 +46,26 @@  discard block
 block discarded – undo
46 46
 	 * @param string $classprefix Decorator class prefix, e.g. "\Aimeos\Controller\Frontend\Basket\Decorator\"
47 47
 	 * @return \Aimeos\Controller\Frontend\Common\Iface Controller object
48 48
 	 */
49
-	protected static function addDecorators( \Aimeos\MShop\Context\Item\Iface $context,
50
-		\Aimeos\Controller\Frontend\Iface $controller, array $decorators, $classprefix )
49
+	protected static function addDecorators(\Aimeos\MShop\Context\Item\Iface $context,
50
+		\Aimeos\Controller\Frontend\Iface $controller, array $decorators, $classprefix)
51 51
 	{
52
-		foreach( $decorators as $name )
52
+		foreach ($decorators as $name)
53 53
 		{
54
-			if( ctype_alnum( $name ) === false )
54
+			if (ctype_alnum($name) === false)
55 55
 			{
56
-				$classname = is_string( $name ) ? $classprefix . $name : '<not a string>';
57
-				throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
56
+				$classname = is_string($name) ? $classprefix . $name : '<not a string>';
57
+				throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
58 58
 			}
59 59
 
60 60
 			$classname = $classprefix . $name;
61 61
 
62
-			if( class_exists( $classname ) === false ) {
63
-				throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $classname ) );
62
+			if (class_exists($classname) === false) {
63
+				throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" not available', $classname));
64 64
 			}
65 65
 
66
-			$controller = new $classname( $controller, $context );
66
+			$controller = new $classname($controller, $context);
67 67
 
68
-			\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\Iface', $controller );
68
+			\Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\Iface', $controller);
69 69
 		}
70 70
 
71 71
 		return $controller;
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	 * @param string $domain Domain name in lower case, e.g. "product"
81 81
 	 * @return \Aimeos\Controller\Frontend\Common\Iface Controller object
82 82
 	 */
83
-	protected static function addControllerDecorators( \Aimeos\MShop\Context\Item\Iface $context,
84
-		\Aimeos\Controller\Frontend\Iface $controller, $domain )
83
+	protected static function addControllerDecorators(\Aimeos\MShop\Context\Item\Iface $context,
84
+		\Aimeos\Controller\Frontend\Iface $controller, $domain)
85 85
 	{
86
-		if( !is_string( $domain ) || $domain === '' ) {
87
-			throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid domain "%1$s"', $domain ) );
86
+		if (!is_string($domain) || $domain === '') {
87
+			throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid domain "%1$s"', $domain));
88 88
 		}
89 89
 
90
-		$localClass = str_replace( ' ', '\\', ucwords( str_replace( '/', ' ', $domain ) ) );
90
+		$localClass = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $domain)));
91 91
 		$config = $context->getConfig();
92 92
 
93 93
 		/** controller/frontend/common/decorators/default
@@ -112,26 +112,26 @@  discard block
 block discarded – undo
112 112
 		 * @since 2014.03
113 113
 		 * @category Developer
114 114
 		 */
115
-		$decorators = $config->get( 'controller/frontend/common/decorators/default', [] );
116
-		$excludes = $config->get( 'controller/frontend/' . $domain . '/decorators/excludes', [] );
115
+		$decorators = $config->get('controller/frontend/common/decorators/default', []);
116
+		$excludes = $config->get('controller/frontend/' . $domain . '/decorators/excludes', []);
117 117
 
118
-		foreach( $decorators as $key => $name )
118
+		foreach ($decorators as $key => $name)
119 119
 		{
120
-			if( in_array( $name, $excludes ) ) {
121
-				unset( $decorators[$key] );
120
+			if (in_array($name, $excludes)) {
121
+				unset($decorators[$key]);
122 122
 			}
123 123
 		}
124 124
 
125 125
 		$classprefix = '\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\';
126
-		$controller = self::addDecorators( $context, $controller, $decorators, $classprefix );
126
+		$controller = self::addDecorators($context, $controller, $decorators, $classprefix);
127 127
 
128 128
 		$classprefix = '\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\';
129
-		$decorators = $config->get( 'controller/frontend/' . $domain . '/decorators/global', [] );
130
-		$controller = self::addDecorators( $context, $controller, $decorators, $classprefix );
129
+		$decorators = $config->get('controller/frontend/' . $domain . '/decorators/global', []);
130
+		$controller = self::addDecorators($context, $controller, $decorators, $classprefix);
131 131
 
132
-		$classprefix = '\\Aimeos\\Controller\\Frontend\\' . ucfirst( $localClass ) . '\\Decorator\\';
133
-		$decorators = $config->get( 'controller/frontend/' . $domain . '/decorators/local', [] );
134
-		$controller = self::addDecorators( $context, $controller, $decorators, $classprefix );
132
+		$classprefix = '\\Aimeos\\Controller\\Frontend\\' . ucfirst($localClass) . '\\Decorator\\';
133
+		$decorators = $config->get('controller/frontend/' . $domain . '/decorators/local', []);
134
+		$controller = self::addDecorators($context, $controller, $decorators, $classprefix);
135 135
 
136 136
 		return $controller;
137 137
 	}
@@ -145,19 +145,19 @@  discard block
 block discarded – undo
145 145
 	 * @param string $interface Name of the controller interface
146 146
 	 * @return \Aimeos\Controller\Frontend\Common\Iface Controller object
147 147
 	 */
148
-	protected static function createControllerBase( \Aimeos\MShop\Context\Item\Iface $context, $classname, $interface )
148
+	protected static function createControllerBase(\Aimeos\MShop\Context\Item\Iface $context, $classname, $interface)
149 149
 	{
150
-		if( isset( self::$objects[$classname] ) ) {
150
+		if (isset(self::$objects[$classname])) {
151 151
 			return self::$objects[$classname];
152 152
 		}
153 153
 
154
-		if( class_exists( $classname ) === false ) {
155
-			throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $classname ) );
154
+		if (class_exists($classname) === false) {
155
+			throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" not available', $classname));
156 156
 		}
157 157
 
158
-		$controller = new $classname( $context );
158
+		$controller = new $classname($context);
159 159
 
160
-		\Aimeos\MW\Common\Base::checkClass( $interface, $controller );
160
+		\Aimeos\MW\Common\Base::checkClass($interface, $controller);
161 161
 
162 162
 		return $controller;
163 163
 	}
Please login to merge, or discard this patch.
controller/frontend/tests/Controller/Frontend/Locale/Decorator/BaseTest.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -20,97 +20,97 @@
 block discarded – undo
20 20
 	{
21 21
 		$this->context = \TestHelperFrontend::getContext();
22 22
 
23
-		$this->stub = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Locale\Standard' )
23
+		$this->stub = $this->getMockBuilder('\Aimeos\Controller\Frontend\Locale\Standard')
24 24
 			->disableOriginalConstructor()
25 25
 			->getMock();
26 26
 
27
-		$this->object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Locale\Decorator\Base' )
28
-			->setConstructorArgs( [$this->stub, $this->context] )
27
+		$this->object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Locale\Decorator\Base')
28
+			->setConstructorArgs([$this->stub, $this->context])
29 29
 			->getMockForAbstractClass();
30 30
 	}
31 31
 
32 32
 
33 33
 	protected function tearDown()
34 34
 	{
35
-		unset( $this->context, $this->object, $this->stub );
35
+		unset($this->context, $this->object, $this->stub);
36 36
 	}
37 37
 
38 38
 
39 39
 	public function testConstructException()
40 40
 	{
41
-		$stub = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Iface' )->getMock();
41
+		$stub = $this->getMockBuilder('\Aimeos\Controller\Frontend\Iface')->getMock();
42 42
 
43
-		$this->setExpectedException( '\Aimeos\MW\Common\Exception' );
43
+		$this->setExpectedException('\Aimeos\MW\Common\Exception');
44 44
 
45
-		$this->getMockBuilder( '\Aimeos\Controller\Frontend\Locale\Decorator\Base' )
46
-			->setConstructorArgs( [$stub, $this->context] )
45
+		$this->getMockBuilder('\Aimeos\Controller\Frontend\Locale\Decorator\Base')
46
+			->setConstructorArgs([$stub, $this->context])
47 47
 			->getMockForAbstractClass();
48 48
 	}
49 49
 
50 50
 
51 51
 	public function testCall()
52 52
 	{
53
-		$stub = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Locale\Standard' )
53
+		$stub = $this->getMockBuilder('\Aimeos\Controller\Frontend\Locale\Standard')
54 54
 			->disableOriginalConstructor()
55
-			->setMethods( ['invalid'] )
55
+			->setMethods(['invalid'])
56 56
 			->getMock();
57 57
 
58
-		$object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Locale\Decorator\Base' )
59
-			->setConstructorArgs( [$stub, $this->context] )
58
+		$object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Locale\Decorator\Base')
59
+			->setConstructorArgs([$stub, $this->context])
60 60
 			->getMockForAbstractClass();
61 61
 
62
-		$stub->expects( $this->once() )->method( 'invalid' )->will( $this->returnValue( true ) );
62
+		$stub->expects($this->once())->method('invalid')->will($this->returnValue(true));
63 63
 
64
-		$this->assertTrue( $object->invalid() );
64
+		$this->assertTrue($object->invalid());
65 65
 	}
66 66
 
67 67
 
68 68
 	public function testCreateFilter()
69 69
 	{
70
-		$search = \Aimeos\MShop\Factory::createManager( $this->context, 'locale' )->createSearch();
70
+		$search = \Aimeos\MShop\Factory::createManager($this->context, 'locale')->createSearch();
71 71
 
72
-		$this->stub->expects( $this->once() )->method( 'createFilter' )
73
-			->will( $this->returnValue( $search ) );
72
+		$this->stub->expects($this->once())->method('createFilter')
73
+			->will($this->returnValue($search));
74 74
 
75
-		$this->assertInstanceOf( '\Aimeos\MW\Criteria\Iface', $this->object->createFilter() );
75
+		$this->assertInstanceOf('\Aimeos\MW\Criteria\Iface', $this->object->createFilter());
76 76
 	}
77 77
 
78 78
 
79 79
 	public function testGetItem()
80 80
 	{
81
-		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'locale' )->createItem();
81
+		$item = \Aimeos\MShop\Factory::createManager($this->context, 'locale')->createItem();
82 82
 
83
-		$this->stub->expects( $this->once() )->method( 'getItem' )
84
-			->will( $this->returnValue( $item ) );
83
+		$this->stub->expects($this->once())->method('getItem')
84
+			->will($this->returnValue($item));
85 85
 
86
-		$this->assertInstanceOf( '\Aimeos\MShop\Locale\Item\Iface', $this->object->getItem( -1 ) );
86
+		$this->assertInstanceOf('\Aimeos\MShop\Locale\Item\Iface', $this->object->getItem( -1 ));
87 87
 	}
88 88
 
89 89
 
90 90
 	public function testSearchItems()
91 91
 	{
92
-		$filter = \Aimeos\MShop\Factory::createManager( $this->context, 'locale' )->createSearch();
92
+		$filter = \Aimeos\MShop\Factory::createManager($this->context, 'locale')->createSearch();
93 93
 
94
-		$this->stub->expects( $this->once() )->method( 'searchItems' )
95
-			->will( $this->returnValue( [] ) );
94
+		$this->stub->expects($this->once())->method('searchItems')
95
+			->will($this->returnValue([]));
96 96
 
97
-		$this->assertEquals( [], $this->object->searchItems( $filter, ['media'] ) );
97
+		$this->assertEquals([], $this->object->searchItems($filter, ['media']));
98 98
 	}
99 99
 
100 100
 
101 101
 	public function testGetController()
102 102
 	{
103
-		$result = $this->access( 'getController' )->invokeArgs( $this->object, [] );
103
+		$result = $this->access('getController')->invokeArgs($this->object, []);
104 104
 
105
-		$this->assertSame( $this->stub, $result );
105
+		$this->assertSame($this->stub, $result);
106 106
 	}
107 107
 
108 108
 
109
-	protected function access( $name )
109
+	protected function access($name)
110 110
 	{
111
-		$class = new \ReflectionClass( '\Aimeos\Controller\Frontend\Locale\Decorator\Base' );
112
-		$method = $class->getMethod( $name );
113
-		$method->setAccessible( true );
111
+		$class = new \ReflectionClass('\Aimeos\Controller\Frontend\Locale\Decorator\Base');
112
+		$method = $class->getMethod($name);
113
+		$method->setAccessible(true);
114 114
 
115 115
 		return $method;
116 116
 	}
Please login to merge, or discard this patch.
controller/frontend/tests/Controller/Frontend/Locale/FactoryTest.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,31 +15,31 @@
 block discarded – undo
15 15
 	{
16 16
 		$target = '\\Aimeos\\Controller\\Frontend\\Locale\\Iface';
17 17
 
18
-		$controller = \Aimeos\Controller\Frontend\Locale\Factory::createController( \TestHelperFrontend::getContext() );
19
-		$this->assertInstanceOf( $target, $controller );
18
+		$controller = \Aimeos\Controller\Frontend\Locale\Factory::createController(\TestHelperFrontend::getContext());
19
+		$this->assertInstanceOf($target, $controller);
20 20
 
21
-		$controller = \Aimeos\Controller\Frontend\Locale\Factory::createController( \TestHelperFrontend::getContext(), 'Standard' );
22
-		$this->assertInstanceOf( $target, $controller );
21
+		$controller = \Aimeos\Controller\Frontend\Locale\Factory::createController(\TestHelperFrontend::getContext(), 'Standard');
22
+		$this->assertInstanceOf($target, $controller);
23 23
 	}
24 24
 
25 25
 
26 26
 	public function testCreateControllerInvalidImplementation()
27 27
 	{
28
-		$this->setExpectedException( '\\Aimeos\\MW\\Common\\Exception' );
29
-		\Aimeos\Controller\Frontend\Locale\Factory::createController( \TestHelperFrontend::getContext(), 'Invalid' );
28
+		$this->setExpectedException('\\Aimeos\\MW\\Common\\Exception');
29
+		\Aimeos\Controller\Frontend\Locale\Factory::createController(\TestHelperFrontend::getContext(), 'Invalid');
30 30
 	}
31 31
 
32 32
 
33 33
 	public function testCreateControllerInvalidName()
34 34
 	{
35
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' );
36
-		\Aimeos\Controller\Frontend\Locale\Factory::createController( \TestHelperFrontend::getContext(), '%^' );
35
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception');
36
+		\Aimeos\Controller\Frontend\Locale\Factory::createController(\TestHelperFrontend::getContext(), '%^');
37 37
 	}
38 38
 
39 39
 
40 40
 	public function testCreateControllerNotExisting()
41 41
 	{
42
-		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' );
43
-		\Aimeos\Controller\Frontend\Locale\Factory::createController( \TestHelperFrontend::getContext(), 'notexist' );
42
+		$this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception');
43
+		\Aimeos\Controller\Frontend\Locale\Factory::createController(\TestHelperFrontend::getContext(), 'notexist');
44 44
 	}
45 45
 }
Please login to merge, or discard this patch.