47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Unit\Auth;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use App\Auth\UserDirectory;
|
|
use App\Tests\Support\FakeDatabase;
|
|
|
|
/**
|
|
* Lecture des infos d'affichage (nom + libelle de role) pour l'entete admin.
|
|
*/
|
|
final class UserDirectoryTest extends TestCase
|
|
{
|
|
private FakeDatabase $db;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->db = new FakeDatabase();
|
|
}
|
|
|
|
public function testDisplayInfoReturnsNameAndRoleLabel(): void
|
|
{
|
|
$this->db->userDisplayRow = [
|
|
'first_name' => 'Corentin',
|
|
'last_name' => 'J',
|
|
'email' => 'corentin@wakdo.local',
|
|
'role_label' => 'Administrateur',
|
|
];
|
|
|
|
self::assertSame(
|
|
['name' => 'Corentin J', 'role_label' => 'Administrateur', 'email' => 'corentin@wakdo.local'],
|
|
(new UserDirectory($this->db))->displayInfo(7),
|
|
);
|
|
}
|
|
|
|
public function testDisplayInfoDefaultsWhenAbsent(): void
|
|
{
|
|
$this->db->userDisplayRow = null;
|
|
|
|
self::assertSame(
|
|
['name' => 'Utilisateur', 'role_label' => '', 'email' => ''],
|
|
(new UserDirectory($this->db))->displayInfo(999),
|
|
);
|
|
}
|
|
}
|