mirror of
https://github.com/ovh/php-ovh.git
synced 2023-11-05 03:20:26 +01:00
chore: bump to php 7.4, guzzle 7, phpunit 9
This commit is contained in:
parent
c473b3d67e
commit
f322f6a819
@ -5,14 +5,10 @@ addons:
|
|||||||
|
|
||||||
language: php
|
language: php
|
||||||
php:
|
php:
|
||||||
- 7.3
|
- 7.4
|
||||||
- 7.2
|
|
||||||
- 7.1
|
|
||||||
- 7.0
|
|
||||||
- 5.6
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- composer self-update
|
- composer self-update
|
||||||
- composer install
|
- composer install
|
||||||
|
|
||||||
script: vendor/bin/phing test -Donly.units=true
|
script: vendor/bin/phpunit
|
||||||
|
@ -3,15 +3,17 @@
|
|||||||
"description": "Wrapper for OVH APIs",
|
"description": "Wrapper for OVH APIs",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"require": {
|
"require": {
|
||||||
"guzzlehttp/guzzle": "^6.0"
|
"php": ">=7.3",
|
||||||
|
"guzzlehttp/guzzle": "^6.0||^7.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {"Ovh\\": "src/"}
|
"psr-4": {"Ovh\\": "src/"}
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "4.*",
|
"phpunit/phpunit": "^9.5",
|
||||||
"phpdocumentor/phpdocumentor": "2.*",
|
"phpdocumentor/phpdocumentor": "v3.0.0",
|
||||||
"squizlabs/php_codesniffer": "2.*",
|
"squizlabs/php_codesniffer": "^3.5",
|
||||||
"phing/phing": "^2.14"
|
"phpdocumentor/graphviz": "^2.0@dev",
|
||||||
|
"symfony/flex": "^1.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<phpunit colors="true" bootstrap="tests/bootstrap.php">
|
<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">
|
||||||
<testsuites>
|
<coverage>
|
||||||
<testsuite name="OVH APIs wrapper">
|
<include>
|
||||||
<directory>tests</directory>
|
<directory>src</directory>
|
||||||
</testsuite>
|
</include>
|
||||||
</testsuites>
|
</coverage>
|
||||||
<php>
|
<testsuites>
|
||||||
<env name="ENDPOINT" value=""/>
|
<testsuite name="OVH APIs wrapper">
|
||||||
<env name="APP_KEY" value=""/>
|
<directory>tests</directory>
|
||||||
<env name="APP_SECRET" value=""/>
|
</testsuite>
|
||||||
<env name="CONSUMER" value=""/>
|
</testsuites>
|
||||||
</php>
|
<php>
|
||||||
<filter>
|
<env name="ENDPOINT" value=""/>
|
||||||
<whitelist>
|
<env name="APP_KEY" value=""/>
|
||||||
<directory>src</directory>
|
<env name="APP_SECRET" value=""/>
|
||||||
</whitelist>
|
<env name="CONSUMER" value=""/>
|
||||||
</filter>
|
</php>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
@ -28,7 +28,9 @@
|
|||||||
namespace Ovh\tests;
|
namespace Ovh\tests;
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
|
use GuzzleHttp\Exception\ClientException;
|
||||||
use Ovh\Api;
|
use Ovh\Api;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Functional tests of Api class
|
* Functional tests of Api class
|
||||||
@ -36,7 +38,7 @@ use Ovh\Api;
|
|||||||
* @package Ovh
|
* @package Ovh
|
||||||
* @category 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
|
* Define id to create object
|
||||||
*/
|
*/
|
||||||
protected function setUp()
|
protected function setUp() :void
|
||||||
{
|
{
|
||||||
$this->application_key = getenv('APP_KEY');
|
$this->application_key = getenv('APP_KEY');
|
||||||
$this->application_secret = getenv('APP_SECRET');
|
$this->application_secret = getenv('APP_SECRET');
|
||||||
@ -238,7 +240,7 @@ class ApiFunctionalTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testApiGetWithParameters()
|
public function testApiGetWithParameters()
|
||||||
{
|
{
|
||||||
$this->setExpectedException('\\GuzzleHttp\\Exception\\ClientException', '400');
|
$this->expectException(ClientException::class);
|
||||||
|
|
||||||
$this->api->get('/me/accessRestriction/ip', ['foo' => 'bar']);
|
$this->api->get('/me/accessRestriction/ip', ['foo' => 'bar']);
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,13 @@
|
|||||||
namespace Ovh\tests;
|
namespace Ovh\tests;
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
|
use GuzzleHttp\Exception\ClientException;
|
||||||
use GuzzleHttp\Middleware;
|
use GuzzleHttp\Middleware;
|
||||||
use GuzzleHttp\Psr7\Response;
|
use GuzzleHttp\Psr7\Response;
|
||||||
use GuzzleHttp\Psr7\Request;
|
use GuzzleHttp\Psr7\Request;
|
||||||
use Ovh\Api;
|
use Ovh\Api;
|
||||||
|
use Ovh\Exceptions\InvalidParameterException;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Api class
|
* Test Api class
|
||||||
@ -39,7 +42,7 @@ use Ovh\Api;
|
|||||||
* @package Ovh
|
* @package Ovh
|
||||||
* @category Ovh
|
* @category Ovh
|
||||||
*/
|
*/
|
||||||
class ApiTest extends \PHPUnit_Framework_TestCase
|
class ApiTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Client
|
* @var Client
|
||||||
@ -69,7 +72,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Define id to create object
|
* Define id to create object
|
||||||
*/
|
*/
|
||||||
protected function setUp()
|
protected function setUp() :void
|
||||||
{
|
{
|
||||||
$this->application_key = 'app_key';
|
$this->application_key = 'app_key';
|
||||||
$this->application_secret = 'app_secret';
|
$this->application_secret = 'app_secret';
|
||||||
@ -116,7 +119,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testMissingApplicationKey()
|
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 = new Api(null, $this->application_secret, $this->endpoint, $this->consumer_key, $this->client);
|
||||||
$api->get('/me');
|
$api->get('/me');
|
||||||
}
|
}
|
||||||
@ -126,7 +129,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testMissingApplicationSecret()
|
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 = new Api($this->application_key, null, $this->endpoint, $this->consumer_key, $this->client);
|
||||||
$api->get('/me');
|
$api->get('/me');
|
||||||
}
|
}
|
||||||
@ -157,7 +160,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testMissingApiEndpoint()
|
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);
|
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()
|
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);
|
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()
|
public function testInvalidApplicationKey()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
|
||||||
'\GuzzleHttp\Exception\ClientException'
|
$this->expectException(ClientException::class);
|
||||||
);
|
|
||||||
|
|
||||||
$handlerStack = $this->client->getConfig('handler');
|
$handlerStack = $this->client->getConfig('handler');
|
||||||
$handlerStack->push(Middleware::mapResponse(function (Response $response) {
|
$handlerStack->push(Middleware::mapResponse(function (Response $response) {
|
||||||
@ -276,9 +278,7 @@ class ApiTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidRight()
|
public function testInvalidRight()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
$this->expectException(ClientException::class);
|
||||||
'\GuzzleHttp\Exception\ClientException'
|
|
||||||
);
|
|
||||||
|
|
||||||
$handlerStack = $this->client->getConfig('handler');
|
$handlerStack = $this->client->getConfig('handler');
|
||||||
$handlerStack->push(Middleware::mapResponse(function (Response $response) {
|
$handlerStack->push(Middleware::mapResponse(function (Response $response) {
|
||||||
|
Loading…
Reference in New Issue
Block a user