5
5
namespace Webclient \Tests \Fake ;
6
6
7
7
use Webclient \Fake \Client ;
8
+ use Webclient \Stuff \Fake \Factory \HttpFactory ;
8
9
use Webclient \Stuff \Fake \Handler \ErrorHandler ;
9
10
use Webclient \Stuff \Fake \Handler \UniversalHandler ;
10
- use Nyholm \Psr7 \Factory \Psr17Factory ;
11
11
use PHPUnit \Framework \TestCase ;
12
12
use Psr \Http \Client \ClientExceptionInterface ;
13
13
use Psr \Http \Client \NetworkExceptionInterface ;
@@ -16,21 +16,16 @@ class ClientTest extends TestCase
16
16
{
17
17
18
18
/**
19
- * @var Psr17Factory
19
+ * @var HttpFactory
20
20
*/
21
21
private $ factory ;
22
22
23
- public function setUp ()
24
- {
25
- parent ::setUp ();
26
- $ this ->factory = new Psr17Factory ();
27
- }
28
-
29
23
/**
30
24
* @throws ClientExceptionInterface
31
25
*/
32
26
public function testSuccessWithRequest ()
33
27
{
28
+ $ this ->init ();
34
29
$ request = $ this ->factory ->createRequest ('GET ' , 'http://phpunit.de/?return=302&redirect=https://phpunit.de ' );
35
30
$ client = new Client (new UniversalHandler ($ this ->factory ));
36
31
$ response = $ client ->sendRequest ($ request );
@@ -44,6 +39,7 @@ public function testSuccessWithRequest()
44
39
*/
45
40
public function testSuccessWithServerRequest ()
46
41
{
42
+ $ this ->init ();
47
43
$ request = $ this ->factory ->createServerRequest (
48
44
'GET ' ,
49
45
'https://phpunit.de ' ,
@@ -64,6 +60,7 @@ public function testSuccessWithServerRequest()
64
60
*/
65
61
public function testSuccessWithPreparedServerRequest ()
66
62
{
63
+ $ this ->init ();
67
64
$ request = $ this ->factory ->createServerRequest (
68
65
'GET ' ,
69
66
'https://phpunit.de ' ,
@@ -83,9 +80,15 @@ public function testSuccessWithPreparedServerRequest()
83
80
*/
84
81
public function testFailWithNetworkError ()
85
82
{
83
+ $ this ->init ();
86
84
$ request = $ this ->factory ->createRequest ('GET ' , '/ ' );
87
85
$ client = new Client (new ErrorHandler ());
88
86
$ this ->expectException (NetworkExceptionInterface::class);
89
87
$ client ->sendRequest ($ request );
90
88
}
89
+
90
+ private function init ()
91
+ {
92
+ $ this ->factory = new HttpFactory ();
93
+ }
91
94
}
0 commit comments