File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434 "psr-4" : {
3535 "Tests\\ " : " tests"
3636 }
37+ },
38+ "scripts" : {
39+ "test" : " ./vendor/bin/phpunit tests"
3740 }
3841}
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <phpunit colors =" true"
3+ bootstrap =" ./vendor/autoload.php" >
4+ <php >
5+ <ini name =" display_errors" value =" stderr" />
6+ <ini name =" error_log" value =" /dev/null" />
7+ </php >
8+ <testsuite name =" Unit tests" >
9+ <directory >.tests/</directory >
10+ </testsuite >
11+ <filter >
12+ <whitelist processUncoveredFilesFromWhitelist =" true" >
13+ <directory suffix =" .php" >src/</directory >
14+ </whitelist >
15+ </filter >
16+ </phpunit >
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Tests \SendCloud ;
4+
5+ use GuzzleHttp \Client ;
6+ use GuzzleHttp \ClientInterface ;
7+ use GuzzleHttp \Psr7 \Response ;
8+ use PHPUnit \Framework \TestCase ;
9+ use Imbue \SendCloud \SendCloudApiClient ;
10+
11+ class ApiClientTest extends TestCase
12+ {
13+ /** @var ClientInterface */
14+ private $ guzzleClient ;
15+ /** @var SendCloudApiClient */
16+ private $ sendCloudApiClient ;
17+
18+ protected function setUp ()
19+ {
20+ parent ::setUp ();
21+ $ this ->guzzleClient = $ this ->createMock (Client::class);
22+ $ this ->sendCloudApiClient = new SendCloudApiClient ($ this ->guzzleClient );
23+ $ this ->sendCloudApiClient ->setApiAuth ('test_api_key ' , 'test_api_secret ' );
24+ }
25+
26+ public function testPerformHttpCallReturnsBodyAsObject ()
27+ {
28+ $ response = new Response (200 , [], '{"object": "parcel"} ' );
29+
30+ $ this ->guzzleClient
31+ ->expects ($ this ->once ())
32+ ->method ('send ' )
33+ ->willReturn ($ response );
34+
35+ $ parsedResponse = $ this ->sendCloudApiClient ->performHttpCall ('GET ' , '' );
36+
37+ $ this ->assertEquals (
38+ (object )['object ' => 'parcel ' ],
39+ $ parsedResponse
40+ );
41+ }
42+ }
You can’t perform that action at this time.
0 commit comments