Skip to content

Commit f322f6a

Browse files
author
Stéphane Bour
committed
chore: bump to php 7.4, guzzle 7, phpunit 9
1 parent c473b3d commit f322f6a

File tree

5 files changed

+43
-43
lines changed

5 files changed

+43
-43
lines changed

.travis.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@ addons:
55

66
language: php
77
php:
8-
- 7.3
9-
- 7.2
10-
- 7.1
11-
- 7.0
12-
- 5.6
8+
- 7.4
139

1410
before_script:
1511
- composer self-update
1612
- composer install
1713

18-
script: vendor/bin/phing test -Donly.units=true
14+
script: vendor/bin/phpunit

composer.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
"description": "Wrapper for OVH APIs",
44
"license": "BSD-3-Clause",
55
"require": {
6-
"guzzlehttp/guzzle": "^6.0"
6+
"php": ">=7.3",
7+
"guzzlehttp/guzzle": "^6.0||^7.0"
78
},
89
"autoload": {
910
"psr-4": {"Ovh\\": "src/"}
1011
},
1112
"require-dev": {
12-
"phpunit/phpunit": "4.*",
13-
"phpdocumentor/phpdocumentor": "2.*",
14-
"squizlabs/php_codesniffer": "2.*",
15-
"phing/phing": "^2.14"
13+
"phpunit/phpunit": "^9.5",
14+
"phpdocumentor/phpdocumentor": "v3.0.0",
15+
"squizlabs/php_codesniffer": "^3.5",
16+
"phpdocumentor/graphviz": "^2.0@dev",
17+
"symfony/flex": "^1.11"
1618
}
1719
}

phpunit.xml.dist

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit colors="true" bootstrap="tests/bootstrap.php">
3-
<testsuites>
4-
<testsuite name="OVH APIs wrapper">
5-
<directory>tests</directory>
6-
</testsuite>
7-
</testsuites>
8-
<php>
9-
<env name="ENDPOINT" value=""/>
10-
<env name="APP_KEY" value=""/>
11-
<env name="APP_SECRET" value=""/>
12-
<env name="CONSUMER" value=""/>
13-
</php>
14-
<filter>
15-
<whitelist>
16-
<directory>src</directory>
17-
</whitelist>
18-
</filter>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory>src</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="OVH APIs wrapper">
10+
<directory>tests</directory>
11+
</testsuite>
12+
</testsuites>
13+
<php>
14+
<env name="ENDPOINT" value=""/>
15+
<env name="APP_KEY" value=""/>
16+
<env name="APP_SECRET" value=""/>
17+
<env name="CONSUMER" value=""/>
18+
</php>
1919
</phpunit>

tests/ApiFunctionalTest.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,17 @@
2828
namespace Ovh\tests;
2929

3030
use GuzzleHttp\Client;
31+
use GuzzleHttp\Exception\ClientException;
3132
use Ovh\Api;
33+
use PHPUnit\Framework\TestCase;
3234

