Allow micropub to post notes and articles

This commit is contained in:
Jonny Barnes 2022-11-29 19:58:44 +00:00
parent 5eed665801
commit ca6205d2a6
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
9 changed files with 102 additions and 49 deletions

View file

@ -675,7 +675,7 @@ class MicropubControllerTest extends TestCase
}
/** @test */
public function micropubClientWebReauestCanEncodeTokenWithinTheForm(): void
public function micropubClientWebRequestCanEncodeTokenWithinTheForm(): void
{
$faker = Factory::create();
$note = $faker->text;
@ -691,4 +691,32 @@ class MicropubControllerTest extends TestCase
$response->assertJson(['response' => 'created']);
$this->assertDatabaseHas('notes', ['note' => $note]);
}
/** @test */
public function micropubClientApiRequestCreatesArticlesWhenItIncludesTheNameProperty(): void
{
$faker = Factory::create();
$name = $faker->text(50);
$content = $faker->paragraphs(5, true);
$response = $this->postJson(
'/api/post',
[
'type' => ['h-entry'],
'properties' => [
'name' => $name,
'content' => $content,
],
],
['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
);
$response
->assertJson(['response' => 'created'])
->assertStatus(201);
$this->assertDatabaseHas('articles', [
'title' => $name,
'main' => $content,
]);
}
}