Completed
Push — master ( 80e97a...1395b9 )
by Aimeos
11:31
created

StandardTest::testAddProductCustomPriceException()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
cc 2
eloc 13
nc 2
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2012
6
 * @copyright Aimeos (aimeos.org), 2015-2017
7
 */
8
9
namespace Aimeos\Controller\Frontend\Basket;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
	private $context;
16
	private static $testItem;
17
18
19
	public static function setUpBeforeClass()
20
	{
21
		$context = \TestHelperFrontend::getContext();
22
		self::$testItem = \Aimeos\MShop\Factory::createManager( $context, 'product' )->findItem( 'U:TESTP' );
23
	}
24
25
26
	protected function setUp()
27
	{
28
		\Aimeos\MShop\Factory::setCache( true );
29
30
		$this->context = \TestHelperFrontend::getContext();
31
		$this->object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
32
	}
33
34
35
	protected function tearDown()
36
	{
37
		\Aimeos\MShop\Factory::setCache( false );
38
		\Aimeos\MShop\Factory::clear();
39
40
		$this->object->clear();
41
		$this->context->getSession()->set( 'aimeos', [] );
42
43
		unset( $this->context, $this->object );
44
	}
45
46
47
	public function testClear()
48
	{
49
		$this->object->addProduct( self::$testItem->getId(), 2 );
50
		$this->object->clear();
51
52
		$this->assertEquals( 0, count( $this->object->get()->getProducts() ) );
53
	}
54
55
56
	public function testGet()
57
	{
58
		$this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Iface', $this->object->get() );
59
	}
60
61
62
	public function testSave()
63
	{
64
		$stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' )
65
			->setConstructorArgs( [$this->context] )
66
			->setMethods( ['setSession'] )
67
			->getMock();
68
69
		\Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub );
70
71
		$stub->expects( $this->exactly( 2 ) )->method( 'setSession' );
72
73
		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
74
		$object->addProduct( self::$testItem->getId(), 2 );
75
		$object->save();
76
	}
77
78
79
	public function testSetType()
80
	{
81
		$this->assertInstanceOf( '\Aimeos\Controller\Frontend\Basket\Iface', $this->object->setType( 'test' ) );
82
	}
83
84
85
	public function testStore()
86
	{
87
		$stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' )
88
			->setConstructorArgs( [$this->context] )
89
			->setMethods( ['store'] )
90
			->getMock();
91
92
		\Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub );
93
94
		$stub->expects( $this->once() )->method( 'store' );
95
96
		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
97
		$object->store();
98
	}
99
100
101
	public function testStoreLimit()
102
	{
103
		$this->context->setEditor( 'core:unittest' );
104
		$config = $this->context->getConfig();
105
		$config->set( 'controller/frontend/basket/limit-count', 0 );
106
		$config->set( 'controller/frontend/basket/limit-seconds', 86400 * 365 );
107
108
		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
109
110
		$this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' );
111
		$object->store();
112
	}
113
114
115
	public function testLoad()
116
	{
117
		$stub = $this->getMockBuilder( '\Aimeos\MShop\Order\Manager\Base\Standard' )
118
			->setConstructorArgs( [$this->context] )
119
			->setMethods( ['load'] )
120
			->getMock();
121
122
		\Aimeos\MShop\Factory::injectManager( $this->context, 'order/base', $stub );
123
124
		$stub->expects( $this->once() )->method( 'load' )
125
			->will( $this->returnValue( $stub->createItem() ) );
126
127
		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
128
		$object->load( -1 );
129
	}
130
131
132
	public function testAddDeleteProduct()
133
	{
134
		$basket = $this->object->get();
135
		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' );
136
137
		$this->object->addProduct( $item->getId(), 2, [], [], [], [], [], 'default' );
138
		$item2 = $this->object->get()->getProduct( 0 );
139
		$this->object->deleteProduct( 0 );
140
141
		$this->assertEquals( 0, count( $basket->getProducts() ) );
142
		$this->assertEquals( 'CNC', $item2->getProductCode() );
143
	}
144
145
146
	public function testAddProductCustomAttribute()
