File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace TraderInteractive \Api ;
4+
5+ class Exception extends \Exception
6+ {
7+ /**
8+ * @var Response
9+ */
10+ private $ response ;
11+
12+ public function __construct (string $ message , Response $ response )
13+ {
14+ parent ::__construct ($ message );
15+ $ this ->response = $ response ;
16+ }
17+
18+ public function getResponse () : Response
19+ {
20+ return $ this ->response ;
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace TraderInteractive \Api ;
4+
5+ use GuzzleHttp \Psr7 ;
6+ use PHPUnit \Framework \TestCase ;
7+
8+ /**
9+ * Defines unit tests for the Exception class
10+ *
11+ * @coversDefaultClass \TraderInteractive\Api\Exception
12+ * @covers ::__construct
13+ */
14+ final class ExceptionTest extends TestCase
15+ {
16+ /**
17+ * @test
18+ * @covers ::getResponse
19+ */
20+ public function getResponseReturnsResponse ()
21+ {
22+ $ httpCode = 200 ;
23+ $ body = ['doesnt ' => 'matter ' ];
24+ $ headers = ['Content-Type ' => ['text/json ' ]];
25+ $ response = new Response ($ httpCode , $ headers , $ body );
26+ $ exception = new Exception ('the error message ' , $ response );
27+ $ this ->assertSame ($ response , $ exception ->getResponse ());
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments