mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-06 14:54:57 +00:00
Merge remote-tracking branch 'origin/master' into rector/rules-up-to-php80
Conflicts: src/Bundle/ChillActivityBundle/Controller/ActivityController.php src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php src/Bundle/ChillEventBundle/Search/EventSearch.php src/Bundle/ChillMainBundle/Controller/ExportController.php src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php src/Bundle/ChillMainBundle/Cron/CronManager.php src/Bundle/ChillMainBundle/Entity/CronJobExecution.php src/Bundle/ChillMainBundle/Export/ExportManager.php src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php src/Bundle/ChillMainBundle/Repository/NotificationRepository.php src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace AccompanyingPeriod\Lifecycle;
|
||||
|
||||
use Chill\MainBundle\Entity\CronJobExecution;
|
||||
use Chill\PersonBundle\AccompanyingPeriod\Lifecycle\AccompanyingPeriodStepChangeCronjob;
|
||||
use Chill\PersonBundle\AccompanyingPeriod\Lifecycle\AccompanyingPeriodStepChangeRequestor;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Component\Clock\MockClock;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class AccompanyingPeriodStepChangeCronjobTest extends TestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
/**
|
||||
* @dataProvider provideRunTimes
|
||||
*/
|
||||
public function testCanRun(string $datetime, \DateTimeImmutable $lastExecutionStart, bool $canRun): void
|
||||
{
|
||||
$requestor = $this->prophesize(AccompanyingPeriodStepChangeRequestor::class);
|
||||
$clock = new MockClock($datetime);
|
||||
|
||||
$cronJob = new AccompanyingPeriodStepChangeCronjob($clock, $requestor->reveal());
|
||||
$cronJobExecution = (new CronJobExecution($cronJob->getKey()))->setLastStart($lastExecutionStart);
|
||||
|
||||
$this->assertEquals($canRun, $cronJob->canRun($cronJobExecution));
|
||||
}
|
||||
|
||||
public function provideRunTimes(): iterable
|
||||
{
|
||||
// can run, during the night
|
||||
yield ['2023-01-15T01:00:00+02:00', new \DateTimeImmutable('2023-01-14T00:00:00+02:00'), true];
|
||||
|
||||
// can not run, not during the night
|
||||
yield ['2023-01-15T10:00:00+02:00', new \DateTimeImmutable('2023-01-14T00:00:00+02:00'), false];
|
||||
|
||||
// can not run: not enough elapsed time
|
||||
yield ['2023-01-15T01:00:00+02:00', new \DateTimeImmutable('2023-01-15T00:30:00+02:00'), false];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user