147
	{
148
		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
149
150
		$search = $attributeManager->createSearch();
151
		$expr = array(
152
			$search->compare( '==', 'attribute.code', 'custom' ),
153
			$search->compare( '==', 'attribute.type.code', 'date' ),
154
		);
155
		$search->setConditions( $search->combine( '&&', $expr ) );
156
157
		$attributes = $attributeManager->searchItems( $search );
158
159
		if( ( $attrItem = reset( $attributes ) ) === false ) {
160
			throw new \RuntimeException( 'Attribute not found' );
161
		}
162
163
		$attrValues = array( $attrItem->getId() => '2000-01-01' );
164
165
		$this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues );
166
		$basket = $this->object->get();
167
168
		$this->assertEquals( 1, count( $basket->getProducts() ) );
169
		$this->assertEquals( '2000-01-01', $basket->getProduct( 0 )->getAttribute( 'date', 'custom' ) );
170
	}
171
172
173
	public function testAddProductCustomPrice()
174
	{
175
		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
176
177
		$search = $attributeManager->createSearch();
178
		$expr = array(
179
			$search->compare( '==', 'attribute.code', 'custom' ),
180
			$search->compare( '==', 'attribute.type.code', 'price' ),
181
		);
182
		$search->setConditions( $search->combine( '&&', $expr ) );
183
184
		$attributes = $attributeManager->searchItems( $search );
185
186
		if( ( $attrItem = reset( $attributes ) ) === false ) {
187
			throw new \RuntimeException( 'Attribute not found' );
188
		}
189
190
		$attrValues = array( $attrItem->getId() => '0.01' );
191
192
		$this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues );
193
		$basket = $this->object->get();
194
195
		$this->assertEquals( 1, count( $basket->getProducts() ) );
196
		$this->assertEquals( '0.01', $basket->getProduct( 0 )->getPrice()->getValue() );
197
	}
198
199
200
	public function testAddProductCustomPriceException()
201
	{
202
		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
203
204
		$search = $attributeManager->createSearch();
205
		$expr = array(
206
			$search->compare( '==', 'attribute.code', 'custom' ),
207
			$search->compare( '==', 'attribute.type.code', 'price' ),
208
		);
209
		$search->setConditions( $search->combine( '&&', $expr ) );
210
211
		$attributes = $attributeManager->searchItems( $search );
212
213
		if( ( $attrItem = reset( $attributes ) ) === false ) {
214
			throw new \RuntimeException( 'Attribute not found' );
215
		}
216
217
		$attrValues = array( $attrItem->getId() => ',' );
218
219
		$this->setExpectedException( '\Aimeos\Controller\Frontend\Basket\Exception' );
220
		$this->object->addProduct( self::$testItem->getId(), 1, [], [], [], [], $attrValues );
221
	}
222
223
224
	public function testAddProductAttributeNotAssigned()
225
	{
226
		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
227
228
		$search = $attributeManager->createSearch();
229
		$expr = array(
230
			$search->compare( '==', 'attribute.code', '30' ),
231
			$search->compare( '==', 'attribute.type.code', 'width' ),
232
		);
233
		$search->setConditions( $search->combine( '&&', $expr ) );
234
235
		$attribute = $attributeManager->searchItems( $search );
236
237
		if( empty( $attribute ) ) {
238
			throw new \RuntimeException( 'Attribute not found' );
239
		}
240
241
		$hiddenAttrIds = array_keys( $attribute );
242
		$configAttrIds = array_keys( $attribute );
243
244
		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
245
		$this->object->addProduct( self::$testItem->getId(), 1, [], [], $configAttrIds, $hiddenAttrIds );
246
	}
247
248
249
	public function testAddProductNegativeQuantityException()
250
	{
251
		$this->setExpectedException( '\\Aimeos\\MShop\\Order\\Exception' );
252
		$this->object->addProduct( self::$testItem->getId(), -1 );
253
	}
254
255
256
	public function testAddProductNoPriceException()
257
	{
258
		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'MNOP' );
259
260
		$this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' );
261
		$this->object->addProduct( $item->getId(), 1 );
262
	}
263
264
265
	public function testAddProductConfigAttributeException()
266
	{
267
		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
268
		$this->object->addProduct( self::$testItem->getId(), 1, [], [], array( -1 ) );
269
	}
270
271
272
	public function testAddProductLowQuantityPriceException()
273
	{
274
		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' );
275
276
		$this->setExpectedException( '\\Aimeos\\MShop\\Price\\Exception' );
277
		$this->object->addProduct( $item->getId(), 1 );
278
	}
