Integration Baniere dans le backend
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Signature\CampaignSelector;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CampaignSelectorTest extends TestCase
|
||||
{
|
||||
private array $campaigns = [
|
||||
['id' => 1, 'priority' => 10, 'group_ids' => []], // générale
|
||||
['id' => 2, 'priority' => 50, 'group_ids' => [200]], // directeurs
|
||||
['id' => 3, 'priority' => 50, 'group_ids' => [300, 400]], // même priorité, plus récente
|
||||
['id' => 4, 'priority' => 10, 'group_ids' => []], // générale plus récente
|
||||
];
|
||||
|
||||
public function test_campagne_generale_pour_un_agent_hors_groupe(): void
|
||||
{
|
||||
$this->assertSame(1, (new CampaignSelector)->select($this->campaigns, []));
|
||||
$this->assertSame(1, (new CampaignSelector)->select($this->campaigns, [999]));
|
||||
}
|
||||
|
||||
public function test_campagne_ciblee_prioritaire_remplace_la_generale(): void
|
||||
{
|
||||
$this->assertSame(2, (new CampaignSelector)->select($this->campaigns, [200]));
|
||||
$this->assertSame(3, (new CampaignSelector)->select($this->campaigns, [400]));
|
||||
}
|
||||
|
||||
public function test_egalite_departagee_par_anciennete(): void
|
||||
{
|
||||
$this->assertSame(2, (new CampaignSelector)->select($this->campaigns, [400, 200]));
|
||||
}
|
||||
|
||||
public function test_aucune_banniere_sans_campagne_applicable(): void
|
||||
{
|
||||
$this->assertNull((new CampaignSelector)->select([], [200]));
|
||||
$this->assertNull((new CampaignSelector)->select([['id' => 9, 'priority' => 0, 'group_ids' => [5]]], [200]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user