mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-08 14:29:42 +00:00
Partage d'export enregistré et génération asynchrone des exports
This commit is contained in:
@@ -14,6 +14,7 @@ namespace Services\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Clock\MockClock;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@@ -22,11 +23,9 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
final class RollingDateConverterTest extends TestCase
|
||||
{
|
||||
private RollingDateConverter $converter;
|
||||
|
||||
protected function setUp(): void
|
||||
private function buildConverter(\DateTimeImmutable|string $pivot = 'now'): RollingDateConverter
|
||||
{
|
||||
$this->converter = new RollingDateConverter();
|
||||
return new RollingDateConverter(new MockClock($pivot));
|
||||
}
|
||||
|
||||
public function testConversionFixedDate()
|
||||
@@ -35,7 +34,7 @@ final class RollingDateConverterTest extends TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
'2022-01-01',
|
||||
$this->converter->convert($rollingDate)->format('Y-m-d')
|
||||
$this->buildConverter()->convert($rollingDate)->format('Y-m-d')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -43,7 +42,7 @@ final class RollingDateConverterTest extends TestCase
|
||||
{
|
||||
$rollingDate = new RollingDate(RollingDate::T_YEAR_PREVIOUS_START);
|
||||
|
||||
$actual = $this->converter->convert($rollingDate);
|
||||
$actual = $this->buildConverter()->convert($rollingDate);
|
||||
|
||||
$this->assertEquals(
|
||||
(int) (new \DateTimeImmutable('now'))->format('Y') - 1,
|
||||
@@ -63,7 +62,21 @@ final class RollingDateConverterTest extends TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
\DateTime::createFromFormat($format, $expectedDateTime),
|
||||
$this->converter->convert($rollingDate)
|
||||
$this->buildConverter()->convert($rollingDate)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateDataConversionDate
|
||||
*/
|
||||
public function testConvertOnClock(string $roll, string $expectedDateTime, string $format)
|
||||
{
|
||||
$pivot = \DateTimeImmutable::createFromFormat('Y-m-d His', '2022-11-07 000000');
|
||||
$rollingDate = new RollingDate($roll, null);
|
||||
|
||||
$this->assertEquals(
|
||||
\DateTime::createFromFormat($format, $expectedDateTime),
|
||||
$this->buildConverter($pivot)->convert($rollingDate)
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,45 @@
|
||||
<?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 Chill\MainBundle\Tests\Services\RollingDate;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class RollingDateTest extends TestCase
|
||||
{
|
||||
public function testNormalizationDenormalizationProcessWithoutPivotDate(): void
|
||||
{
|
||||
$date = new RollingDate(RollingDate::T_YEAR_PREVIOUS_START);
|
||||
|
||||
$actual = RollingDate::fromNormalized($date->normalize());
|
||||
|
||||
self::assertEquals(RollingDate::T_YEAR_PREVIOUS_START, $actual->getRoll());
|
||||
self::assertNull($actual->getFixedDate());
|
||||
self::assertEquals($date->getPivotDate()?->getTimestamp(), $actual->getPivotDate()?->getTimestamp());
|
||||
}
|
||||
|
||||
public function testNormalizationDenormalizationProcessWithPivotDate(): void
|
||||
{
|
||||
$date = new RollingDate(RollingDate::T_FIXED_DATE, $fixed = new \DateTimeImmutable('now'));
|
||||
|
||||
$actual = RollingDate::fromNormalized($date->normalize());
|
||||
|
||||
self::assertEquals(RollingDate::T_FIXED_DATE, $actual->getRoll());
|
||||
self::assertEquals($fixed, $actual->getFixedDate());
|
||||
self::assertEquals($date->getPivotDate()?->getTimestamp(), $actual->getPivotDate()?->getTimestamp());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user