279
280
281
	public function testAddProductHigherQuantities()
282
	{
283
		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'IJKL' );
284
285
		$this->object->addProduct( $item->getId(), 2, [], [], [], [], [], 'unit_type3' );
286
287
		$this->assertEquals( 2, $this->object->get()->getProduct( 0 )->getQuantity() );
288
		$this->assertEquals( 'IJKL', $this->object->get()->getProduct( 0 )->getProductCode() );
289
	}
290
291
292
	public function testDeleteProductFlagError()
293
	{
294
		$this->object->addProduct( self::$testItem->getId(), 2 );
295
296
		$item = $this->object->get()->getProduct( 0 );
297
		$item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE );
298
299
		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
300
		$this->object->deleteProduct( 0 );
301
	}
302
303
304
	public function testEditProduct()
305
	{
306
		$this->object->addProduct( self::$testItem->getId(), 1 );
307
308
		$item = $this->object->get()->getProduct( 0 );
309
		$this->assertEquals( 1, $item->getQuantity() );
310
311
		$this->object->editProduct( 0, 4 );
312
313
		$item = $this->object->get()->getProduct( 0 );
314
		$this->assertEquals( 4, $item->getQuantity() );
315
		$this->assertEquals( 'U:TESTP', $item->getProductCode() );
316
	}
317
318
319
	public function testEditProductAttributes()
320
	{
321
		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->context, 'attribute' );
322
323
		$search = $attributeManager->createSearch();
324
		$conditions = array(
325
			$search->compare( '==', 'attribute.domain', 'product' ),
326
			$search->combine( '||', array(
327
				$search->combine( '&&', array(
328
					$search->compare( '==', 'attribute.code', 'xs' ),
329
					$search->compare( '==', 'attribute.type.code', 'size' ),
330
				) ),
331
				$search->combine( '&&', array(
332
					$search->compare( '==', 'attribute.code', 'white' ),
333
					$search->compare( '==', 'attribute.type.code', 'color' ),
334
				) ),
335
			) )
336
		);
337
		$search->setConditions( $search->combine( '&&', $conditions ) );
338
		$attributes = $attributeManager->searchItems( $search );
339
340
		if( ( $attribute = reset( $attributes ) ) === false ) {
341
			throw new \RuntimeException( 'No attributes available' );
342
		}
343
344
345
		$item = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'U:TESTP' );
346
347
		$this->object->addProduct( $item->getId(), 1, [], [], array_keys( $attributes ) );
348
		$this->object->editProduct( 0, 4 );
349
350
		$item = $this->object->get()->getProduct( 0 );
351
		$this->assertEquals( 2, count( $item->getAttributes() ) );
352
		$this->assertEquals( 4, $item->getQuantity() );
353
354
355
		$this->object->editProduct( 0, 3, [], array( $attribute->getType() ) );
356
357
		$item = $this->object->get()->getProduct( 0 );
358
		$this->assertEquals( 3, $item->getQuantity() );
359
		$this->assertEquals( 1, count( $item->getAttributes() ) );
360
		$this->assertEquals( 'U:TESTP', $item->getProductCode() );
361
	}
362
363
364
	public function testEditProductFlagError()
365
	{
366
		$this->object->addProduct( self::$testItem->getId(), 2 );
367
368
		$item = $this->object->get()->getProduct( 0 );
369
		$item->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE );
370
371
		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
372
		$this->object->editProduct( 0, 4 );
373
	}
374
375
376
	public function testAddCoupon()
377
	{
378
		$this->object->addProduct( self::$testItem->getId(), 2 );
379
		$this->object->addCoupon( 'GHIJ' );
380
381
		$basket = $this->object->get();
382
383
		$this->assertEquals( 1, count( $basket->getCoupons() ) );
384
	}
385
386
387
	public function testAddCouponInvalidCode()
388
	{
389
		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
390
		$this->object->addCoupon( 'invalid' );
391
	}
392
393
394
	public function testAddCouponMissingRequirements()
395
	{
396
		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
397
		$this->object->addCoupon( 'OPQR' );
398
	}
399
400
401
	public function testDeleteCoupon()
