@@ -11,21 +11,19 @@ class ParameterTest extends \PHPUnit\Framework\TestCase
1111 private $ data ;
1212 private $ api ;
1313
14- public function setUp ()
14+ public function setUp (): void
1515 {
1616 $ this ->api = new ComputeV2Api ();
1717
1818 $ this ->data = $ this ->api ->postServer ()['params ' ]['name ' ] + ['name ' => 'name ' ];
1919 $ this ->param = new Parameter ($ this ->data );
2020 }
2121
22- /**
23- * @expectedException \RuntimeException
24- */
2522 public function test_exception_is_thrown_for_invalid_locations ()
2623 {
2724 $ data = $ this ->data ;
2825 $ data ['location ' ] = 'foo ' ;
26+ $ this ->expectException (\RuntimeException::class);
2927 new Parameter ($ data );
3028 }
3129
@@ -82,25 +80,21 @@ public function test_it_should_return_true_when_required_attributes_are_provided
8280 $ this ->assertTrue ($ this ->param ->validate ('TestName ' ));
8381 }
8482
85- /**
86- * @expectedException \Exception
87- */
8883 public function test_it_throws_exception_when_values_do_not_match_their_definition_types ()
8984 {
9085 $ data = $ this ->api ->postServer ()['params ' ]['networks ' ] + ['name ' => 'networks ' ];
9186 $ param = new Parameter ($ data );
87+ $ this ->expectException (\Exception::class);
9288
9389 $ param ->validate ('a_network! ' ); // should be an array
9490 }
9591
96- /**
97- * @expectedException \Exception
98- */
9992 public function test_it_throws_exception_when_deeply_nested_values_have_wrong_types ()
10093 {
10194 $ data = $ this ->api ->postServer ()['params ' ]['networks ' ] + ['name ' => 'networks ' ];
102-
10395 $ param = new Parameter ($ data );
96+ $ this ->expectException (\Exception::class);
97+
10498 $ param ->validate (['name ' => false ]); // value should be a string, not bool
10599 }
106100
@@ -134,15 +128,13 @@ public function test_it_passes_validation_when_array_values_pass()
134128 $ this ->assertTrue ($ param ->validate ($ userVals ));
135129 }
136130
137- /**
138- * @expectedException \Exception
139- */
140131 public function test_an_exception_is_thrown_when_an_undefined_property_is_provided ()
141132 {
142133 $ params = ['type ' => 'object ' , 'properties ' => ['foo ' => ['type ' => 'string ' ]]];
143134 $ userVals = ['bar ' => 'baz ' ];
144-
145135 $ param = new Parameter ($ params );
136+ $ this ->expectException (\Exception::class);
137+
146138 $ param ->validate ($ userVals );
147139 }
148140
@@ -187,15 +179,13 @@ public function test_it_gets_prefixed_name()
187179 $ this ->assertEquals ('foo-metadata ' , $ property ->getPrefixedName ());
188180 }
189181
190- /**
191- * @expectedException \Exception
192- */
193182 public function test_exception_is_thrown_when_value_is_not_in_enum_list ()
194183 {
195184 $ data = $ this ->data ;
196185 $ data ['enum ' ] = ['foo ' ];
197-
198186 $ param = new Parameter ($ data );
187+ $ this ->expectException (\Exception::class);
188+
199189 $ param ->validate ('blah ' );
200190 }
201191}
0 commit comments