Passed
Push — master ( c9c069...cc1d41 )
by Aimeos
05:10
created

BaseTest::testMagicMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2011
6
 * @copyright Aimeos (aimeos.org), 2015-2018
7
 */
8
9
10
namespace Aimeos\MShop\Order\Item\Base;
11
12
13
class BaseTest extends \PHPUnit\Framework\TestCase
14
{
15
	private $object;
16
	private $products;
17
	private $addresses;
18
	private $services;
19
	private $coupons;
20
21
22
	protected function setUp()
23
	{
24
		$context = \TestHelperMShop::getContext();
25
26
		$priceManager = \Aimeos\MShop\Price\Manager\Factory::create( $context );
27
		$locale = \Aimeos\MShop\Locale\Manager\Factory::create( $context )->createItem();
28
29
		$this->object = new \Aimeos\MShop\Order\Item\Base\Standard( $priceManager->createItem(), $locale, [] );
0 ignored issues
show
Bug introduced by
$locale of type Aimeos\MShop\Attribute\Item\Iface is incompatible with the type Aimeos\MShop\Locale\Item\Iface expected by parameter $locale of Aimeos\MShop\Order\Item\...Standard::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

29
		$this->object = new \Aimeos\MShop\Order\Item\Base\Standard( $priceManager->createItem(), /** @scrutinizer ignore-type */ $locale, [] );
Loading history...
Bug introduced by
$priceManager->createItem() of type Aimeos\MShop\Attribute\Item\Iface is incompatible with the type Aimeos\MShop\Price\Item\Iface expected by parameter $price of Aimeos\MShop\Order\Item\...Standard::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

29
		$this->object = new \Aimeos\MShop\Order\Item\Base\Standard( /** @scrutinizer ignore-type */ $priceManager->createItem(), $locale, [] );
Loading history...
30
31
32
		$orderManager = \Aimeos\MShop\Order\Manager\Factory::create( $context );
33
34
		$orderBaseManager = $orderManager->getSubManager( 'base' );
35
		$orderAddressManager = $orderBaseManager->getSubManager( 'address' );
36
		$orderProductManager = $orderBaseManager->getSubManager( 'product' );
37
		$orderServiceManager = $orderBaseManager->getSubManager( 'service' );
38
39
40
		$price = $priceManager->createItem();
41
		$price->setRebate( '3.01' );
0 ignored issues
show
Bug introduced by
The method setRebate() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
		$price->/** @scrutinizer ignore-call */ 
42
          setRebate( '3.01' );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
		$price->setValue( '43.12' );
0 ignored issues
show
Bug introduced by
The method setValue() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
		$price->/** @scrutinizer ignore-call */ 
43
          setValue( '43.12' );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
		$price->setCosts( '1.11' );
0 ignored issues
show
Bug introduced by
The method setCosts() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
		$price->/** @scrutinizer ignore-call */ 
44
          setCosts( '1.11' );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
		$price->setTaxRate( '0.00' );
0 ignored issues
show
Bug introduced by
The method setTaxRate() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
		$price->/** @scrutinizer ignore-call */ 
45
          setTaxRate( '0.00' );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
		$price->setCurrencyId( 'EUR' );
0 ignored issues
show
Bug introduced by
The method setCurrencyId() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

45
		$price->/** @scrutinizer ignore-call */ 
46
          setCurrencyId( 'EUR' );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
46
47
		$prod1 = $orderProductManager->createItem();
48
		$prod1->setProductCode( 'prod1' );
0 ignored issues
show
Bug introduced by
The method setProductCode() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
		$prod1->/** @scrutinizer ignore-call */ 
49
          setProductCode( 'prod1' );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
		$prod1->setPrice( $price );
0 ignored issues
show
Bug introduced by
The method setPrice() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
		$prod1->/** @scrutinizer ignore-call */ 
50
          setPrice( $price );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
50
51
		$price = $priceManager->createItem();
52
		$price->setRebate( '4.00' );
53
		$price->setValue( '20.00' );
54
		$price->setCosts( '2.00' );
55
		$price->setTaxRate( '0.50' );
56
		$price->setCurrencyId( 'EUR' );
57
58
		$prod2 = $orderProductManager->createItem();
59
		$prod2->setProductCode( 'prod2' );
60
		$prod2->setPrice( $price );
61
62
63
		$this->products = [$prod1, $prod2];
64
		$this->coupons = ['OPQR' => [$prod1]];
65
66
		$this->addresses = array(
67
			'payment' => [0 => $orderAddressManager->createItem()->setType( 'payment' )->setId( null )],
68
			'delivery' => [0 => $orderAddressManager->createItem()->setType( 'delivery' )->setId( null )],
69
		);
70
71
		$this->services = array(
72
			'payment' => [0 => $orderServiceManager->createItem()->setType( 'payment' )->setCode( 'testpay' )->setId( null )],
73
			'delivery' => [1 => $orderServiceManager->createItem()->setType( 'delivery' )->setCode( 'testship' )->setId( null )],
74
		);
75
	}
76
77
78
	protected function tearDown()
79
	{
80
		unset( $this->object, $this->products, $this->addresses, $this->services, $this->coupons );
81
	}
82
83
84
	public function testMagicMethods()
85
	{
86
		$this->assertFalse( isset( $this->object->test ) );
87
		$this->assertEquals( null, $this->object->test );
88
89
		$this->object->test = 'value';
90
91
		$this->assertTrue( isset( $this->object->test ) );
92
		$this->assertEquals( 'value', $this->object->test );
93
	}
94
95
96
	public function testGetSet()
97
	{
98
		$this->assertEquals( false, $this->object->get( 'test', false ) );
99
100
		$this->object->set( 'test', 'value' );
101
102
		$this->assertEquals( 'value', $this->object->get( 'test', false ) );
103
	}
104
105
106
	public function testIsModified()
107
	{
108
		$this->assertFalse( $this->object->isModified() );
109
	}
110
111
112
	public function testAddProductAppend()
113
	{
114
		$this->object->setProducts( $this->products );
115
116
		$products = $this->object->getProducts();
117
		$product = $this->createProduct( 'prodid3' );
118
		$products[] = $product;
119
120
		$result = $this->object->addProduct( $product );
121
122
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
123
		$this->assertSame( $products, $this->object->getProducts() );
124
		$this->assertSame( $product, $this->object->getProduct( 2 ) );
125
		$this->assertTrue( $this->object->isModified() );
126
	}
127
128
129
	public function testAddProductInsert()
130
	{
131
		$this->object->setProducts( $this->products );
132
133
		$products = $this->object->getProducts();
134
		$products[1] = $this->createProduct( 'prodid3' );
135
136
		$result = $this->object->addProduct( $products[1], 1 );
137
138
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
139
		$this->assertSame( $products[1], $this->object->getProduct( 1 ) );
140
		$this->assertEquals( $products, $this->object->getProducts() );
141
		$this->assertTrue( $this->object->isModified() );
142
	}
143
144
145
	public function testAddProductInsertEnd()
146
	{
147
		$this->object->setProducts( $this->products );
148
149
		$products = $this->object->getProducts();
150
		$product = $this->createProduct( 'prodid3' );
151
		$products[] = $product;
152
153
		$result = $this->object->addProduct( $product, 2 );
154
155
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
156
		$this->assertEquals( $products, $this->object->getProducts() );
157
		$this->assertSame( $product, $this->object->getProduct( 2 ) );
158
		$this->assertTrue( $this->object->isModified() );
159
	}
160
161
162
	public function testAddProductSame()
163
	{
164
		$product = $this->createProduct( 'prodid3' )->setQuantity( 5 );
0 ignored issues
show
Bug introduced by
The method setQuantity() does not exist on Aimeos\MShop\Attribute\Item\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

164
		$product = $this->createProduct( 'prodid3' )->/** @scrutinizer ignore-call */ setQuantity( 5 );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
165
166
		$this->object->addProduct( $product );
167
		$this->object->addProduct( $product );
168
169
		$this->assertEquals( 10, $this->object->getProduct( 0 )->getQuantity() );
170
		$this->assertEquals( [0 => $product], $this->object->getProducts() );
171
		$this->assertTrue( $this->object->isModified() );
172
	}
173
174
175
	public function testAddProductStablePosition()
176
	{
177
		$this->object->setProducts( $this->products );
178
179
		$product = $this->createProduct( 'prodid3' )->setQuantity( 5 );
180
		$this->object->addProduct( $product );
181
182
		$testProduct = $this->object->getProduct( 1 );
183
		$this->object->deleteProduct( 0 );
184
		$this->object->deleteProduct( 1 );
185
		$result = $this->object->addProduct( $testProduct, 1 );
186
187
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
188
		$this->assertEquals( [1 => $testProduct, 2 => $product], $this->object->getProducts() );
189
	}
190
191
192
	public function testDeleteProduct()
193
	{
194
		$this->object->addProduct( $this->products[0] );
195
		$result = $this->object->deleteProduct( 0 );
196
197
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
198
		$this->assertSame( [], $this->object->getProducts() );
199
		$this->assertTrue( $this->object->isModified() );
200
	}
201
202
203
	public function testGetProducts()
204
	{
205
		$this->object->setProducts( $this->products );
206
207
		$this->assertSame( $this->products, $this->object->getProducts() );
208
		$this->assertSame( $this->products[1], $this->object->getProduct( 1 ) );
209
	}
210
211
212
	public function testSetProducts()
213
	{
214
		$result = $this->object->setProducts( $this->products );
215
216
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
217
		$this->assertSame( $this->products, $this->object->getProducts() );
218
		$this->assertTrue( $this->object->isModified() );
219
	}
220
221
222
	public function testAddAddress()
223
	{
224
		$type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT;
225
		$result = $this->object->addAddress( $this->addresses[$type][0], $type );
226
227
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
228
		$this->assertEquals( $this->addresses[$type], $this->object->getAddress( $type ) );
229
		$this->assertTrue( $this->object->isModified() );
230
	}
231
232
233
	public function testAddAddressMultiple()
234
	{
235
		$this->object->addAddress( $this->addresses['payment'][0], 'payment' );
236
		$result = $this->object->addAddress( $this->addresses['payment'][0], 'payment' );
237
238
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
239
		$this->assertEquals( 2, count( $this->object->getAddress( 'payment' ) ) );
240
		$this->assertTrue( $this->object->isModified() );
241
	}
242
243
244
	public function testAddAddressPosition()
245
	{
246
		$type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT;
247
248
		$this->object->addAddress( $this->addresses[$type][0], $type );
249
		$result = $this->object->addAddress( $this->addresses[$type][0], $type, 0 );
250
251
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
252
		$this->assertEquals( $this->addresses[$type], $this->object->getAddress( $type ) );
253
		$this->assertTrue( $this->object->isModified() );
254
	}
255
256
257
	public function testDeleteAddress()
258
	{
259
		$type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT;
260
		$this->object->setAddresses( $this->addresses );
261
		$result = $this->object->deleteAddress( $type );
262
263
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
264
		$this->assertEquals( [], $this->object->getAddress( $type ) );
265
		$this->assertTrue( $this->object->isModified() );
266
	}
267
268
269
	public function testDeleteAddressPosition()
270
	{
271
		$type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT;
272
		$this->object->setAddresses( $this->addresses );
273
274
		$result = $this->object->deleteAddress( $type, 0 );
275
276
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
277
		$this->assertEquals( [], $this->object->getAddress( $type ) );
278
		$this->assertTrue( $this->object->isModified() );
279
	}
280
281
282
	public function testDeleteAddressPositionInvalid()
283
	{
284
		$type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT;
285
		$this->object->setAddresses( $this->addresses );
286
287
		$result = $this->object->deleteAddress( $type, 1 );
288
289
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
290
		$this->assertEquals( $this->addresses[$type], $this->object->getAddress( $type ) );
291
	}
292
293
294
	public function testGetAddress()
295
	{
296
		$this->object->setAddresses( $this->addresses );
297
		$type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT;
298
299
		$this->assertEquals( $this->addresses[$type], $this->object->getAddress( $type ) );
300
	}
301
302
303
	public function testGetAddressSingle()
304
	{
305
		$this->object->setAddresses( $this->addresses );
306
		$type = \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT;
307
308
		$this->assertEquals( $this->addresses[$type][0], $this->object->getAddress( $type, 0 ) );
309
	}
310
311
312
	public function testGetAddressException()
313
	{
314
		$this->setExpectedException( \Aimeos\MShop\Order\Exception::class );
315
		$this->object->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT, 0 );
316
	}
