diff --git a/tests/SpyPostRequestSenderTest.php b/tests/SpyPostRequestSenderTest.php index 1abec6c..9c1c89d 100644 --- a/tests/SpyPostRequestSenderTest.php +++ b/tests/SpyPostRequestSenderTest.php @@ -17,7 +17,7 @@ class SpyPostRequestSenderTest extends TestCase { public function testGetCalls(): void { - $spy = new SpyPostRequestSender( new StubPostRequestSender( ) ); + $spy = new SpyPostRequestSender( new StubPostRequestSender() ); $spy->post( 'http://first.url', [ 'foo' => 'bar' ] ); $spy->post( 'http://second.url', [ 'baz' => 'bah', 'pew' => 1337 ] ); diff --git a/tests/StubPostRequestSenderTest.php b/tests/StubPostRequestSenderTest.php new file mode 100644 index 0000000..e257bc3 --- /dev/null +++ b/tests/StubPostRequestSenderTest.php @@ -0,0 +1,52 @@ +post( 'https://example.com', [ 'foo' => 'bar' ] ); + + $this->assertSame( + '', + $response->getBody()->getContents() + ); + + $this->assertSame( + 200, + $response->getStatusCode() + ); + } + + public function testAlternativeResponse(): void { + $stubSender = new StubPostRequestSender( + new TestResponse( 'TestBody', 418 ) + ); + + $response = $stubSender->post( 'https://example.com', [ 'foo' => 'bar' ] ); + + $this->assertSame( + 'TestBody', + $response->getBody()->getContents() + ); + + $this->assertSame( + 418, + $response->getStatusCode() + ); + } + +}