Refatoring : Working state

This commit is contained in:
julien
2026-03-16 16:02:01 +01:00
parent a5ca0df375
commit 0453697cd3
25 changed files with 111 additions and 97 deletions

View File

@@ -70,7 +70,6 @@ final class MediaRepositoryTest extends TestCase
return $stmt;
}
// ── findAll ────────────────────────────────────────────────────
/**
@@ -118,7 +117,6 @@ final class MediaRepositoryTest extends TestCase
$this->repository->findAll();
}
// ── findByUserId ───────────────────────────────────────────────
/**
@@ -161,7 +159,6 @@ final class MediaRepositoryTest extends TestCase
$this->repository->findByUserId(5);
}
// ── findById ───────────────────────────────────────────────────
/**
@@ -204,53 +201,8 @@ final class MediaRepositoryTest extends TestCase
$this->repository->findById(8);
}
// ── findByHash ─────────────────────────────────────────────────
/**
* findByHash() retourne null si aucun média ne correspond au hash.
*/
public function testFindByHashReturnsNullWhenMissing(): void
{
$stmt = $this->stmtForRead(row: false);
$this->db->method('prepare')->willReturn($stmt);
$this->assertNull($this->repository->findByHash(str_repeat('b', 64)));
}
/**
* findByHash() retourne une instance Media si le hash existe (doublon détecté).
*/
public function testFindByHashReturnsDuplicateMedia(): void
{
$stmt = $this->stmtForRead(row: $this->rowImage);
$this->db->method('prepare')->willReturn($stmt);
$result = $this->repository->findByHash(str_repeat('a', 64));
$this->assertInstanceOf(Media::class, $result);
$this->assertSame(str_repeat('a', 64), $result->getHash());
}
/**
* findByHash() exécute avec le bon hash.
*/
public function testFindByHashQueriesWithCorrectHash(): void
{
$hash = str_repeat('c', 64);
$stmt = $this->stmtForRead(row: false);
$this->db->method('prepare')->willReturn($stmt);
$stmt->expects($this->once())
->method('execute')
->with([':hash' => $hash]);
$this->repository->findByHash($hash);
}
// ── create ─────────────────────────────────────────────────────
/**
* create() prépare un INSERT avec les bonnes colonnes.
*/
@@ -291,7 +243,6 @@ final class MediaRepositoryTest extends TestCase
$this->assertSame(15, $this->repository->create($media));
}
// ── delete ─────────────────────────────────────────────────────
/**