✨ feat(revervation): [Ajoute la création de session de réservation et le flow] 🐛 fix(PurgeCommandTest): [Utilise addCommand au lieu de add pour les commandes] 📝 chore(deps): [Mise à jour des dépendances Composer et corrections] 🐛 fix(KeycloakAuthenticator): [Corrige le type nullable de l'exception start] ✨ feat(Customer): [Ajoute les sessions de commandes aux entités Customer] ♻️ refactor(AppLogger): [Refactorise l'AppLogger pour obtenir l'UserAgent] ✨ feat(FlowReserve): [Ajoute une action de validation du panier] ```
65 lines
2.0 KiB
PHP
65 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Command;
|
|
|
|
use App\Command\MaintenanceCommand;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Symfony\Component\Console\Application;
|
|
use Symfony\Component\Console\Tester\CommandTester;
|
|
|
|
class MaintenanceCommandTest extends TestCase
|
|
{
|
|
private string $tempDir;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->tempDir = sys_get_temp_dir() . '/maintenance_test_' . uniqid();
|
|
mkdir($this->tempDir . '/var', 0777, true);
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
$this->removeDirectory($this->tempDir);
|
|
}
|
|
|
|
public function testExecuteOn()
|
|
{
|
|
$command = new MaintenanceCommand($this->tempDir);
|
|
$application = new Application();
|
|
$application->addCommand($command);
|
|
$commandTester = new CommandTester($application->find('app:maintenance'));
|
|
|
|
$commandTester->execute(['status' => 'on']);
|
|
|
|
$output = $commandTester->getDisplay();
|
|
$this->assertStringContainsString('Mode maintenance ACTIVÉ', $output);
|
|
$this->assertFileExists($this->tempDir . '/var/.maintenance');
|
|
}
|
|
|
|
public function testExecuteOff()
|
|
{
|
|
// Ensure file exists first
|
|
touch($this->tempDir . '/var/.maintenance');
|
|
|
|
$command = new MaintenanceCommand($this->tempDir);
|
|
$application = new Application();
|
|
$application->addCommand($command);
|
|
$commandTester = new CommandTester($application->find('app:maintenance'));
|
|
|
|
$commandTester->execute(['status' => 'off']);
|
|
|
|
$output = $commandTester->getDisplay();
|
|
$this->assertStringContainsString('Mode maintenance DÉSACTIVÉ', $output);
|
|
$this->assertFileDoesNotExist($this->tempDir . '/var/.maintenance');
|
|
}
|
|
|
|
private function removeDirectory($dir) {
|
|
if (!is_dir($dir)) return;
|
|
$files = array_diff(scandir($dir), array('.','..'));
|
|
foreach ($files as $file) {
|
|
(is_dir("$dir/$file")) ? $this->removeDirectory("$dir/$file") : unlink("$dir/$file");
|
|
}
|
|
rmdir($dir);
|
|
}
|
|
}
|