|
@@ -3,6 +3,7 @@ namespace App\Tests\Service\Utils;
|
|
|
|
|
|
|
|
use App\Entity\Access\Access;
|
|
use App\Entity\Access\Access;
|
|
|
use App\Entity\Organization\Organization;
|
|
use App\Entity\Organization\Organization;
|
|
|
|
|
+use App\Entity\Organization\Parameters;
|
|
|
use App\Service\Utils\DateTimeConstraint;
|
|
use App\Service\Utils\DateTimeConstraint;
|
|
|
use App\Tests\TestToolsTrait;
|
|
use App\Tests\TestToolsTrait;
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
@@ -169,10 +170,17 @@ class DateTimeConstraintTest extends TestCase
|
|
|
$today = new \DateTime('now');
|
|
$today = new \DateTime('now');
|
|
|
|
|
|
|
|
$organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
|
|
$organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
|
|
|
|
|
+ $parameters = new Parameters();
|
|
|
|
|
+ $parameters->setMusicalDate(new \DateTime('2000-09-01'));
|
|
|
|
|
+ $organization->method('getParameters')->willReturn($parameters);
|
|
|
|
|
|
|
|
$access = $this->getMockBuilder(Access::class)->disableOriginalConstructor()->getMock();
|
|
$access = $this->getMockBuilder(Access::class)->disableOriginalConstructor()->getMock();
|
|
|
$access->method('getOrganization')->willReturn($organization);
|
|
$access->method('getOrganization')->willReturn($organization);
|
|
|
- $access->method('getActivityYear')->willReturn(intval($today->format('Y')));
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $activityYear = $today->format('Y');
|
|
|
|
|
+ if($today->format('m') < 9) $activityYear--;
|
|
|
|
|
+
|
|
|
|
|
+ $access->method('getActivityYear')->willReturn(intval($activityYear));
|
|
|
|
|
|
|
|
$periodExpected = ['dateStart' => $today->format('Y-m-d'), 'dateEnd' => '2022-08-31'];
|
|
$periodExpected = ['dateStart' => $today->format('Y-m-d'), 'dateEnd' => '2022-08-31'];
|
|
|
$this->assertEquals($periodExpected, $this->invokeMethod($this->dateTimeConstraint, 'getPeriods', [$access]));
|
|
$this->assertEquals($periodExpected, $this->invokeMethod($this->dateTimeConstraint, 'getPeriods', [$access]));
|