402
	{
403
		$this->object->addProduct( self::$testItem->getId(), 2 );
404
		$this->object->addCoupon( '90AB' );
405
		$this->object->deleteCoupon( '90AB' );
406
407
		$basket = $this->object->get();
408
409
		$this->assertEquals( 0, count( $basket->getCoupons() ) );
410
	}
411
412
413
	public function testSetAddressDelete()
414
	{
415
		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, null );
416
417
		$this->setExpectedException( '\Aimeos\MShop\Order\Exception' );
418
		$this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
419
	}
420
421
422
	public function testSetBillingAddressByItem()
423
	{
424
		$item = $this->getAddress( 'Example company' );
425
426
		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $item );
427
428
		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
429
		$this->assertEquals( 'Example company', $address->getCompany() );
430
	}
431
432
433
	public function testSetBillingAddressByArray()
434
	{
435
		$fixture = array(
436
			'order.base.address.company' => '<p onclick="javascript: alert(\'gotcha\');">Example company</p>',
437
			'order.base.address.vatid' => 'DE999999999',
438
			'order.base.address.title' => '<br/>Dr.',
439
			'order.base.address.salutation' => \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR,
440
			'order.base.address.firstname' => 'firstunit',
441
			'order.base.address.lastname' => 'lastunit',
442
			'order.base.address.address1' => 'unit str.',
443
			'order.base.address.address2' => ' 166',
444
			'order.base.address.address3' => '4.OG',
445
			'order.base.address.postal' => '22769',
446
			'order.base.address.city' => 'Hamburg',
447
			'order.base.address.state' => 'Hamburg',
448
			'order.base.address.countryid' => 'de',
449
			'order.base.address.languageid' => 'de',
450
			'order.base.address.telephone' => '05554433221',
451
			'order.base.address.email' => '[email protected]',
452
			'order.base.address.telefax' => '05554433222',
453
			'order.base.address.website' => 'www.example.com',
454
			'order.base.address.flag' => 0,
455
		);
456
457
		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $fixture );
458
459
		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
460
		$this->assertEquals( 'Example company', $address->getCompany() );
461
		$this->assertEquals( 'Dr.', $address->getTitle() );
462
		$this->assertEquals( 'firstunit', $address->getFirstname() );
463
	}
464
465
466
	public function testSetBillingAddressByArrayError()
467
	{
468
		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
469
		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, array( 'error' => false ) );
470
	}
471
472
473
	public function testSetBillingAddressParameterError()
474
	{
475
		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
476
		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 'error' );
477
	}
478
479
480
	public function testSetDeliveryAddressByItem()
481
	{
482
		$item = $this->getAddress( 'Example company' );
483
484
		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $item );
485
486
		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY );
487
		$this->assertEquals( 'Example company', $address->getCompany() );
488
	}
489
490
491
	public function testSetDeliveryAddressByArray()
492
	{
493
		$fixture = array(
494
			'order.base.address.company' => '<p onclick="javascript: alert(\'gotcha\');">Example company</p>',
495
			'order.base.address.vatid' => 'DE999999999',
496
			'order.base.address.title' => '<br/>Dr.',
497
			'order.base.address.salutation' => \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR,
498
			'order.base.address.firstname' => 'firstunit',
499
			'order.base.address.lastname' => 'lastunit',
500
			'order.base.address.address1' => 'unit str.',
501
			'order.base.address.address2' => ' 166',
502
			'order.base.address.address3' => '4.OG',
503
			'order.base.address.postal' => '22769',
504
			'order.base.address.city' => 'Hamburg',
505
			'order.base.address.state' => 'Hamburg',
506
			'order.base.address.countryid' => 'de',
507
			'order.base.address.languageid' => 'de',
508
			'order.base.address.telephone' => '05554433221',
509
			'order.base.address.email' => '[email protected]',
510
			'order.base.address.telefax' => '05554433222',
511
			'order.base.address.website' => 'www.example.com',
512
			'order.base.address.flag' => 0,
513
		);
514
		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, $fixture );
515
516
		$address = $this->object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY );
517
		$this->assertEquals( 'Example company', $address->getCompany() );
518
		$this->assertEquals( 'Dr.', $address->getTitle() );
519
		$this->assertEquals( 'firstunit', $address->getFirstname() );
520
	}
521
522
523
	public function testSetDeliveryAddressByArrayError()
