Skip to content

Commit 6aa1859

Browse files
committed
Networking/Model/Quota unit test
1 parent 36157e7 commit 6aa1859

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
HTTP/1.1 200 OK
2+
Content-Type: application/json
3+
4+
{
5+
"quota":{
6+
"subnet":10,
7+
"network":10,
8+
"floatingip":50,
9+
"subnetpool":-1,
10+
"security_group_rule":100,
11+
"security_group":10,
12+
"router":10,
13+
"rbac_policy":10,
14+
"port":50
15+
}
16+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
namespace OpenStack\Test\Subneting\v2\Models;
4+
5+
use GuzzleHttp\Psr7\Response;
6+
use OpenStack\Networking\v2\Api;
7+
use OpenStack\Networking\v2\Models\Port;
8+
use OpenStack\Networking\v2\Models\Quota;
9+
use OpenStack\Test\TestCase;
10+
11+
class QuotaTest extends TestCase
12+
{
13+
const TENANT_ID = 'aaaaaaa-bbbbbb-cccc-dddddd';
14+
15+
/** @var Port */
16+
private $quota;
17+
18+
public function setUp()
19+
{
20+
parent::setUp();
21+
22+
$this->rootFixturesDir = dirname(__DIR__);
23+
24+
$this->quota = new Quota($this->client->reveal(), new Api());
25+
$this->quota->tenantId = self::TENANT_ID;
26+
}
27+
28+
public function test_it_retrieves()
29+
{
30+
$this->setupMock('GET', 'v2.0/quotas/' . self::TENANT_ID, null, [], 'quota-get');
31+
32+
$this->quota->retrieve();
33+
}
34+
35+
public function test_it_deletes()
36+
{
37+
$this->setupMock('DELETE', 'v2.0/quotas/' . self::TENANT_ID, null, [], new Response(204));
38+
39+
$this->quota->delete();
40+
}
41+
42+
public function test_it_updates()
43+
{
44+
$this->quota->subnet = 11;
45+
$this->quota->network = 22;
46+
$this->quota->floatingip = 33;
47+
$this->quota->subnetpool = 44;
48+
$this->quota->securityGroupRule = 55;
49+
$this->quota->securityGroup = 66;
50+
$this->quota->router = 77;
51+
$this->quota->rbacPolicy = 88;
52+
$this->quota->port = 99;
53+
54+
$expectedJson = ['quota' => [
55+
'subnet' => 11,
56+
'network' => 22,
57+
'floatingip' => 33,
58+
'subnetpool' => 44,
59+
'security_group_rule' => 55,
60+
'security_group' => 66,
61+
'router' => 77,
62+
'rbac_policy' => 88,
63+
'port' => 99
64+
]];
65+
66+
$this->setupMock('PUT', 'v2.0/quotas/' . self::TENANT_ID, $expectedJson, [], 'quota-get');
67+
68+
$this->quota->update();
69+
}
70+
}

0 commit comments

Comments
 (0)