4
4
5
5
use Http \Adapter \React \Exception \UnexpectedValueException ;
6
6
use Http \Adapter \React \Promise ;
7
- use Http \Adapter \React \ReactFactory ;
8
7
use Http \Client \Exception \HttpException ;
9
8
use Http \Client \Exception \NetworkException ;
10
9
use Http \Client \Exception \TransferException ;
11
- use InvalidArgumentException ;
12
10
use Nyholm \Psr7 \Factory \Psr17Factory ;
13
11
use PHPUnit \Framework \TestCase ;
14
12
use Psr \Http \Message \RequestInterface ;
15
13
use Psr \Http \Message \ResponseInterface ;
16
14
use React \Promise \Promise as ReactPromise ;
17
- use RuntimeException ;
18
15
19
16
class PromiseTest extends TestCase
20
17
{
21
- private $ loop ;
22
-
23
- public function setUp (): void
24
- {
25
- $ this ->loop = ReactFactory::buildEventLoop ();
26
- }
27
-
28
18
public function testChain ()
29
19
{
30
20
$ factory = new Psr17Factory ();
@@ -35,7 +25,7 @@ public function testChain()
35
25
$ resolve ($ response );
36
26
});
37
27
38
- $ promise = new Promise ($ reactPromise , $ this -> loop , $ request );
28
+ $ promise = new Promise ($ reactPromise , $ request );
39
29
40
30
$ lastPromise = $ promise ->then (function (ResponseInterface $ response ) use ($ factory ) {
41
31
return $ factory ->createResponse (300 , $ response ->getReasonPhrase ());
@@ -60,7 +50,7 @@ public function testPromiseExceptionsAreTranslatedToHttplug(
60
50
$ reject ($ reason );
61
51
});
62
52
63
- $ promise = new Promise ($ reactPromise , $ this -> loop , $ request );
53
+ $ promise = new Promise ($ reactPromise , $ request );
64
54
$ this ->expectException ($ adapterExceptionClass );
65
55
$ promise ->wait ();
66
56
}
@@ -72,8 +62,8 @@ public function exceptionThatIsThrownFromReactProvider()
72
62
73
63
return [
74
64
'string ' => [$ request , 'whatever ' , UnexpectedValueException::class],
75
- 'InvalidArgumentException ' => [$ request , new InvalidArgumentException ('Something went wrong ' ), TransferException::class],
76
- 'RuntimeException ' => [$ request , new RuntimeException ('Something happened inside ReactPHP engine ' ), NetworkException::class],
65
+ 'InvalidArgumentException ' => [$ request , new \ InvalidArgumentException ('Something went wrong ' ), TransferException::class],
66
+ 'RuntimeException ' => [$ request , new \ RuntimeException ('Something happened inside ReactPHP engine ' ), NetworkException::class],
77
67
'NetworkException ' => [$ request , new NetworkException ('Something happened inside ReactPHP engine ' , $ request ), NetworkException::class],
78
68
'HttpException ' => [$ request , new HttpException ('Something happened inside ReactPHP engine ' , $ request , $ response ), HttpException::class],
79
69
];
0 commit comments