524
	{
525
		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
526
		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, array( 'error' => false ) );
527
	}
528
529
530
	public function testSetDeliveryAddressTypeError()
531
	{
532
		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
533
		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_DELIVERY, 'error' );
534
	}
535
536
537
	public function testSetServicePayment()
538
	{
539
		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' );
540
		$service = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' );
541
542
		$this->object->setService( 'payment', $service->getId(), [] );
543
		$this->assertEquals( 'unitpaymentcode', $this->object->get()->getService( 'payment' )->getCode() );
544
545
		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
546
		$this->object->setService( 'payment', $service->getId(), array( 'prepay' => true ) );
547
	}
548
549
550
	public function testSetDeliveryOption()
551
	{
552
		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' );
553
		$service = $manager->findItem( 'unitcode', [], 'service', 'delivery' );
554
555
		$this->object->setService( 'delivery', $service->getId(), [] );
556
		$this->assertEquals( 'unitcode', $this->object->get()->getService( 'delivery' )->getCode() );
557
558
		$this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Basket\\Exception' );
559
		$this->object->setService( 'delivery', $service->getId(), array( 'fast shipping' => true, 'air shipping' => false ) );
560
	}
561
562
563
	public function testCheckLocale()
564
	{
565
		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' );
566
		$payment = $manager->findItem( 'unitpaymentcode', [], 'service', 'payment' );
567
		$delivery = $manager->findItem( 'unitcode', [], 'service', 'delivery' );
568
569
		$this->object->addProduct( self::$testItem->getId(), 2 );
570
		$this->object->addCoupon( 'OPQR' );
571
572
		$this->object->setService( 'payment', $payment->getId() );
573
		$this->object->setService( 'delivery', $delivery->getId() );
574
575
		$basket = $this->object->get();
576
		$price = $basket->getPrice();
577
578
		foreach( $basket->getProducts() as $product )
579
		{
580
			$this->assertEquals( 2, $product->getQuantity() );
581
			$product->getPrice()->setCurrencyId( 'CHF' );
582
		}
583
584
		$basket->getService( 'delivery' )->getPrice()->setCurrencyId( 'CHF' );
585
		$basket->getService( 'payment' )->getPrice()->setCurrencyId( 'CHF' );
586
		$basket->getLocale()->setCurrencyId( 'CHF' );
587
		$price->setCurrencyId( 'CHF' );
588
589
		$this->context->getLocale()->setCurrencyId( 'CHF' );
590
		$this->object->setAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, $this->getAddress( 'Example company' ) );
591
592
		$this->context->getSession()->set( 'aimeos/basket/currency', 'CHF' );
593
		$this->context->getLocale()->setCurrencyId( 'EUR' );
594
595
		$this->context->getSession()->set( 'aimeos/basket/content-unittest-en-EUR-', null );
596
597
		$object = new \Aimeos\Controller\Frontend\Basket\Standard( $this->context );
598
		$basket = $object->get();
599
600
		foreach( $basket->getProducts() as $product )
601
		{
602
			$this->assertEquals( 'EUR', $product->getPrice()->getCurrencyId() );
603
			$this->assertEquals( 2, $product->getQuantity() );
604
		}
605
606
		$this->assertEquals( 'EUR', $basket->getService( 'payment' )->getPrice()->getCurrencyId() );
607
		$this->assertEquals( 'EUR', $basket->getService( 'delivery' )->getPrice()->getCurrencyId() );
608
		$this->assertEquals( 'EUR', $basket->getLocale()->getCurrencyId() );
609
		$this->assertEquals( 'EUR', $basket->getPrice()->getCurrencyId() );
610
	}
611
612
613
	/**
614
	 * @param string $company
615
	 */
616
	protected function getAddress( $company )
617
	{
618
		$customer = \Aimeos\MShop\Customer\Manager\Factory::createManager( \TestHelperFrontend::getContext(), 'Standard' );
619
		$addressManager = $customer->getSubManager( 'address', 'Standard' );
620
621
		$search = $addressManager->createSearch();
622
		$search->setConditions( $search->compare( '==', 'customer.address.company', $company ) );
623
		$items = $addressManager->searchItems( $search );
624
625
		if( ( $item = reset( $items ) ) === false ) {
626
			throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) );
627
		}
628
629
		return $item;
630
	}
631
}
632