-
Notifications
You must be signed in to change notification settings - Fork 157
Expand file tree
/
Copy pathRoleTest.php
More file actions
66 lines (56 loc) · 1.76 KB
/
RoleTest.php
File metadata and controls
66 lines (56 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace OpenStack\Sample\Identity\v3;
use OpenStack\Identity\v3\Models\Role;
class RoleTest extends TestCase
{
public function testCreate(): Role
{
/** @var $role \OpenStack\Identity\v3\Models\Role */
require_once $this->sampleFile('roles/create.php', ['{name}' => $this->randomStr()]);
$this->assertInstanceOf(Role::class, $role);
return $role;
}
/**
* @depends testCreate
*/
public function testList(Role $createdRole): void
{
$found = false;
require_once $this->sampleFile(
'roles/list.php',
[
'/** @var $role \OpenStack\Identity\v3\Models\Role */' => <<<'PHP'
/** @var $role \OpenStack\Identity\v3\Models\Role */
if ($role->id === $createdRole->id) {
$found = true;
}
PHP
,
]
);
$this->assertTrue($found);
}
/**
* @depends testCreate
*/
public function testListAssignments(Role $createdRole): void
{
$createdDomain = $this->getService()->createDomain(['name' => $this->randomStr()]);
$createdUser = $this->getService()->createUser(['name' => $this->randomStr(), 'domainId' => $createdDomain->id]);
$createdDomain->grantUserRole(['userId' => $createdUser->id, 'roleId' => $createdRole->id]);
$found = false;
require_once $this->sampleFile(
'roles/list_assignments.php',
[
'/** @var $assignment \OpenStack\Identity\v3\Models\Assignment */' => <<<'PHP'
/** @var $assignment \OpenStack\Identity\v3\Models\Assignment */
if ($assignment->user !== null && $assignment->user->id === $createdUser->id) {
$found = true;
}
PHP
,
]
);
$this->assertTrue($found);
}
}