Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SISH - Visite] Message notification #2111

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ public static function buildDescriptionVisiteCreated(Intervention $intervention)
{
$labelVisite = strtolower($intervention->getType()->label());
$partnerName = $intervention->getPartner() ? $intervention->getPartner()->getNom() : 'Non renseigné';
$today = new \DateTimeImmutable();
$isInPast = $today > $intervention->getScheduledAt()
&& Intervention::STATUS_DONE === $intervention->getStatus();

return sprintf(
'%s programmée : une %s du logement situé %s est prévue le %s.<br>La %s sera effectuée par %s.',
'%s %s : une %s du logement situé %s %s le %s.<br>La %s %s par %s.',
ucfirst($labelVisite),
$isInPast ? 'réalisée' : 'programmée',
$labelVisite,
$intervention->getSignalement()->getAdresseOccupant(),
$isInPast ? 'a été effectuée' : 'est prévue',
$intervention->getScheduledAt()->format('d/m/Y'),
$labelVisite,
$isInPast ? 'a été réalisée' : 'sera effectuée',
$partnerName
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public function testArreteDescriptionOnInterventionCreated(): void
->setDetails('Test description')
->setType(InterventionType::ARRETE_PREFECTORAL);

$this->assertEquals('Test description',
$this->assertEquals(
'Test description',
InterventionDescriptionGenerator::generate(
$intervention,
InterventionCreatedEvent::NAME
Expand All @@ -69,19 +70,31 @@ public function testVisiteDescriptionOnUnknownEvent()

public function provideVisiteIntervention(): \Generator
{
yield 'Visite de contrôle' => [
yield 'Visite de contrôle dans le passé' => [
$this->getIntervention(
InterventionType::VISITE_CONTROLE,
new \DateTimeImmutable('2023-09-01'),
Intervention::STATUS_PLANNED
Intervention::STATUS_DONE
),
'Visite de contrôle programmée :',
'Visite de contrôle réalisée :',
'25 rue du test',
'01/09/2023',
'ARS',
];

yield 'Visite' => [
yield 'Visite dans le passé' => [
$this->getIntervention(
InterventionType::VISITE,
new \DateTimeImmutable('2023-10-01'),
Intervention::STATUS_DONE
),
'Visite réalisée',
'25 rue du test',
'01/10/2023',
'ARS',
];

yield 'Visite dans le passé mais au status planned' => [
$this->getIntervention(
InterventionType::VISITE,
new \DateTimeImmutable('2023-10-01'),
Expand All @@ -92,5 +105,30 @@ public function provideVisiteIntervention(): \Generator
'01/10/2023',
'ARS',
];

$dateInFutur = (new \DateTimeImmutable())->add(new \DateInterval('P10D'));
yield 'Visite de contrôle dans le futur' => [
$this->getIntervention(
InterventionType::VISITE_CONTROLE,
$dateInFutur,
Intervention::STATUS_PLANNED
),
'Visite de contrôle programmée :',
'25 rue du test',
$dateInFutur->format('d/m/Y'),
'ARS',
];

yield 'Visite dans le futur' => [
$this->getIntervention(
InterventionType::VISITE,
$dateInFutur,
Intervention::STATUS_PLANNED
),
'Visite programmée',
'25 rue du test',
$dateInFutur->format('d/m/Y'),
'ARS',
];
}
}
Loading