File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111
1212use GuzzleHttp \Client ;
1313use GuzzleHttp \Handler \MockHandler ;
14+ use LKDev \HetznerCloud \Clients \GuzzleClient ;
1415use LKDev \HetznerCloud \HetznerAPIClient ;
1516
1617abstract class TestCase extends \PHPUnit \Framework \TestCase
@@ -29,7 +30,10 @@ public function setUp(): void
2930 {
3031 $ this ->mockHandler = new MockHandler ();
3132 $ this ->hetznerApi = new HetznerAPIClient ('abcdef ' , 'http://localhost:4000/v1/ ' );
32- $ this ->hetznerApi ->setHttpClient (new Client (['handler ' => $ this ->mockHandler ]));
33+
34+ $ guzzleClient = new GuzzleClient ($ this ->hetznerApi , ['handler ' => $ this ->mockHandler ]);
35+
36+ $ this ->hetznerApi ->setHttpClient ($ guzzleClient );
3337 }
3438
3539 public function tearDown (): void
@@ -41,7 +45,7 @@ public function tearDown(): void
4145 public function assertLastRequestEquals ($ method , $ urlFragment )
4246 {
4347 $ this ->assertEquals ($ this ->mockHandler ->getLastRequest ()->getMethod (), $ method );
44- $ this ->assertEquals ( ' / ' . $ this ->mockHandler ->getLastRequest ()->getUri ()->getPath (), $ urlFragment );
48+ $ this ->assertStringEndsWith ( $ urlFragment , $ this ->mockHandler ->getLastRequest ()->getUri ()->getPath ());
4549 }
4650
4751 public function assertLastRequestBodyParametersEqual (array $ parameters )
Original file line number Diff line number Diff line change 1010namespace LKDev \Tests \Unit ;
1111
1212use GuzzleHttp \Client ;
13+ use LKDev \HetznerCloud \Clients \GuzzleClient ;
1314use LKDev \HetznerCloud \HetznerAPIClient ;
1415use LKDev \HetznerCloud \Models \Actions \Actions ;
1516use LKDev \HetznerCloud \Models \Datacenters \Datacenters ;
@@ -61,7 +62,7 @@ public function testSetUserAgent()
6162 public function testSetHttpClient ()
6263 {
6364 $ client = new HetznerAPIClient ('IAmTheTestToken ' , '' );
64- $ httpClient = new Client ( );
65+ $ httpClient = new GuzzleClient ( $ client );
6566 $ client ->setHttpClient ($ httpClient );
6667 $ this ->assertEquals ($ httpClient , $ client ->getHttpClient ());
6768 }
You can’t perform that action at this time.
0 commit comments