Lorsqu'un super-admin crée un établissement via l'interface, le système doit automatiquement créer la base tenant, exécuter les migrations, créer le premier utilisateur admin et envoyer l'invitation — le tout de manière asynchrone pour ne pas bloquer la réponse HTTP. Ce mécanisme rend chaque établissement opérationnel dès sa création sans intervention manuelle sur l'infrastructure.
79 lines
2.7 KiB
PHP
79 lines
2.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Unit\Scolarite\Application\Query\GetStudentProgression;
|
|
|
|
use App\Scolarite\Application\Query\GetStudentProgression\GetStudentProgressionHandler;
|
|
use App\Scolarite\Application\Query\GetStudentProgression\GetStudentProgressionQuery;
|
|
use App\Scolarite\Domain\Service\TeacherStatisticsCalculator;
|
|
use App\Scolarite\Infrastructure\ReadModel\InMemoryTeacherStatisticsReader;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class GetStudentProgressionHandlerTest extends TestCase
|
|
{
|
|
private InMemoryTeacherStatisticsReader $reader;
|
|
private GetStudentProgressionHandler $handler;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->reader = new InMemoryTeacherStatisticsReader();
|
|
$this->handler = new GetStudentProgressionHandler(
|
|
$this->reader,
|
|
new TeacherStatisticsCalculator(),
|
|
);
|
|
}
|
|
|
|
#[Test]
|
|
public function itReturnsEmptyProgressionWhenNoGrades(): void
|
|
{
|
|
$result = ($this->handler)($this->query());
|
|
|
|
self::assertSame([], $result->grades);
|
|
self::assertNull($result->trendLine);
|
|
}
|
|
|
|
#[Test]
|
|
public function itReturnsSingleGradeWithNoTrendLine(): void
|
|
{
|
|
$this->reader->feedGradeHistory([
|
|
['date' => '2026-01-15', 'value' => 12.0, 'evaluationTitle' => 'Contrôle 1'],
|
|
]);
|
|
|
|
$result = ($this->handler)($this->query());
|
|
|
|
self::assertCount(1, $result->grades);
|
|
self::assertSame('2026-01-15', $result->grades[0]->date);
|
|
self::assertSame(12.0, $result->grades[0]->value);
|
|
self::assertNull($result->trendLine);
|
|
}
|
|
|
|
#[Test]
|
|
public function itComputesTrendLineFromMultipleGrades(): void
|
|
{
|
|
$this->reader->feedGradeHistory([
|
|
['date' => '2026-01-15', 'value' => 10.0, 'evaluationTitle' => 'Contrôle 1'],
|
|
['date' => '2026-02-10', 'value' => 12.0, 'evaluationTitle' => 'Contrôle 2'],
|
|
['date' => '2026-03-05', 'value' => 14.0, 'evaluationTitle' => 'Contrôle 3'],
|
|
]);
|
|
|
|
$result = ($this->handler)($this->query());
|
|
|
|
self::assertCount(3, $result->grades);
|
|
self::assertNotNull($result->trendLine);
|
|
self::assertGreaterThan(0, $result->trendLine->slope); // Positive trend
|
|
}
|
|
|
|
private function query(): GetStudentProgressionQuery
|
|
{
|
|
return new GetStudentProgressionQuery(
|
|
studentId: '550e8400-e29b-41d4-a716-446655440050',
|
|
subjectId: '550e8400-e29b-41d4-a716-446655440030',
|
|
classId: '550e8400-e29b-41d4-a716-446655440020',
|
|
teacherId: '550e8400-e29b-41d4-a716-446655440010',
|
|
tenantId: '550e8400-e29b-41d4-a716-446655440001',
|
|
);
|
|
}
|
|
}
|