summaryrefslogtreecommitdiff
path: root/server/vendor/php-opencloud/common/tests/unit/Common/Error
diff options
context:
space:
mode:
authorEoleDev <EoleDev@outlook.fr>2016-04-14 16:24:44 +0200
committerEoleDev <EoleDev@outlook.fr>2016-04-14 16:24:44 +0200
commit24bb5fefbdf93ce0969b7f56cc46c459ebb82a95 (patch)
tree531fc8b774c035040774234efba780a3d4fe9242 /server/vendor/php-opencloud/common/tests/unit/Common/Error
parent646af6fd4d14c5b5edb1372e5f68ed9bdc35b3d2 (diff)
Mise a jour et nettoyage depot
Diffstat (limited to 'server/vendor/php-opencloud/common/tests/unit/Common/Error')
-rw-r--r--server/vendor/php-opencloud/common/tests/unit/Common/Error/BadResponseErrorTest.php34
-rw-r--r--server/vendor/php-opencloud/common/tests/unit/Common/Error/BuilderTest.php117
2 files changed, 0 insertions, 151 deletions
diff --git a/server/vendor/php-opencloud/common/tests/unit/Common/Error/BadResponseErrorTest.php b/server/vendor/php-opencloud/common/tests/unit/Common/Error/BadResponseErrorTest.php
deleted file mode 100644
index 7aa4bf1..0000000
--- a/server/vendor/php-opencloud/common/tests/unit/Common/Error/BadResponseErrorTest.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-namespace OpenCloud\Test\Common\Error;
-
-use GuzzleHttp\Psr7\Request;
-use GuzzleHttp\Psr7\Response;
-use OpenCloud\Common\Error\BadResponseError;
-use OpenCloud\Test\TestCase;
-
-class BadResponseErrorTest extends TestCase
-{
- private $e;
-
- public function setUp()
- {
- $this->e = new BadResponseError();
- }
-
- public function test_it_gets_request()
- {
- $r = new Request('GET', '');
-
- $this->e->setRequest($r);
- $this->assertEquals($this->e->getRequest(), $r);
- }
-
- public function test_it_gets_response()
- {
- $r = new Response(500);
-
- $this->e->setResponse($r);
- $this->assertEquals($this->e->getResponse(), $r);
- }
-}
diff --git a/server/vendor/php-opencloud/common/tests/unit/Common/Error/BuilderTest.php b/server/vendor/php-opencloud/common/tests/unit/Common/Error/BuilderTest.php
deleted file mode 100644
index e23806d..0000000
--- a/server/vendor/php-opencloud/common/tests/unit/Common/Error/BuilderTest.php
+++ /dev/null
@@ -1,117 +0,0 @@
-<?php
-
-namespace OpenCloud\Test\Common\Error;
-
-use function GuzzleHttp\Psr7\{stream_for,str};
-
-use GuzzleHttp\ClientInterface;
-use GuzzleHttp\Exception\ClientException;
-use GuzzleHttp\Psr7\{Request,Response};
-use OpenCloud\Common\Error\{BadResponseError,Builder,UserInputError};
-
-class BuilderTest extends \PHPUnit_Framework_TestCase
-{
- private $builder;
- private $client;
-
- public function __construct()
- {
- $this->client = $this->prophesize(ClientInterface::class);
- $this->builder = new Builder($this->client->reveal());
- }
-
- public function test_it_injects_client()
- {
- $this->assertInstanceOf(Builder::class, new Builder($this->client->reveal()));
- }
-
- public function test_it_builds_http_errors()
- {
- $request = new Request('POST', '/servers');
- $response = new Response(400, [], stream_for('Invalid parameters'));
-
- $requestStr = trim($this->builder->str($request));
- $responseStr = trim($this->builder->str($response));
-
- $errorMessage = <<<EOT
-HTTP Error
-~~~~~~~~~~
-The remote server returned a "400 Bad Request" error for the following transaction:
-
-Request
-~~~~~~~
-$requestStr
-
-Response
-~~~~~~~~
-$responseStr
-
-Further information
-~~~~~~~~~~~~~~~~~~~
-Please ensure that your input values are valid and well-formed. Visit http://docs.php-opencloud.com/en/latest/http-codes for more information about debugging HTTP status codes, or file a support issue on https://github.com/php-opencloud/openstack/issues.
-EOT;
-
- $e = new BadResponseError($errorMessage);
- $e->setRequest($request);
- $e->setResponse($response);
-
- $this->assertEquals($e, $this->builder->httpError($request, $response));
- }
-
- public function test_it_builds_user_input_errors()
- {
- $expected = 'A well-formed string';
- $value = ['foo' => true];
- $link = 'http://docs.php-opencloud.com/en/latest/index.html';
-
- $errorMessage = <<<EOT
-User Input Error
-~~~~~~~~~~~~~~~~
-A well-formed string was expected, but the following value was passed in:
-
-Array
-(
- [foo] => 1
-)
-
-Please ensure that the value adheres to the expectation above. Visit $link for more information about input arguments. If you run into trouble, please open a support issue on https://github.com/php-opencloud/openstack/issues.
-EOT;
-
- $this->client
- ->request('HEAD', $link)
- ->shouldBeCalled()
- ->willReturn(new Response(200));
-
- $e = new UserInputError($errorMessage);
-
- $this->assertEquals($e, $this->builder->userInputError($expected, $value, 'index.html'));
- }
-
- public function test_dead_links_are_ignored()
- {
- $expected = 'A well-formed string';
- $value = ['foo' => true];
-
- $errorMessage = <<<EOT
-User Input Error
-~~~~~~~~~~~~~~~~
-A well-formed string was expected, but the following value was passed in:
-
-Array
-(
- [foo] => 1
-)
-
-Please ensure that the value adheres to the expectation above. If you run into trouble, please open a support issue on https://github.com/php-opencloud/openstack/issues.
-EOT;
-
- $this->client
- ->request('HEAD', 'http://docs.php-opencloud.com/en/latest/sdffsda')
- ->shouldBeCalled()
- ->willThrow(ClientException::class);
-
- $e = new UserInputError($errorMessage);
-
- $this->assertEquals($e, $this->builder->userInputError($expected, $value, 'sdffsda'));
- }
-}