7
7
use OpenCloud \Common \Service \Builder ;
8
8
use OpenStack \Identity \v3 \Api ;
9
9
use OpenStack \OpenStack ;
10
+ use OpenStack \Compute \v2 \Service as ComputeServiceV2 ;
11
+ use OpenStack \Identity \v2 \Service as IdentityServiceV2 ;
12
+ use OpenStack \Identity \v3 \Service as IdentityServiceV3 ;
13
+ use OpenStack \Networking \v2 \Service as NetworkingServiceV2 ;
14
+ use OpenStack \Networking \v2 \Extensions \Layer3 \Service as NetworkingServiceV2ExtLayer3 ;
15
+ use OpenStack \Networking \v2 \Extensions \SecurityGroups \Service as NetworkingServiceV2ExtSecGroup ;
16
+ use OpenStack \ObjectStore \v1 \Service as ObjectStoreServiceV1 ;
17
+ use OpenStack \BlockStorage \v2 \Service as BlockStorageServiceV2 ;
18
+ use OpenStack \Images \v2 \Service as ImageServiceV2 ;
10
19
11
20
class OpenStackTest extends TestCase
12
21
{
13
22
private $ builder ;
23
+ /** @var OpenStack */
14
24
private $ openstack ;
15
25
16
26
public function setUp ()
@@ -24,7 +34,7 @@ public function test_it_supports_compute_v2()
24
34
$ this ->builder
25
35
->createService ('Compute \\v2 ' , ['catalogName ' => 'nova ' , 'catalogType ' => 'compute ' ])
26
36
->shouldBeCalled ()
27
- ->willReturn ($ this ->service (' Compute ' , 2 ));
37
+ ->willReturn ($ this ->service (ComputeServiceV2::class ));
28
38
29
39
$ this ->openstack ->computeV2 ();
30
40
}
@@ -34,7 +44,7 @@ public function test_it_supports_identity_v2()
34
44
$ this ->builder
35
45
->createService ('Identity \\v2 ' , ['catalogName ' => 'keystone ' , 'catalogType ' => 'identity ' ])
36
46
->shouldBeCalled ()
37
- ->willReturn ($ this ->service (' Identity ' , 2 ));
47
+ ->willReturn ($ this ->service (IdentityServiceV2::class ));
38
48
39
49
$ this ->openstack ->identityV2 ();
40
50
}
@@ -44,7 +54,7 @@ public function test_it_supports_identity_v3()
44
54
$ this ->builder
45
55
->createService ('Identity \\v3 ' , ['catalogName ' => 'keystone ' , 'catalogType ' => 'identity ' ])
46
56
->shouldBeCalled ()
47
- ->willReturn ($ this ->service (' Identity ' , 3 ));
57
+ ->willReturn ($ this ->service (IdentityServiceV3::class ));
48
58
49
59
$ this ->openstack ->identityV3 ();
50
60
}
@@ -54,17 +64,37 @@ public function test_it_supports_networking_v2()
54
64
$ this ->builder
55
65
->createService ('Networking \\v2 ' , ['catalogName ' => 'neutron ' , 'catalogType ' => 'network ' ])
56
66
->shouldBeCalled ()
57
- ->willReturn ($ this ->service (' Networking ' , 2 ));
67
+ ->willReturn ($ this ->service (NetworkingServiceV2::class ));
58
68
59
69
$ this ->openstack ->networkingV2 ();
60
70
}
61
71
72
+ public function test_it_supports_networking_v2_ext_layer3 ()
73
+ {
74
+ $ this ->builder
75
+ ->createService ('Networking \\v2 \\Extensions \\Layer3 ' , ['catalogName ' => 'neutron ' , 'catalogType ' => 'network ' ])
76
+ ->shouldBeCalled ()
77
+ ->willReturn ($ this ->service (NetworkingServiceV2ExtLayer3::class));
78
+
79
+ $ this ->openstack ->networkingV2ExtLayer3 ();
80
+ }
81
+
82
+ public function test_it_supports_networking_v2_ext_security_group ()
83
+ {
84
+ $ this ->builder
85
+ ->createService ('Networking \\v2 \\Extensions \\SecurityGroups ' , ['catalogName ' => 'neutron ' , 'catalogType ' => 'network ' ])
86
+ ->shouldBeCalled ()
87
+ ->willReturn ($ this ->service (NetworkingServiceV2ExtSecGroup::class));
88
+
89
+ $ this ->openstack ->networkingV2ExtSecGroups ();
90
+ }
91
+
62
92
public function test_it_supports_object_store_v1 ()
63
93
{
64
94
$ this ->builder
65
95
->createService ('ObjectStore \\v1 ' , ['catalogName ' => 'swift ' , 'catalogType ' => 'object-store ' ])
66
96
->shouldBeCalled ()
67
- ->willReturn ($ this ->service (' ObjectStore ' , 1 ));
97
+ ->willReturn ($ this ->service (ObjectStoreServiceV1::class ));
68
98
69
99
$ this ->openstack ->objectStoreV1 ();
70
100
}
@@ -74,7 +104,7 @@ public function test_it_supports_block_storage_v2()
74
104
$ this ->builder
75
105
->createService ('BlockStorage \\v2 ' , ['catalogName ' => 'cinderv2 ' , 'catalogType ' => 'volumev2 ' ])
76
106
->shouldBeCalled ()
77
- ->willReturn ($ this ->service (' BlockStorage ' , 2 ));
107
+ ->willReturn ($ this ->service (BlockStorageServiceV2::class ));
78
108
79
109
$ this ->openstack ->blockStorageV2 ();
80
110
}
@@ -84,15 +114,13 @@ public function test_it_supports_images_v2()
84
114
$ this ->builder
85
115
->createService ('Images \\v2 ' , ['catalogName ' => 'glance ' , 'catalogType ' => 'image ' ])
86
116
->shouldBeCalled ()
87
- ->willReturn ($ this ->service (' Images ' , 2 ));
117
+ ->willReturn ($ this ->service (ImageServiceV2::class ));
88
118
89
119
$ this ->openstack ->imagesV2 ();
90
120
}
91
121
92
- private function service ($ service , $ version )
122
+ private function service ($ class )
93
123
{
94
- $ class = sprintf ("OpenStack \\%s \\v%d \\Service " , $ service , $ version );
95
-
96
124
return new $ class ($ this ->prophesize (ClientInterface::class)->reveal (), new Api ());
97
125
}
98
126
}
0 commit comments