Files
myep-team/tests/Config/HouseCatalogTest.php

56 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Config;
use App\Config\HouseCatalog;
use PHPUnit\Framework\TestCase;
class HouseCatalogTest extends TestCase
{
private const HOUSES = [
'SVS' => 'Silvana',
'AGR' => 'Rotbach',
'DPW' => 'Waldschlössli',
];
public function testNameChoicesAreSortedAndMapLabelToName(): void
{
$catalog = new HouseCatalog(self::HOUSES);
$this->assertSame([
'Rotbach' => 'Rotbach',
'Silvana' => 'Silvana',
'Waldschlössli' => 'Waldschlössli',
], $catalog->getNameChoices());
}
public function testCodeChoicesAreSortedByLabelAndMapLabelToCode(): void
{
$catalog = new HouseCatalog(self::HOUSES);
$this->assertSame([
'Rotbach' => 'AGR',
'Silvana' => 'SVS',
'Waldschlössli' => 'DPW',
], $catalog->getCodeChoices());
}
public function testGetName(): void
{
$catalog = new HouseCatalog(self::HOUSES);
$this->assertSame('Silvana', $catalog->getName('SVS'));
$this->assertNull($catalog->getName('XYZ'));
}
public function testEmptyCatalog(): void
{
$catalog = new HouseCatalog([]);
$this->assertSame([], $catalog->getNameChoices());
$this->assertSame([], $catalog->getCodeChoices());
}
}