Something went wrong. Try again.
A barebones implementation of an atproto PDS in PHP and Slim Framework 4.
pds php atproto
Something went wrong. Try again.
2.1 kB · 68 lines
PHP
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869<?php
declare(strict_types=1);
namespace Tests\Infrastructure\Persistence\Account;
use App\Domain\Account\Account;use App\Domain\Account\AccountNotFoundException;use App\Infrastructure\Database\Database;use App\Infrastructure\Database\Schema\AccountSchema;use App\Infrastructure\Persistence\Account\SqliteAccountRepository;use Tests\TestCase;
class SqliteAccountRepositoryTest extends TestCase{ private function newRepo(): SqliteAccountRepository { $db = new Database(':memory:'); AccountSchema::apply($db);
return new SqliteAccountRepository($db); }
public function testFindAllReturnsProvidedAccounts(): void { $repo = $this->newRepo(); $alice = new Account('did:web:alice.pds.test', 'alice@pds.test', 'hash'); $repo->save($alice);
$this->assertEquals([$alice], $repo->findAll()); }
public function testFindAccountByDid(): void { $repo = $this->newRepo(); $alice = new Account('did:web:alice.pds.test', 'alice@pds.test', 'hash'); $repo->save($alice);
$found = $repo->findAccountByDid('did:web:alice.pds.test'); $this->assertSame('did:web:alice.pds.test', $found->getDid()); }
public function testFindAccountByDidThrowsWhenMissing(): void { $repo = $this->newRepo();
$this->expectException(AccountNotFoundException::class); $repo->findAccountByDid('did:web:missing.pds.test'); }
public function testFindAccountByEmailIsCaseInsensitive(): void { $repo = $this->newRepo(); $alice = new Account('did:web:alice.pds.test', 'alice@pds.test', 'hash'); $repo->save($alice);
$found = $repo->findAccountByEmail(' Alice@PDS.test '); $this->assertSame('alice@pds.test', $found->getEmail()); }
public function testFindAccountByEmailThrowsWhenMissing(): void { $repo = $this->newRepo();
$this->expectException(AccountNotFoundException::class); $repo->findAccountByEmail('missing@pds.test'); }}