Files
chill-bundles/src/Bundle/ChillMainBundle/Tests/Services/RollingDate/RollingDateTest.php

46 lines
1.4 KiB
PHP

<?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());
}
}