45
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Signature\TemplateSelector;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TemplateSelectorTest extends TestCase
|
||||
{
|
||||
private array $assignments = [
|
||||
['id' => 1, 'template_id' => 10, 'group_id' => 100, 'priority' => 10], // agents
|
||||
['id' => 2, 'template_id' => 20, 'group_id' => 200, 'priority' => 100], // directeurs
|
||||
['id' => 3, 'template_id' => 30, 'group_id' => 300, 'priority' => 100], // même priorité, plus récent
|
||||
];
|
||||
|
||||
public function test_priorite_la_plus_haute_gagne(): void
|
||||
{
|
||||
$this->assertSame(20, (new TemplateSelector)->select($this->assignments, [100, 200], 99));
|
||||
}
|
||||
|
||||
public function test_egalite_departagee_par_anciennete(): void
|
||||
{
|
||||
$this->assertSame(20, (new TemplateSelector)->select($this->assignments, [300, 200], 99));
|
||||
}
|
||||
|
||||
public function test_template_par_defaut_hors_groupe(): void
|
||||
{
|
||||
$this->assertSame(99, (new TemplateSelector)->select($this->assignments, [555], 99));
|
||||
$this->assertNull((new TemplateSelector)->select($this->assignments, [], null));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user