317
318
319
	public function testSetAddresses()
320
	{
321
		$result = $this->object->setAddresses( $this->addresses );
322
323
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
324
		$this->assertEquals( $this->addresses, $this->object->getAddresses() );
325
		$this->assertTrue( $this->object->isModified() );
326
	}
327
328
329
	public function testAddService()
330
	{
331
		$type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT;
332
		$result = $this->object->addService( $this->services[$type][0], $type );
333
334
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
335
		$this->assertEquals( 1, count( $this->object->getService( $type ) ) );
336
		$this->assertTrue( $this->object->isModified() );
337
	}
338
339
340
	public function testAddServicePosition()
341
	{
342
		$type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT;
343
344
		$this->object->addService( $this->services[$type][0], $type );
345
		$result = $this->object->addService( $this->services[$type][0], $type, 0 );
346
347
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
348
		$this->assertEquals( 1, count( $this->object->getService( $type ) ) );
349
		$this->assertTrue( $this->object->isModified() );
350
	}
351
352
353
	public function testDeleteService()
354
	{
355
		$type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT;
356
		$this->object->setServices( $this->services );
357
358
		$result = $this->object->deleteService( $type );
359
360
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
361
		$this->assertEquals( [], $this->object->getService( $type ) );
362
		$this->assertTrue( $this->object->isModified() );
363
	}
