Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"require": {
"php": ">=5.4",
"php-http/httplug": "^1.0",
"php-http/httplug-async": "^0.1"
"php-http/httplug-async": "^0.1",
"php-http/utils": "^0.1@dev"
},
"require-dev": {
"phpspec/phpspec": "^2.2",
Expand Down
4 changes: 2 additions & 2 deletions spec/CookiePluginSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace spec\Http\Client\Plugin;

use Http\Client\Plugin\FulfilledPromise;
use Http\Client\Promise;
use Http\Client\Utils\Promise\FulfilledPromise;
use Http\Cookie\Cookie;
use Http\Cookie\CookieJar;
use PhpSpec\ObjectBehavior;
Expand Down Expand Up @@ -153,7 +153,7 @@ function it_saves_cookie(CookieJar $cookieJar, RequestInterface $request, Respon
$uri->getPath()->shouldBeCalled()->willReturn('/');

$promise = $this->handleRequest($request, $next, function () {});
$promise->shouldReturnAnInstanceOf('Http\Client\Plugin\FulfilledPromise');
$promise->shouldReturnAnInstanceOf('Http\Client\Promise');
$response = $promise->getResponse();
$response->shouldReturnAnInstanceOf('Psr\Http\Message\ResponseInterface');
}
Expand Down
8 changes: 4 additions & 4 deletions spec/ErrorPluginSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace spec\Http\Client\Plugin;

use Http\Client\Plugin\FulfilledPromise;
use Http\Client\Utils\Promise\FulfilledPromise;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Psr\Http\Message\RequestInterface;
Expand All @@ -26,7 +26,7 @@ function it_throw_request_exception_on_500_error(RequestInterface $request, Resp
}
};

$this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Plugin\RejectedPromise');
$this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Utils\Promise\RejectedPromise');
}

function it_returns_response(RequestInterface $request, ResponseInterface $response)
Expand All @@ -39,7 +39,7 @@ function it_returns_response(RequestInterface $request, ResponseInterface $respo
}
};

$this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Plugin\FulfilledPromise');
$this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Utils\Promise\FulfilledPromise');
}

function it_throw_request_exception_on_custom_regex(RequestInterface $request, ResponseInterface $response)
Expand All @@ -52,6 +52,6 @@ function it_throw_request_exception_on_custom_regex(RequestInterface $request, R
}
};

$this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Plugin\RejectedPromise');
$this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Utils\Promise\RejectedPromise');
}
}
18 changes: 7 additions & 11 deletions spec/RedirectPluginSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

namespace spec\Http\Client\Plugin;

use Http\Client\HttpClient;
use Http\Client\Plugin\Exception\CircularRedirectionException;
use Http\Client\Plugin\Exception\RebootChainException;
use Http\Client\Plugin\FulfilledPromise;
use Http\Client\Plugin\PluginClient;
use Http\Client\Utils\Promise\FulfilledPromise;
use Http\Client\Plugin\RedirectPlugin;
use Http\Client\Promise;
use PhpSpec\ObjectBehavior;
Expand Down Expand Up @@ -66,7 +62,7 @@ function it_redirect_on_302(
$promise->getResponse()->shouldBeCalled()->willReturn($finalResponse);

$finalPromise = $this->handleRequest($request, $next, $first);
$finalPromise->shouldReturnAnInstanceOf('Http\Client\Plugin\FulfilledPromise');
$finalPromise->shouldReturnAnInstanceOf('Http\Client\Utils\Promise\FulfilledPromise');
$finalPromise->getResponse()->shouldReturn($finalResponse);
}

Expand Down Expand Up @@ -200,7 +196,7 @@ function it_throws_http_exception_on_no_location(UriInterface $uri, RequestInter
$responseRedirect->hasHeader('Location')->shouldBeCalled()->willReturn(false);

$promise = $this->handleRequest($request, $next, function () {});
$promise->shouldReturnAnInstanceOf('Http\Client\Plugin\RejectedPromise');
$promise->shouldReturnAnInstanceOf('Http\Client\Utils\Promise\RejectedPromise');
$promise->getException()->shouldReturnAnInstanceOf('Http\Client\Exception\HttpException');
}

Expand All @@ -220,7 +216,7 @@ function it_throws_http_exception_on_invalid_location(UriInterface $uri, Request
$responseRedirect->hasHeader('Location')->shouldBeCalled()->willReturn(true);

$promise = $this->handleRequest($request, $next, function () {});
$promise->shouldReturnAnInstanceOf('Http\Client\Plugin\RejectedPromise');
$promise->shouldReturnAnInstanceOf('Http\Client\Utils\Promise\RejectedPromise');
$promise->getException()->shouldReturnAnInstanceOf('Http\Client\Exception\HttpException');
}

Expand All @@ -236,7 +232,7 @@ function it_throw_multi_redirect_exception_on_300(RequestInterface $request, Res
$responseRedirect->getStatusCode()->shouldBeCalled()->willReturn('300');

$promise = $this->handleRequest($request, $next, function () {});
$promise->shouldReturnAnInstanceOf('Http\Client\Plugin\RejectedPromise');
$promise->shouldReturnAnInstanceOf('Http\Client\Utils\Promise\RejectedPromise');
$promise->getException()->shouldReturnAnInstanceOf('Http\Client\Plugin\Exception\MultipleRedirectionException');
}

