Working state but no uploads
This commit is contained in:
@@ -13,6 +13,8 @@ use App\Shared\Html\HtmlSanitizerInterface;
|
||||
use PDO;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
|
||||
|
||||
final class PostConcurrentUpdateIntegrationTest extends TestCase
|
||||
{
|
||||
private PDO $db;
|
||||
|
||||
@@ -27,6 +27,7 @@ use Tests\ControllerTestCase;
|
||||
* - update() : 404, droits insuffisants, succès, erreur de validation
|
||||
* - delete() : 404, droits insuffisants, succès
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
|
||||
final class PostControllerTest extends ControllerTestCase
|
||||
{
|
||||
/** @var \Slim\Views\Twig&MockObject */
|
||||
@@ -100,7 +101,7 @@ final class PostControllerTest extends ControllerTestCase
|
||||
public function testIndexFiltersByCategoryWhenSlugProvided(): void
|
||||
{
|
||||
$category = new Category(3, 'PHP', 'php');
|
||||
$this->categoryService->method('findBySlug')->with('php')->willReturn($category);
|
||||
$this->categoryService->expects($this->once())->method('findBySlug')->with('php')->willReturn($category);
|
||||
|
||||
$this->postService->expects($this->once())
|
||||
->method('getAllPosts')
|
||||
@@ -233,7 +234,7 @@ final class PostControllerTest extends ControllerTestCase
|
||||
public function testFormRendersFilledFormWhenUserIsAuthor(): void
|
||||
{
|
||||
$post = $this->buildPostEntity(7, 'Titre', 'Contenu', 'titre', 5);
|
||||
$this->postService->method('getPostById')->with(7)->willReturn($post);
|
||||
$this->postService->expects($this->once())->method('getPostById')->with(7)->willReturn($post);
|
||||
$this->sessionManager->method('isAdmin')->willReturn(false);
|
||||
$this->sessionManager->method('isEditor')->willReturn(false);
|
||||
$this->sessionManager->method('getUserId')->willReturn(5);
|
||||
|
||||
@@ -8,6 +8,8 @@ use App\Post\PostExtension;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
|
||||
|
||||
final class PostExtensionTest extends TestCase
|
||||
{
|
||||
/** @var array<string, TwigFunction> */
|
||||
|
||||
@@ -8,6 +8,8 @@ use App\Shared\Database\Migrator;
|
||||
use PDO;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
|
||||
|
||||
final class PostFtsUsernameSyncIntegrationTest extends TestCase
|
||||
{
|
||||
private PDO $db;
|
||||
|
||||
@@ -6,6 +6,8 @@ namespace Tests\Post;
|
||||
use App\Post\Post;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
|
||||
|
||||
final class PostModelEdgeCasesTest extends TestCase
|
||||
{
|
||||
public function testFromArrayKeepsMissingOptionalFieldsNull(): void
|
||||
|
||||
@@ -7,6 +7,8 @@ use App\Post\Post;
|
||||
use DateTime;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
|
||||
|
||||
final class PostModelTest extends TestCase
|
||||
{
|
||||
public function testConstructAndGettersExposePostData(): 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 PostRepositoryTest extends TestCase
|
||||
{
|
||||
/** @var PDO&MockObject */
|
||||
@@ -339,7 +340,7 @@ final class PostRepositoryTest extends TestCase
|
||||
$post = Post::fromArray($this->rowPost);
|
||||
$stmt = $this->stmtForWrite();
|
||||
|
||||
$this->db->method('prepare')
|
||||
$this->db->expects($this->once())->method('prepare')
|
||||
->with($this->stringContains('INSERT INTO posts'))
|
||||
->willReturn($stmt);
|
||||
|
||||
@@ -403,7 +404,7 @@ final class PostRepositoryTest extends TestCase
|
||||
$post = Post::fromArray($this->rowPost);
|
||||
$stmt = $this->stmtForWrite(1);
|
||||
|
||||
$this->db->method('prepare')
|
||||
$this->db->expects($this->once())->method('prepare')
|
||||
->with($this->stringContains('UPDATE posts'))
|
||||
->willReturn($stmt);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ use PHPUnit\Framework\TestCase;
|
||||
* Couvre la création, la mise à jour, la suppression et les lectures.
|
||||
* HtmlSanitizerInterface et PostRepository sont mockés pour isoler la logique métier.
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
|
||||
final class PostServiceTest extends TestCase
|
||||
{
|
||||
/** @var PostRepositoryInterface&MockObject */
|
||||
@@ -65,7 +66,7 @@ final class PostServiceTest extends TestCase
|
||||
public function testGetPostsByUserIdDelegatesToRepository(): void
|
||||
{
|
||||
$posts = [$this->makePost(1, 'Titre', 'slug-titre')];
|
||||
$this->repository->method('findByUserId')->with(3, null)->willReturn($posts);
|
||||
$this->repository->expects($this->once())->method('findByUserId')->with(3, null)->willReturn($posts);
|
||||
|
||||
$this->assertSame($posts, $this->service->getPostsByUserId(3));
|
||||
}
|
||||
@@ -181,7 +182,7 @@ final class PostServiceTest extends TestCase
|
||||
public function testSearchPostsDelegatesToRepository(): void
|
||||
{
|
||||
$posts = [$this->makePost(1, 'Résultat', 'resultat')];
|
||||
$this->repository->method('search')->with('mot', null, null)->willReturn($posts);
|
||||
$this->repository->expects($this->once())->method('search')->with('mot', null, null)->willReturn($posts);
|
||||
|
||||
$this->assertSame($posts, $this->service->searchPosts('mot'));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ use Tests\ControllerTestCase;
|
||||
* - Flux vide : XML minimal valide
|
||||
* - Appel à getRecentPosts() avec la constante FEED_LIMIT (20)
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
|
||||
final class RssControllerTest extends ControllerTestCase
|
||||
{
|
||||
/** @var PostServiceInterface&MockObject */
|
||||
|
||||
Reference in New Issue
Block a user