364
365
366
	public function testDeleteServicePosition()
367
	{
368
		$type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT;
369
		$this->object->setServices( $this->services );
370
371
		$result = $this->object->deleteService( $type, 0 );
372
373
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
374
		$this->assertEquals( [], $this->object->getService( $type ) );
375
		$this->assertTrue( $this->object->isModified() );
376
	}
377
378
379
	public function testDeleteServicePositionInvalid()
380
	{
381
		$type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT;
382
		$this->object->setServices( $this->services );
383
384
		$result = $this->object->deleteService( $type, 1 );
385
386
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
387
		$this->assertEquals( $this->services[$type], $this->object->getService( $type ) );
388
	}
389
390
391
	public function testGetService()
392
	{
393
		$this->object->setServices( $this->services );
394
395
		$payments = $this->object->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT );
396
		$deliveries = $this->object->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY );
397
398
		$this->assertEquals( 2, count( $this->object->getServices() ) );
399
		$this->assertEquals( 1, count( $payments ) );
400
		$this->assertEquals( 1, count( $deliveries ) );
401
402
		$this->assertEquals( $this->services['payment'], $payments );
403
		$this->assertEquals( $this->services['delivery'], $deliveries );
404
	}
405
406
407
	public function testGetServiceSingle()
408
	{
409
		$this->object->setServices( $this->services );
410
411
		$service = $this->object->getService( 'payment', 0 );
412
		$this->assertEquals( 'testpay', $service->getCode() );
413
	}
