28
28
namespace Ovh \tests ;
29
29
30
30
use GuzzleHttp \Client ;
31
+ use GuzzleHttp \Exception \ClientException ;
31
32
use GuzzleHttp \Middleware ;
32
33
use GuzzleHttp \Psr7 \Response ;
33
34
use GuzzleHttp \Psr7 \Request ;
34
35
use Ovh \Api ;
36
+ use Ovh \Exceptions \InvalidParameterException ;
37
+ use PHPUnit \Framework \TestCase ;
35
38
36
39
/**
37
40
* Test Api class
38
41
*
39
42
* @package Ovh
40
43
* @category Ovh
41
44
*/
42
- class ApiTest extends \PHPUnit_Framework_TestCase
45
+ class ApiTest extends TestCase
43
46
{
44
47
/**
45
48
* @var Client
@@ -69,7 +72,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase
69
72
/**
70
73
* Define id to create object
71
74
*/
72
- protected function setUp ()
75
+ protected function setUp () : void
73
76
{
74
77
$ this ->application_key = 'app_key ' ;
75
78
$ this ->application_secret = 'app_secret ' ;
@@ -116,7 +119,7 @@ protected static function getPrivateProperty($name)
116
119
*/
117
120
public function testMissingApplicationKey ()
118
121
{
119
- $ this ->setExpectedException ( '\\ Ovh \\ Exceptions \\ InvalidParameterException ' , ' Application key ' );
122
+ $ this ->expectException ( InvalidParameterException::class );
120
123
$ api = new Api (null , $ this ->application_secret , $ this ->endpoint , $ this ->consumer_key , $ this ->client );
121
124
$ api ->get ('/me ' );
122
125
}
@@ -126,7 +129,7 @@ public function testMissingApplicationKey()
126
129
*/
127
130
public function testMissingApplicationSecret ()
128
131
{
129
- $ this ->setExpectedException ( '\\ Ovh \\ Exceptions \\ InvalidParameterException ' , ' Application secret ' );
132
+ $ this ->expectException ( InvalidParameterException::class );
130
133
$ api = new Api ($ this ->application_key , null , $ this ->endpoint , $ this ->consumer_key , $ this ->client );
131
134
$ api ->get ('/me ' );
132
135
}
@@ -157,7 +160,7 @@ public function testNoCheckAppKeyForUnauthCall()
157
160
*/
158
161
public function testMissingApiEndpoint ()
159
162
{
160
- $ this ->setExpectedException ( '\\ Ovh \\ Exceptions \\ InvalidParameterException ' , ' Endpoint ' );
163
+ $ this ->expectException ( InvalidParameterException::class );
161
164
new Api ($ this ->application_key , $ this ->application_secret , null , $ this ->consumer_key , $ this ->client );
162
165
}
163
166
@@ -166,7 +169,7 @@ public function testMissingApiEndpoint()
166
169
*/
167
170
public function testBadApiEndpoint ()
168
171
{
169
- $ this ->setExpectedException ( '\\ Ovh \\ Exceptions \\ InvalidParameterException ' , ' Unknown ' );
172
+ $ this ->expectException ( InvalidParameterException::class );
170
173
new Api ($ this ->application_key , $ this ->application_secret , 'i_am_invalid ' , $ this ->consumer_key , $ this ->client );
171
174
}
172
175
@@ -243,9 +246,8 @@ public function testIfConsumerKeyIsReplace()
243
246
*/
244
247
public function testInvalidApplicationKey ()
245
248
{
246
- $ this ->setExpectedException (
247
- '\GuzzleHttp\Exception\ClientException '
248
- );
249
+
250
+ $ this ->expectException (ClientException::class);
249
251
250
252
$ handlerStack = $ this ->client ->getConfig ('handler ' );
251
253
$ handlerStack ->push (Middleware::mapResponse (function (Response $ response ) {
@@ -276,9 +278,7 @@ public function testInvalidApplicationKey()
276
278
*/
277
279
public function testInvalidRight ()
278
280
{
279
- $ this ->setExpectedException (
280
- '\GuzzleHttp\Exception\ClientException '
281
- );
281
+ $ this ->expectException (ClientException::class);
282
282
283
283
$ handlerStack = $ this ->client ->getConfig ('handler ' );
284
284
$ handlerStack ->push (Middleware::mapResponse (function (Response $ response ) {
0 commit comments