Store authors alongside webmentions

This commit is contained in:
Lewis Dale committed 2023-03-16 09:34:57 +00:00
1 parent 3cafc5238e
commit 51f1269600
4 files changed
+210 -19

No files matched your search

+87 -1
View File
@@ -43,7 +43,7 @@ class SqliteGatewayTest extends TestCase
"https://a-source.url",
MentionType::Like,
"No content",
new \Lewisdale\Webmentions\Models\Author(),
new \Lewisdale\Webmentions\Models\Author(null, null, null, null),
);
$webmention->id = $this->gateway->save($webmention);
@@ -155,4 +155,90 @@ class SqliteGatewayTest extends TestCase
])
);
}
public function testItSavesAnAuthorWithTheWebmention()
{
$webmention = new Webmention(
null,
"https://a-target-url.com",
"https://a-source-url.com",
MentionType::Like,
"Liked this post",
new \Lewisdale\Webmentions\Models\Author(
null,
"Doreen Mifah",
"https://my-homepage.com",
"https://cdn.imgserver.com/400/400"
)
);
$webmention->id = $this->gateway->save($webmention);
$retrieved = $this->gateway->get($webmention->id)?->author;
$expected = $webmention->author;
$this->assertEquals($expected->name, $retrieved?->name);
$this->assertEquals($expected->url, $retrieved?->url);
$this->assertEquals($expected->photo, $retrieved?->photo);
}
public function testItLooksUpWebmentionsByAuthorName()
{
$this->gateway->save(new Webmention(
null,
"https://a-target-url.com",
"https://a-source-url.com",
MentionType::Like,
"Liked this post",
new \Lewisdale\Webmentions\Models\Author(
null,
"Doreen Mifah",
"https://my-homepage.com",
"https://cdn.imgserver.com/400/400"
)
));
$this->gateway->save(new Webmention(
null,
"https://a-target-url.com",
"https://a-source-url.com",
MentionType::Like,
"Liked this post",
new \Lewisdale\Webmentions\Models\Author(
null,
"Carl Weathers",
"https://carl-weathers.com",
"https://cdn.imgserver.com/400/400"
)
));
$this->gateway->save(new Webmention(
null,
"https://a-target-url.com",
"https://a-source-url.com",
MentionType::Like,
"Liked this post",
new \Lewisdale\Webmentions\Models\Author(
null,
"Barry White",
"https://barry.white.com",
"https://cdn.imgserver.com/400/400"
)
));
$this->gateway->save(new Webmention(
null,
"https://a-target-url.com",
"https://a-source-url.com",
MentionType::Reply,
"This was a cool post!",
new \Lewisdale\Webmentions\Models\Author(
null,
"Carl Weathers",
"https://carl-weathers.com",
"https://cdn.imgserver.com/400/400"
)
));
$retrieved = $this->gateway->find(["author_name" => "Carl Weathers"]);
$this->assertCount(2, $retrieved);
}
}