Skip to content

Commit

Permalink
Merge 8723ea4 into 1296815
Browse files Browse the repository at this point in the history
  • Loading branch information
alcalyn committed Apr 23, 2021
2 parents 1296815 + 8723ea4 commit 7c28a88
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/Common/Auth/AuthHandler.php
Expand Up @@ -4,7 +4,7 @@

namespace OpenStack\Common\Auth;

use function GuzzleHttp\Psr7\modify_request;
use GuzzleHttp\Psr7\Utils;
use Psr\Http\Message\RequestInterface;

/**
Expand Down Expand Up @@ -53,7 +53,7 @@ public function __invoke(RequestInterface $request, array $options)

$modify = ['set_headers' => ['X-Auth-Token' => $this->token->getId()]];

return $fn(modify_request($request, $modify), $options);
return $fn(Utils::modifyRequest($request, $modify), $options);
}

/**
Expand Down
1 change: 0 additions & 1 deletion tests/unit/Common/Api/OperatorTraitTest.php
Expand Up @@ -2,7 +2,6 @@

namespace OpenStack\Test\Common\Api;

use function GuzzleHttp\Psr7\uri_for;
use GuzzleHttp\Promise\Promise;
use GuzzleHttp\Psr7\Response;
use OpenStack\Common\Api\Operation;
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/Common/Error/BuilderTest.php
Expand Up @@ -2,13 +2,11 @@

namespace OpenStack\Test\Common\Error;

use function GuzzleHttp\Psr7\stream_for;
use function GuzzleHttp\Psr7\str;

use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Utils;
use OpenStack\Common\Error\BadResponseError;
use OpenStack\Common\Error\Builder;
use OpenStack\Common\Error\UserInputError;
Expand All @@ -32,7 +30,7 @@ public function test_it_injects_client()
public function test_it_builds_http_errors()
{
$request = new Request('POST', '/servers');
$response = new Response(400, [], stream_for('Invalid parameters'));
$response = new Response(400, [], Utils::streamFor('Invalid parameters'));

$requestStr = trim($this->builder->str($request));
$responseStr = trim($this->builder->str($response));
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Common/Resource/AbstractResourceTest.php
Expand Up @@ -3,7 +3,7 @@
namespace OpenStack\Test\Common\Resource;

use GuzzleHttp\Psr7\Response;
use function GuzzleHttp\Psr7\stream_for;
use GuzzleHttp\Psr7\Utils;
use OpenStack\Common\Resource\AbstractResource;
use OpenStack\Common\Resource\Alias;
use OpenStack\Common\Resource\ResourceInterface;
Expand All @@ -25,7 +25,7 @@ public function setUp(): void

public function test_it_populates_from_response()
{
$response = new Response(200, ['Content-Type' => 'application/json'], stream_for(
$response = new Response(200, ['Content-Type' => 'application/json'], Utils::streamFor(
json_encode(['foo' => ['bar' => '1']])
));

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/Common/Transport/UtilsTest.php
Expand Up @@ -3,26 +3,26 @@
namespace OpenStack\Test\Common\Transport;

use GuzzleHttp\Psr7\Response;
use function GuzzleHttp\Psr7\uri_for;
use GuzzleHttp\Psr7\Uri;
use GuzzleHttp\Psr7\Utils as Psr7Utils;
use OpenStack\Common\Transport\Utils;
use OpenStack\Test\TestCase;

class UtilsTest extends TestCase
{
public function test_decoding_malformed_json_throws_error()
{
$response = new Response(200, [], \GuzzleHttp\Psr7\stream_for('{'));
$response = new Response(200, [], Psr7Utils::streamFor('{'));
$this->expectException(\InvalidArgumentException::class);

Utils::jsonDecode($response);
}

public function test_it_adds_paths()
{
$uri = Utils::addPaths(uri_for('http://openstack.org/foo'), 'bar', 'baz', '1', '2');
$uri = Utils::addPaths(Psr7Utils::uriFor('http://openstack.org/foo'), 'bar', 'baz', '1', '2');

self::assertInstanceOf(Uri::class, $uri);
self::assertEquals(uri_for('http://openstack.org/foo/bar/baz/1/2'), $uri);
self::assertEquals(Psr7Utils::uriFor('http://openstack.org/foo/bar/baz/1/2'), $uri);
}
}
6 changes: 3 additions & 3 deletions tests/unit/ObjectStore/v1/Models/ObjectTest.php
Expand Up @@ -2,8 +2,8 @@

namespace OpenStack\Test\ObjectStore\v1\Models;

use function GuzzleHttp\Psr7\uri_for;
use GuzzleHttp\Psr7\Stream;
use GuzzleHttp\Psr7\Utils;
use OpenStack\ObjectStore\v1\Api;
use OpenStack\ObjectStore\v1\Models\StorageObject;
use OpenStack\Test\TestCase;
Expand Down Expand Up @@ -128,11 +128,11 @@ public function test_It_Gets_Public_Uri()
{
$this->client->getConfig('base_uri')
->shouldBeCalled()
->willReturn(uri_for('myopenstack.org:9000/tenantId'));
->willReturn(Utils::uriFor('myopenstack.org:9000/tenantId'));

$this->object->containerName = 'foo';
$this->object->name = 'bar';

self::assertEquals(uri_for('myopenstack.org:9000/tenantId/foo/bar'), $this->object->getPublicUri());
self::assertEquals(Utils::uriFor('myopenstack.org:9000/tenantId/foo/bar'), $this->object->getPublicUri());
}
}
8 changes: 4 additions & 4 deletions tests/unit/TestCase.php
Expand Up @@ -2,10 +2,10 @@

namespace OpenStack\Test;

use function GuzzleHttp\Psr7\stream_for;
use function GuzzleHttp\Psr7\parse_response;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Psr7\Message;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Utils;
use Prophecy\Argument;

abstract class TestCase extends \PHPUnit\Framework\TestCase
Expand All @@ -25,7 +25,7 @@ protected function setUp(): void

protected function createResponse($status, array $headers, array $json)
{
return new Response($status, $headers, stream_for(json_encode($json)));
return new Response($status, $headers, Utils::streamFor(json_encode($json)));
}

protected function getFixture($file)
Expand All @@ -40,7 +40,7 @@ protected function getFixture($file)
throw new \RuntimeException(sprintf("%s does not exist", $path));
}

return parse_response(file_get_contents($path));
return Message::parseResponse(file_get_contents($path));
}

protected function setupMock($method, $path, $body = null, array $headers = [], $response = null)
Expand Down

0 comments on commit 7c28a88

Please sign in to comment.