|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2025 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\MShop\Customer\Item; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class FosUserTest extends \PHPUnit\Framework\TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
private $address; |
|
15
|
|
|
private $object; |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
protected function setUp() : void |
|
19
|
|
|
{ |
|
20
|
|
|
$values = array( |
|
21
|
|
|
'customer.id' => 541, |
|
22
|
|
|
'customer.siteid' => 123, |
|
23
|
|
|
'customer.label' => 'unitObject', |
|
24
|
|
|
'customer.code' => '12345ABCDEF', |
|
25
|
|
|
'customer.birthday' => '2010-01-01', |
|
26
|
|
|
'customer.status' => 1, |
|
27
|
|
|
'customer.password' => 'testpwd', |
|
28
|
|
|
'customer.vdate' => null, |
|
29
|
|
|
'customer.company' => 'unitCompany', |
|
30
|
|
|
'customer.vatid' => 'DE999999999', |
|
31
|
|
|
'customer.salutation' => 'mr', |
|
32
|
|
|
'customer.title' => 'Dr.', |
|
33
|
|
|
'customer.firstname' => 'firstunit', |
|
34
|
|
|
'customer.lastname' => 'lastunit', |
|
35
|
|
|
'customer.address1' => 'unit str.', |
|
36
|
|
|
'customer.address2' => ' 166', |
|
37
|
|
|
'customer.address3' => '4.OG', |
|
38
|
|
|
'customer.postal' => '22769', |
|
39
|
|
|
'customer.city' => 'Hamburg', |
|
40
|
|
|
'customer.state' => 'Hamburg', |
|
41
|
|
|
'customer.countryid' => 'de', |
|
42
|
|
|
'customer.languageid' => 'de', |
|
43
|
|
|
'customer.telephone' => '05554433221', |
|
44
|
|
|
'customer.email' => '[email protected]', |
|
45
|
|
|
'customer.telefax' => '05554433222', |
|
46
|
|
|
'customer.website' => 'www.example.com', |
|
47
|
|
|
'customer.mtime'=> '2010-01-05 00:00:05', |
|
48
|
|
|
'customer.ctime'=> '2010-01-01 00:00:00', |
|
49
|
|
|
'customer.editor' => 'unitTestUser', |
|
50
|
|
|
'roles' => array( 'ROLE_ADMIN' ), |
|
51
|
|
|
'salt' => 'test', |
|
52
|
|
|
); |
|
53
|
|
|
|
|
54
|
|
|
$this->address = new \Aimeos\MShop\Common\Item\Address\Standard( 'customer.', $values ); |
|
55
|
|
|
$this->object = new \Aimeos\MShop\Customer\Item\FosUser( $this->address, 'customer.', $values ); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
protected function tearDown() : void |
|
59
|
|
|
{ |
|
60
|
|
|
unset( $this->object ); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function testGetPassword() |
|
64
|
|
|
{ |
|
65
|
|
|
$this->assertEquals( 'testpwd', $this->object->getPassword() ); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function testSetPassword() |
|
69
|
|
|
{ |
|
70
|
|
|
$this->object->setPassword( 'new' ); |
|
71
|
|
|
$this->assertTrue( $this->object->isModified() ); |
|
72
|
|
|
$this->assertEquals( 'new', $this->object->getPassword() ); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function testSetPasswordGenerated() |
|
76
|
|
|
{ |
|
77
|
|
|
$helper = new \Aimeos\Base\Password\Standard(); |
|
78
|
|
|
$object = new \Aimeos\MShop\Customer\Item\FosUser( $this->address, 'customer.', [], $helper ); |
|
79
|
|
|
|
|
80
|
|
|
$object->setPassword( 'newpwd' ); |
|
81
|
|
|
$this->assertStringStartsWith( '$2y$', $object->getPassword() ); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
public function testGetRoles() |
|
85
|
|
|
{ |
|
86
|
|
|
$this->assertEquals( array( 'ROLE_ADMIN' ), $this->object->getRoles() ); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function testSetRoles() |
|
90
|
|
|
{ |
|
91
|
|
|
$this->object->setRoles( array( 'ROLE_USER' ) ); |
|
92
|
|
|
$this->assertTrue( $this->object->isModified() ); |
|
93
|
|
|
$this->assertEquals( array( 'ROLE_USER' ), $this->object->getRoles() ); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function testGetSalt() |
|
97
|
|
|
{ |
|
98
|
|
|
$this->assertEquals( 'test', $this->object->getSalt() ); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function testGetSaltGenerated() |
|
102
|
|
|
{ |
|
103
|
|
|
$object = new \Aimeos\MShop\Customer\Item\FosUser( $this->address, 'customer.' ); |
|
104
|
|
|
$this->assertEquals( '', $object->getSalt() ); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function testSetSalt() |
|
108
|
|
|
{ |
|
109
|
|
|
$this->object->setSalt( 'new' ); |
|
110
|
|
|
$this->assertTrue( $this->object->isModified() ); |
|
111
|
|
|
$this->assertEquals( 'new', $this->object->getSalt() ); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public function testIsModified() |
|
115
|
|
|
{ |
|
116
|
|
|
$this->assertFalse( $this->object->isModified() ); |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
|