mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-03 21:34:59 +00:00
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:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user