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.5 kB · 87 lines
PHP
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788<?php
declare(strict_types=1);
namespace Tests\Infrastructure\Persistence\Preference;
use App\Domain\Preference\AccountPref;use App\Domain\Preference\AccountPrefNotFoundException;use App\Infrastructure\Database\Database;use App\Infrastructure\Database\Schema\ActorStoreSchema;use App\Infrastructure\Persistence\Preference\SqliteAccountPrefRepository;use Tests\TestCase;
class SqliteAccountPrefRepositoryTest extends TestCase{ private function newRepo(): SqliteAccountPrefRepository { $db = new Database(':memory:'); ActorStoreSchema::apply($db);
return new SqliteAccountPrefRepository($db); }
private function makePref( string $name = 'muted-words', int $id = 0, ): AccountPref { return new AccountPref(id: $id, name: $name, valueJson: '[]'); }
public function testSaveAssignsAutoIncrementedId(): void { $repo = $this->newRepo(); $saved = $repo->save($this->makePref());
$this->assertSame(1, $saved->getId()); }
public function testFindById(): void { $repo = $this->newRepo(); $saved = $repo->save($this->makePref());
$result = $repo->findById($saved->getId()); $this->assertSame($saved->getId(), $result->getId()); }
public function testFindByIdThrowsWhenMissing(): void { $repo = $this->newRepo();
$this->expectException(AccountPrefNotFoundException::class); $repo->findById(999); }
public function testFindByName(): void { $repo = $this->newRepo(); $repo->save($this->makePref(name: 'muted-words')); $repo->save($this->makePref(name: 'muted-words')); $repo->save($this->makePref(name: 'theme'));
$results = $repo->findByName('muted-words'); $this->assertCount(2, $results); }
public function testDeleteByName(): void { $repo = $this->newRepo(); $repo->save($this->makePref(name: 'muted-words')); $repo->save($this->makePref(name: 'theme')); $repo->deleteByName('muted-words');
$this->assertEmpty($repo->findByName('muted-words')); $this->assertCount(1, $repo->findAll()); }
public function testDeleteAll(): void { $repo = $this->newRepo(); $repo->save($this->makePref()); $repo->save($this->makePref(name: 'foo')); $repo->deleteAll();
$this->assertEmpty($repo->findAll()); }}