Working state but no uploads
This commit is contained in:
@@ -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