44
55use Http \Client \Common \Plugin ;
66use Http \Client \Common \Plugin \AddPathPlugin ;
7- use Http \Client \Common \PluginClient ;
8- use Http \Client \HttpClient ;
7+ use Http \Client \Promise \HttpFulfilledPromise ;
98use Nyholm \Psr7 \Request ;
109use Nyholm \Psr7 \Response ;
1110use Nyholm \Psr7 \Uri ;
@@ -24,7 +23,7 @@ class AddPathPluginTest extends TestCase
2423 */
2524 private $ first ;
2625
27- protected function setUp ()
26+ protected function setUp (): void
2827 {
2928 $ this ->first = function () {};
3029 $ this ->plugin = new AddPathPlugin (new Uri ('/api ' ));
@@ -34,16 +33,18 @@ public function testRewriteSameUrl()
3433 {
3534 $ verify = function (RequestInterface $ request ) {
3635 $ this ->assertEquals ('https://example.com/api/foo ' , $ request ->getUri ()->__toString ());
36+
37+ return new HttpFulfilledPromise (new Response ());
3738 };
3839
39- $ request = new Request ('GET ' , 'https://example.com/foo ' , ['Content-Type ' => 'text/html ' ]);
40+ $ request = new Request ('GET ' , 'https://example.com/foo ' , ['Content-Type ' => 'text/html ' ]);
4041 $ this ->plugin ->handleRequest ($ request , $ verify , $ this ->first );
4142
4243 // Make a second call with the same $request object
4344 $ this ->plugin ->handleRequest ($ request , $ verify , $ this ->first );
4445
4546 // Make a new call with a new object but same URL
46- $ request = new Request ('GET ' , 'https://example.com/foo ' , ['Content-Type ' => 'text/plain ' ]);
47+ $ request = new Request ('GET ' , 'https://example.com/foo ' , ['Content-Type ' => 'text/plain ' ]);
4748 $ this ->plugin ->handleRequest ($ request , $ verify , $ this ->first );
4849 }
4950
@@ -56,7 +57,11 @@ public function testRewriteCallingThePluginTwice()
5657 // Run the plugin again with the modified request
5758 $ this ->plugin ->handleRequest ($ request , function (RequestInterface $ request ) {
5859 $ this ->assertEquals ('https://example.com/api/foo ' , $ request ->getUri ()->__toString ());
60+
61+ return new HttpFulfilledPromise (new Response ());
5962 }, $ this ->first );
63+
64+ return new HttpFulfilledPromise (new Response ());
6065 }, $ this ->first );
6166 }
6267
@@ -65,18 +70,24 @@ public function testRewriteWithDifferentUrl()
6570 $ request = new Request ('GET ' , 'https://example.com/foo ' );
6671 $ this ->plugin ->handleRequest ($ request , function (RequestInterface $ request ) {
6772 $ this ->assertEquals ('https://example.com/api/foo ' , $ request ->getUri ()->__toString ());
73+
74+ return new HttpFulfilledPromise (new Response ());
6875 }, $ this ->first );
6976
7077 $ request = new Request ('GET ' , 'https://example.com/bar ' );
7178 $ this ->plugin ->handleRequest ($ request , function (RequestInterface $ request ) {
7279 $ this ->assertEquals ('https://example.com/api/bar ' , $ request ->getUri ()->__toString ());
80+
81+ return new HttpFulfilledPromise (new Response ());
7382 }, $ this ->first );
7483 }
7584
7685 public function testRewriteWhenPathIsIncluded ()
7786 {
7887 $ verify = function (RequestInterface $ request ) {
7988 $ this ->assertEquals ('https://example.com/api/foo ' , $ request ->getUri ()->__toString ());
89+
90+ return new HttpFulfilledPromise (new Response ());
8091 };
8192
8293 $ request = new Request ('GET ' , 'https://example.com/api/foo ' );
0 commit comments