Merge branch '111_exports_suite' into 641_issues_with_children

This commit is contained in:
2022-10-17 18:16:30 +02:00
99 changed files with 3043 additions and 512 deletions

View File

@@ -29,6 +29,38 @@ use function count;
*/
final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
{
public function testChangeStepKeepHistory()
{
$period = new AccompanyingPeriod();
$this->assertCount(0, $period->getStepHistories(), 'at initialization, period should not have any step history');
$period->setStep(AccompanyingPeriod::STEP_DRAFT);
$this->assertCount(0, $period->getStepHistories(), 're applying a draft should not create a history');
$period->setStep(AccompanyingPeriod::STEP_CONFIRMED);
$this->assertCount(1, $period->getStepHistories());
$this->assertEquals(AccompanyingPeriod::STEP_CONFIRMED, $period->getStepHistories()->first()->getStep());
$period->setOpeningDate($aMonthAgo = new DateTime('1 month ago'));
$this->assertCount(1, $period->getStepHistories());
$this->assertEquals($aMonthAgo, $period->getStepHistories()->first()->getStartDate(), 'when changing the opening date, the start date of the first history should change');
$period->setOpeningDate($tenDaysAgo = new DateTime('10 days ago'));
$this->assertCount(1, $period->getStepHistories());
$this->assertEquals($tenDaysAgo, $period->getStepHistories()->first()->getStartDate(), 'when changing the opening date, the start date of the first history should change');
$period->setStep(AccompanyingPeriod::STEP_CLOSED);
$this->assertCount(2, $period->getStepHistories());
$period->setOpeningDate($tomorrow = new DateTime('tomorrow'));
$this->assertEquals($tenDaysAgo, $period->getStepHistories()->first()->getStartDate(), 'when changing the opening date to a later one and no history after, start date should change');
}
public function testClosingEqualOpening()
{
$datetime = new DateTime('now');