414
415
416
	public function testGetServiceException()
417
	{
418
		$this->setExpectedException( \Aimeos\MShop\Order\Exception::class );
419
		$this->object->getService( 'payment', 100 );
420
	}
421
422
423
	public function testSetServices()
424
	{
425
		$result = $this->object->setServices( $this->services );
426
427
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
428
		$this->assertEquals( $this->services, $this->object->getServices() );
429
		$this->assertTrue( $this->object->isModified() );
430
	}
431
432
433
	public function testAddCoupon()
434
	{
435
		$result = $this->object->addCoupon( 'OPQR' );
436
437
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
438
		$this->assertEquals( ['OPQR' => []], $this->object->getCoupons() );
439
		$this->assertTrue( $this->object->isModified() );
440
	}
441
442
443
	public function testDeleteCoupon()
444
	{
445
		$this->object->setCoupons( $this->coupons );
446
		$result = $this->object->deleteCoupon( 'OPQR' );
447
448
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
449
		$this->assertEquals( [], $this->object->getCoupons() );
450
		$this->assertTrue( $this->object->isModified() );
451
	}
452
453
454
	public function testGetCoupons()
455
	{
456
		$this->object->setCoupons( $this->coupons );
457
		$this->assertEquals( $this->coupons, $this->object->getCoupons() );
458
	}
