1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2011 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2021 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\MShop\Order\Item\Base\Product; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
14
|
|
|
{ |
15
|
|
|
private $object; |
16
|
|
|
private $values; |
17
|
|
|
private $price; |
18
|
|
|
private $attribute = []; |
19
|
|
|
private $subProducts; |
20
|
|
|
|
21
|
|
|
|
22
|
|
|
protected function setUp() : void |
23
|
|
|
{ |
24
|
|
|
$this->price = \Aimeos\MShop\Price\Manager\Factory::create( \TestHelperMShop::getContext() )->create(); |
25
|
|
|
|
26
|
|
|
$attrValues = array( |
27
|
|
|
'order.base.product.attribute.id' => 4, |
28
|
|
|
'order.base.product.attribute.siteid' => '99', |
29
|
|
|
'order.base.product.attribute.parentid' => 11, |
30
|
|
|
'order.base.product.attribute.type' => 'default', |
31
|
|
|
'order.base.product.attribute.code' => 'size', |
32
|
|
|
'order.base.product.attribute.value' => '30', |
33
|
|
|
'order.base.product.attribute.name' => 'small', |
34
|
|
|
'order.base.product.attribute.mtime' => '2011-01-06 13:20:34', |
35
|
|
|
'order.base.product.attribute.ctime' => '2011-01-01 00:00:01', |
36
|
|
|
'order.base.product.attribute.editor' => 'unitTestUser' |
37
|
|
|
); |
38
|
|
|
$this->attribute = array( new \Aimeos\MShop\Order\Item\Base\Product\Attribute\Standard( $attrValues ) ); |
39
|
|
|
|
40
|
|
|
$this->values = array( |
41
|
|
|
'order.base.product.id' => 1, |
42
|
|
|
'order.base.product.baseid' => 42, |
43
|
|
|
'order.base.product.siteid' => '99', |
44
|
|
|
'order.base.product.orderproductid' => 10, |
45
|
|
|
'order.base.product.orderaddressid' => 11, |
46
|
|
|
'order.base.product.type' => 'bundle', |
47
|
|
|
'order.base.product.productid' => '100', |
48
|
|
|
'order.base.product.supplierid' => '123', |
49
|
|
|
'order.base.product.suppliername' => 'UnitSupplier', |
50
|
|
|
'order.base.product.prodcode' => 'UnitProd', |
51
|
|
|
'order.base.product.stocktype' => 'unittype', |
52
|
|
|
'order.base.product.timeframe' => '1-2w', |
53
|
|
|
'order.base.product.name' => 'UnitProduct', |
54
|
|
|
'order.base.product.description' => 'Unit product description', |
55
|
|
|
'order.base.product.mediaurl' => 'testurl', |
56
|
|
|
'order.base.product.target' => 'testtarget', |
57
|
|
|
'order.base.product.quantity' => 11, |
58
|
|
|
'order.base.product.qtyopen' => 5, |
59
|
|
|
'order.base.product.flags' => \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_NONE, |
60
|
|
|
'order.base.product.status' => \Aimeos\MShop\Order\Item\Base::STAT_PROGRESS, |
61
|
|
|
'order.base.product.position' => 1, |
62
|
|
|
'order.base.product.notes' => 'test note', |
63
|
|
|
'order.base.product.mtime' => '2000-12-31 23:59:59', |
64
|
|
|
'order.base.product.ctime' => '2011-01-01 00:00:01', |
65
|
|
|
'order.base.product.editor' => 'unitTestUser', |
66
|
|
|
'.product' => \Aimeos\MShop::create( \TestHelperMShop::getContext(), 'product' )->create(), |
67
|
|
|
'.supplier' => \Aimeos\MShop::create( \TestHelperMShop::getContext(), 'supplier' )->create(), |
68
|
|
|
); |
69
|
|
|
|
70
|
|
|
$this->subProducts = array( |
71
|
|
|
new \Aimeos\MShop\Order\Item\Base\Product\Standard( clone $this->price ), |
72
|
|
|
new \Aimeos\MShop\Order\Item\Base\Product\Standard( clone $this->price ) |
73
|
|
|
); |
74
|
|
|
|
75
|
|
|
$this->object = new \Aimeos\MShop\Order\Item\Base\Product\Standard( |
76
|
|
|
$this->price, $this->values, $this->attribute, $this->subProducts |
77
|
|
|
); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
protected function tearDown() : void |
82
|
|
|
{ |
83
|
|
|
unset( $this->object ); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
public function testGetProductItem() |
88
|
|
|
{ |
89
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Product\Item\Iface::class, $this->object->getProductItem() ); |
90
|
|
|
$this->assertNull( ( new \Aimeos\MShop\Order\Item\Base\Product\Standard( $this->price ) )->getProductItem() ); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
public function testGetSupplierItem() |
95
|
|
|
{ |
96
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Supplier\Item\Iface::class, $this->object->getSupplierItem() ); |
97
|
|
|
$this->assertNull( ( new \Aimeos\MShop\Order\Item\Base\Product\Standard( $this->price ) )->getSupplierItem() ); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
|
101
|
|
|
public function testCompare() |
102
|
|
|
{ |
103
|
|
|
$product = new \Aimeos\MShop\Order\Item\Base\Product\Standard( $this->price, $this->values, $this->attribute, $this->subProducts ); |
104
|
|
|
$this->assertTrue( $this->object->compare( $product ) ); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
public function testCompareFail() |
109
|
|
|
{ |
110
|
|
|
$this->values['order.base.product.stocktype'] = 'default'; |
111
|
|
|
|
112
|
|
|
$product = new \Aimeos\MShop\Order\Item\Base\Product\Standard( $this->price, $this->values, $this->attribute, $this->subProducts ); |
113
|
|
|
$this->assertFalse( $this->object->compare( $product ) ); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
|
117
|
|
|
public function testGetId() |
118
|
|
|
{ |
119
|
|
|
$this->assertEquals( 1, $this->object->getId() ); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
|
123
|
|
|
public function testSetId() |
124
|
|
|
{ |
125
|
|
|
$return = $this->object->setId( null ); |
126
|
|
|
|
127
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
128
|
|
|
$this->assertEquals( null, $this->object->getId() ); |
129
|
|
|
$this->assertTrue( $this->object->isModified() ); |
130
|
|
|
|
131
|
|
|
$return = $this->object->setId( 5 ); |
132
|
|
|
|
133
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
134
|
|
|
$this->assertEquals( 5, $this->object->getId() ); |
135
|
|
|
$this->assertFalse( $this->object->isModified() ); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
|
139
|
|
|
public function testGetSiteId() |
140
|
|
|
{ |
141
|
|
|
$this->assertEquals( 99, $this->object->getSiteId() ); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
|
145
|
|
|
public function testSetSiteId() |
146
|
|
|
{ |
147
|
|
|
$this->object->setSiteId( 100 ); |
148
|
|
|
$this->assertEquals( 100, $this->object->getSiteId() ); |
149
|
|
|
$this->assertTrue( $this->object->isModified() ); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
|
153
|
|
|
public function testGetOrderProductId() |
154
|
|
|
{ |
155
|
|
|
$this->assertEquals( 10, $this->object->getOrderProductId() ); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
|
159
|
|
|
public function testSetOrderProductId() |
160
|
|
|
{ |
161
|
|
|
$return = $this->object->setOrderProductId( 1001 ); |
162
|
|
|
|
163
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
164
|
|
|
$this->assertEquals( 1001, $this->object->getOrderProductId() ); |
165
|
|
|
$this->assertTrue( $this->object->isModified() ); |
166
|
|
|
|
167
|
|
|
$return = $this->object->setOrderProductId( null ); |
168
|
|
|
|
169
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
170
|
|
|
$this->assertEquals( null, $this->object->getOrderProductId() ); |
171
|
|
|
$this->assertTrue( $this->object->isModified() ); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
|
175
|
|
|
public function testGetOrderAddressId() |
176
|
|
|
{ |
177
|
|
|
$this->assertEquals( 11, $this->object->getOrderAddressId() ); |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
|
181
|
|
|
public function testSetOrderAddressId() |
182
|
|
|
{ |
183
|
|
|
$return = $this->object->setOrderAddressId( 1011 ); |
184
|
|
|
|
185
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
186
|
|
|
$this->assertEquals( 1011, $this->object->getOrderAddressId() ); |
187
|
|
|
$this->assertTrue( $this->object->isModified() ); |
188
|
|
|
|
189
|
|
|
$return = $this->object->setOrderAddressId( null ); |
190
|
|
|
|
191
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
192
|
|
|
$this->assertEquals( null, $this->object->getOrderAddressId() ); |
193
|
|
|
$this->assertTrue( $this->object->isModified() ); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
|
197
|
|
|
public function testGetType() |
198
|
|
|
{ |
199
|
|
|
$this->assertEquals( 'bundle', $this->object->getType() ); |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
|
203
|
|
|
public function testSetType() |
204
|
|
|
{ |
205
|
|
|
$return = $this->object->setType( 'default' ); |
206
|
|
|
|
207
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
208
|
|
|
$this->assertEquals( 'default', $this->object->getType() ); |
209
|
|
|
$this->assertTrue( $this->object->isModified() ); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
|
213
|
|
|
public function testGetSupplierId() |
214
|
|
|
{ |
215
|
|
|
$this->assertEquals( '123', $this->object->getSupplierId() ); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
|
219
|
|
|
public function testSetSupplierId() |
220
|
|
|
{ |
221
|
|
|
$return = $this->object->setSupplierId( '345' ); |
222
|
|
|
|
223
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
224
|
|
|
$this->assertEquals( '345', $this->object->getSupplierId() ); |
225
|
|
|
$this->assertTrue( $this->object->isModified() ); |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
|
229
|
|
|
public function testGetSupplierName() |
230
|
|
|
{ |
231
|
|
|
$this->assertEquals( 'UnitSupplier', $this->object->getSupplierName() ); |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
|
235
|
|
|
public function testSetSupplierName() |
236
|
|
|
{ |
237
|
|
|
$return = $this->object->setSupplierName( 'test supplier' ); |
238
|
|
|
|
239
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
240
|
|
|
$this->assertEquals( 'test supplier', $this->object->getSupplierName() ); |
241
|
|
|
$this->assertTrue( $this->object->isModified() ); |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
|
245
|
|
|
public function testGetProductId() |
246
|
|
|
{ |
247
|
|
|
$this->assertEquals( 100, $this->object->getProductId() ); |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
|
251
|
|
|
public function testSetProductId() |
252
|
|
|
{ |
253
|
|
|
$return = $this->object->setProductId( 'testProdId' ); |
254
|
|
|
|
255
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
256
|
|
|
$this->assertEquals( 'testProdId', $this->object->getProductId() ); |
257
|
|
|
$this->assertTrue( $this->object->isModified() ); |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
|
261
|
|
|
public function testGetProductCode() |
262
|
|
|
{ |
263
|
|
|
$this->assertEquals( 'UnitProd', $this->object->getProductCode() ); |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
|
267
|
|
|
public function testSetProductCode() |
268
|
|
|
{ |
269
|
|
|
$return = $this->object->setProductCode( 'testProdCode' ); |
270
|
|
|
|
271
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
272
|
|
|
$this->assertEquals( 'testProdCode', $this->object->getProductCode() ); |
273
|
|
|
$this->assertTrue( $this->object->isModified() ); |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
|
277
|
|
|
public function testGetStockType() |
278
|
|
|
{ |
279
|
|
|
$this->assertEquals( 'unittype', $this->object->getStockType() ); |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
|
283
|
|
|
public function testSetStockType() |
284
|
|
|
{ |
285
|
|
|
$return = $this->object->setStockType( 'testStockType' ); |
286
|
|
|
|
287
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
288
|
|
|
$this->assertEquals( 'testStockType', $this->object->getStockType() ); |
289
|
|
|
$this->assertTrue( $this->object->isModified() ); |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
|
293
|
|
|
public function testGetName() |
294
|
|
|
{ |
295
|
|
|
$this->assertEquals( 'UnitProduct', $this->object->getName() ); |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
|
299
|
|
|
public function testSetName() |
300
|
|
|
{ |
301
|
|
|
$return = $this->object->setName( 'Testname2' ); |
302
|
|
|
|
303
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
304
|
|
|
$this->assertEquals( 'Testname2', $this->object->getName() ); |
305
|
|
|
$this->assertTrue( $this->object->isModified() ); |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
|
309
|
|
|
public function testGetDescription() |
310
|
|
|
{ |
311
|
|
|
$this->assertEquals( 'Unit product description', $this->object->getDescription() ); |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
|
315
|
|
|
public function testSetDescription() |
316
|
|
|
{ |
317
|
|
|
$return = $this->object->setDescription( 'Test description' ); |
318
|
|
|
|
319
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
320
|
|
|
$this->assertEquals( 'Test description', $this->object->getDescription() ); |
321
|
|
|
$this->assertTrue( $this->object->isModified() ); |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
|
325
|
|
|
public function testGetMediaUrl() |
326
|
|
|
{ |
327
|
|
|
$this->assertEquals( 'testurl', $this->object->getMediaUrl() ); |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
|
331
|
|
|
public function testSetMediaUrl() |
332
|
|
|
{ |
333
|
|
|
$return = $this->object->setMediaUrl( 'testUrl' ); |
334
|
|
|
|
335
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
336
|
|
|
$this->assertEquals( 'testUrl', $this->object->getMediaUrl() ); |
337
|
|
|
$this->assertTrue( $this->object->isModified() ); |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
|
341
|
|
|
public function testGetTarget() |
342
|
|
|
{ |
343
|
|
|
$this->assertEquals( 'testtarget', $this->object->getTarget() ); |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
|
347
|
|
|
public function testSetTarget() |
348
|
|
|
{ |
349
|
|
|
$return = $this->object->setTarget( 'ttarget' ); |
350
|
|
|
|
351
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
352
|
|
|
$this->assertEquals( 'ttarget', $this->object->getTarget() ); |
353
|
|
|
$this->assertTrue( $this->object->isModified() ); |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
|
357
|
|
|
public function testGetTimeFrame() |
358
|
|
|
{ |
359
|
|
|
$this->assertEquals( '1-2w', $this->object->getTimeFrame() ); |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
|
363
|
|
|
public function testSetTimeFrame() |
364
|
|
|
{ |
365
|
|
|
$return = $this->object->setTimeFrame( '3-4d' ); |
366
|
|
|
|
367
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
368
|
|
|
$this->assertEquals( '3-4d', $this->object->getTimeFrame() ); |
369
|
|
|
$this->assertTrue( $this->object->isModified() ); |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
|
373
|
|
|
public function testGetQuantity() |
374
|
|
|
{ |
375
|
|
|
$this->assertEquals( 11, $this->object->getQuantity() ); |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
|
379
|
|
|
public function testSetQuantity() |
380
|
|
|
{ |
381
|
|
|
$return = $this->object->setQuantity( 20 ); |
382
|
|
|
|
383
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
384
|
|
|
$this->assertEquals( 20, $this->object->getQuantity() ); |
385
|
|
|
$this->assertTrue( $this->object->isModified() ); |
386
|
|
|
} |
387
|
|
|
|
388
|
|
|
|
389
|
|
|
public function testSetQuantityDecimal() |
390
|
|
|
{ |
391
|
|
|
$return = $this->object->setQuantity( 1.5 ); |
392
|
|
|
|
393
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
394
|
|
|
$this->assertEquals( 1.5, $this->object->getQuantity() ); |
395
|
|
|
$this->assertTrue( $this->object->isModified() ); |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
|
399
|
|
|
public function testSetQuantityNegative() |
400
|
|
|
{ |
401
|
|
|
$this->expectException( \Aimeos\MShop\Order\Exception::class ); |
402
|
|
|
$this->object->setQuantity( -5 ); |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
|
406
|
|
|
public function testSetQuantityZero() |
407
|
|
|
{ |
408
|
|
|
$this->expectException( \Aimeos\MShop\Order\Exception::class ); |
409
|
|
|
$this->object->setQuantity( 0 ); |
410
|
|
|
} |
411
|
|
|
|
412
|
|
|
|
413
|
|
|
public function testSetQuantityOverflow() |
414
|
|
|
{ |
415
|
|
|
$this->expectException( \Aimeos\MShop\Order\Exception::class ); |
416
|
|
|
$this->object->setQuantity( 2147483648 ); |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
|
420
|
|
|
public function testGetQuantityOpen() |
421
|
|
|
{ |
422
|
|
|
$this->assertEquals( 5, $this->object->getQuantityOpen() ); |
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
|
426
|
|
|
public function testSetQuantityOpen() |
427
|
|
|
{ |
428
|
|
|
$return = $this->object->setQuantityOpen( 3 ); |
429
|
|
|
|
430
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
431
|
|
|
$this->assertEquals( 3, $this->object->getQuantityOpen() ); |
432
|
|
|
$this->assertTrue( $this->object->isModified() ); |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
|
436
|
|
|
public function testSetQuantityOpenDecimal() |
437
|
|
|
{ |
438
|
|
|
$return = $this->object->setQuantityOpen( 1.5 ); |
439
|
|
|
|
440
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
441
|
|
|
$this->assertEquals( 1.5, $this->object->getQuantityOpen() ); |
442
|
|
|
$this->assertTrue( $this->object->isModified() ); |
443
|
|
|
} |
444
|
|
|
|
445
|
|
|
|
446
|
|
|
public function testSetQuantityOpenNegative() |
447
|
|
|
{ |
448
|
|
|
$this->expectException( \Aimeos\MShop\Order\Exception::class ); |
449
|
|
|
$this->object->setQuantityOpen( -5 ); |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
|
453
|
|
|
public function testSetQuantityOpenZero() |
454
|
|
|
{ |
455
|
|
|
$return = $this->object->setQuantityOpen( 0 ); |
456
|
|
|
|
457
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
458
|
|
|
$this->assertEquals( 0, $this->object->getQuantityOpen() ); |
459
|
|
|
$this->assertTrue( $this->object->isModified() ); |
460
|
|
|
} |
461
|
|
|
|
462
|
|
|
|
463
|
|
|
public function testSetQuantityOpenOverflow() |
464
|
|
|
{ |
465
|
|
|
$this->expectException( \Aimeos\MShop\Order\Exception::class ); |
466
|
|
|
$this->object->setQuantityOpen( 12 ); |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
|
470
|
|
|
public function testGetNotes() |
471
|
|
|
{ |
472
|
|
|
$this->assertEquals( 'test note', $this->object->getNotes() ); |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
|
476
|
|
|
public function testSetNotes() |
477
|
|
|
{ |
478
|
|
|
$return = $this->object->setNotes( 'some notes' ); |
479
|
|
|
|
480
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
481
|
|
|
$this->assertEquals( 'some notes', $this->object->getNotes() ); |
482
|
|
|
$this->assertTrue( $this->object->isModified() ); |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
|
486
|
|
|
public function testGetPrice() |
487
|
|
|
{ |
488
|
|
|
$this->assertSame( $this->price, $this->object->getPrice() ); |
489
|
|
|
} |
490
|
|
|
|
491
|
|
|
|
492
|
|
|
public function testSetPrice() |
493
|
|
|
{ |
494
|
|
|
$this->price->setValue( '5.00' ); |
495
|
|
|
$return = $this->object->setPrice( $this->price ); |
496
|
|
|
|
497
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
498
|
|
|
$this->assertSame( $this->price, $this->object->getPrice() ); |
499
|
|
|
$this->assertFalse( $this->object->isModified() ); |
500
|
|
|
} |
501
|
|
|
|
502
|
|
|
|
503
|
|
|
public function testGetFlags() |
504
|
|
|
{ |
505
|
|
|
$this->assertEquals( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_NONE, $this->object->getFlags() ); |
506
|
|
|
} |
507
|
|
|
|
508
|
|
|
|
509
|
|
|
public function testSetFlags() |
510
|
|
|
{ |
511
|
|
|
$return = $this->object->setFlags( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ); |
512
|
|
|
|
513
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
514
|
|
|
$this->assertEquals( \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE, $this->object->getFlags() ); |
515
|
|
|
$this->assertTrue( $this->object->isModified() ); |
516
|
|
|
} |
517
|
|
|
|
518
|
|
|
|
519
|
|
|
public function testGetPosition() |
520
|
|
|
{ |
521
|
|
|
$this->assertEquals( 1, $this->object->getPosition() ); |
522
|
|
|
} |
523
|
|
|
|
524
|
|
|
|
525
|
|
|
public function testSetPosition() |
526
|
|
|
{ |
527
|
|
|
$return = $this->object->setPosition( 2 ); |
528
|
|
|
|
529
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
530
|
|
|
$this->assertEquals( 2, $this->object->getPosition() ); |
531
|
|
|
$this->assertTrue( $this->object->isModified() ); |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
|
535
|
|
|
public function testSetPositionReset() |
536
|
|
|
{ |
537
|
|
|
$return = $this->object->setPosition( null ); |
538
|
|
|
|
539
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
540
|
|
|
$this->assertEquals( null, $this->object->getPosition() ); |
541
|
|
|
$this->assertTrue( $this->object->isModified() ); |
542
|
|
|
} |
543
|
|
|
|
544
|
|
|
|
545
|
|
|
public function testSetPositionInvalid() |
546
|
|
|
{ |
547
|
|
|
$this->expectException( \Aimeos\MShop\Order\Exception::class ); |
548
|
|
|
$this->object->setPosition( -1 ); |
549
|
|
|
} |
550
|
|
|
|
551
|
|
|
|
552
|
|
|
public function testGetStatus() |
553
|
|
|
{ |
554
|
|
|
$this->assertEquals( \Aimeos\MShop\Order\Item\Base::STAT_PROGRESS, $this->object->getStatus() ); |
555
|
|
|
} |
556
|
|
|
|
557
|
|
|
|
558
|
|
|
public function testSetStatus() |
559
|
|
|
{ |
560
|
|
|
$return = $this->object->setStatus( \Aimeos\MShop\Order\Item\Base::STAT_LOST ); |
561
|
|
|
|
562
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
563
|
|
|
$this->assertEquals( \Aimeos\MShop\Order\Item\Base::STAT_LOST, $this->object->getStatus() ); |
564
|
|
|
$this->assertTrue( $this->object->isModified() ); |
565
|
|
|
} |
566
|
|
|
|
567
|
|
|
|
568
|
|
|
public function testGetBaseId() |
569
|
|
|
{ |
570
|
|
|
$this->assertEquals( 42, $this->object->getBaseId() ); |
571
|
|
|
} |
572
|
|
|
|
573
|
|
|
|
574
|
|
|
public function testSetBaseId() |
575
|
|
|
{ |
576
|
|
|
$return = $this->object->setBaseId( 111 ); |
577
|
|
|
|
578
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
579
|
|
|
$this->assertEquals( 111, $this->object->getBaseId() ); |
580
|
|
|
$this->assertTrue( $this->object->isModified() ); |
581
|
|
|
} |
582
|
|
|
|
583
|
|
|
|
584
|
|
|
public function testSetBaseIdReset() |
585
|
|
|
{ |
586
|
|
|
$return = $this->object->setBaseId( null ); |
587
|
|
|
|
588
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
589
|
|
|
$this->assertEquals( null, $this->object->getBaseId() ); |
590
|
|
|
$this->assertTrue( $this->object->isModified() ); |
591
|
|
|
} |
592
|
|
|
|
593
|
|
|
|
594
|
|
|
public function testGetTimeModified() |
595
|
|
|
{ |
596
|
|
|
$regexp = '/^[0-9]{4}-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]$/'; |
597
|
|
|
$this->assertRegExp( $regexp, $this->object->getTimeModified() ); |
598
|
|
|
$this->assertEquals( '2000-12-31 23:59:59', $this->object->getTimeModified() ); |
599
|
|
|
} |
600
|
|
|
|
601
|
|
|
|
602
|
|
|
public function testGetTimeCreated() |
603
|
|
|
{ |
604
|
|
|
$this->assertEquals( '2011-01-01 00:00:01', $this->object->getTimeCreated() ); |
605
|
|
|
} |
606
|
|
|
|
607
|
|
|
|
608
|
|
|
public function testGetEditor() |
609
|
|
|
{ |
610
|
|
|
$this->assertEquals( 'unitTestUser', $this->object->getEditor() ); |
611
|
|
|
} |
612
|
|
|
|
613
|
|
|
|
614
|
|
|
public function testGetAttribute() |
615
|
|
|
{ |
616
|
|
|
$manager = \Aimeos\MShop\Order\Manager\Factory::create( \TestHelperMShop::getContext() ); |
617
|
|
|
$attManager = $manager->getSubManager( 'base' )->getSubManager( 'product' )->getSubManager( 'attribute' ); |
618
|
|
|
|
619
|
|
|
$attrItem001 = $attManager->create(); |
620
|
|
|
$attrItem001->setAttributeId( '1' ); |
621
|
|
|
$attrItem001->setCode( 'code_001' ); |
622
|
|
|
$attrItem001->setValue( 'value_001' ); |
623
|
|
|
|
624
|
|
|
$attrItem002 = $attManager->create(); |
625
|
|
|
$attrItem002->setAttributeId( '2' ); |
626
|
|
|
$attrItem002->setCode( 'code_002' ); |
627
|
|
|
$attrItem002->setType( 'test_002' ); |
628
|
|
|
$attrItem002->setValue( 'value_002' ); |
629
|
|
|
|
630
|
|
|
$this->object->setAttributeItems( array( $attrItem001, $attrItem002 ) ); |
631
|
|
|
|
632
|
|
|
$result = $this->object->getAttribute( 'code_001' ); |
633
|
|
|
$this->assertEquals( 'value_001', $result ); |
634
|
|
|
|
635
|
|
|
$result = $this->object->getAttribute( 'code_002', ['test_002'] ); |
636
|
|
|
$this->assertEquals( 'value_002', $result ); |
637
|
|
|
|
638
|
|
|
$result = $this->object->getAttribute( 'code_002', 'test_002' ); |
639
|
|
|
$this->assertEquals( 'value_002', $result ); |
640
|
|
|
|
641
|
|
|
$result = $this->object->getAttribute( 'code_002' ); |
642
|
|
|
$this->assertEquals( null, $result ); |
643
|
|
|
|
644
|
|
|
$result = $this->object->getAttribute( 'code_003' ); |
645
|
|
|
$this->assertEquals( null, $result ); |
646
|
|
|
|
647
|
|
|
$this->object->setAttributeItems( [] ); |
648
|
|
|
|
649
|
|
|
$result = $this->object->getAttribute( 'code_001' ); |
650
|
|
|
$this->assertEquals( null, $result ); |
651
|
|
|
} |
652
|
|
|
|
653
|
|
|
|
654
|
|
|
public function testGetAttributeList() |
655
|
|
|
{ |
656
|
|
|
$manager = \Aimeos\MShop\Order\Manager\Factory::create( \TestHelperMShop::getContext() ); |
657
|
|
|
$attManager = $manager->getSubManager( 'base' )->getSubManager( 'product' )->getSubManager( 'attribute' ); |
658
|
|
|
|
659
|
|
|
$attrItem001 = $attManager->create(); |
660
|
|
|
$attrItem001->setAttributeId( '1' ); |
661
|
|
|
$attrItem001->setCode( 'code_001' ); |
662
|
|
|
$attrItem001->setType( 'test_001' ); |
663
|
|
|
$attrItem001->setValue( 'value_001' ); |
664
|
|
|
|
665
|
|
|
$attrItem002 = $attManager->create(); |
666
|
|
|
$attrItem002->setAttributeId( '2' ); |
667
|
|
|
$attrItem002->setCode( 'code_001' ); |
668
|
|
|
$attrItem002->setType( 'test_001' ); |
669
|
|
|
$attrItem002->setValue( 'value_002' ); |
670
|
|
|
|
671
|
|
|
$this->object->setAttributeItems( array( $attrItem001, $attrItem002 ) ); |
672
|
|
|
|
673
|
|
|
$result = $this->object->getAttribute( 'code_001', 'test_001' ); |
674
|
|
|
$this->assertEquals( ['value_001', 'value_002'], $result ); |
675
|
|
|
} |
676
|
|
|
|
677
|
|
|
|
678
|
|
|
public function testGetAttributeItem() |
679
|
|
|
{ |
680
|
|
|
$manager = \Aimeos\MShop\Order\Manager\Factory::create( \TestHelperMShop::getContext() ); |
681
|
|
|
$attManager = $manager->getSubManager( 'base' )->getSubManager( 'product' )->getSubManager( 'attribute' ); |
682
|
|
|
|
683
|
|
|
$attrItem001 = $attManager->create(); |
684
|
|
|
$attrItem001->setAttributeId( '1' ); |
685
|
|
|
$attrItem001->setCode( 'code_001' ); |
686
|
|
|
$attrItem001->setValue( 'value_001' ); |
687
|
|
|
|
688
|
|
|
$attrItem002 = $attManager->create(); |
689
|
|
|
$attrItem002->setAttributeId( '2' ); |
690
|
|
|
$attrItem002->setCode( 'code_002' ); |
691
|
|
|
$attrItem002->setType( 'test_002' ); |
692
|
|
|
$attrItem002->setValue( 'value_002' ); |
693
|
|
|
|
694
|
|
|
$this->object->setAttributeItems( array( $attrItem001, $attrItem002 ) ); |
695
|
|
|
|
696
|
|
|
$result = $this->object->getAttributeItem( 'code_001' ); |
697
|
|
|
$this->assertEquals( 'value_001', $result->getValue() ); |
698
|
|
|
|
699
|
|
|
$result = $this->object->getAttributeItem( 'code_002', 'test_002' ); |
700
|
|
|
$this->assertEquals( 'value_002', $result->getValue() ); |
701
|
|
|
|
702
|
|
|
$result = $this->object->getAttributeItem( 'code_002' ); |
703
|
|
|
$this->assertEquals( null, $result ); |
704
|
|
|
|
705
|
|
|
$result = $this->object->getAttribute( 'code_003' ); |
706
|
|
|
$this->assertEquals( null, $result ); |
707
|
|
|
|
708
|
|
|
$this->object->setAttributeItems( [] ); |
709
|
|
|
|
710
|
|
|
$result = $this->object->getAttribute( 'code_001' ); |
711
|
|
|
$this->assertEquals( null, $result ); |
712
|
|
|
} |
713
|
|
|
|
714
|
|
|
|
715
|
|
|
public function testGetAttributeItemList() |
716
|
|
|
{ |
717
|
|
|
$manager = \Aimeos\MShop\Order\Manager\Factory::create( \TestHelperMShop::getContext() ); |
718
|
|
|
$attManager = $manager->getSubManager( 'base' )->getSubManager( 'product' )->getSubManager( 'attribute' ); |
719
|
|
|
|
720
|
|
|
$attrItem001 = $attManager->create(); |
721
|
|
|
$attrItem001->setAttributeId( '1' ); |
722
|
|
|
$attrItem001->setCode( 'code_001' ); |
723
|
|
|
$attrItem001->setType( 'test_001' ); |
724
|
|
|
$attrItem001->setValue( 'value_001' ); |
725
|
|
|
|
726
|
|
|
$attrItem002 = $attManager->create(); |
727
|
|
|
$attrItem002->setAttributeId( '2' ); |
728
|
|
|
$attrItem002->setCode( 'code_001' ); |
729
|
|
|
$attrItem002->setType( 'test_001' ); |
730
|
|
|
$attrItem002->setValue( 'value_002' ); |
731
|
|
|
|
732
|
|
|
$this->object->setAttributeItems( array( $attrItem001, $attrItem002 ) ); |
733
|
|
|
|
734
|
|
|
$result = $this->object->getAttributeItem( 'code_001', 'test_001' ); |
735
|
|
|
$this->assertEquals( 2, count( $result ) ); |
736
|
|
|
} |
737
|
|
|
|
738
|
|
|
|
739
|
|
|
public function testGetAttributeItems() |
740
|
|
|
{ |
741
|
|
|
$this->assertEquals( $this->attribute, $this->object->getAttributeItems()->toArray() ); |
742
|
|
|
} |
743
|
|
|
|
744
|
|
|
|
745
|
|
|
public function testGetAttributeItemsByType() |
746
|
|
|
{ |
747
|
|
|
$this->assertEquals( $this->attribute, $this->object->getAttributeItems( 'default' )->toArray() ); |
748
|
|
|
} |
749
|
|
|
|
750
|
|
|
|
751
|
|
|
public function testGetAttributeItemsInvalidType() |
752
|
|
|
{ |
753
|
|
|
$this->assertEquals( [], $this->object->getAttributeItems( 'invalid' )->toArray() ); |
754
|
|
|
} |
755
|
|
|
|
756
|
|
|
|
757
|
|
|
public function testSetAttributeItem() |
758
|
|
|
{ |
759
|
|
|
$manager = \Aimeos\MShop\Order\Manager\Factory::create( \TestHelperMShop::getContext() ); |
760
|
|
|
$attManager = $manager->getSubManager( 'base' )->getSubManager( 'product' )->getSubManager( 'attribute' ); |
761
|
|
|
|
762
|
|
|
$item = $attManager->create(); |
763
|
|
|
$item->setAttributeId( '1' ); |
764
|
|
|
$item->setCode( 'test_code' ); |
765
|
|
|
$item->setType( 'test_type' ); |
766
|
|
|
$item->setValue( 'test_value' ); |
767
|
|
|
|
768
|
|
|
$return = $this->object->setAttributeItem( $item ); |
769
|
|
|
|
770
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
771
|
|
|
$this->assertEquals( 'test_value', $this->object->getAttributeItem( 'test_code', 'test_type' )->getValue() ); |
772
|
|
|
$this->assertTrue( $this->object->isModified() ); |
773
|
|
|
|
774
|
|
|
|
775
|
|
|
$item = $attManager->create(); |
776
|
|
|
$item->setAttributeId( '1' ); |
777
|
|
|
$item->setCode( 'test_code' ); |
778
|
|
|
$item->setType( 'test_type' ); |
779
|
|
|
$item->setValue( 'test_value2' ); |
780
|
|
|
|
781
|
|
|
$return = $this->object->setAttributeItem( $item ); |
782
|
|
|
|
783
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
784
|
|
|
$this->assertEquals( 'test_value2', $this->object->getAttributeItem( 'test_code', 'test_type' )->getValue() ); |
785
|
|
|
$this->assertTrue( $this->object->isModified() ); |
786
|
|
|
} |
787
|
|
|
|
788
|
|
|
|
789
|
|
|
public function testSetAttributeItems() |
790
|
|
|
{ |
791
|
|
|
$manager = \Aimeos\MShop\Order\Manager\Factory::create( \TestHelperMShop::getContext() ); |
792
|
|
|
$attManager = $manager->getSubManager( 'base' )->getSubManager( 'product' )->getSubManager( 'attribute' ); |
793
|
|
|
|
794
|
|
|
$list = array( |
795
|
|
|
$attManager->create(), |
796
|
|
|
$attManager->create(), |
797
|
|
|
); |
798
|
|
|
|
799
|
|
|
$return = $this->object->setAttributeItems( $list ); |
800
|
|
|
|
801
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
802
|
|
|
$this->assertEquals( $list, $this->object->getAttributeItems()->toArray() ); |
803
|
|
|
$this->assertTrue( $this->object->isModified() ); |
804
|
|
|
} |
805
|
|
|
|
806
|
|
|
|
807
|
|
|
public function testGetProducts() |
808
|
|
|
{ |
809
|
|
|
$this->assertEquals( $this->subProducts, $this->object->getProducts()->toArray() ); |
810
|
|
|
} |
811
|
|
|
|
812
|
|
|
|
813
|
|
|
public function testSetProducts() |
814
|
|
|
{ |
815
|
|
|
$return = $this->object->setProducts( [] ); |
816
|
|
|
|
817
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
818
|
|
|
$this->assertEquals( [], $this->object->getProducts()->toArray() ); |
819
|
|
|
|
820
|
|
|
$return = $this->object->setProducts( $this->subProducts ); |
821
|
|
|
|
822
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
823
|
|
|
$this->assertEquals( $this->subProducts, $this->object->getProducts()->toArray() ); |
824
|
|
|
$this->assertTrue( $this->object->isModified() ); |
825
|
|
|
} |
826
|
|
|
|
827
|
|
|
|
828
|
|
|
public function testGetResourceType() |
829
|
|
|
{ |
830
|
|
|
$this->assertEquals( 'order/base/product', $this->object->getResourceType() ); |
831
|
|
|
} |
832
|
|
|
|
833
|
|
|
|
834
|
|
|
public function testFromArray() |
835
|
|
|
{ |
836
|
|
|
$item = new \Aimeos\MShop\Order\Item\Base\Product\Standard( new \Aimeos\MShop\Price\Item\Standard() ); |
837
|
|
|
|
838
|
|
|
$list = $entries = array( |
839
|
|
|
'order.base.product.id' => 1, |
840
|
|
|
'order.base.product.baseid' => 2, |
841
|
|
|
'order.base.product.siteid' => 123, |
842
|
|
|
'order.base.product.orderproductid' => 10, |
843
|
|
|
'order.base.product.orderaddressid' => 11, |
844
|
|
|
'order.base.product.productid' => 3, |
845
|
|
|
'order.base.product.prodcode' => 'test', |
846
|
|
|
'order.base.product.name' => 'test item', |
847
|
|
|
'order.base.product.description' => 'test description', |
848
|
|
|
'order.base.product.stocktype' => 'stocktype', |
849
|
|
|
'order.base.product.supplierid' => '456', |
850
|
|
|
'order.base.product.suppliername' => 'testsup', |
851
|
|
|
'order.base.product.prodcode' => 'test', |
852
|
|
|
'order.base.product.mediaurl' => '/path/to/image.jpg', |
853
|
|
|
'order.base.product.target' => 'ttarget', |
854
|
|
|
'order.base.product.timeframe' => '1-2d', |
855
|
|
|
'order.base.product.position' => 4, |
856
|
|
|
'order.base.product.quantity' => 5, |
857
|
|
|
'order.base.product.qtyopen' => 3, |
858
|
|
|
'order.base.product.status' => 0, |
859
|
|
|
'order.base.product.flags' => 1, |
860
|
|
|
'order.base.product.notes' => 'note', |
861
|
|
|
'order.base.product.price' => '10.00', |
862
|
|
|
'order.base.product.costs' => '5.00', |
863
|
|
|
'order.base.product.rebate' => '2.00', |
864
|
|
|
'order.base.product.taxrate' => '20.00', |
865
|
|
|
); |
866
|
|
|
|
867
|
|
|
$item = $item->fromArray( $entries, true ); |
868
|
|
|
|
869
|
|
|
$this->assertEquals( [], $entries ); |
870
|
|
|
$this->assertEquals( $list['order.base.product.id'], $item->getId() ); |
871
|
|
|
$this->assertEquals( $list['order.base.product.baseid'], $item->getBaseId() ); |
872
|
|
|
$this->assertEquals( $list['order.base.product.siteid'], $item->getSiteId() ); |
873
|
|
|
$this->assertEquals( $list['order.base.product.orderproductid'], $item->getOrderProductId() ); |
874
|
|
|
$this->assertEquals( $list['order.base.product.orderaddressid'], $item->getOrderAddressId() ); |
875
|
|
|
$this->assertEquals( $list['order.base.product.productid'], $item->getProductId() ); |
876
|
|
|
$this->assertEquals( $list['order.base.product.prodcode'], $item->getProductCode() ); |
877
|
|
|
$this->assertEquals( $list['order.base.product.name'], $item->getName() ); |
878
|
|
|
$this->assertEquals( $list['order.base.product.description'], $item->getDescription() ); |
879
|
|
|
$this->assertEquals( $list['order.base.product.stocktype'], $item->getStockType() ); |
880
|
|
|
$this->assertEquals( $list['order.base.product.supplierid'], $item->getSupplierId() ); |
881
|
|
|
$this->assertEquals( $list['order.base.product.suppliername'], $item->getSupplierName() ); |
882
|
|
|
$this->assertEquals( $list['order.base.product.prodcode'], $item->getProductCode() ); |
883
|
|
|
$this->assertEquals( $list['order.base.product.mediaurl'], $item->getMediaUrl() ); |
884
|
|
|
$this->assertEquals( $list['order.base.product.timeframe'], $item->getTimeFrame() ); |
885
|
|
|
$this->assertEquals( $list['order.base.product.target'], $item->getTarget() ); |
886
|
|
|
$this->assertEquals( $list['order.base.product.position'], $item->getPosition() ); |
887
|
|
|
$this->assertEquals( $list['order.base.product.quantity'], $item->getQuantity() ); |
888
|
|
|
$this->assertEquals( $list['order.base.product.qtyopen'], $item->getQuantityOpen() ); |
889
|
|
|
$this->assertEquals( $list['order.base.product.status'], $item->getStatus() ); |
890
|
|
|
$this->assertEquals( $list['order.base.product.flags'], $item->getFlags() ); |
891
|
|
|
$this->assertEquals( $list['order.base.product.notes'], $item->getNotes() ); |
892
|
|
|
$this->assertEquals( $list['order.base.product.price'], $item->getPrice()->getValue() ); |
893
|
|
|
$this->assertEquals( $list['order.base.product.costs'], $item->getPrice()->getCosts() ); |
894
|
|
|
$this->assertEquals( $list['order.base.product.rebate'], $item->getPrice()->getRebate() ); |
895
|
|
|
$this->assertEquals( $list['order.base.product.taxrate'], $item->getPrice()->getTaxRate() ); |
896
|
|
|
} |
897
|
|
|
|
898
|
|
|
|
899
|
|
|
public function testToArray() |
900
|
|
|
{ |
901
|
|
|
$arrayObject = $this->object->toArray( true ); |
902
|
|
|
|
903
|
|
|
$this->assertEquals( $this->object->getId(), $arrayObject['order.base.product.id'] ); |
904
|
|
|
$this->assertEquals( $this->object->getSiteId(), $arrayObject['order.base.product.siteid'] ); |
905
|
|
|
$this->assertEquals( $this->object->getBaseId(), $arrayObject['order.base.product.baseid'] ); |
906
|
|
|
$this->assertEquals( $this->object->getOrderProductId(), $arrayObject['order.base.product.orderproductid'] ); |
907
|
|
|
$this->assertEquals( $this->object->getOrderAddressId(), $arrayObject['order.base.product.orderaddressid'] ); |
908
|
|
|
$this->assertEquals( $this->object->getStockType(), $arrayObject['order.base.product.stocktype'] ); |
909
|
|
|
$this->assertEquals( $this->object->getSupplierName(), $arrayObject['order.base.product.suppliername'] ); |
910
|
|
|
$this->assertEquals( $this->object->getSupplierId(), $arrayObject['order.base.product.supplierid'] ); |
911
|
|
|
$this->assertEquals( $this->object->getProductId(), $arrayObject['order.base.product.productid'] ); |
912
|
|
|
$this->assertEquals( $this->object->getProductCode(), $arrayObject['order.base.product.prodcode'] ); |
913
|
|
|
$this->assertEquals( $this->object->getName(), $arrayObject['order.base.product.name'] ); |
914
|
|
|
$this->assertEquals( $this->object->getDescription(), $arrayObject['order.base.product.description'] ); |
915
|
|
|
$this->assertEquals( $this->object->getMediaUrl(), $arrayObject['order.base.product.mediaurl'] ); |
916
|
|
|
$this->assertEquals( $this->object->getTimeFrame(), $arrayObject['order.base.product.timeframe'] ); |
917
|
|
|
$this->assertEquals( $this->object->getTarget(), $arrayObject['order.base.product.target'] ); |
918
|
|
|
$this->assertEquals( $this->object->getPosition(), $arrayObject['order.base.product.position'] ); |
919
|
|
|
$this->assertEquals( $this->object->getPrice()->getValue(), $arrayObject['order.base.product.price'] ); |
920
|
|
|
$this->assertEquals( $this->object->getPrice()->getCosts(), $arrayObject['order.base.product.costs'] ); |
921
|
|
|
$this->assertEquals( $this->object->getPrice()->getRebate(), $arrayObject['order.base.product.rebate'] ); |
922
|
|
|
$this->assertEquals( $this->object->getPrice()->getTaxRate(), $arrayObject['order.base.product.taxrate'] ); |
923
|
|
|
$this->assertEquals( $this->object->getQuantityOpen(), $arrayObject['order.base.product.qtyopen'] ); |
924
|
|
|
$this->assertEquals( $this->object->getQuantity(), $arrayObject['order.base.product.quantity'] ); |
925
|
|
|
$this->assertEquals( $this->object->getStatus(), $arrayObject['order.base.product.status'] ); |
926
|
|
|
$this->assertEquals( $this->object->getFlags(), $arrayObject['order.base.product.flags'] ); |
927
|
|
|
$this->assertEquals( $this->object->getNotes(), $arrayObject['order.base.product.notes'] ); |
928
|
|
|
$this->assertEquals( $this->object->getTimeModified(), $arrayObject['order.base.product.mtime'] ); |
929
|
|
|
$this->assertEquals( $this->object->getTimeCreated(), $arrayObject['order.base.product.ctime'] ); |
930
|
|
|
$this->assertEquals( $this->object->getTimeModified(), $arrayObject['order.base.product.mtime'] ); |
931
|
|
|
$this->assertEquals( $this->object->getEditor(), $arrayObject['order.base.product.editor'] ); |
932
|
|
|
} |
933
|
|
|
|
934
|
|
|
|
935
|
|
|
public function testIsModified() |
936
|
|
|
{ |
937
|
|
|
$this->assertFalse( $this->object->isModified() ); |
938
|
|
|
} |
939
|
|
|
|
940
|
|
|
|
941
|
|
|
public function testCopyFrom() |
942
|
|
|
{ |
943
|
|
|
$manager = \Aimeos\MShop::create( \TestHelperMShop::getContext(), 'product' ); |
944
|
|
|
$product = $manager->find( 'CNE', ['text'] ); |
945
|
|
|
|
946
|
|
|
$productCopy = new \Aimeos\MShop\Order\Item\Base\Product\Standard( $this->price ); |
947
|
|
|
$return = $productCopy->copyFrom( $product->set( 'customprop', 'abc' ) ); |
948
|
|
|
|
949
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Base\Product\Iface::class, $return ); |
950
|
|
|
$this->assertEquals( 'default', $productCopy->getType() ); |
951
|
|
|
$this->assertEquals( 'CNE', $productCopy->getProductCode() ); |
952
|
|
|
$this->assertEquals( 'Cafe Noire Expresso', $productCopy->getName() ); |
953
|
|
|
$this->assertEquals( 'Cafe Noire Expresso for basket', $productCopy->getDescription() ); |
954
|
|
|
$this->assertEquals( $product->getId(), $productCopy->getProductId() ); |
955
|
|
|
$this->assertEquals( \Aimeos\MShop\Order\Item\Base::STAT_UNFINISHED, $productCopy->getStatus() ); |
956
|
|
|
$this->assertEquals( '', $productCopy->getSupplierName() ); |
957
|
|
|
$this->assertEquals( '', $productCopy->getMediaUrl() ); |
958
|
|
|
$this->assertEquals( '', $productCopy->getTarget() ); |
959
|
|
|
$this->assertEquals( 'abc', $productCopy->get( 'customprop' ) ); |
960
|
|
|
|
961
|
|
|
$this->assertTrue( $productCopy->isModified() ); |
962
|
|
|
} |
963
|
|
|
} |
964
|
|
|
|