|
| 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