1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017-2021 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Controller\Frontend\Customer; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
private $context; |
15
|
|
|
private $object; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
protected function setUp() : void |
19
|
|
|
{ |
20
|
|
|
$this->context = \TestHelperFrontend::getContext(); |
21
|
|
|
$this->object = new \Aimeos\Controller\Frontend\Customer\Standard( $this->context ); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
protected function tearDown() : void |
26
|
|
|
{ |
27
|
|
|
unset( $this->object, $this->context ); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
public function testAdd() |
32
|
|
|
{ |
33
|
|
|
$this->assertSame( $this->object, $this->object->add( ['customer.code' => 'test'] ) ); |
34
|
|
|
$this->assertEquals( 'test', $this->object->get()->getCode() ); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testChangePassword() |
38
|
|
|
{ |
39
|
|
|
$oldPassword = $this->object->get()->getPassword(); |
40
|
|
|
$this->object = $this->object->add([ |
41
|
|
|
"customer.oldpassword" => "test", |
42
|
|
|
"customer.newpassword" => "test1", |
43
|
|
|
"customer.confirmnewpassword" => "test1" |
44
|
|
|
]); |
45
|
|
|
$this->assertNotSame($this->object->get()->getPassword(), $oldPassword); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
|
49
|
|
|
public function testAddAddressItem() |
50
|
|
|
{ |
51
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer/address' )->create(); |
52
|
|
|
$this->assertSame( $this->object, $this->object->addAddressItem( $item ) ); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
public function testAddListItem() |
57
|
|
|
{ |
58
|
|
|
$listItem = \Aimeos\MShop::create( $this->context, 'customer/lists' )->create(); |
59
|
|
|
$this->assertSame( $this->object, $this->object->addListItem( 'customer', $listItem ) ); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
|
63
|
|
|
public function testAddListItemGroup() |
64
|
|
|
{ |
65
|
|
|
$listItem = \Aimeos\MShop::create( $this->context, 'customer/lists' )->create(); |
66
|
|
|
|
67
|
|
|
$this->expectException( \Aimeos\Controller\Frontend\Customer\Exception::class ); |
68
|
|
|
$this->object->addListItem( 'customer/group', $listItem ); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
public function testAddPropertyItem() |
73
|
|
|
{ |
74
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer/property' )->create(); |
75
|
|
|
$this->assertSame( $this->object, $this->object->addPropertyItem( $item ) ); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
public function testCreateAddressItem() |
80
|
|
|
{ |
81
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Address\Iface::class, $this->object->createAddressItem() ); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
|
85
|
|
|
public function testCreateListItem() |
86
|
|
|
{ |
87
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Lists\Iface::class, $this->object->createListItem() ); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
|
91
|
|
|
public function testCreatePropertyItem() |
92
|
|
|
{ |
93
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Property\Iface::class, $this->object->createPropertyItem() ); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
|
97
|
|
|
public function testDeleteAddressItem() |
98
|
|
|
{ |
99
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer/address' )->create(); |
100
|
|
|
$this->assertSame( $this->object, $this->object->deleteAddressItem( $item ) ); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
|
104
|
|
|
public function testDeleteListItem() |
105
|
|
|
{ |
106
|
|
|
$listItem = \Aimeos\MShop::create( $this->context, 'customer/lists' )->create(); |
107
|
|
|
$this->assertSame( $this->object, $this->object->deleteListItem( 'customer', $listItem ) ); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
|
111
|
|
|
public function testDeleteListItemGroup() |
112
|
|
|
{ |
113
|
|
|
$listItem = \Aimeos\MShop::create( $this->context, 'customer/lists' )->create(); |
114
|
|
|
|
115
|
|
|
$this->expectException( \Aimeos\Controller\Frontend\Customer\Exception::class ); |
116
|
|
|
$this->object->deleteListItem( 'customer/group', $listItem ); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
|
120
|
|
|
public function testDeletePropertyItem() |
121
|
|
|
{ |
122
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer/property' )->create(); |
123
|
|
|
$this->assertSame( $this->object, $this->object->deletePropertyItem( $item ) ); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
|
127
|
|
|
public function testFind() |
128
|
|
|
{ |
129
|
|
|
$item = $this->object->uses( ['product'] )->find( '[email protected]' ); |
130
|
|
|
|
131
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Customer\Item\Iface::class, $item ); |
132
|
|
|
$this->assertEquals( 1, count( $item->getRefItems( 'product' ) ) ); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
|
136
|
|
|
public function testGet() |
137
|
|
|
{ |
138
|
|
|
$this->context->setUserId( $this->object->find( '[email protected]' )->getId() ); |
139
|
|
|
$item = $this->object->uses( ['product'] )->get(); |
140
|
|
|
|
141
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Customer\Item\Iface::class, $item ); |
142
|
|
|
$this->assertEquals( 1, count( $item->getRefItems( 'product' ) ) ); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
|
146
|
|
|
public function testStoreDelete() |
147
|
|
|
{ |
148
|
|
|
$this->object->add( ['customer.code' => 'cntl-test'] ); |
149
|
|
|
|
150
|
|
|
$this->assertSame( $this->object, $this->object->store() ); |
151
|
|
|
$this->assertEquals( 'cntl-test', $this->object->get()->getCode() ); |
152
|
|
|
$this->assertSame( $this->object, $this->object->delete() ); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
|
156
|
|
|
public function testUses() |
157
|
|
|
{ |
158
|
|
|
$this->assertSame( $this->object, $this->object->uses( ['product'] ) ); |
159
|
|
|
} |
160
|
|
|
} |
161
|
|
|
|