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.3 kB · 83 lines
PHP
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384<?php
declare(strict_types=1);
namespace Tests\Infrastructure\Persistence\Repo;
use App\Domain\Repo\RepoBlock;use App\Domain\Repo\RepoBlockNotFoundException;use App\Infrastructure\Database\Database;use App\Infrastructure\Database\Schema\ActorStoreSchema;use App\Infrastructure\Persistence\Repo\SqliteRepoBlockRepository;use Tests\TestCase;
class SqliteRepoBlockRepositoryTest extends TestCase{ private function newRepo(): SqliteRepoBlockRepository { $db = new Database(':memory:'); ActorStoreSchema::apply($db);
return new SqliteRepoBlockRepository($db); }
private function makeBlock( string $cid = 'bafyreiblock', string $rev = '3aaaa', ): RepoBlock { return new RepoBlock( cid: $cid, repoRev: $rev, size: 42, content: 'placeholder-cbor', ); }
public function testFindByCidReturnsSeededBlock(): void { $repo = $this->newRepo(); $repo->save($this->makeBlock());
$found = $repo->findByCid('bafyreiblock'); $this->assertSame('bafyreiblock', $found->getCid()); }
public function testFindByCidThrowsWhenMissing(): void { $repo = $this->newRepo();
$this->expectException(RepoBlockNotFoundException::class); $repo->findByCid('bafyreinone'); }
public function testFindByRepoRev(): void { $repo = $this->newRepo(); $repo->save($this->makeBlock(cid: 'cid1', rev: 'rev-a')); $repo->save($this->makeBlock(cid: 'cid2', rev: 'rev-b'));
$results = $repo->findByRepoRev('rev-a'); $this->assertCount(1, $results); $this->assertSame('cid1', $results[0]->getCid()); }
public function testSaveAndDeleteByCid(): void { $repo = $this->newRepo(); $repo->save($this->makeBlock()); $repo->deleteByCid('bafyreiblock');
$this->expectException(RepoBlockNotFoundException::class); $repo->findByCid('bafyreiblock'); }
public function testDeleteAll(): void { $repo = $this->newRepo(); $repo->save($this->makeBlock(cid: 'cid1')); $repo->save($this->makeBlock(cid: 'cid2')); $repo->deleteAll();
$this->assertEmpty($repo->findAll()); }}