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\Basket; |
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.basket.id' => '123-456-789', |
20
|
|
|
'order.basket.siteid' => '1.', |
21
|
|
|
'order.basket.customerid' => '11', |
22
|
|
|
'order.basket.name' => 'testbasket', |
23
|
|
|
'order.basket.content' => 'this is a value from unittest', |
24
|
|
|
'order.basket.mtime' => '2011-01-01 00:00:02', |
25
|
|
|
'order.basket.ctime' => '2011-01-01 00:00:01', |
26
|
|
|
'order.basket.editor' => 'unitTestUser' |
27
|
|
|
); |
28
|
|
|
|
29
|
|
|
$this->object = new \Aimeos\MShop\Order\Item\Basket\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\Basket\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\Basket\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\Basket\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( 'testbasket', $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\Basket\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/basket', $this->object->getResourceType() ); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
|
133
|
|
|
public function testFromArray() |
134
|
|
|
{ |
135
|
|
|
$item = new \Aimeos\MShop\Order\Item\Basket\Standard(); |
136
|
|
|
|
137
|
|
|
$list = $entries = array( |
138
|
|
|
'order.basket.id' => '123-456', |
139
|
|
|
'order.basket.customerid' => '123', |
140
|
|
|
'order.basket.content' => 'basket value', |
141
|
|
|
'order.basket.name' => 'test basket name', |
142
|
|
|
); |
143
|
|
|
|
144
|
|
|
$item = $item->fromArray( $entries, true ); |
145
|
|
|
|
146
|
|
|
$this->assertEquals( [], $entries ); |
147
|
|
|
$this->assertEquals( '', $item->getSiteId() ); |
148
|
|
|
$this->assertEquals( $list['order.basket.id'], $item->getId() ); |
149
|
|
|
$this->assertEquals( $list['order.basket.customerid'], $item->getCustomerId() ); |
150
|
|
|
$this->assertEquals( $list['order.basket.content'], $item->getContent() ); |
151
|
|
|
$this->assertEquals( $list['order.basket.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.basket.id'] ); |
162
|
|
|
$this->assertEquals( $this->object->getSiteId(), $list['order.basket.siteid'] ); |
163
|
|
|
$this->assertEquals( $this->object->getCustomerId(), $list['order.basket.customerid'] ); |
164
|
|
|
$this->assertEquals( $this->object->getContent(), $list['order.basket.content'] ); |
165
|
|
|
$this->assertEquals( $this->object->getName(), $list['order.basket.name'] ); ; |
166
|
|
|
$this->assertEquals( $this->object->getTimeModified(), $list['order.basket.mtime'] ); |
167
|
|
|
$this->assertEquals( $this->object->getTimeCreated(), $list['order.basket.ctime'] ); |
168
|
|
|
$this->assertEquals( $this->object->editor(), $list['order.basket.editor'] ); |
169
|
|
|
} |
170
|
|
|
} |
171
|
|
|
|