|
|
@@ -135,47 +135,84 @@ class UtilsTest extends TestCase
|
|
|
|
|
|
$access = $this->getMockBuilder(Access::class)->getMock();
|
|
|
|
|
|
+ // Valide: pas de date de fin ou de début
|
|
|
$functionType1 = $this->getMockBuilder(FunctionType::class)->getMock();
|
|
|
$functionType1->method('getMission')->willReturn('Mission1');
|
|
|
|
|
|
$function1 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
|
|
|
$function1->method('getEndDate')->willReturn(null);
|
|
|
+ $function1->method('getStartDate')->willReturn(null);
|
|
|
$function1->method('getFunctionType')->willReturn($functionType1);
|
|
|
|
|
|
+ // Valide: pas de date de fin ou de début
|
|
|
$functionType2 = $this->getMockBuilder(FunctionType::class)->getMock();
|
|
|
$functionType2->method('getMission')->willReturn('Mission2');
|
|
|
|
|
|
$function2 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
|
|
|
$function2->method('getEndDate')->willReturn(null);
|
|
|
+ $function2->method('getStartDate')->willReturn(null);
|
|
|
$function2->method('getFunctionType')->willReturn($functionType2);
|
|
|
|
|
|
+ // Invalide: date de fin dépassée
|
|
|
$functionType3 = $this->getMockBuilder(FunctionType::class)->getMock();
|
|
|
$functionType3->method('getMission')->willReturn('Mission3');
|
|
|
|
|
|
$function3 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
|
|
|
$function3->method('getEndDate')->willReturn(new \DateTime('2022-01-01'));
|
|
|
+ $function3->method('getStartDate')->willReturn(null);
|
|
|
$function3->method('getFunctionType')->willReturn($functionType3);
|
|
|
|
|
|
+ // Valide : date de fin dans les 24h suivant le jour même
|
|
|
$functionType4 = $this->getMockBuilder(FunctionType::class)->getMock();
|
|
|
$functionType4->method('getMission')->willReturn('Mission4');
|
|
|
|
|
|
$function4 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
|
|
|
$function4->method('getEndDate')->willReturn(new \DateTime('2023-01-01 18:00'));
|
|
|
+ $function4->method('getStartDate')->willReturn(null);
|
|
|
$function4->method('getFunctionType')->willReturn($functionType4);
|
|
|
|
|
|
+ // Valide: date de fin dans le futur
|
|
|
$functionType5 = $this->getMockBuilder(FunctionType::class)->getMock();
|
|
|
$functionType5->method('getMission')->willReturn('Mission5');
|
|
|
|
|
|
$function5 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
|
|
|
$function5->method('getEndDate')->willReturn(new \DateTime('2023-06-01'));
|
|
|
+ $function5->method('getStartDate')->willReturn(null);
|
|
|
$function5->method('getFunctionType')->willReturn($functionType5);
|
|
|
|
|
|
+ // Invalide: date de début dans le futur
|
|
|
+ $functionType6 = $this->getMockBuilder(FunctionType::class)->getMock();
|
|
|
+ $functionType6->method('getMission')->willReturn('Mission6');
|
|
|
+
|
|
|
+ $function6 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
|
|
|
+ $function6->method('getEndDate')->willReturn(null);
|
|
|
+ $function6->method('getStartDate')->willReturn(new \DateTime('2023-06-01'));
|
|
|
+ $function6->method('getFunctionType')->willReturn($functionType6);
|
|
|
+
|
|
|
+ // Valide: date de début dans le passé
|
|
|
+ $functionType7 = $this->getMockBuilder(FunctionType::class)->getMock();
|
|
|
+ $functionType7->method('getMission')->willReturn('Mission7');
|
|
|
+
|
|
|
+ $function7 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
|
|
|
+ $function7->method('getEndDate')->willReturn(null);
|
|
|
+ $function7->method('getStartDate')->willReturn(new \DateTime('2022-06-01'));
|
|
|
+ $function7->method('getFunctionType')->willReturn($functionType7);
|
|
|
+
|
|
|
+ // Valide: date de début dans le passé et date de fin dans le futur
|
|
|
+ $functionType8 = $this->getMockBuilder(FunctionType::class)->getMock();
|
|
|
+ $functionType8->method('getMission')->willReturn('Mission8');
|
|
|
+
|
|
|
+ $function8 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
|
|
|
+ $function8->method('getEndDate')->willReturn(new \DateTime('2023-06-01'));
|
|
|
+ $function8->method('getStartDate')->willReturn(new \DateTime('2022-06-01'));
|
|
|
+ $function8->method('getFunctionType')->willReturn($functionType8);
|
|
|
+
|
|
|
$access->method('getOrganizationFunction')->willReturn(
|
|
|
- new ArrayCollection([$function1, $function2, $function3, $function4, $function5])
|
|
|
+ new ArrayCollection([$function1, $function2, $function3, $function4, $function5, $function6, $function7, $function8])
|
|
|
);
|
|
|
|
|
|
$this->assertEquals(
|
|
|
- ['Mission1', 'Mission2', 'Mission4', 'Mission5'],
|
|
|
+ ['Mission1', 'Mission2', 'Mission4', 'Mission5', 'Mission7', 'Mission8'],
|
|
|
$accessUtils->getActiveFunctions($access)
|
|
|
);
|
|
|
}
|