459
460
461
	public function testSetCoupon()
462
	{
463
		$result = $this->object->setCoupon( 'OPQR', $this->coupons['OPQR'] );
464
465
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
466
		$this->assertEquals( ['OPQR' => $this->coupons['OPQR']], $this->object->getCoupons() );
467
		$this->assertTrue( $this->object->isModified() );
468
	}
469
470
471
	public function testSetCoupons()
472
	{
473
		$result = $this->object->setCoupons( $this->coupons );
474
475
		$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Iface::class, $result );
476
		$this->assertEquals( $this->coupons, $this->object->getCoupons() );
477
		$this->assertTrue( $this->object->isModified() );
478
	}
479
480
481
	public function testCheck()
482
	{
483
		foreach( $this->products as $product ) {
484
			$this->object->addProduct( $product );
485
		}
486
487
		foreach( $this->addresses as $type => $addresses )
488
		{
489
			foreach( $addresses as $address ) {
490
				$this->object->addAddress( $address, $type );
491
			}
492
		}
493
494
		foreach( $this->services as $type => $services )
495
		{
496
			foreach( $services as $service ) {
497
				$this->object->addService( $service, $type );
498
			}
499
		}
500
501
		$this->object->check( \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL );
502
	}
503
504
505
	public function testCheckInvalid()
506
	{
507
		$this->setExpectedException( \Aimeos\MShop\Order\Exception::class );
508
		$this->object->check( -1 );
509
	}
510
511
512
	public function testCheckAllFailure()
513
	{
514
		$this->setExpectedException( \Aimeos\MShop\Order\Exception::class );
515
		$this->object->check( \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL );
516
	}
517
518
519
	public function testCheckProductsFailure()
520
	{
521
		$this->setExpectedException( \Aimeos\MShop\Order\Exception::class );
522
		$this->object->check( \Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT );
523
	}
524
525
526
	/**
527
	 * @param string $code
528
	 */
529
	protected function createProduct( $code )
530
	{
531
		$orderManager = \Aimeos\MShop\Order\Manager\Factory::create( \TestHelperMShop::getContext() );
532
		$orderProductManager = $orderManager->getSubManager( 'base' )->getSubManager( 'product' );
533
		$product = $orderProductManager->createItem();
534
535
		$price = \Aimeos\MShop\Price\Manager\Factory::create( \TestHelperMShop::getContext() )->createItem();
536
		$price->setValue( '2.99' );
537
538
		$product->setPrice( $price );
539
		$product->setProductCode( $code );
540
541
		return $product;
542
	}
543
}
544