3335
/**
3436
* Functional tests of Api class
3537
*
3638
* @package Ovh
3739
* @category Ovh
3840
*/
39-
class ApiFunctionalTest extends \PHPUnit_Framework_TestCase
41+
class ApiFunctionalTest extends TestCase
4042
{
4143

4244
/**
@@ -82,7 +84,7 @@ class ApiFunctionalTest extends \PHPUnit_Framework_TestCase
8284
/**
8385
* Define id to create object
8486
*/
85-
protected function setUp()
87+
protected function setUp() :void
8688
{
8789
$this->application_key = getenv('APP_KEY');
8890
$this->application_secret = getenv('APP_SECRET');
@@ -238,7 +240,7 @@ public function testIfRequestWithoutAuthenticationWorks()
238240
*/
239241
public function testApiGetWithParameters()
240242
{
241-
$this->setExpectedException('\\GuzzleHttp\\Exception\\ClientException', '400');
243+
$this->expectException(ClientException::class);
242244

243245
$this->api->get('/me/accessRestriction/ip', ['foo' => 'bar']);
244246
}

tests/ApiTest.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,21 @@
2828
namespace Ovh\tests;
2929

3030
use GuzzleHttp\Client;
31+
use GuzzleHttp\Exception\ClientException;
3132
use GuzzleHttp\Middleware;
3233
use GuzzleHttp\Psr7\Response;
3334
use GuzzleHttp\Psr7\Request;
3435
use Ovh\Api;
36+
use Ovh\Exceptions\InvalidParameterException;
37+
use PHPUnit\Framework\TestCase;
3538

3639
/**
3740
* Test Api class
3841
*
3942
* @package Ovh
4043
* @category Ovh
4144
*/
42-
class ApiTest extends \PHPUnit_Framework_TestCase
45+
class ApiTest extends TestCase
4346
{
4447
/**
4548
* @var Client
@@ -69,7 +72,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase
6972
/**
7073
* Define id to create object
7174
*/
72-
protected function setUp()
75+
protected function setUp() :void
7376
{
7477
$this->application_key = 'app_key';
7578
$this->application_secret = 'app_secret';
@@ -116,7 +119,7 @@ protected static function getPrivateProperty($name)
116119
*/
117120
public function testMissingApplicationKey()
118121
{
119-
$this->setExpectedException('\\Ovh\\Exceptions\\InvalidParameterException', 'Application key');
122+
$this->expectException(InvalidParameterException::class);
120123
$api = new Api(null, $this->application_secret, $this->endpoint, $this->consumer_key, $this->client);
121124
$api->get('/me');
122125
}
@@ -126,7 +129,7 @@ public function testMissingApplicationKey()
126129
*/
127130
public function testMissingApplicationSecret()
128131
{
129-
$this->setExpectedException('\\Ovh\\Exceptions\\InvalidParameterException', 'Application secret');
132+
$this->expectException(InvalidParameterException::class);
130133
$api = new Api($this->application_key, null, $this->endpoint, $this->consumer_key, $this->client);
131134
$api->get('/me');
132135
}
@@ -157,7 +160,7 @@ public function testNoCheckAppKeyForUnauthCall()
157160
*/
158161
public function testMissingApiEndpoint()
159162
{
160-
$this->setExpectedException('\\Ovh\\Exceptions\\InvalidParameterException', 'Endpoint');
163+
$this->expectException(InvalidParameterException::class);
161164
new Api($this->application_key, $this->application_secret, null, $this->consumer_key, $this->client);
162165
}
163166

@@ -166,7 +169,7 @@ public function testMissingApiEndpoint()
166169
*/
167170
public function testBadApiEndpoint()
168171
{
169-
$this->setExpectedException('\\Ovh\\Exceptions\\InvalidParameterException', 'Unknown');
172+
$this->expectException(InvalidParameterException::class);
170173
new Api($this->application_key, $this->application_secret, 'i_am_invalid', $this->consumer_key, $this->client);
171174
}
172175

@@ -243,9 +246,8 @@ public function testIfConsumerKeyIsReplace()
243246
*/
244247
public function testInvalidApplicationKey()
245248
{
246-
$this->setExpectedException(
247-
'\GuzzleHttp\Exception\ClientException'
248-
);
249+
250+
$this->expectException(ClientException::class);
249251

250252
$handlerStack = $this->client->getConfig('handler');
251253
$handlerStack->push(Middleware::mapResponse(function (Response $response) {
@@ -276,9 +278,7 @@ public function testInvalidApplicationKey()
276278
*/
277279
public function testInvalidRight()
278280
{
279-
$this->setExpectedException(
280-
'\GuzzleHttp\Exception\ClientException'
281-
);
281+
$this->expectException(ClientException::class);
282282

283283
$handlerStack = $this->client->getConfig('handler');
284284
$handlerStack->push(Middleware::mapResponse(function (Response $response) {

0 commit comments

Comments
 (0)