55namespace  Webclient \Tests \Fake ;
66
77use  Webclient \Fake \Client ;
8+ use  Webclient \Stuff \Fake \Factory \HttpFactory ;
89use  Webclient \Stuff \Fake \Handler \ErrorHandler ;
910use  Webclient \Stuff \Fake \Handler \UniversalHandler ;
10- use  Nyholm \Psr7 \Factory \Psr17Factory ;
1111use  PHPUnit \Framework \TestCase ;
1212use  Psr \Http \Client \ClientExceptionInterface ;
1313use  Psr \Http \Client \NetworkExceptionInterface ;
@@ -16,21 +16,16 @@ class ClientTest extends TestCase
1616{
1717
1818    /** 
19-      * @var Psr17Factory  
19+      * @var HttpFactory  
2020     */ 
2121    private  $ factory ;
2222
23-     public  function  setUp ()
24-     {
25-         parent ::setUp ();
26-         $ this  ->factory  = new  Psr17Factory ();
27-     }
28- 
2923    /** 
3024     * @throws ClientExceptionInterface 
3125     */ 
3226    public  function  testSuccessWithRequest ()
3327    {
28+         $ this  ->init ();
3429        $ request  = $ this  ->factory ->createRequest ('GET ' , 'http://phpunit.de/?return=302&redirect=https://phpunit.de ' );
3530        $ client  = new  Client (new  UniversalHandler ($ this  ->factory ));
3631        $ response  = $ client ->sendRequest ($ request );
@@ -44,6 +39,7 @@ public function testSuccessWithRequest()
4439     */ 
4540    public  function  testSuccessWithServerRequest ()
4641    {
42+         $ this  ->init ();
4743        $ request  = $ this  ->factory ->createServerRequest (
4844            'GET ' ,
4945            'https://phpunit.de ' ,
@@ -64,6 +60,7 @@ public function testSuccessWithServerRequest()
6460     */ 
6561    public  function  testSuccessWithPreparedServerRequest ()
6662    {
63+         $ this  ->init ();
6764        $ request  = $ this  ->factory ->createServerRequest (
6865            'GET ' ,
6966            'https://phpunit.de ' ,
@@ -83,9 +80,15 @@ public function testSuccessWithPreparedServerRequest()
8380     */ 
8481    public  function  testFailWithNetworkError ()
8582    {
83+         $ this  ->init ();
8684        $ request  = $ this  ->factory ->createRequest ('GET ' , '/ ' );
8785        $ client  = new  Client (new  ErrorHandler ());
8886        $ this  ->expectException (NetworkExceptionInterface::class);
8987        $ client ->sendRequest ($ request );
9088    }
89+ 
90+     private  function  init ()
91+     {
92+         $ this  ->factory  = new  HttpFactory ();
93+     }
9194}
0 commit comments