|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* test security contract (mainly getters and defaults) |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace Graviton\SecurityBundle\Entities; |
|
7
|
|
|
|
|
8
|
|
|
use Graviton\TestBundle\Test\WebTestCase; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class SecurityContractTest |
|
12
|
|
|
* |
|
13
|
|
|
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors> |
|
14
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
15
|
|
|
* @link http://swisscom.ch |
|
16
|
|
|
*/ |
|
17
|
|
|
class SecurityUserTest extends WebTestCase |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @param string[] $methods methods to mock |
|
21
|
|
|
* |
|
22
|
|
|
* @return \PHPUnit_Framework_MockObject_MockObject|\Graviton\SecurityBundle\Entities\SecurityUser |
|
23
|
|
|
*/ |
|
24
|
|
|
protected function getUserMock(array $methods = array()) |
|
25
|
|
|
{ |
|
26
|
|
|
return $this->getMockBuilder('\Graviton\SecurityBundle\Entities\SecurityUser') |
|
27
|
|
|
->disableOriginalConstructor() |
|
28
|
|
|
->setMethods($methods) |
|
29
|
|
|
->getMock(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* roles should always return an array |
|
34
|
|
|
* |
|
35
|
|
|
* @return void |
|
36
|
|
|
*/ |
|
37
|
|
|
public function testGetRoles() |
|
38
|
|
|
{ |
|
39
|
|
|
$entity = new SecurityUser($this->getUserMock()); |
|
40
|
|
|
|
|
41
|
|
|
$this->assertInternalType('array', $entity->getRoles()); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* get password should return empty |
|
46
|
|
|
* |
|
47
|
|
|
* @return void |
|
48
|
|
|
*/ |
|
49
|
|
|
public function testGetPassword() |
|
50
|
|
|
{ |
|
51
|
|
|
$entity = new SecurityUser($this->getUserMock()); |
|
52
|
|
|
|
|
53
|
|
|
$this->assertEmpty($entity->getPassword()); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* get salt should return empty |
|
58
|
|
|
* |
|
59
|
|
|
* @return void |
|
60
|
|
|
*/ |
|
61
|
|
|
public function testGetSalt() |
|
62
|
|
|
{ |
|
63
|
|
|
$entity = new SecurityUser($this->getUserMock()); |
|
64
|
|
|
|
|
65
|
|
|
$this->assertEmpty($entity->getSalt()); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* test credential removal |
|
70
|
|
|
* |
|
71
|
|
|
* @return void |
|
72
|
|
|
*/ |
|
73
|
|
|
public function testEraseCredentials() |
|
74
|
|
|
{ |
|
75
|
|
|
$entity = new SecurityUser($this->getUserMock()); |
|
76
|
|
|
|
|
77
|
|
|
$this->assertEmpty($entity->eraseCredentials()); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|