gateway = new SqliteGateway(":memory:"); } public function testCanInsertAWebmention() { $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->assertNotNull($webmention->id); } public function testCanRetrieveAWebmention() { $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); $retrieved = $this->gateway->get($webmention->id); $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); } }