1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2025 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\MShop\Order\Item\Service; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
private $context; |
15
|
|
|
private $object; |
16
|
|
|
private $values; |
17
|
|
|
private $price; |
18
|
|
|
private $attributes; |
19
|
|
|
private $transactions; |
20
|
|
|
|
21
|
|
|
|
22
|
|
|
protected function setUp() : void |
23
|
|
|
{ |
24
|
|
|
$this->context = \TestHelper::context(); |
25
|
|
|
$this->price = \Aimeos\MShop::create( $this->context, 'price' )->create(); |
26
|
|
|
|
27
|
|
|
$attrValues = array( |
28
|
|
|
'order.service.attribute.id' => 3, |
29
|
|
|
'order.service.attribute.siteid' => 99, |
30
|
|
|
'order.service.attribute.parentid' => 42, |
31
|
|
|
'order.service.attribute.name' => 'UnitName', |
32
|
|
|
'order.service.attribute.type' => 'default', |
33
|
|
|
'order.service.attribute.code' => 'UnitCode', |
34
|
|
|
'order.service.attribute.value' => 'UnitValue', |
35
|
|
|
'order.service.attribute.mtime' => '2020-12-31 23:59:59', |
36
|
|
|
'order.service.attribute.ctime' => '2011-01-01 00:00:01', |
37
|
|
|
'order.service.attribute.editor' => 'unitTestUser' |
38
|
|
|
); |
39
|
|
|
|
40
|
|
|
$this->attributes = map( [new \Aimeos\MShop\Order\Item\Service\Attribute\Standard( 'order.service.attribute.', $attrValues )] ); |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
$txValues = array( |
44
|
|
|
'order.service.transaction.id' => 3, |
45
|
|
|
'order.service.transaction.siteid' => 99, |
46
|
|
|
'order.service.transaction.parentid' => 42, |
47
|
|
|
'order.service.transaction.type' => 'payment', |
48
|
|
|
'order.service.attribute.config' => [], |
49
|
|
|
'order.service.attribute.status' => 6, |
50
|
|
|
'order.service.attribute.mtime' => '2020-12-31 23:59:59', |
51
|
|
|
'order.service.attribute.ctime' => '2011-01-01 00:00:01', |
52
|
|
|
'order.service.attribute.editor' => 'unitTestUser', |
53
|
|
|
'.price' => clone $this->price, |
54
|
|
|
); |
55
|
|
|
|
56
|
|
|
$this->transactions = map( [new \Aimeos\MShop\Order\Item\Service\Transaction\Standard( 'order.service.transaction.', $txValues )] ); |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
$this->values = array( |
60
|
|
|
'order.service.id' => 1, |
61
|
|
|
'order.service.siteid' => 99, |
62
|
|
|
'order.service.serviceid' => 'ServiceID', |
63
|
|
|
'order.service.parentid' => 42, |
64
|
|
|
'order.service.code' => 'UnitCode', |
65
|
|
|
'order.service.name' => 'UnitName', |
66
|
|
|
'order.service.mediaurl' => 'Url for test', |
67
|
|
|
'order.service.position' => 1, |
68
|
|
|
'order.service.type' => 'payment', |
69
|
|
|
'order.service.mtime' => '2012-01-01 00:00:01', |
70
|
|
|
'order.service.ctime' => '2011-01-01 00:00:01', |
71
|
|
|
'order.service.editor' => 'unitTestUser', |
72
|
|
|
'.service' => \Aimeos\MShop::create( $this->context, 'service' )->create(), |
73
|
|
|
'.transactions' => $this->transactions, |
74
|
|
|
'.attributes' => $this->attributes, |
75
|
|
|
'.price' => $this->price, |
76
|
|
|
); |
77
|
|
|
|
78
|
|
|
$this->object = new \Aimeos\MShop\Order\Item\Service\Standard( 'order.service.', $this->values ); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
|
82
|
|
|
protected function tearDown() : void |
83
|
|
|
{ |
84
|
|
|
unset( $this->object, $this->price, $this->values, $this->attributes, $this->transactions ); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
|
88
|
|
|
public function testGetServiceItem() |
89
|
|
|
{ |
90
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Service\Item\Iface::class, $this->object->getServiceItem() ); |
91
|
|
|
$this->assertNull( ( new \Aimeos\MShop\Order\Item\Service\Standard( 'order.service.' ) )->getServiceItem() ); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
|
95
|
|
|
public function testGetId() |
96
|
|
|
{ |
97
|
|
|
$this->assertEquals( 1, $this->object->getId() ); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
|
101
|
|
|
public function testSetId() |
102
|
|
|
{ |
103
|
|
|
$return = $this->object->setId( null ); |
104
|
|
|
|
105
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
106
|
|
|
$this->assertEquals( null, $this->object->getId() ); |
107
|
|
|
$this->assertTrue( $this->object->isModified() ); |
108
|
|
|
|
109
|
|
|
$return = $this->object->setId( 5 ); |
110
|
|
|
|
111
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
112
|
|
|
$this->assertEquals( 5, $this->object->getId() ); |
113
|
|
|
$this->assertFalse( $this->object->isModified() ); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
|
117
|
|
|
public function testGetSiteId() |
118
|
|
|
{ |
119
|
|
|
$this->assertEquals( 99, $this->object->getSiteId() ); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
|
123
|
|
|
public function testSetSiteId() |
124
|
|
|
{ |
125
|
|
|
$this->object->setSiteId( 100 ); |
126
|
|
|
$this->assertEquals( 100, $this->object->getSiteId() ); |
127
|
|
|
$this->assertTrue( $this->object->isModified() ); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
|
131
|
|
|
public function testGetParentId() |
132
|
|
|
{ |
133
|
|
|
$this->assertEquals( 42, $this->object->getParentId() ); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
|
137
|
|
|
public function testSetParentId() |
138
|
|
|
{ |
139
|
|
|
$return = $this->object->setParentId( 111 ); |
140
|
|
|
|
141
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
142
|
|
|
$this->assertEquals( 111, $this->object->getParentId() ); |
143
|
|
|
$this->assertTrue( $this->object->isModified() ); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
|
147
|
|
|
public function testSetParentIdReset() |
148
|
|
|
{ |
149
|
|
|
$return = $this->object->setParentId( null ); |
150
|
|
|
|
151
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
152
|
|
|
$this->assertEquals( null, $this->object->getParentId() ); |
153
|
|
|
$this->assertTrue( $this->object->isModified() ); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
|
157
|
|
|
public function testGetServiceId() |
158
|
|
|
{ |
159
|
|
|
$this->assertEquals( 'ServiceID', $this->object->getServiceId() ); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
|
163
|
|
|
public function testSetServiceId() |
164
|
|
|
{ |
165
|
|
|
$return = $this->object->setServiceId( 'testServiceID' ); |
166
|
|
|
|
167
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
168
|
|
|
$this->assertEquals( 'testServiceID', $this->object->getServiceId() ); |
169
|
|
|
$this->assertTrue( $this->object->isModified() ); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
|
173
|
|
|
public function testGetCode() |
174
|
|
|
{ |
175
|
|
|
$this->assertEquals( 'UnitCode', $this->object->getCode() ); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
|
179
|
|
|
public function testSetCode() |
180
|
|
|
{ |
181
|
|
|
$return = $this->object->setCode( 'testCode' ); |
182
|
|
|
|
183
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
184
|
|
|
$this->assertEquals( 'testCode', $this->object->getCode() ); |
185
|
|
|
$this->assertTrue( $this->object->isModified() ); |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
|
189
|
|
|
public function testGetName() |
190
|
|
|
{ |
191
|
|
|
$this->assertEquals( 'UnitName', $this->object->getName() ); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
|
195
|
|
|
public function testSetName() |
196
|
|
|
{ |
197
|
|
|
$return = $this->object->setName( 'testName' ); |
198
|
|
|
|
199
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
200
|
|
|
$this->assertEquals( 'testName', $this->object->getName() ); |
201
|
|
|
$this->assertTrue( $this->object->isModified() ); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
|
205
|
|
|
public function testGetMediaUrl() |
206
|
|
|
{ |
207
|
|
|
$this->assertEquals( 'Url for test', $this->object->getMediaUrl() ); |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
|
211
|
|
|
public function testSetMediaUrl() |
212
|
|
|
{ |
213
|
|
|
$return = $this->object->setMediaUrl( 'testUrl' ); |
214
|
|
|
|
215
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
216
|
|
|
$this->assertEquals( 'testUrl', $this->object->getMediaUrl() ); |
217
|
|
|
$this->assertTrue( $this->object->isModified() ); |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
|
221
|
|
|
public function testGetType() |
222
|
|
|
{ |
223
|
|
|
$this->assertEquals( 'payment', $this->object->getType() ); |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
|
227
|
|
|
public function testSetType() |
228
|
|
|
{ |
229
|
|
|
$return = $this->object->setType( 'delivery' ); |
230
|
|
|
|
231
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
232
|
|
|
$this->assertEquals( 'delivery', $this->object->getType() ); |
233
|
|
|
$this->assertTrue( $this->object->isModified() ); |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
|
237
|
|
|
public function testGetPrice() |
238
|
|
|
{ |
239
|
|
|
$this->assertSame( $this->price, $this->object->getPrice() ); |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
|
243
|
|
|
public function testSetPrice() |
244
|
|
|
{ |
245
|
|
|
$this->price->setCosts( '5.00' ); |
246
|
|
|
$return = $this->object->setPrice( $this->price ); |
247
|
|
|
|
248
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
249
|
|
|
$this->assertFalse( $this->object->isModified() ); |
250
|
|
|
$this->assertSame( $this->price, $this->object->getPrice() ); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
|
254
|
|
|
public function testGetPosition() |
255
|
|
|
{ |
256
|
|
|
$this->assertEquals( 1, $this->object->getPosition() ); |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
|
260
|
|
|
public function testSetPosition() |
261
|
|
|
{ |
262
|
|
|
$return = $this->object->setPosition( 2 ); |
263
|
|
|
|
264
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
265
|
|
|
$this->assertEquals( 2, $this->object->getPosition() ); |
266
|
|
|
$this->assertTrue( $this->object->isModified() ); |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
|
270
|
|
|
public function testSetPositionReset() |
271
|
|
|
{ |
272
|
|
|
$return = $this->object->setPosition( null ); |
273
|
|
|
|
274
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
275
|
|
|
$this->assertEquals( null, $this->object->getPosition() ); |
276
|
|
|
$this->assertTrue( $this->object->isModified() ); |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
|
280
|
|
|
public function testSetPositionInvalid() |
281
|
|
|
{ |
282
|
|
|
$this->expectException( \Aimeos\MShop\Order\Exception::class ); |
283
|
|
|
$this->object->setPosition( -1 ); |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
|
287
|
|
|
public function testAddAttributeItems() |
288
|
|
|
{ |
289
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'order/service' )->createAttributeItem(); |
290
|
|
|
|
291
|
|
|
$return = $this->object->addAttributeItems( [$item] ); |
292
|
|
|
|
293
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
294
|
|
|
$this->assertEquals( 2, count( $this->object->getAttributeItems() ) ); |
295
|
|
|
$this->assertTrue( $this->object->isModified() ); |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
|
299
|
|
|
public function testGetAttribute() |
300
|
|
|
{ |
301
|
|
|
$attManager = \Aimeos\MShop::create( $this->context, 'order/service/attribute' ); |
302
|
|
|
|
303
|
|
|
$attrItem001 = $attManager->create(); |
304
|
|
|
$attrItem001->setAttributeId( '1' ); |
305
|
|
|
$attrItem001->setCode( 'code_001' ); |
306
|
|
|
$attrItem001->setValue( 'value_001' ); |
307
|
|
|
|
308
|
|
|
$attrItem002 = $attManager->create(); |
309
|
|
|
$attrItem002->setAttributeId( '2' ); |
310
|
|
|
$attrItem002->setCode( 'code_002' ); |
311
|
|
|
$attrItem002->setType( 'test_002' ); |
312
|
|
|
$attrItem002->setValue( 'value_002' ); |
313
|
|
|
|
314
|
|
|
$this->object->setAttributeItems( array( $attrItem001, $attrItem002 ) ); |
315
|
|
|
|
316
|
|
|
$result = $this->object->getAttribute( 'code_001' ); |
317
|
|
|
$this->assertEquals( 'value_001', $result ); |
318
|
|
|
|
319
|
|
|
$result = $this->object->getAttribute( 'code_002', ['test_002'] ); |
320
|
|
|
$this->assertEquals( 'value_002', $result ); |
321
|
|
|
|
322
|
|
|
$result = $this->object->getAttribute( 'code_002', 'test_002' ); |
323
|
|
|
$this->assertEquals( 'value_002', $result ); |
324
|
|
|
|
325
|
|
|
$result = $this->object->getAttribute( 'code_002' ); |
326
|
|
|
$this->assertEquals( null, $result ); |
327
|
|
|
|
328
|
|
|
$result = $this->object->getAttribute( 'code_003' ); |
329
|
|
|
$this->assertEquals( null, $result ); |
330
|
|
|
|
331
|
|
|
$this->object->setAttributeItems( [] ); |
332
|
|
|
|
333
|
|
|
$result = $this->object->getAttribute( 'code_001' ); |
334
|
|
|
$this->assertEquals( null, $result ); |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
|
338
|
|
|
public function testGetAttributeList() |
339
|
|
|
{ |
340
|
|
|
$attManager = \Aimeos\MShop::create( $this->context, 'order/service/attribute' ); |
341
|
|
|
|
342
|
|
|
$attrItem001 = $attManager->create(); |
343
|
|
|
$attrItem001->setAttributeId( '1' ); |
344
|
|
|
$attrItem001->setCode( 'code_001' ); |
345
|
|
|
$attrItem001->setType( 'test_001' ); |
346
|
|
|
$attrItem001->setValue( 'value_001' ); |
347
|
|
|
|
348
|
|
|
$attrItem002 = $attManager->create(); |
349
|
|
|
$attrItem002->setAttributeId( '2' ); |
350
|
|
|
$attrItem002->setCode( 'code_001' ); |
351
|
|
|
$attrItem002->setType( 'test_001' ); |
352
|
|
|
$attrItem002->setValue( 'value_002' ); |
353
|
|
|
|
354
|
|
|
$this->object->setAttributeItems( array( $attrItem001, $attrItem002 ) ); |
355
|
|
|
|
356
|
|
|
$result = $this->object->getAttribute( 'code_001', 'test_001' ); |
357
|
|
|
$this->assertEquals( ['value_001', 'value_002'], $result ); |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
|
361
|
|
|
public function testGetAttributeItem() |
362
|
|
|
{ |
363
|
|
|
$attManager = \Aimeos\MShop::create( $this->context, 'order/service/attribute' ); |
364
|
|
|
|
365
|
|
|
$attrItem001 = $attManager->create(); |
366
|
|
|
$attrItem001->setAttributeId( '1' ); |
367
|
|
|
$attrItem001->setCode( 'code_001' ); |
368
|
|
|
$attrItem001->setValue( 'value_001' ); |
369
|
|
|
|
370
|
|
|
$attrItem002 = $attManager->create(); |
371
|
|
|
$attrItem002->setAttributeId( '2' ); |
372
|
|
|
$attrItem002->setCode( 'code_002' ); |
373
|
|
|
$attrItem002->setType( 'test_002' ); |
374
|
|
|
$attrItem002->setValue( 'value_002' ); |
375
|
|
|
|
376
|
|
|
$this->object->setAttributeItems( array( $attrItem001, $attrItem002 ) ); |
377
|
|
|
|
378
|
|
|
$result = $this->object->getAttributeItem( 'code_001' ); |
379
|
|
|
$this->assertEquals( 'value_001', $result->getValue() ); |
380
|
|
|
|
381
|
|
|
$result = $this->object->getAttributeItem( 'code_002', 'test_002' ); |
382
|
|
|
$this->assertEquals( 'value_002', $result->getValue() ); |
383
|
|
|
|
384
|
|
|
$result = $this->object->getAttributeItem( 'code_002' ); |
385
|
|
|
$this->assertEquals( null, $result ); |
386
|
|
|
|
387
|
|
|
$result = $this->object->getAttributeItem( 'code_003' ); |
388
|
|
|
$this->assertEquals( null, $result ); |
389
|
|
|
|
390
|
|
|
$this->object->setAttributeItems( [] ); |
391
|
|
|
|
392
|
|
|
$result = $this->object->getAttributeItem( 'code_001' ); |
393
|
|
|
$this->assertEquals( null, $result ); |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
|
397
|
|
|
public function testGetAttributeItemList() |
398
|
|
|
{ |
399
|
|
|
$attManager = \Aimeos\MShop::create( $this->context, 'order/service/attribute' ); |
400
|
|
|
|
401
|
|
|
$attrItem001 = $attManager->create(); |
402
|
|
|
$attrItem001->setAttributeId( '1' ); |
403
|
|
|
$attrItem001->setCode( 'code_001' ); |
404
|
|
|
$attrItem001->setType( 'test_001' ); |
405
|
|
|
$attrItem001->setValue( 'value_001' ); |
406
|
|
|
|
407
|
|
|
$attrItem002 = $attManager->create(); |
408
|
|
|
$attrItem002->setAttributeId( '2' ); |
409
|
|
|
$attrItem002->setCode( 'code_001' ); |
410
|
|
|
$attrItem002->setType( 'test_001' ); |
411
|
|
|
$attrItem002->setValue( 'value_002' ); |
412
|
|
|
|
413
|
|
|
$this->object->setAttributeItems( array( $attrItem001, $attrItem002 ) ); |
414
|
|
|
|
415
|
|
|
$result = $this->object->getAttributeItem( 'code_001', 'test_001' ); |
416
|
|
|
$this->assertEquals( 2, count( $result ) ); |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
|
420
|
|
|
public function testGetAttributeItems() |
421
|
|
|
{ |
422
|
|
|
$this->assertEquals( $this->attributes, $this->object->getAttributeItems() ); |
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
|
426
|
|
|
public function testGetAttributeItemsByType() |
427
|
|
|
{ |
428
|
|
|
$this->assertEquals( $this->attributes, $this->object->getAttributeItems( 'default' ) ); |
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
|
432
|
|
|
public function testGetAttributeItemsInvalidType() |
433
|
|
|
{ |
434
|
|
|
$this->assertEquals( [], $this->object->getAttributeItems( 'invalid' )->toArray() ); |
435
|
|
|
} |
436
|
|
|
|
437
|
|
|
|
438
|
|
|
public function testGetAttributeItemsDeleted() |
439
|
|
|
{ |
440
|
|
|
$this->object->setAttributeItems( $this->attributes ); |
441
|
|
|
$this->object->setAttributeItems( [] ); |
442
|
|
|
|
443
|
|
|
$this->assertEquals( $this->attributes, $this->object->getAttributeItemsDeleted() ); |
444
|
|
|
} |
445
|
|
|
|
446
|
|
|
|
447
|
|
|
public function testSetAttributeItem() |
448
|
|
|
{ |
449
|
|
|
$attManager = \Aimeos\MShop::create( $this->context, 'order/service/attribute' ); |
450
|
|
|
|
451
|
|
|
$item = $attManager->create(); |
452
|
|
|
$item->setAttributeId( '1' ); |
453
|
|
|
$item->setCode( 'test_code' ); |
454
|
|
|
$item->setType( 'test_type' ); |
455
|
|
|
$item->setValue( 'test_value' ); |
456
|
|
|
|
457
|
|
|
$return = $this->object->setAttributeItem( $item ); |
458
|
|
|
|
459
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
460
|
|
|
$this->assertEquals( 'test_value', $this->object->getAttributeItem( 'test_code', 'test_type' )->getValue() ); |
461
|
|
|
$this->assertTrue( $this->object->isModified() ); |
462
|
|
|
|
463
|
|
|
$item = $attManager->create(); |
464
|
|
|
$item->setAttributeId( '1' ); |
465
|
|
|
$item->setCode( 'test_code' ); |
466
|
|
|
$item->setType( 'test_type' ); |
467
|
|
|
$item->setValue( 'test_value2' ); |
468
|
|
|
|
469
|
|
|
$return = $this->object->setAttributeItem( $item ); |
470
|
|
|
|
471
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
472
|
|
|
$this->assertEquals( 'test_value2', $this->object->getAttributeItem( 'test_code', 'test_type' )->getValue() ); |
473
|
|
|
$this->assertTrue( $this->object->isModified() ); |
474
|
|
|
} |
475
|
|
|
|
476
|
|
|
|
477
|
|
|
public function testSetAttributeItems() |
478
|
|
|
{ |
479
|
|
|
$attManager = \Aimeos\MShop::create( $this->context, 'order/service/attribute' ); |
480
|
|
|
|
481
|
|
|
$list = array( |
482
|
|
|
$attManager->create(), |
483
|
|
|
$attManager->create(), |
484
|
|
|
); |
485
|
|
|
|
486
|
|
|
$return = $this->object->setAttributeItems( $list ); |
487
|
|
|
|
488
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
489
|
|
|
$this->assertEquals( $list, $this->object->getAttributeItems()->toArray() ); |
490
|
|
|
$this->assertTrue( $this->object->isModified() ); |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
|
494
|
|
|
public function testGetTransactions() |
495
|
|
|
{ |
496
|
|
|
$this->assertEquals( $this->transactions, $this->object->getTransactions() ); |
497
|
|
|
} |
498
|
|
|
|
499
|
|
|
|
500
|
|
|
public function testSetTransactions() |
501
|
|
|
{ |
502
|
|
|
$txValues = array( |
503
|
|
|
'order.service.transaction.id' => 5, |
504
|
|
|
'order.service.transaction.siteid' => 100, |
505
|
|
|
'order.service.transaction.parentid' => 50, |
506
|
|
|
'order.service.transaction.type' => 'refund', |
507
|
|
|
'order.service.attribute.config' => ['tx' => '001'], |
508
|
|
|
'order.service.attribute.status' => 3, |
509
|
|
|
'order.service.attribute.mtime' => '2020-12-31 23:59:59', |
510
|
|
|
'order.service.attribute.ctime' => '2011-01-01 00:00:01', |
511
|
|
|
'order.service.attribute.editor' => 'unitTestUser' |
512
|
|
|
); |
513
|
|
|
|
514
|
|
|
$list = [new \Aimeos\MShop\Order\Item\Service\Transaction\Standard( 'order.service.', $txValues )]; |
515
|
|
|
$result = $this->object->setTransactions( $list ); |
516
|
|
|
|
517
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $result ); |
518
|
|
|
$this->assertEquals( $list, $this->object->getTransactions()->toArray() ); |
519
|
|
|
$this->assertTrue( $this->object->isModified() ); |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
|
523
|
|
|
public function testGetTimeModified() |
524
|
|
|
{ |
525
|
|
|
$this->assertEquals( '2012-01-01 00:00:01', $this->object->getTimeModified() ); |
526
|
|
|
} |
527
|
|
|
|
528
|
|
|
|
529
|
|
|
public function testGetTimeCreated() |
530
|
|
|
{ |
531
|
|
|
$this->assertEquals( '2011-01-01 00:00:01', $this->object->getTimeCreated() ); |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
|
535
|
|
|
public function testGetEditor() |
536
|
|
|
{ |
537
|
|
|
$this->assertEquals( 'unitTestUser', $this->object->editor() ); |
538
|
|
|
} |
539
|
|
|
|
540
|
|
|
|
541
|
|
|
public function testFromArray() |
542
|
|
|
{ |
543
|
|
|
$item = new \Aimeos\MShop\Order\Item\Service\Standard( 'order.service.', ['.price' => $this->price] ); |
544
|
|
|
|
545
|
|
|
$list = $entries = array( |
546
|
|
|
'order.service.id' => 1, |
547
|
|
|
'order.service.parentid' => 2, |
548
|
|
|
'order.service.serviceid' => 3, |
549
|
|
|
'order.service.position' => 4, |
550
|
|
|
'order.service.currencyid' => 'EUR', |
551
|
|
|
'order.service.price' => '1.00', |
552
|
|
|
'order.service.costs' => '0.50', |
553
|
|
|
'order.service.rebate' => '0.50', |
554
|
|
|
'order.service.taxrates' => ['tax' => '20.00'], |
555
|
|
|
'order.service.taxvalue' => '0.2500', |
556
|
|
|
'order.service.taxflag' => 1, |
557
|
|
|
'order.service.code' => 'test', |
558
|
|
|
'order.service.name' => 'test item', |
559
|
|
|
'order.service.type' => 'delivery', |
560
|
|
|
); |
561
|
|
|
|
562
|
|
|
$item = $item->fromArray( $entries, true ); |
563
|
|
|
|
564
|
|
|
$this->assertEquals( [], $entries ); |
565
|
|
|
$this->assertEquals( '', $item->getSiteId() ); |
566
|
|
|
$this->assertEquals( $list['order.service.id'], $item->getId() ); |
567
|
|
|
$this->assertEquals( $list['order.service.parentid'], $item->getParentId() ); |
568
|
|
|
$this->assertEquals( $list['order.service.serviceid'], $item->getServiceId() ); |
569
|
|
|
$this->assertEquals( $list['order.service.position'], $item->getPosition() ); |
570
|
|
|
$this->assertEquals( $list['order.service.currencyid'], $item->getPrice()->getCurrencyId() ); |
571
|
|
|
$this->assertEquals( $list['order.service.price'], $item->getPrice()->getValue() ); |
572
|
|
|
$this->assertEquals( $list['order.service.costs'], $item->getPrice()->getCosts() ); |
573
|
|
|
$this->assertEquals( $list['order.service.rebate'], $item->getPrice()->getRebate() ); |
574
|
|
|
$this->assertEquals( $list['order.service.taxrates'], $item->getPrice()->getTaxRates() ); |
575
|
|
|
$this->assertEquals( $list['order.service.taxvalue'], $item->getPrice()->getTaxValue() ); |
576
|
|
|
$this->assertEquals( $list['order.service.taxflag'], $item->getPrice()->getTaxFlag() ); |
577
|
|
|
$this->assertEquals( $list['order.service.code'], $item->getCode() ); |
578
|
|
|
$this->assertEquals( $list['order.service.name'], $item->getName() ); |
579
|
|
|
$this->assertEquals( $list['order.service.type'], $item->getType() ); |
580
|
|
|
} |
581
|
|
|
|
582
|
|
|
|
583
|
|
|
public function testToArray() |
584
|
|
|
{ |
585
|
|
|
$arrayObject = $this->object->toArray( true ); |
586
|
|
|
|
587
|
|
|
$this->assertEquals( count( $this->values ) - 4 + 7, count( $arrayObject ) ); |
588
|
|
|
|
589
|
|
|
$this->assertEquals( $this->object->getId(), $arrayObject['order.service.id'] ); |
590
|
|
|
$this->assertEquals( $this->object->getParentId(), $arrayObject['order.service.parentid'] ); |
591
|
|
|
$this->assertEquals( $this->object->getServiceId(), $arrayObject['order.service.serviceid'] ); |
592
|
|
|
$this->assertEquals( $this->object->getPosition(), $arrayObject['order.service.position'] ); |
593
|
|
|
$this->assertEquals( $this->object->getCode(), $arrayObject['order.service.code'] ); |
594
|
|
|
$this->assertEquals( $this->object->getName(), $arrayObject['order.service.name'] ); |
595
|
|
|
$this->assertEquals( $this->object->getType(), $arrayObject['order.service.type'] ); |
596
|
|
|
$this->assertEquals( $this->object->getTimeCreated(), $arrayObject['order.service.ctime'] ); |
597
|
|
|
$this->assertEquals( $this->object->getTimeModified(), $arrayObject['order.service.mtime'] ); |
598
|
|
|
$this->assertEquals( $this->object->editor(), $arrayObject['order.service.editor'] ); |
599
|
|
|
|
600
|
|
|
$price = $this->object->getPrice(); |
601
|
|
|
$this->assertEquals( $price->getCurrencyId(), $arrayObject['order.service.currencyid'] ); |
602
|
|
|
$this->assertEquals( $price->getValue(), $arrayObject['order.service.price'] ); |
603
|
|
|
$this->assertEquals( $price->getCosts(), $arrayObject['order.service.costs'] ); |
604
|
|
|
$this->assertEquals( $price->getRebate(), $arrayObject['order.service.rebate'] ); |
605
|
|
|
$this->assertEquals( $price->getTaxRates(), $arrayObject['order.service.taxrates'] ); |
606
|
|
|
$this->assertEquals( $price->getTaxValue(), $arrayObject['order.service.taxvalue'] ); |
607
|
|
|
$this->assertEquals( $price->getTaxFlag(), $arrayObject['order.service.taxflag'] ); |
608
|
|
|
} |
609
|
|
|
|
610
|
|
|
public function testIsModified() |
611
|
|
|
{ |
612
|
|
|
$this->assertFalse( $this->object->isModified() ); |
613
|
|
|
} |
614
|
|
|
|
615
|
|
|
|
616
|
|
|
public function testGetResourceType() |
617
|
|
|
{ |
618
|
|
|
$this->assertEquals( 'order/service', $this->object->getResourceType() ); |
619
|
|
|
} |
620
|
|
|
|
621
|
|
|
|
622
|
|
|
public function testCopyFrom() |
623
|
|
|
{ |
624
|
|
|
$serviceCopy = new \Aimeos\MShop\Order\Item\Service\Standard( 'order.service.', ['.price' => $this->price] ); |
625
|
|
|
|
626
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'service' ); |
627
|
|
|
|
628
|
|
|
$filter = $manager->filter()->add( ['service.provider' => 'Standard'] ); |
629
|
|
|
$item = $manager->search( $filter )->first( new \RuntimeException( 'No service found' ) ); |
630
|
|
|
|
631
|
|
|
$return = $serviceCopy->copyFrom( $item->set( 'customprop', 123 ) ); |
632
|
|
|
|
633
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Service\Iface::class, $return ); |
634
|
|
|
$this->assertEquals( 'unitdeliverycode', $serviceCopy->getCode() ); |
635
|
|
|
$this->assertEquals( 'unitlabel', $serviceCopy->getName() ); |
636
|
|
|
$this->assertEquals( 'delivery', $serviceCopy->getType() ); |
637
|
|
|
$this->assertEquals( '', $serviceCopy->getMediaUrl() ); |
638
|
|
|
$this->assertEquals( '123', $serviceCopy->get( 'customprop' ) ); |
639
|
|
|
|
640
|
|
|
$this->assertTrue( $serviceCopy->isModified() ); |
641
|
|
|
} |
642
|
|
|
} |
643
|
|
|
|