diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
new file mode 100644
index 0000000..1611c6b
--- /dev/null
+++ b/.github/workflows/ci.yaml
@@ -0,0 +1,97 @@
+# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
+
+name: "CI"
+
+on:
+ pull_request:
+ push:
+ branches:
+ - "main"
+ - "master"
+
+env:
+ COMPOSER_ROOT_VERSION: "1.99.99"
+ APP_KEY: ${{ secrets.OVH_TESTS_APP_KEY }}
+ APP_SECRET: ${{ secrets.OVH_TESTS_APP_SECRET }}
+ CONSUMER: ${{ secrets.OVH_TESTS_CONSUMER_KEY }}
+ ENDPOINT: ${{ secrets.OVH_TESTS_ENDPOINT }}
+
+jobs:
+
+ lint:
+ name: "Lint"
+ runs-on: "ubuntu-latest"
+ strategy:
+ fail-fast: false
+ matrix:
+ php-version: [ '7.4', '8.0', '8.1', '8.2' ]
+ steps:
+ - uses: "actions/checkout@v2"
+ - uses: "shivammathur/setup-php@v2"
+ with:
+ php-version: "${{ matrix.php-version }}"
+ coverage: "none"
+ ini-values: "memory_limit=-1, zend.assertions=1, error_reporting=-1, display_errors=On"
+ tools: "composer:v2"
+ - uses: "ramsey/composer-install@v2"
+ - name: "Lint the PHP source code"
+ run: "composer parallel-lint"
+
+ coding-standards:
+ name: "Coding Standards"
+ runs-on: "ubuntu-latest"
+ steps:
+ - uses: "actions/checkout@v2"
+ - uses: "shivammathur/setup-php@v2"
+ with:
+ php-version: "latest"
+ coverage: "none"
+ ini-values: "memory_limit=-1"
+ tools: "composer:v2"
+ - uses: "ramsey/composer-install@v2"
+ - name: "Check coding standards"
+ run: "composer phpcs"
+
+ coverage:
+ name: "Coverage"
+ runs-on: "ubuntu-latest"
+ steps:
+ - uses: "actions/checkout@v2"
+ - uses: "shivammathur/setup-php@v2"
+ with:
+ php-version: "latest"
+ coverage: "pcov"
+ ini-values: "memory_limit=-1, zend.assertions=1, error_reporting=-1, display_errors=On"
+ tools: "composer"
+ - name: "Prepare for tests"
+ run: "mkdir -p build/logs"
+ - uses: "ramsey/composer-install@v2"
+ - name: "Run unit tests"
+ run: "composer phpunit"
+ - name: "Publish coverage report to Codecov"
+ uses: "codecov/codecov-action@v2"
+ with:
+ files: ./build/logs/clover.xml
+
+ unit-tests:
+ needs: coverage
+ name: "Unit Tests"
+ runs-on: "ubuntu-latest"
+ strategy:
+ max-parallel: 1
+ fail-fast: false
+ matrix:
+ php-version: [ '7.4', '8.0', '8.1', '8.2' ]
+ steps:
+ - uses: "actions/checkout@v2"
+ - uses: "shivammathur/setup-php@v2"
+ with:
+ php-version: "${{ matrix.php-version }}"
+ coverage: "none"
+ ini-values: "memory_limit=-1, zend.assertions=1, error_reporting=-1, display_errors=On"
+ tools: "composer"
+ - name: "Prepare for tests"
+ run: "mkdir -p build/logs"
+ - uses: "ramsey/composer-install@v2"
+ - name: "Run unit tests"
+ run: "composer phpunit"
diff --git a/.gitignore b/.gitignore
index 2a9cd3f..f72eefc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,9 @@
node_modules
-vendor
+/build
+/vendor
composer.lock
composer.phar
/phpunit.xml
/build.properties
/docs
+.phpunit.*.cache
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index e438a90..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-addons:
- apt:
- packages:
- - libcurl4-openssl-dev
-
-language: php
-dist: focal
-php:
- - 8.1.0
- - 8.0
- - 7.4
-
-before_script:
- - composer self-update
- - composer install
-
-script: vendor/bin/phpunit tests/ApiTest.php
diff --git a/README.md b/README.md
index 3a34bd5..e7ac80a 100644
--- a/README.md
+++ b/README.md
@@ -1,140 +1,62 @@
+# OVHcloud APIs lightweight PHP wrapper
+
[![PHP Wrapper for OVH APIs](https://github.com/ovh/php-ovh/blob/master/img/logo.png)](https://packagist.org/packages/ovh/ovh)
-This PHP package is a lightweight wrapper for OVH APIs. That's the easiest way to use OVH.com APIs in your PHP applications.
+[![Source Code](https://img.shields.io/badge/source-ovh/php--ovh-blue.svg?style=flat-square)](https://github.com/ovh/php-ovh)
+[![Build Status](https://img.shields.io/github/actions/workflow/status/ovh/php-ovh/ci.yaml?label=CI&logo=github&style=flat-square)](https://github.com/ovh/php-ovh/actions?query=workflow%3ACI)
+[![Codecov Code Coverage](https://img.shields.io/codecov/c/gh/ovh/php-ovh?label=codecov&logo=codecov&style=flat-square)](https://codecov.io/gh/ovh/php-ovh)
+[![Total Downloads](https://img.shields.io/packagist/dt/ovh/ovh.svg?style=flat-square)](https://packagist.org/packages/ovh/ovh)
-[![Build Status](https://travis-ci.org/ovh/php-ovh.svg)](https://travis-ci.org/ovh/php-ovh)
-[![HHVM Status](https://img.shields.io/hhvm/ovh/ovh.svg)](http://hhvm.h4cc.de/package/ovh/ovh)
+This PHP package is a lightweight wrapper for OVHcloud APIs.
-```php
-get('/me')['firstname'];
-?>
-```
+Compatible with PHP 7.4, 8.0, 8.1, 8.2.
-Quickstart
-----------
+## Installation
-To download this wrapper and integrate it inside your PHP application, you can use [Composer](https://getcomposer.org).
-
-Quick integration with the following command:
+Install this wrapper and integrate it inside your PHP application with [Composer](https://getcomposer.org) :
composer require ovh/ovh
-Or add the repository in your **composer.json** file or, if you don't already have
-this file, create it at the root of your project with this content:
-
-```json
-{
- "name": "Example Application",
- "description": "This is an example of OVH APIs wrapper usage",
- "require": {
- "ovh/ovh": "dev-master"
- }
-}
-
-```
-
-Then, you can install OVH APIs wrapper and dependencies with:
-
- php composer.phar install
-
-This will install ``ovh/ovh`` to ``./vendor``, along with other dependencies
-including ``autoload.php``.
-
-OVH cookbook
-------------
-
-Do you want to use OVH APIs? Maybe the script you want is already written in the [example part](examples/README.md) of this repository!
-
-How to login as a user?
------------------------
-
-To communicate with APIs, the SDK uses a token on each request to identify the
-user. This token is called *Consumer Key*. To have a validated *Consumer Key*,
-you need to redirect your user on specific authentication page. Once the user has
-logged in, the token is validated and user will be redirected on __$redirection__ url.
+## Basic usage
```php
'GET',
- 'path' => '/me*'
-]);
-
-// Get credentials
-$conn = new Api($applicationKey, $applicationSecret, $endpoint);
-$credentials = $conn->requestCredentials($rights, $redirection);
-
-// Save consumer key and redirect to authentication page
-$_SESSION['consumer_key'] = $credentials["consumerKey"];
-header('location: '. $credentials["validationUrl"]);
-...
-?>
+// Api credentials can be retreived from the urls specified in the "Supported endpoints" section below.
+$ovh = new Api($applicationKey,
+ $applicationSecret,
+ $endpoint,
+ $consumerKey);
+echo 'Welcome '.$ovh->get('/me')['firstname'];
```
-How to use OVH API to enable network burst on SBG1 servers?
------------------------------------------------------------
+## Advanced usage
+
+### Handle exceptions
+
+Under the hood, ```php-ovh``` uses [Guzzle](http://docs.guzzlephp.org/en/latest/quickstart.html) by default to issue API requests.
+
+If everything goes well, it will return the response directly as shown in the examples above.
+
+If there is an error like a missing endpoint or object (404), an authentication or authorization error (401 or 403) or a parameter error, the Guzzle will raise a ``GuzzleHttp\Exception\ClientException`` exception. For server-side errors (5xx), it will raise a ``GuzzleHttp\Exception\ServerException`` exception.
+
+You can get the error details with a code like:
```php
-get('/dedicated/server/');
-
-foreach ($servers as $server) {
-
- // Search servers inside SBG1
- $details = $conn->get('/dedicated/server/'. $server);
- if ($details['datacenter'] == 'sbg1') {
-
- // Activate burst on server
- $content = (object) array('status' => "active");
- $conn->put('/dedicated/server/'. $server . '/burst', $content);
- echo "We burst " . $server;
- }
+try {
+ echo "Welcome " . $ovh->get('/me')['firstname'];
+} catch (GuzzleHttp\Exception\ClientException $e) {
+ $response = $e->getResponse();
+ $responseBodyAsString = $response->getBody()->getContents();
+ echo $responseBodyAsString;
}
-
-?>
```
-How to customize HTTP client configuration?
--------------------------------------------
+
+### Customize HTTP client configuration
You can inject your own HTTP client with your specific configuration. For instance, you can edit user-agent and timeout for all your requests
@@ -144,170 +66,205 @@ require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;
use GuzzleHttp\Client;
-// Informations about your application
-$applicationKey = "your_app_key";
-$applicationSecret = "your_app_secret";
-$consumer_key = "your_consumer_key";
-
-// Information about API and rights asked
-$endpoint = 'ovh-eu';
-
+// Instantiate a custom Guzzle HTTP client and tweak it
$client = new Client();
$client->setDefaultOption('timeout', 1);
-$client->setDefaultOption('headers', array('User-Agent' => 'api_client') );
+$client->setDefaultOption('headers', ['User-Agent' => 'api_client']);
-// Get servers list
-$conn = new Api( $applicationKey,
- $applicationSecret,
- $endpoint,
- $consumer_key,
- $client);
-$webHosting = $conn->get('/hosting/web/');
+// Api credentials can be retreived from the urls specified in the "Supported endpoints" section below.
+// Inject the custom HTTP client as the 5th argument of the constructor
+$ovh = new Api($applicationKey,
+ $applicationSecret,
+ $endpoint,
+ $consumerKey,
+ $client);
-foreach ($webHosting as $webHosting) {
- echo "One of our web hosting: " . $webHosting . "\n";
-}
-?>
+echo 'Welcome '.$ovh->get('/me')['firstname'];
```
-How to print API error details?
--------------------------------
+### Authorization flow
-Under the hood, ```php-ovh``` uses [GuzzlePHP 6](http://docs.guzzlephp.org/en/latest/quickstart.html) by default to issue API requests. If everything goes well, it will return the response directly as shown in the examples above. If there is an error like a missing endpoint or object (404), an authentication or authorization error (401 or 403) or a parameter error, the Guzzle will raise a ``GuzzleHttp\Exception\ClientException`` exception. For server-side errors (5xx), it will raise a ``GuzzleHttp\Exception\ServerException`` exception.
+This flow will allow you to request consumerKey from an OVHcloud account owner.
+After allowing access to his account, he will be redirected to your application.
-You can get the error details with a code like:
+See "OVHcloud API authentication" section below for more information about the authorization flow.
+
+
+```php
+use \Ovh\Api;
+session_start();
+
+// Api credentials can be retreived from the urls specified in the "Supported endpoints" section below.
+$ovh = new Api($applicationKey,
+ $applicationSecret,
+ $endpoint);
+
+// Specify the list of API routes you want to request
+$rights = [
+ [ 'method' => 'GET', 'path' => '/me*' ],
+];
+
+// After allowing your application access, the customer will be redirected to this URL.
+$redirectUrl = 'https://your_application_redirect_url'
+
+$credentials = $conn->requestCredentials($rights, $redirectUrl);
+
+// Save consumer key and redirect to authentication page
+$_SESSION['consumerKey'] = $credentials['consumerKey'];
+header('location: '. $credentials['validationUrl']);
+// After successful redirect, the consumerKey in the session will be activated and you will be able to use it to make API requests like in the "Basic usage" section above.
+```
+
+### Code sample : Enable network burst on GRA1 dedicated servers
+
+Here is a more complex example of how to use the wrapper to enable network burst on GRA1 dedicated servers.
```php
get('/me')['firstname'];
-} catch (GuzzleHttp\Exception\ClientException $e) {
- $response = $e->getResponse();
- $responseBodyAsString = $response->getBody()->getContents();
- echo $responseBodyAsString;
+// Load the list of dedicated servers
+$servers = $conn->get('/dedicated/server/');
+foreach ($servers as $server) {
+ // Load the server details
+ $details = $conn->get('/dedicated/server/'.$server);
+ // Filter servers only inside GRA1
+ if ($details['datacenter'] == 'gra1') {
+ // Activate burst on server
+ $content = ['status' => 'active'];
+ $conn->put('/dedicated/server/'.$server.'/burst', $content);
+ echo 'Burst enabled on '.$server;
+ }
}
-?>
```
+### More code samples
-How to build the documentation?
--------------------------------
+Do you want to use OVH APIs? Maybe the script you want is already written in the [example part](examples/README.md) of this repository!
-Documentation is based on phpdocumentor. To install it with other quality tools,
-you can install local npm project in a clone a project
+## OVHcloud API authentication
- git clone https://github.com/ovh/php-ovh.git
- cd php-ovh
- php composer.phar install
+To use the OVHcloud APIs you need three credentials :
+* An application key
+* An application secret
+* A consumer key
+
+The application key and secret are not granting access to a specific account and are unique to identify your application.
+The consumer key is used to grant access to a specific OVHcloud account to a specified application.
+
+They can be created separately if your application is intended to be used by multiple accounts (your app will need to implement an authorization flow).
+In the authorization flow, the customer will be prompted to allow access to his account to your application, then he will be redirected to your application.
+
+They can also be created together if your application is intended to use only your own OVHcloud account.
+
+## Supported endpoints
+
+### OVHcloud Europe
+
+* ```$endpoint = 'ovh-eu';```
+* Documentation:
+* Console:
+* Create application credentials (generate only application credentials, your app will need to implement an authorization flow):
+* Create account credentials (all keys at once for your own account only):
+* Community support: api-subscribe@ml.ovh.net
+
+### OVHcloud US
+
+* ```$endpoint = 'ovh-us';```
+* Documentation:
+* Console:
+* Create application credentials (generate only application credentials, your app will need to implement an authorization flow):
+* Create account credentials (all keys at once for your own account only):
+
+### OVHcloud North America / Canada
+
+* ```$endpoint = 'ovh-ca';```
+* Documentation:
+* Console:
+* Create application credentials (generate only application credentials, your app will need to implement an authorization flow):
+* Create account credentials (all keys at once for your own account only):
+* Community support: api-subscribe@ml.ovh.net
+
+### So you Start Europe
+
+* ```$endpoint = 'soyoustart-eu';```
+* Documentation:
+* Console:
+* Create application credentials (generate only application credentials, your app will need to implement an authorization flow):
+* Create account credentials (all keys at once for your own account only):
+* Community support: api-subscribe@ml.ovh.net
+
+### So you Start North America
+
+* ```$endpoint = 'soyoustart-ca';```
+* Documentation:
+* Console:
+* Create application credentials (generate only application credentials, your app will need to implement an authorization flow):
+* Create account credentials (all keys at once for your own account only):
+* Community support: api-subscribe@ml.ovh.net
+
+### Kimsufi Europe
+
+* ```$endpoint = 'kimsufi-eu';```
+* Documentation:
+* Console:
+* Create application credentials (generate only application credentials, your app will need to implement an authorization flow):
+* Create account credentials (all keys at once for your own account only):
+* Community support: api-subscribe@ml.ovh.net
+
+### Kimsufi North America
+
+* ```$endpoint = 'kimsufi-ca';```
+* Documentation:
+* Console:
+* Create application credentials (generate only application credentials, your app will need to implement an authorization flow):
+* Create account credentials (all keys at once for your own account only):
+* Community support: api-subscribe@ml.ovh.net
+
+## Building documentation
+
+Documentation is based on phpdocumentor and inclued in the project.
To generate documentation, it's possible to use directly:
- vendor/bin/phing phpdocs
+ composer phpdoc
Documentation is available in docs/ directory.
-How to run tests?
------------------
+## Code check / Linting
-Tests are based on phpunit. To install it with other quality tools, you can install
-local npm project in a clone a project
+Code check is based on PHP CodeSniffer and inclued in the project.
+To check code, it's possible to use directly:
- git https://github.com/ovh/php-ovh.git
- cd php-ovh
- php composer.phar install
- vendor/bin/phpunit tests/ApiTest.php
+ composer phpcs
+Code linting is based on PHP Code Beautifier and Fixer and inclued in the project.
+To lint code, it's possible to use directly:
+
+ composer phpcbf
+
+## Testing
+
+Tests are based on phpunit and inclued in the project.
To run functionals tests, you need to provide valid API credentials, that you can provide them via environment:
- APP_KEY=xxx APP_SECRET=xxx CONSUMER=xxx ENDPOINT=xxx vendor/bin/phpunit tests/ApiFunctionalTest.php
+ APP_KEY=xxx APP_SECRET=xxx CONSUMER=xxx ENDPOINT=xxx composer phpunit
-Supported APIs
---------------
+## Contributing
-## OVH Europe
+Please see [CONTRIBUTING](https://github.com/ovh/php-ovh/blob/master/CONTRIBUTING.rst) for details.
- * ```$endpoint = 'ovh-eu';```
- * Documentation: https://eu.api.ovh.com/
- * Community support: api-subscribe@ml.ovh.net
- * Console: https://eu.api.ovh.com/console
- * Create application credentials: https://eu.api.ovh.com/createApp/
- * Create script credentials (all keys at once): https://eu.api.ovh.com/createToken/
+## Credits
-## OVH US
+[All Contributors from this repo](https://github.com/ovh/php-ovh/contributors)
- * ```$endpoint = 'ovh-us';```
- * Documentation: https://api.us.ovhcloud.com/
- * Console: https://api.us.ovhcloud.com/console
- * Create application credentials: https://api.us.ovhcloud.com/createApp/
- * Create script credentials (all keys at once): https://api.us.ovhcloud.com/createToken/
-
-## OVH North America
-
- * ```$endpoint = 'ovh-ca';```
- * Documentation: https://ca.api.ovh.com/
- * Community support: api-subscribe@ml.ovh.net
- * Console: https://ca.api.ovh.com/console
- * Create application credentials: https://ca.api.ovh.com/createApp/
- * Create script credentials (all keys at once): https://ca.api.ovh.com/createToken/
-
-## So you Start Europe
-
- * ```$endpoint = 'soyoustart-eu';```
- * Documentation: https://eu.api.soyoustart.com/
- * Community support: api-subscribe@ml.ovh.net
- * Console: https://eu.api.soyoustart.com/console/
- * Create application credentials: https://eu.api.soyoustart.com/createApp/
- * Create script credentials (all keys at once): https://eu.api.soyoustart.com/createToken/
-
-## So you Start North America
-
- * ```$endpoint = 'soyoustart-ca';```
- * Documentation: https://ca.api.soyoustart.com/
- * Community support: api-subscribe@ml.ovh.net
- * Console: https://ca.api.soyoustart.com/console/
- * Create application credentials: https://ca.api.soyoustart.com/createApp/
- * Create script credentials (all keys at once): https://ca.api.soyoustart.com/createToken/
-
-## Kimsufi Europe
-
- * ```$endpoint = 'kimsufi-eu';```
- * Documentation: https://eu.api.kimsufi.com/
- * Community support: api-subscribe@ml.ovh.net
- * Console: https://eu.api.kimsufi.com/console/
- * Create application credentials: https://eu.api.kimsufi.com/createApp/
- * Create script credentials (all keys at once): https://eu.api.kimsufi.com/createToken/
-
-## Kimsufi North America
-
- * ```$endpoint = 'kimsufi-ca';```
- * Documentation: https://ca.api.kimsufi.com/
- * Community support: api-subscribe@ml.ovh.net
- * Console: https://ca.api.kimsufi.com/console/
- * Create application credentials: https://ca.api.kimsufi.com/createApp/
- * Create script credentials (all keys at once): https://ca.api.kimsufi.com/createToken/
-
-## Runabove
-
- * ```$endpoint = 'runabove-ca';```
- * Documentation: https://community.runabove.com/kb/en/instances/how-to-use-runabove-api.html
- * Community support: https://community.runabove.com
- * Console: https://api.runabove.com/console/
- * Create application credentials: https://api.runabove.com/createApp/
-
-## Related links
-
- * Contribute: https://github.com/ovh/php-ovh
- * Report bugs: https://github.com/ovh/php-ovh/issues
+## License
+ (Modified) BSD license. Please see [LICENSE](https://github.com/ovh/php-ovh/blob/master/LICENSE) for more information.
diff --git a/build.xml b/build.xml
deleted file mode 100644
index 4bcd5bf..0000000
--- a/build.xml
+++ /dev/null
@@ -1,114 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/codecov.yml b/codecov.yml
new file mode 100644
index 0000000..65a3bcc
--- /dev/null
+++ b/codecov.yml
@@ -0,0 +1,29 @@
+codecov:
+ require_ci_to_pass: yes
+
+coverage:
+ precision: 2
+ round: down
+ range: "70...100"
+ status:
+ project:
+ default:
+ target: auto
+ threshold: 0%
+ patch:
+ default:
+ target: auto
+ threshold: 0%
+
+parsers:
+ gcov:
+ branch_detection:
+ conditional: yes
+ loop: yes
+ method: no
+ macro: no
+
+comment:
+ layout: "reach,diff,flags,tree"
+ behavior: default
+ require_changes: false
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 1b00e64..a771425 100644
--- a/composer.json
+++ b/composer.json
@@ -1,20 +1,45 @@
{
"name": "ovh/ovh",
- "description": "Wrapper for OVH APIs",
+ "description": "Wrapper for OVHcloud APIs",
"license": "BSD-3-Clause",
+ "config": {
+ "sort-packages": true,
+ "allow-plugins": {
+ "phpdocumentor/shim": true
+ }
+ },
+ "keywords": [
+ "api",
+ "client",
+ "authorization",
+ "authorisation",
+ "ovh",
+ "ovhcloud"
+ ],
"require": {
"php": ">=7.4",
"guzzlehttp/guzzle": "^6.0||^7.0",
"ext-json": "*"
},
+ "require-dev": {
+ "php-parallel-lint/php-parallel-lint": "^1.3.1",
+ "phpdocumentor/shim": "^3",
+ "phpunit/phpunit": "^9.5",
+ "squizlabs/php_codesniffer": "^3.6"
+ },
"autoload": {
"psr-4": {"Ovh\\": "src/"}
},
- "require-dev": {
- "phpunit/phpunit": "^9.5",
- "phpdocumentor/phpdocumentor": "v3.0.0",
- "squizlabs/php_codesniffer": "^3.5",
- "phpdocumentor/graphviz": "^2.0@dev",
- "symfony/flex": "^1.11"
+ "autoload-dev": {
+ "psr-4": {
+ "Ovh\\tests\\": "test/"
+ }
+ },
+ "scripts": {
+ "phpdoc": "vendor/bin/phpdoc",
+ "phpcs": "vendor/bin/phpcs -sp --colors",
+ "phpcbf": "vendor/bin/phpcbf -sp",
+ "parallel-lint": "vendor/bin/parallel-lint src tests",
+ "phpunit": "vendor/bin/phpunit --colors=always"
}
}
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..b0e3834
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+ src
+ tests
+
+
\ No newline at end of file
diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml
new file mode 100644
index 0000000..de2ff5a
--- /dev/null
+++ b/phpdoc.dist.xml
@@ -0,0 +1,19 @@
+
+
+
+
+ build/phpdoc-cache
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 0f9e1cf..6e5fc99 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,19 +1,31 @@
-
-
-
- src
-
-
-
-
- tests
-
-
-
-
-
-
-
-
-
+
+
+
+ ./tests
+
+
+
+
+
+ src/
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/ApiFunctionalTest.php b/tests/ApiFunctionalTest.php
index 512509c..97b692b 100644
--- a/tests/ApiFunctionalTest.php
+++ b/tests/ApiFunctionalTest.php
@@ -198,14 +198,18 @@ class ApiFunctionalTest extends TestCase
{
$result = $this->api->get('/me/accessRestriction/ip');
- $restrictionId = array_pop($result);
+ foreach ($result as $restrictionId) {
+ $restriction = $this->api->get('/me/accessRestriction/ip/' . $restrictionId);
- $this->assertNull(
- $this->api->put('/me/accessRestriction/ip/' . $restrictionId, ['rule' => 'accept', 'warning' => true])
- );
+ if (in_array($restriction["ip"], [$this->rangeIP, $this->alternativeRangeIP])) {
+ $this->assertNull(
+ $this->api->put('/me/accessRestriction/ip/' . $restrictionId, ['rule' => 'accept', 'warning' => true])
+ );
- $restriction = $this->api->get('/me/accessRestriction/ip/' . $restrictionId);
- $this->assertEquals('accept', $restriction['rule']);
+ $restriction = $this->api->get('/me/accessRestriction/ip/' . $restrictionId);
+ $this->assertEquals('accept', $restriction['rule']);
+ }
+ }
}
/**
@@ -220,7 +224,6 @@ class ApiFunctionalTest extends TestCase
if (in_array($restriction["ip"], [$this->rangeIP, $this->alternativeRangeIP])) {
$result = $this->api->delete('/me/accessRestriction/ip/' . $restrictionId);
$this->assertNull($result);
- break;
}
}
}
@@ -232,7 +235,8 @@ class ApiFunctionalTest extends TestCase
{
$api = new Api($this->application_key, $this->application_secret, $this->endpoint, null, $this->client);
$invoker = self::getPrivateMethod('rawCall');
- $invoker->invokeArgs($api, ['GET', '/xdsl/incidents']);
+ $result = $invoker->invokeArgs($api, ['GET', '/xdsl/incidents']);
+ $this->assertIsObject($result);
}
/**
@@ -250,7 +254,8 @@ class ApiFunctionalTest extends TestCase
*/
public function testApiGetWithQueryString()
{
- $this->api->get('/me/api/credential', ['status' => 'pendingValidation']);
+ $result = $this->api->get('/me/api/credential', ['status' => 'pendingValidation']);
+ $this->assertIsArray($result);
}
/**
@@ -258,7 +263,8 @@ class ApiFunctionalTest extends TestCase
*/
public function testApiGetWithoutAuthentication()
{
- $api = new Api(NULL,NULL, $this->endpoint, null, $this->client);
- $api->get('/hosting/web/moduleList',null,null,false);
+ $api = new Api(null, null, $this->endpoint, null, $this->client);
+ $result = $api->get('/hosting/web/moduleList', null, null, false);
+ $this->assertIsArray($result);
}
}
diff --git a/tests/ApiTest.php b/tests/ApiTest.php
index fbd6aea..20185ff 100644
--- a/tests/ApiTest.php
+++ b/tests/ApiTest.php
@@ -142,7 +142,7 @@ class ApiTest extends TestCase
{
$handlerStack = $this->client->getConfig('handler');
$handlerStack->push(Middleware::mapRequest(function (Request $request) {
- if($request->getUri()->getPath() == "/1.0/unauthcall") {
+ if ($request->getUri()->getPath() == "/1.0/unauthcall") {
return $request;
}
@@ -156,7 +156,7 @@ class ApiTest extends TestCase
->withHeader('Content-Type', 'application/json; charset=utf-8')
->withBody($body);
}));
- $api = new Api(NULL, NULL, $this->endpoint, $this->consumer_key, $this->client);
+ $api = new Api(null, null, $this->endpoint, $this->consumer_key, $this->client);
$api->get('/unauthcall', null, null, false);
$this->assertEquals(1, 1);
}
@@ -321,7 +321,7 @@ class ApiTest extends TestCase
{
$handlerStack = $this->client->getConfig('handler');
$handlerStack->push(Middleware::mapRequest(function (Request $request) {
- if($request->getUri()->getPath() == "/1.0/auth/time") {
+ if ($request->getUri()->getPath() == "/1.0/auth/time") {
return $request;
}
@@ -354,7 +354,7 @@ class ApiTest extends TestCase
{
$handlerStack = $this->client->getConfig('handler');
$handlerStack->push(Middleware::mapRequest(function (Request $request) {
- if($request->getUri()->getPath() == "/1.0/auth/time") {
+ if ($request->getUri()->getPath() == "/1.0/auth/time") {
return $request;
}
@@ -387,7 +387,7 @@ class ApiTest extends TestCase
{
$handlerStack = $this->client->getConfig('handler');
$handlerStack->push(Middleware::mapRequest(function (Request $request) {
- if($request->getUri()->getPath() == "/1.0/auth/time") {
+ if ($request->getUri()->getPath() == "/1.0/auth/time") {
return $request;
}
@@ -420,7 +420,7 @@ class ApiTest extends TestCase
{
$handlerStack = $this->client->getConfig('handler');
$handlerStack->push(Middleware::mapRequest(function (Request $request) {
- if($request->getUri()->getPath() == "/1.0/auth/time") {
+ if ($request->getUri()->getPath() == "/1.0/auth/time") {
return $request;
}
@@ -459,7 +459,7 @@ class ApiTest extends TestCase
{
$handlerStack = $this->client->getConfig('handler');
$handlerStack->push(Middleware::mapRequest(function (Request $request) {
- if($request->getUri()->getPath() == "/1.0/auth/time") {
+ if ($request->getUri()->getPath() == "/1.0/auth/time") {
return $request;
}
@@ -498,7 +498,7 @@ class ApiTest extends TestCase
{
$handlerStack = $this->client->getConfig('handler');
$handlerStack->push(Middleware::mapRequest(function (Request $request) {
- if($request->getUri()->getPath() == "/1.0/auth/time") {
+ if ($request->getUri()->getPath() == "/1.0/auth/time") {
return $request;
}
@@ -537,7 +537,7 @@ class ApiTest extends TestCase
{
$handlerStack = $this->client->getConfig('handler');
$handlerStack->push(Middleware::mapRequest(function (Request $request) {
- if($request->getUri()->getPath() == "/1.0/auth/time") {
+ if ($request->getUri()->getPath() == "/1.0/auth/time") {
return $request;
}
@@ -563,5 +563,4 @@ class ApiTest extends TestCase
$api = new Api($this->application_key, $this->application_secret, $this->endpoint, $this->consumer_key, $this->client);
$api->requestCredentials([]);
}
-
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index cc59e6f..dbcd754 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -26,4 +26,3 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
require __DIR__ . '/../vendor/autoload.php';
-