webmentions/tests/Gateways/SqliteGatewayTest.php

48 lines
1.2 KiB
PHP
Raw Normal View History

2023-03-09 09:48:08 +00:00
<?php
declare(strict_types=1);
error_reporting(E_ALL); ini_set('display_errors',1);
use Lewisdale\Webmentions\Gateways\SqliteGateway;
use Lewisdale\Webmentions\Models\Webmention;
use PHPUnit\Framework\TestCase;
class SqliteGatewayTest extends TestCase
{
public function testCanInsertAWebmention()
{
$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 = $gateway->save($webmention);
$this->assertNotNull($webmention->id);
}
public function testCanRetrieveAWebmention()
{
$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 = $gateway->save($webmention);
$retrieved = $gateway->get($webmention->id);
$this->assertEquals($webmention, $retrieved, ((string) $webmention). " " . ((string) $retrieved));
}
}