Expand All @@ -252,7 +248,7 @@ function it_throw_multi_redirect_exception_on_300_if_no_location(RequestInterfac
$responseRedirect->hasHeader('Location')->shouldBeCalled()->willReturn(false);

$promise = $this->handleRequest($request, $next, function () {});
$promise->shouldReturnAnInstanceOf('Http\Client\Plugin\RejectedPromise');
$promise->shouldReturnAnInstanceOf('Http\Client\Utils\Promise\RejectedPromise');
$promise->getException()->shouldReturnAnInstanceOf('Http\Client\Plugin\Exception\MultipleRedirectionException');
}

Expand Down Expand Up @@ -383,7 +379,7 @@ function it_throws_circular_redirection_exception(UriInterface $uri, UriInterfac
};

$promise = $this->handleRequest($request, $next, $first);
$promise->shouldReturnAnInstanceOf('Http\Client\Plugin\RejectedPromise');
$promise->shouldReturnAnInstanceOf('Http\Client\Utils\Promise\RejectedPromise');
$promise->getException()->shouldReturnAnInstanceOf('Http\Client\Plugin\Exception\CircularRedirectionException');
}
}
Expand Down
15 changes: 7 additions & 8 deletions spec/RetryPluginSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
namespace spec\Http\Client\Plugin;

use Http\Client\Exception;
use Http\Client\HttpClient;
use Http\Client\Plugin\FulfilledPromise;
use Http\Client\Plugin\RejectedPromise;
use Http\Client\Utils\Promise\FulfilledPromise;
use Http\Client\Utils\Promise\RejectedPromise;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Psr\Http\Message\RequestInterface;
Expand All @@ -27,7 +26,7 @@ function it_returns_response(RequestInterface $request, ResponseInterface $respo
}
};

$this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Plugin\FulfilledPromise');
$this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Utils\Promise\FulfilledPromise');
}

function it_throws_exception_on_multiple_exceptions(RequestInterface $request)
Expand All @@ -50,7 +49,7 @@ function it_throws_exception_on_multiple_exceptions(RequestInterface $request)
};

$promise = $this->handleRequest($request, $next, function () {});
$promise->shouldReturnAnInstanceOf('Http\Client\Plugin\RejectedPromise');
$promise->shouldReturnAnInstanceOf('Http\Client\Utils\Promise\RejectedPromise');
$promise->getException()->shouldReturn($exception2);
}

Expand All @@ -73,7 +72,7 @@ function it_returns_response_on_second_try(RequestInterface $request, ResponseIn
};

$promise = $this->handleRequest($request, $next, function () {});
$promise->shouldReturnAnInstanceOf('Http\Client\Plugin\FulfilledPromise');
$promise->shouldReturnAnInstanceOf('Http\Client\Utils\Promise\FulfilledPromise');
$promise->getResponse()->shouldReturn($response);
}

Expand All @@ -95,7 +94,7 @@ function it_does_not_keep_history_of_old_failure(RequestInterface $request, Resp
}
};

$this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Plugin\FulfilledPromise');
$this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Plugin\FulfilledPromise');
$this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Utils\Promise\FulfilledPromise');
$this->handleRequest($request, $next, function () {})->shouldReturnAnInstanceOf('Http\Client\Utils\Promise\FulfilledPromise');
}
}
4 changes: 2 additions & 2 deletions spec/StopwatchPluginSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace spec\Http\Client\Plugin;

use Http\Client\Exception\NetworkException;
use Http\Client\Plugin\FulfilledPromise;
use Http\Client\Plugin\RejectedPromise;
use Http\Client\Utils\Promise\FulfilledPromise;
use Http\Client\Utils\Promise\RejectedPromise;
use PhpSpec\ObjectBehavior;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down
37 changes: 0 additions & 37 deletions src/FakeAsyncClient.php

This file was deleted.

65 changes: 0 additions & 65 deletions src/FulfilledPromise.php

This file was deleted.

3 changes: 2 additions & 1 deletion src/PluginClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Http\Client\HttpClient;
use Http\Client\Plugin\Exception\RebootChainException;
use Http\Client\Promise;
use Http\Client\Utils\EmulateAsyncClient;
use Psr\Http\Message\RequestInterface;

class PluginClient implements HttpClient, HttpAsyncClient
Expand All @@ -31,7 +32,7 @@ public function __construct($client, array $plugins = array())
if ($client instanceof HttpAsyncClient) {
$this->client = $client;
} elseif ($client instanceof HttpClient) {
$this->client = new FakeAsyncClient($client);
$this->client = new EmulateAsyncClient($client);
} else {
throw new \RuntimeException("Client must be an instance of Http\\Client\\HttpClient or Http\\Client\\HttpAsyncClient");
}
Expand Down
60 changes: 0 additions & 60 deletions src/RejectedPromise.php

This file was deleted.