Finish implementing SqliteGateway
This commit is contained in:
1 parent
adeb7a1b51
commit
f85c48b4a9
2 files changed
+87
-16
No files matched your search
@@ -10,9 +10,15 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SqliteGatewayTest extends TestCase
|
||||
{
|
||||
private SqliteGateway $gateway;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->gateway = new SqliteGateway(":memory:");
|
||||
}
|
||||
|
||||
public function testCanInsertAWebmention()
|
||||
{
|
||||
$gateway = new SqliteGateway(":memory:");
|
||||
|
||||
$webmention = new Webmention(
|
||||
null,
|
||||
@@ -22,13 +28,13 @@ class SqliteGatewayTest extends TestCase
|
||||
"Some Author Name"
|
||||
);
|
||||
|
||||
$webmention->id = $gateway->save($webmention);
|
||||
$webmention->id = $this->gateway->save($webmention);
|
||||
$this->assertNotNull($webmention->id);
|
||||
}
|
||||
|
||||
public function testCanRetrieveAWebmention()
|
||||
{
|
||||
$gateway = new SqliteGateway(":memory:");
|
||||
$this->gateway = new SqliteGateway(":memory:");
|
||||
|
||||
$webmention = new Webmention(
|
||||
null,
|
||||
@@ -38,10 +44,59 @@ class SqliteGatewayTest extends TestCase
|
||||
"Some Author Name"
|
||||
);
|
||||
|
||||
$webmention->id = $gateway->save($webmention);
|
||||
$webmention->id = $this->gateway->save($webmention);
|
||||
|
||||
$retrieved = $gateway->get($webmention->id);
|
||||
$retrieved = $this->gateway->get($webmention->id);
|
||||
|
||||
$this->assertEquals($webmention, $retrieved, ((string) $webmention). " " . ((string) $retrieved));
|
||||
$this->assertEquals($webmention, $retrieved);
|
||||
}
|
||||
|
||||
public function testCanDeleteAWebmention()
|
||||
{
|
||||
$this->gateway = new SqliteGateway(":memory:");
|
||||
|
||||
$webmention = new Webmention(
|
||||
null,
|
||||
"https://lewisdale.dev/post/a-post",
|
||||
"https://a-source.url",
|
||||
"No content",
|
||||
"Some Author Name"
|
||||
);
|
||||
|
||||
$webmention->id = $this->gateway->save($webmention);
|
||||
$this->gateway->delete($webmention);
|
||||
|
||||
$retrieved = $this->gateway->get($webmention->id);
|
||||
|
||||
$this->assertNull($retrieved);
|
||||
}
|
||||
|
||||
public function testCanGetByPost()
|
||||
{
|
||||
$this->gateway = new SqliteGateway(":memory:");
|
||||
|
||||
foreach(range(0, 4) as $_) {
|
||||
$this->gateway->save(new Webmention(
|
||||
null,
|
||||
"https://lewisdale.dev/post/a-new-post",
|
||||
"https://a-source.url",
|
||||
"No content",
|
||||
"Some Author Name"
|
||||
));
|
||||
}
|
||||
|
||||
foreach(range(0, 4) as $_) {
|
||||
$this->gateway->save(new Webmention(
|
||||
null,
|
||||
"https://lewisdale.dev/post/a-different-post",
|
||||
"https://a-source.url",
|
||||
"No content",
|
||||
"Some Author Name"
|
||||
));
|
||||
}
|
||||
|
||||
$mentions = $this->gateway->getByPost("https://lewisdale.dev/post/a-new-post");
|
||||
|
||||
$this->assertCount(5, $mentions);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user