66
77namespace Commercetools \Core ;
88
9- use Commercetools \Core \Client \Adapter \AdapterFactory ;
109use Commercetools \Core \Client \Adapter \AdapterOptionInterface ;
1110use Commercetools \Core \Client \Adapter \ConfigAware ;
1211use Commercetools \Core \Client \OAuth \Manager ;
2928use GuzzleHttp \Handler \MockHandler ;
3029use GuzzleHttp \HandlerStack ;
3130use GuzzleHttp \Middleware ;
31+ use GuzzleHttp \Promise \PromiseInterface ;
32+ use GuzzleHttp \Ring \Future \FutureInterface ;
3233use GuzzleHttp \Psr7 \BufferStream ;
3334use GuzzleHttp \Psr7 \Request ;
3435use GuzzleHttp \Psr7 \Response ;
@@ -745,11 +746,9 @@ public function testUserAgent()
745746 $ this ->assertSame ('commercetools-php-sdk/ ' . AbstractHttpClient::VERSION , $ userAgent [$ n ++]);
746747 $ this ->assertSame ('GuzzleHttp/ ' . HttpClient::VERSION , trim ($ userAgent [$ n ++], '(); ' ));
747748 if (extension_loaded ('curl ' ) && function_exists ('curl_version ' )) {
748- $ this ->assertSame ('curl/ ' . \curl_version ()['version ' ],trim ($ userAgent [$ n ++], '(); ' ));
749+ $ this ->assertSame ('curl/ ' . \curl_version ()['version ' ], trim ($ userAgent [$ n ++], '(); ' ));
749750 }
750751 $ this ->assertSame ('PHP/ ' . PHP_VERSION , $ userAgent [$ n ++]);
751-
752-
753752 }
754753 }
755754
@@ -805,7 +804,6 @@ public function testHtmlBody()
805804 $ this ->assertInstanceOf (ErrorContainer::class, $ response ->getErrors ());
806805 $ this ->assertEmpty ($ response ->getErrors ());
807806 $ this ->assertSame ('Length Required ' , $ response ->getMessage ());
808-
809807 }
810808
811809 public function testSetClientOptions ()
@@ -827,4 +825,24 @@ public function testSetClientOptions()
827825 $ this ->assertInstanceOf (ConfigAware::class, $ client ->getHttpClient ());
828826 $ this ->assertFalse ($ client ->getHttpClient ()->getConfig ('verify ' ));
829827 }
828+
829+ public function testGetPromise ()
830+ {
831+ $ client = $ this ->getMockClient ($ this ->getConfig (), $ this ->getSingleOpResult (), 200 );
832+
833+ $ endpoint = new JsonEndpoint ('test ' );
834+ $ request = $ this ->getMockForAbstractClass (
835+ AbstractByIdGetRequest::class,
836+ [$ endpoint , 'id ' ]
837+ );
838+ $ response = $ client ->executeAsync ($ request );
839+
840+ $ this ->assertFalse ($ response ->isError ());
841+
842+ if (version_compare (HttpClient::VERSION , '6.0.0 ' , '>= ' )) {
843+ $ this ->assertInstanceOf (PromiseInterface::class, $ response ->getPromise ());
844+ } else {
845+ $ this ->assertInstanceOf (FutureInterface::class, $ response ->getPromise ());
846+ }
847+ }
830848}
0 commit comments