From cdf265fcc1950ddb7c4d7522153b2ca439ae8fc7 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Fri, 19 May 2017 11:30:28 +0100 Subject: [PATCH] Add a test for generated JSON --- .../Feature/MicropubClientControllerTest.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/Feature/MicropubClientControllerTest.php diff --git a/tests/Feature/MicropubClientControllerTest.php b/tests/Feature/MicropubClientControllerTest.php new file mode 100644 index 00000000..19d0b407 --- /dev/null +++ b/tests/Feature/MicropubClientControllerTest.php @@ -0,0 +1,51 @@ + 'http://example.org/a'], 'Created'), + ]); + + $stack = HandlerStack::create($mock); + $stack->push($history); + $guzzleClient = new GuzzleClient(['handler' => $stack]); + + $this->app->instance(GuzzleClient::class, $guzzleClient); + + $response = $this->post( + '/micropub', + [ + 'content' => 'Hello Fred', + 'in-reply-to' => 'https://fredbloggs.com/note/abc', + 'mp-syndicate-to' => ['https://twitter.com/jonnybarnes', 'https://facebook.com/jonnybarnes'], + ] + ); + + $expected = '{"type":["h-entry"],"properties":{"content":["Hello Fred"],"in-reply-to":["https:\/\/fredbloggs.com\/note\/abc"],"mp-syndicate-to":["https:\/\/twitter.com\/jonnybarnes","https:\/\/facebook.com\/jonnybarnes"]}}'; + foreach ($container as $transaction) { + $this->assertEquals($expected, $transaction['request']->getBody()->getContents()); + } + } +}