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()); } }