|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
|
4
|
|
|
* @copyright Aimeos (aimeos.org), 2022 |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace Aimeos\MShop\Order\Item\Cart; |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
private $object; |
|
13
|
|
|
private $values; |
|
14
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
protected function setUp() : void |
|
17
|
|
|
{ |
|
18
|
|
|
$this->values = array( |
|
19
|
|
|
'order.cart.id' => '123-456-789', |
|
20
|
|
|
'order.cart.siteid' => '1.', |
|
21
|
|
|
'order.cart.customerid' => '11', |
|
22
|
|
|
'order.cart.name' => 'testcart', |
|
23
|
|
|
'order.cart.content' => 'this is a value from unittest', |
|
24
|
|
|
'order.cart.mtime' => '2011-01-01 00:00:02', |
|
25
|
|
|
'order.cart.ctime' => '2011-01-01 00:00:01', |
|
26
|
|
|
'order.cart.editor' => 'unitTestUser' |
|
27
|
|
|
); |
|
28
|
|
|
|
|
29
|
|
|
$this->object = new \Aimeos\MShop\Order\Item\Cart\Standard( $this->values ); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
protected function tearDown() : void |
|
34
|
|
|
{ |
|
35
|
|
|
unset( $this->object ); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
public function testGetId() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->assertEquals( '123-456-789', $this->object->getId() ); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
public function testSetId() |
|
46
|
|
|
{ |
|
47
|
|
|
$return = $this->object->setId( '987-654-321' ); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Cart\Iface::class, $return ); |
|
50
|
|
|
$this->assertEquals( '987-654-321', $this->object->getId() ); |
|
51
|
|
|
$this->assertTrue( $this->object->isModified() ); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
public function testGetSiteId() |
|
56
|
|
|
{ |
|
57
|
|
|
$this->assertEquals( '1.', $this->object->getSiteId() ); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
public function testGetCustomerId() |
|
62
|
|
|
{ |
|
63
|
|
|
$this->assertEquals( '11', $this->object->getCustomerId() ); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
public function testSetCustomerId() |
|
68
|
|
|
{ |
|
69
|
|
|
$return = $this->object->setCustomerId( '12' ); |
|
70
|
|
|
|
|
71
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Cart\Iface::class, $return ); |
|
72
|
|
|
$this->assertEquals( '12', $this->object->getCustomerId() ); |
|
73
|
|
|
$this->assertTrue( $this->object->isModified() ); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
public function testGetContent() |
|
78
|
|
|
{ |
|
79
|
|
|
$this->assertEquals( "this is a value from unittest", $this->object->getContent() ); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
|
|
83
|
|
|
public function testSetContent() |
|
84
|
|
|
{ |
|
85
|
|
|
$return = $this->object->setContent( 'was changed by unittest' ); |
|
86
|
|
|
|
|
87
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Cart\Iface::class, $return ); |
|
88
|
|
|
$this->assertEquals( 'was changed by unittest', $this->object->getContent() ); |
|
89
|
|
|
$this->assertTrue( $this->object->isModified() ); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
|
|
93
|
|
|
public function testGetName() |
|
94
|
|
|
{ |
|
95
|
|
|
$this->assertEquals( 'testcart', $this->object->getName() ); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
|
|
99
|
|
|
public function testSetName() |
|
100
|
|
|
{ |
|
101
|
|
|
$return = $this->object->setName( 'unittest' ); |
|
102
|
|
|
|
|
103
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Order\Item\Cart\Iface::class, $return ); |
|
104
|
|
|
$this->assertEquals( 'unittest', $this->object->getName() ); |
|
105
|
|
|
$this->assertTrue( $this->object->isModified() ); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
|
|
109
|
|
|
public function testGetTimeModified() |
|
110
|
|
|
{ |
|
111
|
|
|
$this->assertEquals( '2011-01-01 00:00:02', $this->object->getTimeModified() ); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
|
|
115
|
|
|
public function testGetTimeCreated() |
|
116
|
|
|
{ |
|
117
|
|
|
$this->assertEquals( '2011-01-01 00:00:01', $this->object->getTimeCreated() ); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
|
|
121
|
|
|
public function testGetEditor() |
|
122
|
|
|
{ |
|
123
|
|
|
$this->assertEquals( 'unitTestUser', $this->object->editor() ); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
|
|
127
|
|
|
public function testGetResourceType() |
|
128
|
|
|
{ |
|
129
|
|
|
$this->assertEquals( 'order/cart', $this->object->getResourceType() ); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
|
|
133
|
|
|
public function testFromArray() |
|
134
|
|
|
{ |
|
135
|
|
|
$item = new \Aimeos\MShop\Order\Item\Cart\Standard(); |
|
136
|
|
|
|
|
137
|
|
|
$list = $entries = array( |
|
138
|
|
|
'order.cart.id' => '123-456', |
|
139
|
|
|
'order.cart.customerid' => '123', |
|
140
|
|
|
'order.cart.content' => 'cart value', |
|
141
|
|
|
'order.cart.name' => 'test cart name', |
|
142
|
|
|
); |
|
143
|
|
|
|
|
144
|
|
|
$item = $item->fromArray( $entries, true ); |
|
145
|
|
|
|
|
146
|
|
|
$this->assertEquals( [], $entries ); |
|
147
|
|
|
$this->assertEquals( '', $item->getSiteId() ); |
|
148
|
|
|
$this->assertEquals( $list['order.cart.id'], $item->getId() ); |
|
149
|
|
|
$this->assertEquals( $list['order.cart.customerid'], $item->getCustomerId() ); |
|
150
|
|
|
$this->assertEquals( $list['order.cart.content'], $item->getContent() ); |
|
151
|
|
|
$this->assertEquals( $list['order.cart.name'], $item->getName() ); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
|
|
155
|
|
|
public function testToArray() |
|
156
|
|
|
{ |
|
157
|
|
|
$list = $this->object->toArray( true ); |
|
158
|
|
|
|
|
159
|
|
|
$this->assertEquals( count( $this->values ), count( $list ) ); |
|
160
|
|
|
|
|
161
|
|
|
$this->assertEquals( $this->object->getId(), $list['order.cart.id'] ); |
|
162
|
|
|
$this->assertEquals( $this->object->getSiteId(), $list['order.cart.siteid'] ); |
|
163
|
|
|
$this->assertEquals( $this->object->getCustomerId(), $list['order.cart.customerid'] ); |
|
164
|
|
|
$this->assertEquals( $this->object->getContent(), $list['order.cart.content'] ); |
|
165
|
|
|
$this->assertEquals( $this->object->getName(), $list['order.cart.name'] ); ; |
|
166
|
|
|
$this->assertEquals( $this->object->getTimeModified(), $list['order.cart.mtime'] ); |
|
167
|
|
|
$this->assertEquals( $this->object->getTimeCreated(), $list['order.cart.ctime'] ); |
|
168
|
|
|
$this->assertEquals( $this->object->editor(), $list['order.cart.editor'] ); |
|
169
|
|
|
} |
|
170
|
|
|
} |
|
171
|
|
|
|