-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathAuthenticationPluginSpec.php
More file actions
40 lines (32 loc) · 1.21 KB
/
AuthenticationPluginSpec.php
File metadata and controls
40 lines (32 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace spec\Http\Client\Plugin;
use Http\Message\Authentication;
use Http\Promise\Promise;
use Psr\Http\Message\RequestInterface;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class AuthenticationPluginSpec extends ObjectBehavior
{
function let(Authentication $authentication)
{
$this->beConstructedWith($authentication);
}
function it_is_initializable(Authentication $authentication)
{
$this->shouldHaveType('Http\Client\Plugin\AuthenticationPlugin');
}
function it_is_a_plugin()
{
$this->shouldImplement('Http\Client\Plugin\Plugin');
}
function it_sends_an_authenticated_request(Authentication $authentication, RequestInterface $notAuthedRequest, RequestInterface $authedRequest, Promise $promise)
{
$authentication->authenticate($notAuthedRequest)->willReturn($authedRequest);
$next = function (RequestInterface $request) use($authedRequest, $promise) {
if (Argument::is($authedRequest->getWrappedObject())->scoreArgument($request)) {
return $promise->getWrappedObject();
}
};
$this->handleRequest($notAuthedRequest, $next, function () {})->shouldReturn($promise);
}
}