Add a test for JSON request to endpoint

This commit is contained in:
Jonny Barnes 2016-07-11 17:32:58 +01:00
parent 72e61032d8
commit 7d381eaf81
2 changed files with 20 additions and 1 deletions

View file

@ -25,7 +25,7 @@ class NoteService
if ($request->header('Content-Type') == 'application/json') { if ($request->header('Content-Type') == 'application/json') {
$content = $request->input('properties.content')[0]; $content = $request->input('properties.content')[0];
$inReplyTo = $request->input('properties.in-reply-to')[0]; $inReplyTo = $request->input('properties.in-reply-to')[0];
$placeSlug = $request->input('proprties.location'); $placeSlug = $request->input('properties.location');
if (is_array($placeSlug)) { if (is_array($placeSlug)) {
$placeSlug = $placeSlug[0]; $placeSlug = $placeSlug[0];
} }

View file

@ -100,6 +100,25 @@ class MicropubTest extends TestCase
$this->seeInDatabase('places', ['slug' => 'the-barton-arms']); $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() private function getToken()
{ {
$signer = new Sha256(); $signer = new Sha256();