test: Ajouter les tests unitaires manquants (backend et frontend)
Couverture des processors (RefreshToken, RequestPasswordReset, ResetPassword, SwitchRole, UpdateUserRoles), des query handlers (HasGradesInPeriod, HasStudentsInClass), des messaging handlers (SendActivationConfirmation, SendPasswordResetEmail), et côté frontend des modules auth, roles, monitoring, types et E2E tokens.
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Administration\Application\Query\HasStudentsInClass;
|
||||
|
||||
use App\Administration\Application\Query\HasStudentsInClass\HasStudentsInClassHandler;
|
||||
use App\Administration\Application\Query\HasStudentsInClass\HasStudentsInClassQuery;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Tests for HasStudentsInClassHandler.
|
||||
*
|
||||
* Currently returns 0 (stub) until the student module is available.
|
||||
* These tests document the expected behavior for when the implementation
|
||||
* is completed.
|
||||
*/
|
||||
final class HasStudentsInClassHandlerTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function returnsZeroForAnyClass(): void
|
||||
{
|
||||
$handler = new HasStudentsInClassHandler();
|
||||
|
||||
$query = new HasStudentsInClassQuery(
|
||||
classId: '550e8400-e29b-41d4-a716-446655440020',
|
||||
);
|
||||
|
||||
$result = ($handler)($query);
|
||||
|
||||
self::assertSame(0, $result);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function returnsIntegerType(): void
|
||||
{
|
||||
$handler = new HasStudentsInClassHandler();
|
||||
|
||||
$query = new HasStudentsInClassQuery(
|
||||
classId: '550e8400-e29b-41d4-a716-446655440021',
|
||||
);
|
||||
|
||||
$result = ($handler)($query);
|
||||
|
||||
self::assertIsInt($result);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function isConsistentAcrossMultipleCalls(): void
|
||||
{
|
||||
$handler = new HasStudentsInClassHandler();
|
||||
$classId = '550e8400-e29b-41d4-a716-446655440022';
|
||||
|
||||
$result1 = ($handler)(new HasStudentsInClassQuery(classId: $classId));
|
||||
$result2 = ($handler)(new HasStudentsInClassQuery(classId: $classId));
|
||||
|
||||
self::assertSame($result1, $result2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user