diff --git a/.travis.yml b/.travis.yml index 6038996..279cd4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,14 +5,10 @@ addons: language: php php: - - 7.3 - - 7.2 - - 7.1 - - 7.0 - - 5.6 + - 7.4 before_script: - composer self-update - composer install -script: vendor/bin/phing test -Donly.units=true +script: vendor/bin/phpunit diff --git a/composer.json b/composer.json index 823c769..5b4ad1b 100644 --- a/composer.json +++ b/composer.json @@ -3,15 +3,17 @@ "description": "Wrapper for OVH APIs", "license": "BSD-3-Clause", "require": { - "guzzlehttp/guzzle": "^6.0" + "php": ">=7.3", + "guzzlehttp/guzzle": "^6.0||^7.0" }, "autoload": { "psr-4": {"Ovh\\": "src/"} }, "require-dev": { - "phpunit/phpunit": "4.*", - "phpdocumentor/phpdocumentor": "2.*", - "squizlabs/php_codesniffer": "2.*", - "phing/phing": "^2.14" + "phpunit/phpunit": "^9.5", + "phpdocumentor/phpdocumentor": "v3.0.0", + "squizlabs/php_codesniffer": "^3.5", + "phpdocumentor/graphviz": "^2.0@dev", + "symfony/flex": "^1.11" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index aa6b117..0f9e1cf 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,19 +1,19 @@ - - - - tests - - - - - - - - - - - src - - + + + + src + + + + + tests + + + + + + + + diff --git a/tests/ApiFunctionalTest.php b/tests/ApiFunctionalTest.php index 59d3954..512509c 100644 --- a/tests/ApiFunctionalTest.php +++ b/tests/ApiFunctionalTest.php @@ -28,7 +28,9 @@ namespace Ovh\tests; use GuzzleHttp\Client; +use GuzzleHttp\Exception\ClientException; use Ovh\Api; +use PHPUnit\Framework\TestCase; /** * Functional tests of Api class @@ -36,7 +38,7 @@ use Ovh\Api; * @package Ovh * @category Ovh */ -class ApiFunctionalTest extends \PHPUnit_Framework_TestCase +class ApiFunctionalTest extends TestCase { /** @@ -82,7 +84,7 @@ class ApiFunctionalTest extends \PHPUnit_Framework_TestCase /** * Define id to create object */ - protected function setUp() + protected function setUp() :void { $this->application_key = getenv('APP_KEY'); $this->application_secret = getenv('APP_SECRET'); @@ -238,7 +240,7 @@ class ApiFunctionalTest extends \PHPUnit_Framework_TestCase */ public function testApiGetWithParameters() { - $this->setExpectedException('\\GuzzleHttp\\Exception\\ClientException', '400'); + $this->expectException(ClientException::class); $this->api->get('/me/accessRestriction/ip', ['foo' => 'bar']); } diff --git a/tests/ApiTest.php b/tests/ApiTest.php index 970fb6d..fada6ae 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -28,10 +28,13 @@ namespace Ovh\tests; use GuzzleHttp\Client; +use GuzzleHttp\Exception\ClientException; use GuzzleHttp\Middleware; use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Request; use Ovh\Api; +use Ovh\Exceptions\InvalidParameterException; +use PHPUnit\Framework\TestCase; /** * Test Api class @@ -39,7 +42,7 @@ use Ovh\Api; * @package Ovh * @category Ovh */ -class ApiTest extends \PHPUnit_Framework_TestCase +class ApiTest extends TestCase { /** * @var Client @@ -69,7 +72,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase /** * Define id to create object */ - protected function setUp() + protected function setUp() :void { $this->application_key = 'app_key'; $this->application_secret = 'app_secret'; @@ -116,7 +119,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase */ public function testMissingApplicationKey() { - $this->setExpectedException('\\Ovh\\Exceptions\\InvalidParameterException', 'Application key'); + $this->expectException(InvalidParameterException::class); $api = new Api(null, $this->application_secret, $this->endpoint, $this->consumer_key, $this->client); $api->get('/me'); } @@ -126,7 +129,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase */ public function testMissingApplicationSecret() { - $this->setExpectedException('\\Ovh\\Exceptions\\InvalidParameterException', 'Application secret'); + $this->expectException(InvalidParameterException::class); $api = new Api($this->application_key, null, $this->endpoint, $this->consumer_key, $this->client); $api->get('/me'); } @@ -157,7 +160,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase */ public function testMissingApiEndpoint() { - $this->setExpectedException('\\Ovh\\Exceptions\\InvalidParameterException', 'Endpoint'); + $this->expectException(InvalidParameterException::class); new Api($this->application_key, $this->application_secret, null, $this->consumer_key, $this->client); } @@ -166,7 +169,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase */ public function testBadApiEndpoint() { - $this->setExpectedException('\\Ovh\\Exceptions\\InvalidParameterException', 'Unknown'); + $this->expectException(InvalidParameterException::class); new Api($this->application_key, $this->application_secret, 'i_am_invalid', $this->consumer_key, $this->client); } @@ -243,9 +246,8 @@ class ApiTest extends \PHPUnit_Framework_TestCase */ public function testInvalidApplicationKey() { - $this->setExpectedException( - '\GuzzleHttp\Exception\ClientException' - ); + + $this->expectException(ClientException::class); $handlerStack = $this->client->getConfig('handler'); $handlerStack->push(Middleware::mapResponse(function (Response $response) { @@ -276,9 +278,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase */ public function testInvalidRight() { - $this->setExpectedException( - '\GuzzleHttp\Exception\ClientException' - ); + $this->expectException(ClientException::class); $handlerStack = $this->client->getConfig('handler'); $handlerStack->push(Middleware::mapResponse(function (Response $response) {