feat(ReserverController): Ajoute vérification de disponibilité produit.
🛠️ refactor(BackupCommand): Utilise DatabaseDumper et ZipArchiver.
 feat(GitSyncLogCommand): Utilise Gemini pour messages plus clairs.
 feat(GenerateVideoThumbsCommand): Utilise VideoThumbnailer service.
 feat(AppWarmupImagesCommand): Utilise StorageInterface pour warmup.
🔒️ security(nelmio_security): Renforce la sécurité avec des en-têtes.
🔧 chore(caddy): Améliore la configuration de Caddy pour la performance.
🐛 fix(makefile): Corrige les commandes de test.
🧪 chore(.env.test): Supprime la ligne vide à la fin du fichier.
🔧 chore(doctrine): Active native_lazy_objects.
🔧 chore(cache): Ajoute un cache system.
```
This commit is contained in:
Serreau Jovann
2026-01-30 17:58:12 +01:00
parent a6fc8fdf3b
commit 36a51c5a54
34 changed files with 1879 additions and 164 deletions

View File

@@ -0,0 +1,107 @@
<?php
namespace App\Tests\Command;
use App\Command\CleanCommand;
use App\Entity\CustomerTracking;
use App\Entity\SitePerformance;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
class CleanCommandTest extends TestCase
{
private MockObject&EntityManagerInterface $entityManager;
private MockObject&QueryBuilder $qb1;
private MockObject&QueryBuilder $qb2;
private MockObject&Query $query1;
private MockObject&Query $query2;
protected function setUp(): void
{
$this->entityManager = $this->createMock(EntityManagerInterface::class);
$this->qb1 = $this->createMock(QueryBuilder::class);
$this->qb2 = $this->createMock(QueryBuilder::class);
$this->query1 = $this->createMock(Query::class);
$this->query2 = $this->createMock(Query::class);
}
public function testExecute()
{
// Configure EntityManager to return two different QueryBuilders in sequence
$this->entityManager->expects($this->exactly(2))
->method('createQueryBuilder')
->willReturnOnConsecutiveCalls($this->qb1, $this->qb2);
// --- Sequence 1: SitePerformance ---
$this->qb1->expects($this->once())
->method('delete')
->with(SitePerformance::class, 'p')
->willReturnSelf();
$this->qb1->expects($this->once())
->method('where')
->with('p.createdAt <= :limit')
->willReturnSelf();
$this->qb1->expects($this->once())
->method('setParameter')
->with('limit', $this->isInstanceOf(\DateTime::class))
->willReturnSelf();
$this->qb1->expects($this->once())
->method('getQuery')
->willReturn($this->query1);
$this->query1->expects($this->once())
->method('execute')
->willReturn(5); // Simulate 5 records deleted
// --- Sequence 2: CustomerTracking ---
$this->qb2->expects($this->once())
->method('delete')
->with(CustomerTracking::class, 't')
->willReturnSelf();
$this->qb2->expects($this->once())
->method('where')
->with('t.createAT <= :limit')
->willReturnSelf();
$this->qb2->expects($this->once())
->method('setParameter')
->with('limit', $this->isInstanceOf(\DateTime::class))
->willReturnSelf();
$this->qb2->expects($this->once())
->method('getQuery')
->willReturn($this->query2);
$this->query2->expects($this->once())
->method('execute')
->willReturn(10); // Simulate 10 records deleted
// Expect final flush
$this->entityManager->expects($this->once())
->method('flush');
// Instantiate and run Command
$command = new CleanCommand($this->entityManager);
$application = new Application();
$application->add($command);
$commandTester = new CommandTester($application->find('app:clean'));
$commandTester->execute([]);
$output = $commandTester->getDisplay();
// Assertions on output
$this->assertStringContainsString('5 entrées de performance supprimées', $output);
$this->assertStringContainsString('10 entrées de tracking supprimées', $output);
$this->assertStringContainsString('Nettoyage terminé avec succès', $output);
}
}