|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017-2025 |
|
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 = \TestHelper::context(); |
|
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
|
|
|
|
|
38
|
|
|
public function testAddAddressItem() |
|
39
|
|
|
{ |
|
40
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer/address' )->create(); |
|
41
|
|
|
$this->assertSame( $this->object, $this->object->addAddressItem( $item ) ); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
public function testAddListItem() |
|
46
|
|
|
{ |
|
47
|
|
|
$listItem = \Aimeos\MShop::create( $this->context, 'customer/lists' )->create(); |
|
48
|
|
|
$this->assertSame( $this->object, $this->object->addListItem( 'customer', $listItem ) ); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
public function testAddListItemGroup() |
|
53
|
|
|
{ |
|
54
|
|
|
$listItem = \Aimeos\MShop::create( $this->context, 'customer/lists' )->create(); |
|
55
|
|
|
|
|
56
|
|
|
$this->expectException( \Aimeos\Controller\Frontend\Customer\Exception::class ); |
|
57
|
|
|
$this->object->addListItem( 'group', $listItem ); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
public function testAddPropertyItem() |
|
62
|
|
|
{ |
|
63
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer/property' )->create(); |
|
64
|
|
|
$this->assertSame( $this->object, $this->object->addPropertyItem( $item ) ); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
|
|
68
|
|
|
public function testCreateAddressItem() |
|
69
|
|
|
{ |
|
70
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Address\Iface::class, $this->object->createAddressItem() ); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
public function testCreateListItem() |
|
75
|
|
|
{ |
|
76
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Lists\Iface::class, $this->object->createListItem() ); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
public function testCreatePropertyItem() |
|
81
|
|
|
{ |
|
82
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Common\Item\Property\Iface::class, $this->object->createPropertyItem() ); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
|
|
86
|
|
|
public function testDeleteAddressItem() |
|
87
|
|
|
{ |
|
88
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer/address' )->create(); |
|
89
|
|
|
$this->assertSame( $this->object, $this->object->deleteAddressItem( $item ) ); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
|
|
93
|
|
|
public function testDeleteListItem() |
|
94
|
|
|
{ |
|
95
|
|
|
$listItem = \Aimeos\MShop::create( $this->context, 'customer/lists' )->create(); |
|
96
|
|
|
$this->assertSame( $this->object, $this->object->deleteListItem( 'customer', $listItem ) ); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
|
|
100
|
|
|
public function testDeleteListItemGroup() |
|
101
|
|
|
{ |
|
102
|
|
|
$listItem = \Aimeos\MShop::create( $this->context, 'customer/lists' )->create(); |
|
103
|
|
|
|
|
104
|
|
|
$this->expectException( \Aimeos\Controller\Frontend\Customer\Exception::class ); |
|
105
|
|
|
$this->object->deleteListItem( 'group', $listItem ); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
|
|
109
|
|
|
public function testDeletePropertyItem() |
|
110
|
|
|
{ |
|
111
|
|
|
$item = \Aimeos\MShop::create( $this->context, 'customer/property' )->create(); |
|
112
|
|
|
$this->assertSame( $this->object, $this->object->deletePropertyItem( $item ) ); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
|
|
116
|
|
|
public function testFind() |
|
117
|
|
|
{ |
|
118
|
|
|
$item = $this->object->uses( ['product'] )->find( '[email protected]' ); |
|
119
|
|
|
|
|
120
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Customer\Item\Iface::class, $item ); |
|
121
|
|
|
$this->assertEquals( 1, count( $item->getRefItems( 'product' ) ) ); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
|
|
125
|
|
|
public function testGet() |
|
126
|
|
|
{ |
|
127
|
|
|
$this->context->setUser( $this->object->find( '[email protected]' ) ); |
|
128
|
|
|
$item = $this->object->uses( ['product'] )->get(); |
|
129
|
|
|
|
|
130
|
|
|
$this->assertInstanceOf( \Aimeos\MShop\Customer\Item\Iface::class, $item ); |
|
131
|
|
|
$this->assertEquals( 1, count( $item->getRefItems( 'product' ) ) ); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
|
|
135
|
|
|
public function testStoreDelete() |
|
136
|
|
|
{ |
|
137
|
|
|
$this->object->add( ['customer.code' => 'cntl-test'] ); |
|
138
|
|
|
|
|
139
|
|
|
$this->assertSame( $this->object, $this->object->store() ); |
|
140
|
|
|
$this->assertEquals( 'cntl-test', $this->object->get()->getCode() ); |
|
141
|
|
|
$this->assertSame( $this->object, $this->object->delete() ); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
|
|
145
|
|
|
public function testUses() |
|
146
|
|
|
{ |
|
147
|
|
|
$this->assertSame( $this->object, $this->object->uses( ['product'] ) ); |
|
148
|
|
|
} |
|
149
|
|
|
} |
|
150
|
|
|
|