Skip to content

Commit c2bafcf

Browse files
committed
Added missing unit tests
1 parent 76e7889 commit c2bafcf

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace OpenStack\Test\Metric\v1\Gnocchi\Models;
4+
5+
use OpenStack\Metric\v1\Gnocchi\Models\Metric;
6+
use OpenStack\Metric\v1\Gnocchi\Api;
7+
use OpenStack\Test\TestCase;
8+
9+
class MetricTest extends TestCase
10+
{
11+
/** @var Metric */
12+
private $metric;
13+
14+
public function setUp()
15+
{
16+
parent::setUp();
17+
18+
$this->rootFixturesDir = dirname(__DIR__);
19+
20+
$this->metric = new Metric($this->client->reveal(), new Api());
21+
$this->metric->id = '000b7bf8-0271-46dd-90aa-cfe89026a55a';
22+
}
23+
24+
public function test_it_retrieves()
25+
{
26+
$this->setupMock('GET', 'v1/metric/000b7bf8-0271-46dd-90aa-cfe89026a55a', null, [], 'metric-get');
27+
$this->metric->retrieve();
28+
29+
$this->assertEquals('000b7bf8-0271-46dd-90aa-cfe89026a55a', $this->metric->id);
30+
$this->assertEquals('storage.objects.outgoing.bytes', $this->metric->name);
31+
}
32+
}

tests/unit/OpenStackTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use OpenStack\ObjectStore\v1\Service as ObjectStoreServiceV1;
1616
use OpenStack\BlockStorage\v2\Service as BlockStorageServiceV2;
1717
use OpenStack\Images\v2\Service as ImageServiceV2;
18+
use OpenStack\Metric\v1\Gnocchi\Service as MetricGnocchiV1;
1819

1920
class OpenStackTest extends TestCase
2021
{
@@ -118,6 +119,16 @@ public function test_it_supports_images_v2()
118119
$this->openstack->imagesV2();
119120
}
120121

122+
public function test_it_support_metrics_gnocchi_v1()
123+
{
124+
$this->builder
125+
->createService('Metric\\v1\\Gnocchi', ['catalogName' => 'gnocchi', 'catalogType' => 'metric'])
126+
->shouldBeCalled()
127+
->willReturn($this->service(MetricGnocchiV1::class));
128+
129+
$this->openstack->metricGnocchiV1();
130+
}
131+
121132
private function service($class)
122133
{
123134
return new $class($this->prophesize(ClientInterface::class)->reveal(), new Api());

0 commit comments

Comments
 (0)