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

Corrige la duplication d'un arreté #1025

Merged
merged 1 commit into from
Oct 23, 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 @@ -55,8 +55,8 @@ private function duplicateRegulationOrderRecord(
$generalInfo->description = $originalRegulationOrder->getDescription();
$generalInfo->startDate = $originalRegulationOrder->getStartDate();
$generalInfo->endDate = $originalRegulationOrder->getEndDate();
$generalInfo->additionalVisas = $originalRegulationOrder->getAdditionalVisas();
$generalInfo->additionalReasons = $originalRegulationOrder->getAdditionalReasons();
$generalInfo->additionalVisas = $originalRegulationOrder->getAdditionalVisas() ?? [];
Copy link
Collaborator

@florimondmanca florimondmanca Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ça corrige mais je me demandais si ça faisait sens de mettre ce ?? [] directement dans getAdditionalVisas() et getAdditionalReasons() ?

Car en réalité on ne veut jamais manipuler null sur ces arrays, c'est une source d'erreur, il faut un array quitte à ce qu'il soit vide

Or en l'état on devrait se rappeler d'utiliser ?? [] chaque fois qu'on appelle un de ces deux getters

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disons que nous l'avons déjà fait à différents endroits. Je ne suis absolument pas contre le fait de faire évoluer les getters devant retourner des tableaux.
Je pense faire une PR à part pour avoir une refacto plus large. Mais je partage ton avis !

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK !

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$generalInfo->additionalReasons = $originalRegulationOrder->getAdditionalReasons() ?? [];
$generalInfo->visaModelUuid = $originalRegulationOrder->getVisaModel()?->getUuid();

return $this->commandBus->handle($generalInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public function testRegulationFullyDuplicated(): void
$this->originalRegulationOrder
->expects(self::once())
->method('getAdditionalVisas')
->willReturn(['Vu 1']);
->willReturn(null);
$this->originalRegulationOrder
->expects(self::once())
->method('getVisaModel')
Expand Down Expand Up @@ -329,7 +329,7 @@ public function testRegulationFullyDuplicated(): void
$generalInfoCommand->startDate = $startDate;
$generalInfoCommand->endDate = $endDate;
$generalInfoCommand->organization = $originalOrganization;
$generalInfoCommand->additionalVisas = ['Vu 1'];
$generalInfoCommand->additionalVisas = [];
$generalInfoCommand->additionalReasons = ['Motif 1'];
$generalInfoCommand->visaModelUuid = 'P67f7f275-51b2-4f7f-914a-45168a28d4c2';

Expand Down
Loading