-
Notifications
You must be signed in to change notification settings - Fork 157
Expand file tree
/
Copy pathEndpointTest.php
More file actions
94 lines (80 loc) · 2.48 KB
/
EndpointTest.php
File metadata and controls
94 lines (80 loc) · 2.48 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
namespace OpenStack\Sample\Identity\v3;
use OpenStack\Common\Error\BadResponseError;
use OpenStack\Identity\v3\Enum;
use OpenStack\Identity\v3\Models\Endpoint;
class EndpointTest extends TestCase
{
public function testCreate(): Endpoint
{
$service = $this->getService()->createService(['name' => $this->randomStr(), 'type' => 'volume', 'description' => $this->randomStr()]);
/** @var $endpoint \OpenStack\Identity\v3\Models\Endpoint */
require_once $this->sampleFile(
'endpoints/create.php',
[
'{endpointName}' => $this->randomStr(),
'{serviceId}' => $service->id,
'{endpointUrl}' => getenv('OS_AUTH_URL'),
'{region}' => 'RegionOne',
]
);
self::assertInstanceOf(Endpoint::class, $endpoint);
return $endpoint;
}
/**
* @depends testCreate
*/
public function testList(Endpoint $createdEndpoint)
{
$found = false;
require_once $this->sampleFile(
'endpoints/list.php',
[
'/** @var $endpoint \OpenStack\Identity\v3\Models\Endpoint */' => <<<'PHP'
/** @var $endpoint \OpenStack\Identity\v3\Models\Endpoint */
if ($endpoint->id === $createdEndpoint->id) {
$found = true;
}
PHP
,
]
);
$this->assertTrue($found);
}
/**
* @depends testCreate
*/
public function testUpdate(Endpoint $createdEndpoint)
{
$this->assertEquals(Enum::INTERFACE_INTERNAL, $createdEndpoint->interface);
require_once $this->sampleFile(
'endpoints/update.php',
[
'{endpointId}' => $createdEndpoint->id,
]
);
$createdEndpoint->retrieve();
$this->assertEquals(Enum::INTERFACE_PUBLIC, $createdEndpoint->interface);
}
/**
* @depends testCreate
*/
public function testDelete(Endpoint $createdEndpoint)
{
require_once $this->sampleFile(
'endpoints/delete.php',
[
'{endpointId}' => $createdEndpoint->id,
]
);
$found = false;
foreach ($this->getService()->listEndpoints() as $endpoint) {
if ($endpoint->id === $createdEndpoint->id) {
$found = true;
}
}
$this->assertFalse($found);
$this->expectException(BadResponseError::class);
$createdEndpoint->retrieve();
}
}