Working state but no uploads
This commit is contained in:
@@ -17,6 +17,7 @@ use Tests\ControllerTestCase;
|
||||
* rendu de la liste, création réussie, erreur de création,
|
||||
* suppression avec catégorie introuvable, succès et erreur métier.
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
|
||||
final class CategoryControllerTest extends ControllerTestCase
|
||||
{
|
||||
/** @var \Slim\Views\Twig&MockObject */
|
||||
|
||||
@@ -6,6 +6,8 @@ namespace Tests\Category;
|
||||
use App\Category\Category;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
|
||||
|
||||
final class CategoryModelTest extends TestCase
|
||||
{
|
||||
public function testConstructAndGettersExposeCategoryData(): void
|
||||
|
||||
@@ -19,6 +19,7 @@ use PHPUnit\Framework\TestCase;
|
||||
* PDO et PDOStatement sont mockés pour isoler complètement
|
||||
* le dépôt de la base de données.
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
|
||||
final class CategoryRepositoryTest extends TestCase
|
||||
{
|
||||
/** @var PDO&MockObject */
|
||||
@@ -221,7 +222,7 @@ final class CategoryRepositoryTest extends TestCase
|
||||
$category = Category::fromArray($this->rowPhp);
|
||||
$stmt = $this->stmtForWrite();
|
||||
|
||||
$this->db->method('prepare')
|
||||
$this->db->expects($this->once())->method('prepare')
|
||||
->with($this->stringContains('INSERT INTO categories'))
|
||||
->willReturn($stmt);
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ use PHPUnit\Framework\TestCase;
|
||||
* et la suppression (blocage si articles rattachés).
|
||||
* Le repository est remplacé par un mock pour isoler le service.
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
|
||||
final class CategoryServiceTest extends TestCase
|
||||
{
|
||||
/** @var CategoryRepositoryInterface&MockObject */
|
||||
@@ -129,7 +130,7 @@ final class CategoryServiceTest extends TestCase
|
||||
{
|
||||
$category = new Category(5, 'PHP', 'php');
|
||||
|
||||
$this->repository->method('hasPost')->with(5)->willReturn(false);
|
||||
$this->repository->expects($this->once())->method('hasPost')->with(5)->willReturn(false);
|
||||
$this->repository->expects($this->once())->method('delete')->with(5);
|
||||
|
||||
$this->service->delete($category);
|
||||
@@ -142,7 +143,7 @@ final class CategoryServiceTest extends TestCase
|
||||
{
|
||||
$category = new Category(5, 'PHP', 'php');
|
||||
|
||||
$this->repository->method('hasPost')->with(5)->willReturn(true);
|
||||
$this->repository->expects($this->once())->method('hasPost')->with(5)->willReturn(true);
|
||||
$this->repository->expects($this->never())->method('delete');
|
||||
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
@@ -181,7 +182,7 @@ final class CategoryServiceTest extends TestCase
|
||||
public function testFindBySlugReturnsCategoryWhenFound(): void
|
||||
{
|
||||
$cat = new Category(3, 'PHP', 'php');
|
||||
$this->repository->method('findBySlug')->with('php')->willReturn($cat);
|
||||
$this->repository->expects($this->once())->method('findBySlug')->with('php')->willReturn($cat);
|
||||
|
||||
$this->assertSame($cat, $this->service->findBySlug('php'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user