3
3
namespace spec \Http \Promise ;
4
4
5
5
use Http \Promise \Promise ;
6
- use Psr \Http \Message \RequestInterface ;
7
- use Psr \Http \Message \ResponseInterface ;
8
6
use PhpSpec \ObjectBehavior ;
9
7
use Prophecy \Argument ;
10
8
11
9
class FulfilledPromiseSpec extends ObjectBehavior
12
10
{
13
- function let (ResponseInterface $ response )
11
+ function let ()
14
12
{
15
- $ this ->beConstructedWith ($ response );
13
+ $ this ->beConstructedWith (' result ' );
16
14
}
17
15
18
- function it_is_initializable (ResponseInterface $ response )
16
+ function it_is_initializable ()
19
17
{
20
18
$ this ->shouldHaveType ('Http\Promise\FulfilledPromise ' );
21
19
}
@@ -25,28 +23,24 @@ function it_is_a_promise()
25
23
$ this ->shouldImplement ('Http\Promise\Promise ' );
26
24
}
27
25
28
- function it_returns_a_fulfilled_promise (ResponseInterface $ response )
26
+ function it_returns_a_fulfilled_promise ()
29
27
{
30
- $ promise = $ this ->then (function (ResponseInterface $ responseReceived ) use ($ response ) {
31
- if (Argument::is ($ responseReceived )->scoreArgument ($ response ->getWrappedObject ())) {
32
- return $ response ->getWrappedObject ();
33
- }
28
+ $ promise = $ this ->then (function ($ result ) {
29
+ return $ result ;
34
30
});
35
31
36
32
$ promise ->shouldHaveType ('Http\Promise\Promise ' );
37
33
$ promise ->shouldHaveType ('Http\Promise\FulfilledPromise ' );
38
34
$ promise ->getState ()->shouldReturn (Promise::FULFILLED );
39
- $ promise ->wait ()->shouldReturn ($ response );
35
+ $ promise ->wait ()->shouldReturn (' result ' );
40
36
}
41
37
42
- function it_returns_a_rejected_promise (RequestInterface $ request , ResponseInterface $ response )
38
+ function it_returns_a_rejected_promise ()
43
39
{
44
40
$ exception = new \Exception ();
45
41
46
- $ promise = $ this ->then (function (ResponseInterface $ responseReceived ) use ($ response , $ exception ) {
47
- if (Argument::is ($ responseReceived )->scoreArgument ($ response ->getWrappedObject ())) {
48
- throw $ exception ;
49
- }
42
+ $ promise = $ this ->then (function () use ($ exception ) {
43
+ throw $ exception ;
50
44
});
51
45
52
46
$ promise ->shouldHaveType ('Http\Promise\Promise ' );
@@ -65,13 +59,13 @@ function it_is_in_fulfilled_state()
65
59
$ this ->getState ()->shouldReturn (Promise::FULFILLED );
66
60
}
67
61
68
- function it_has_a_response ( ResponseInterface $ response )
62
+ function it_has_a_result ( )
69
63
{
70
- $ this ->wait ()->shouldReturn ($ response );
64
+ $ this ->wait ()->shouldReturn (' result ' );
71
65
}
72
66
73
- function it_does_not_unwrap_a_value (ResponseInterface $ response )
67
+ function it_does_not_unwrap_a_value ()
74
68
{
75
- $ this ->wait (false )->shouldNotReturn ($ response );
69
+ $ this ->wait (false )->shouldNotReturn (' result ' );
76
70
}
77
71
}
0 commit comments