1
1
<?php
2
+
2
3
namespace OpenStack \Test \Metric \v1 \Gnocchi ;
3
4
4
5
use OpenStack \Metric \v1 \Gnocchi \Models \Metric ;
@@ -12,34 +13,43 @@ class ServiceTest extends TestCase
12
13
{
13
14
/** @var Service */
14
15
private $ service ;
16
+
15
17
public function setUp ()
16
18
{
17
19
parent ::setUp ();
18
20
$ this ->rootFixturesDir = __DIR__ ;
19
21
$ this ->service = new Service ($ this ->client ->reveal (), new Api ());
20
22
}
23
+
21
24
public function test_it_lists_resource_types ()
22
25
{
23
26
$ this ->client
24
27
->request ('GET ' , 'v1/resource_type ' , ['headers ' => []])
25
28
->shouldBeCalled ()
26
29
->willReturn ($ this ->getFixture ('resourcetypes-get ' ));
30
+
27
31
$ result = $ this ->service ->listResourceTypes ();
32
+
28
33
$ this ->assertContainsOnlyInstancesOf (ResourceType::class, $ result );
29
34
}
35
+
30
36
public function test_it_lists_resources ()
31
37
{
32
38
$ this ->client
33
39
->request ('GET ' , 'v1/resource/generic ' , ['headers ' => [], 'query ' => ['limit ' => 3 ]])
34
40
->shouldBeCalled ()
35
41
->willReturn ($ this ->getFixture ('resources-get ' ));
42
+
36
43
$ result = $ this ->service ->listResources (['limit ' => 3 ]);
44
+
37
45
$ this ->assertContainsOnlyInstancesOf (Resource::class, $ result );
38
46
}
47
+
39
48
public function test_it_get_resource ()
40
49
{
41
50
$ this ->assertInstanceOf (Resource::class, $ this ->service ->getResource (['id ' => '1 ' ]));
42
51
}
52
+
43
53
public function test_it_search_resources ()
44
54
{
45
55
$ this ->client
@@ -49,24 +59,31 @@ public function test_it_search_resources()
49
59
$ result = $ this ->service ->searchResources (['type ' => 'generic ' ]);
50
60
$ this ->assertContainsOnlyInstancesOf (Resource::class, $ result );
51
61
}
62
+
52
63
public function test_it_search_resources_with_custom_type ()
53
64
{
54
65
$ this ->client
55
66
->request ('POST ' , 'v1/search/resource/instance ' , ['headers ' => ['Content-Type ' => 'application/json ' ]])
56
67
->shouldBeCalled ()
57
68
->willReturn ($ this ->getFixture ('resources-get ' ));
69
+
58
70
$ result = $ this ->service ->searchResources (['type ' => 'instance ' ]);
71
+
59
72
$ this ->assertContainsOnlyInstancesOf (Resource::class, $ result );
60
73
}
74
+
61
75
public function test_it_lists_metrics ()
62
76
{
63
77
$ this ->client
64
78
->request ('GET ' , 'v1/metric ' , ['headers ' => [], 'query ' => ['limit ' => 5 ]])
65
79
->shouldBeCalled ()
66
80
->willReturn ($ this ->getFixture ('metrics-get ' ));
81
+
67
82
$ result = $ this ->service ->listMetrics (['limit ' => 5 ]);
83
+
68
84
$ this ->assertContainsOnlyInstancesOf (Metric::class, $ result );
69
85
}
86
+
70
87
public function test_it_get_metric ()
71
88
{
72
89
$ this ->assertInstanceOf (Metric::class, $ this ->service ->getMetric ('metric-id ' ));
0 commit comments