Add capability to store closing motive when closing accompanying period

The commit introduces new functionality in the bundle that allows storing the closing motive when a course is closed. This is achieved by modifying the model and database schema to include a new `closingMotive` field in AccompanyingPeriodStepHistory entity.
This commit is contained in:
2024-01-23 21:56:17 +01:00
parent 0c9010f065
commit f8840d89bf
5 changed files with 108 additions and 4 deletions

View File

@@ -312,4 +312,34 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
$this->assertNull($period->getRequestorPerson());
$this->assertNull($period->getRequestor());
}
public function testSetStep(): void
{
$period = new AccompanyingPeriod();
$period->setStep(AccompanyingPeriod::STEP_CONFIRMED);
self::assertEquals(AccompanyingPeriod::STEP_CONFIRMED, $period->getStep());
self::assertCount(1, $period->getStepHistories());
$period->setStep(AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT);
self::assertEquals(AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT, $period->getStep());
self::assertCount(2, $period->getStepHistories());
$periodInactiveSteps = $period->getStepHistories()->filter(fn (AccompanyingPeriod\AccompanyingPeriodStepHistory $h) => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT === $h->getStep());
self::assertCount(1, $periodInactiveSteps);
$period->setStep(AccompanyingPeriod::STEP_CLOSED, ['closing_motive' => $closingMotive = new AccompanyingPeriod\ClosingMotive()]);
self::assertEquals(AccompanyingPeriod::STEP_CLOSED, $period->getStep());
self::assertCount(3, $period->getStepHistories());
$periodClosedSteps = $period->getStepHistories()->filter(fn (AccompanyingPeriod\AccompanyingPeriodStepHistory $h) => AccompanyingPeriod::STEP_CLOSED === $h->getStep());
self::assertCount(1, $periodClosedSteps);
$periodClosedStep = $periodClosedSteps->first();
self::assertSame($closingMotive, $periodClosedStep->getClosingMotive());
}
}