feat: Permettre la consultation et gestion des droits à l'image des élèves
Les administrateurs et enseignants ont besoin de consulter et gérer les autorisations de droit à l'image des élèves pour respecter la réglementation lors de publications contenant des photos (FR82). Cette fonctionnalité ajoute une page dédiée avec liste filtrable par statut, modification individuelle via dropdown, export CSV avec BOM UTF-8 pour Excel, et préparation du système d'avertissement avant publication (query/handler prêts, intégration à faire quand le module publication existera). Le filtrage par classe (AC2) est bloqué en attente d'une table d'affectation élève↔classe qui n'existe pas encore.
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Administration\Application\Service;
|
||||
|
||||
use App\Administration\Application\Query\GetStudentsImageRights\StudentImageRightsDto;
|
||||
use App\Administration\Application\Service\ImageRightsExporter;
|
||||
use DateTimeImmutable;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class ImageRightsExporterTest extends TestCase
|
||||
{
|
||||
private ImageRightsExporter $exporter;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->exporter = new ImageRightsExporter();
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function startsWithUtf8Bom(): void
|
||||
{
|
||||
$csv = $this->exporter->export([]);
|
||||
|
||||
self::assertStringStartsWith("\xEF\xBB\xBF", $csv);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function exportsHeaderRow(): void
|
||||
{
|
||||
$csv = $this->exporter->export([]);
|
||||
|
||||
self::assertStringContainsString('Nom;Prénom;Classe;Statut', $csv);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function exportsStudentData(): void
|
||||
{
|
||||
$students = [
|
||||
new StudentImageRightsDto(
|
||||
id: 'id-1',
|
||||
firstName: 'Alice',
|
||||
lastName: 'Dupont',
|
||||
email: 'alice@example.com',
|
||||
imageRightsStatus: 'authorized',
|
||||
imageRightsStatusLabel: 'Autorisé',
|
||||
imageRightsUpdatedAt: new DateTimeImmutable(),
|
||||
className: '6ème A',
|
||||
),
|
||||
new StudentImageRightsDto(
|
||||
id: 'id-2',
|
||||
firstName: 'Bob',
|
||||
lastName: 'Martin',
|
||||
email: 'bob@example.com',
|
||||
imageRightsStatus: 'refused',
|
||||
imageRightsStatusLabel: 'Refusé',
|
||||
imageRightsUpdatedAt: null,
|
||||
className: '5ème B',
|
||||
),
|
||||
];
|
||||
|
||||
$csv = $this->exporter->export($students);
|
||||
|
||||
self::assertStringContainsString('Dupont;Alice;"6ème A";Autorisé', $csv);
|
||||
self::assertStringContainsString('Martin;Bob;"5ème B";Refusé', $csv);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function handlesNullClassName(): void
|
||||
{
|
||||
$students = [
|
||||
new StudentImageRightsDto(
|
||||
id: 'id-1',
|
||||
firstName: 'Alice',
|
||||
lastName: 'Dupont',
|
||||
email: 'alice@example.com',
|
||||
imageRightsStatus: 'not_specified',
|
||||
imageRightsStatusLabel: 'Non renseigné',
|
||||
imageRightsUpdatedAt: null,
|
||||
className: null,
|
||||
),
|
||||
];
|
||||
|
||||
$csv = $this->exporter->export($students);
|
||||
|
||||
self::assertStringContainsString('Dupont;Alice;;"Non renseigné"', $csv);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function exportContainsCorrectNumberOfLines(): void
|
||||
{
|
||||
$students = [
|
||||
new StudentImageRightsDto(
|
||||
id: 'id-1',
|
||||
firstName: 'Alice',
|
||||
lastName: 'Dupont',
|
||||
email: 'alice@example.com',
|
||||
imageRightsStatus: 'authorized',
|
||||
imageRightsStatusLabel: 'Autorisé',
|
||||
imageRightsUpdatedAt: null,
|
||||
className: '6ème A',
|
||||
),
|
||||
];
|
||||
|
||||
$csv = $this->exporter->export($students);
|
||||
$lines = array_filter(explode("\n", trim($csv)));
|
||||
|
||||
// 1 header + 1 data row
|
||||
self::assertCount(2, $lines);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user