From 7d381eaf812d8fc924fd489af7c1fe0833f5f216 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Mon, 11 Jul 2016 17:32:58 +0100 Subject: [PATCH] Add a test for JSON request to endpoint --- app/Services/NoteService.php | 2 +- tests/MicropubTest.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/Services/NoteService.php b/app/Services/NoteService.php index 33c88fe9..38cbe531 100644 --- a/app/Services/NoteService.php +++ b/app/Services/NoteService.php @@ -25,7 +25,7 @@ class NoteService if ($request->header('Content-Type') == 'application/json') { $content = $request->input('properties.content')[0]; $inReplyTo = $request->input('properties.in-reply-to')[0]; - $placeSlug = $request->input('proprties.location'); + $placeSlug = $request->input('properties.location'); if (is_array($placeSlug)) { $placeSlug = $placeSlug[0]; } diff --git a/tests/MicropubTest.php b/tests/MicropubTest.php index 4da3853d..26addf48 100644 --- a/tests/MicropubTest.php +++ b/tests/MicropubTest.php @@ -100,6 +100,25 @@ class MicropubTest extends TestCase $this->seeInDatabase('places', ['slug' => 'the-barton-arms']); } + public function testMicropubJSONRequestCreateNewNote() + { + $faker = \Faker\Factory::create(); + $note = $faker->text; + $this->json( + 'POST', + $this->appurl . '/api/post', + [ + 'type' => ['h-entry'], + 'properties' => [ + 'content' => [$note], + ], + ], + ['HTTP_Authorization' => 'Bearer ' . $this->getToken()] + )->seeJson([ + 'response' => 'created' + ]); + } + private function getToken() { $signer = new Sha256();