Skip to content

Commit 078c986

Browse files
committed
Améliore la description de l'export CIFS
1 parent 743bb7a commit 078c986

File tree

6 files changed

+44
-43
lines changed

6 files changed

+44
-43
lines changed

src/Application/Regulation/Query/GetCifsIncidentsQueryHandler.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
use App\Domain\Regulation\Measure;
1919
use App\Domain\Regulation\RegulationOrderRecord;
2020
use App\Domain\Regulation\Repository\RegulationOrderRecordRepositoryInterface;
21+
use Symfony\Contracts\Translation\TranslatorInterface;
2122

2223
final class GetCifsIncidentsQueryHandler
2324
{
2425
public function __construct(
2526
private RegulationOrderRecordRepositoryInterface $repository,
2627
private PolylineMakerInterface $polylineMaker,
2728
private DateUtilsInterface $dateUtils,
29+
private TranslatorInterface $translator,
2830
private CifsFilterSet $cifsFilterSet = new CifsFilterSet(),
2931
) {
3032
}
@@ -131,7 +133,6 @@ public function __invoke(GetCifsIncidentsQuery $query): array
131133
/** @var Location $location */
132134
foreach ($measure->getLocations() as $location) {
133135
$locationId = $location->getUuid();
134-
$street = $location->getCifsStreetLabel();
135136

136137
$geometry = $location->getGeometry();
137138
if ($geometry === null) {
@@ -171,7 +172,7 @@ public function __invoke(GetCifsIncidentsQuery $query): array
171172
creationTime: $incidentCreationTime,
172173
type: $measureType->getCifsKey(),
173174
subType: $this->getSubType($regulationSubject, $measureType),
174-
street: $street,
175+
description: $this->translator->trans('regulation.measure.type.' . $measureType->value),
175176
direction: $direction,
176177
polyline: $polyline,
177178
startTime: $incidentPeriod['start'],

src/Application/Regulation/View/CifsIncidentView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public function __construct(
1010
public string $id,
1111
public \DateTimeInterface $creationTime,
1212
public string $type,
13-
public string $street,
13+
public string $description,
1414
public string $direction,
1515
public string $polyline,
1616
public \DateTimeInterface $startTime,

templates/api/regulations/cifs.xml.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<incident id="{{ incident.id }}">
55
<creationtime>{{ incident.creationTime|date('Y-m-d\\TH:i:sP') }}</creationtime>
66
<type>{{ incident.type }}</type>
7-
<description>{{ 'api.cifs.incident.description'|trans({'%street%': incident.street}) }}</description>
7+
<description>{{ incident.description}}</description>
88
<street>{{ incident.street }}</street>
99
<direction>{{ incident.direction }}</direction>
1010
<polyline>{{ incident.polyline }}</polyline>

tests/Integration/Infrastructure/Controller/Api/cifs-incidents-expected-result.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<incident id="F/CIFS/2023:06548f85-d545-7b45-8000-8a23c45850b3:06548fe3-7bfb-73af-8000-f7f34af31312">
44
<creationtime>2023-09-06T00:00:00+00:00</creationtime>
55
<type>ROAD_CLOSED</type>
6-
<description>Rue Claude Monet : circulation interdite tous les jours pour tous les véhicules</description>
6+
<description>Circulation interdite</description>
77
<street>Rue Claude Monet</street>
88
<direction>BOTH_DIRECTIONS</direction>
99
<polyline>48.910599408 2.337514404 48.910695641 2.337678265 48.911459354 2.338854183 48.911521022 2.338947542 48.911545625 2.339005897 48.911549433 2.339044051 48.911546991 2.339090471 48.911532934 2.339150682 48.911316524 2.339535452</polyline>
@@ -21,7 +21,7 @@
2121
<incident id="F/CIFS/2023:06548f85-d545-7b45-8000-8a23c45850b3:0654b639-cd33-7507-8000-e2ea21673135">
2222
<creationtime>2023-09-06T00:00:00+00:00</creationtime>
2323
<type>ROAD_CLOSED</type>
24-
<description>Rue Claude Monet : circulation interdite tous les jours pour tous les véhicules</description>
24+
<description>Circulation interdite</description>
2525
<street>Rue Claude Monet</street>
2626
<direction>BOTH_DIRECTIONS</direction>
2727
<polyline>48.910599408 2.337514404 48.910695641 2.337678265 48.911459354 2.338854183 48.911521022 2.338947542 48.911545625 2.339005897 48.911549433 2.339044051 48.911546991 2.339090471 48.911532934 2.339150682 48.911316524 2.339535452</polyline>
@@ -39,7 +39,7 @@
3939
<incident id="F/CIFS/2023:06548f85-d545-7b45-8000-8a23c45850b3:0654b63a-838d-798b-8000-044b619f225d">
4040
<creationtime>2023-09-06T00:00:00+00:00</creationtime>
4141
<type>ROAD_CLOSED</type>
42-
<description>Rue Claude Monet : circulation interdite tous les jours pour tous les véhicules</description>
42+
<description>Circulation interdite</description>
4343
<street>Rue Claude Monet</street>
4444
<direction>BOTH_DIRECTIONS</direction>
4545
<polyline>48.910599408 2.337514404 48.910695641 2.337678265 48.911459354 2.338854183 48.911521022 2.338947542 48.911545625 2.339005897 48.911549433 2.339044051 48.911546991 2.339090471 48.911532934 2.339150682 48.911316524 2.339535452</polyline>
@@ -58,7 +58,7 @@
5858
<incident id="F/CIFS/2023:065f94ef-ea0a-7ab5-8000-bd5686102151:06548fe3-7bfb-73af-8000-f7f34af31312">
5959
<creationtime>2023-09-06T00:00:00+00:00</creationtime>
6060
<type>ROAD_CLOSED</type>
61-
<description>D14 : circulation interdite tous les jours pour tous les véhicules</description>
61+
<description>Circulation interdite</description>
6262
<street>D14</street>
6363
<direction>BOTH_DIRECTIONS</direction>
6464
<polyline>48.911986097 2.344241283 48.908845831 2.344182729</polyline>
@@ -76,7 +76,7 @@
7676
<incident id="F/CIFS/2023:065f94ef-ea0a-7ab5-8000-bd5686102151:0654b639-cd33-7507-8000-e2ea21673135">
7777
<creationtime>2023-09-06T00:00:00+00:00</creationtime>
7878
<type>ROAD_CLOSED</type>
79-
<description>D14 : circulation interdite tous les jours pour tous les véhicules</description>
79+
<description>Circulation interdite</description>
8080
<street>D14</street>
8181
<direction>BOTH_DIRECTIONS</direction>
8282
<polyline>48.911986097 2.344241283 48.908845831 2.344182729</polyline>
@@ -94,7 +94,7 @@
9494
<incident id="F/CIFS/2023:065f94ef-ea0a-7ab5-8000-bd5686102151:0654b63a-838d-798b-8000-044b619f225d">
9595
<creationtime>2023-09-06T00:00:00+00:00</creationtime>
9696
<type>ROAD_CLOSED</type>
97-
<description>D14 : circulation interdite tous les jours pour tous les véhicules</description>
97+
<description>Circulation interdite</description>
9898
<street>D14</street>
9999
<direction>BOTH_DIRECTIONS</direction>
100100
<polyline>48.911986097 2.344241283 48.908845831 2.344182729</polyline>
@@ -113,7 +113,7 @@
113113
<incident id="117374#24-A-0473:066e984f-4746-78f8-8000-dce555b28604:0671628e-04f8-7c89-8000-43928d1376ba">
114114
<creationtime>2024-09-05T00:00:00+00:00</creationtime>
115115
<type>ROAD_CLOSED</type>
116-
<description>ROUTE 147 (NOYELLES-LÈS-SECLIN) DU PR7 +779 AU PR8 +413 : circulation interdite tous les jours pour tous les véhicules</description>
116+
<description>Circulation interdite</description>
117117
<street>ROUTE 147 (NOYELLES-LÈS-SECLIN) DU PR7 +779 AU PR8 +413</street>
118118
<direction>BOTH_DIRECTIONS</direction>
119119
<polyline>50.568969715 3.022717354 50.56945561 3.023119183 50.569455721 3.023119275 50.569492048 3.023149663 50.569832708 3.02343789 50.569835923 3.023440948 50.569868822 3.023475742 50.570148629 3.02384667 50.570151247 3.023850386 50.570177599 3.023890325 50.570503315 3.024458944 50.570527945 3.024500711 50.570528488 3.024501619 50.570901355 3.025116052 50.570929555 3.02515503 50.570932711 3.025159053 50.571355649 3.025653937 50.57138952 3.02569009 50.571390856 3.025691455 50.571842058 3.026131049 50.571877523 3.026159516 50.571879188 3.02616073 50.57338937 3.027150974</polyline>

tests/Unit/Application/Regulation/Query/GetCifsIncidentsQueryHandlerTest.php

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@
2323
use App\Domain\Regulation\RegulationOrderRecord;
2424
use App\Domain\Regulation\Repository\RegulationOrderRecordRepositoryInterface;
2525
use PHPUnit\Framework\TestCase;
26+
use Symfony\Contracts\Translation\TranslatorInterface;
2627

2728
final class GetCifsIncidentsQueryHandlerTest extends TestCase
2829
{
2930
private $regulationOrderRecordRepository;
3031
private $polylineMaker;
3132
private $dateUtils;
33+
private $translator;
3234

3335
protected function setUp(): void
3436
{
3537
$this->regulationOrderRecordRepository = $this->createMock(RegulationOrderRecordRepositoryInterface::class);
3638
$this->polylineMaker = $this->createMock(PolylineMakerInterface::class);
3739
$this->dateUtils = $this->createMock(DateUtilsInterface::class);
40+
$this->translator = $this->createMock(TranslatorInterface::class);
3841
}
3942

4043
public function testGetAllEmpty(): void
@@ -44,7 +47,7 @@ public function testGetAllEmpty(): void
4447
->method('findRegulationOrdersForCifsIncidentFormat')
4548
->willReturn([]);
4649

47-
$handler = new GetCifsIncidentsQueryHandler($this->regulationOrderRecordRepository, $this->polylineMaker, $this->dateUtils);
50+
$handler = new GetCifsIncidentsQueryHandler($this->regulationOrderRecordRepository, $this->polylineMaker, $this->dateUtils, $this->translator);
4851
$regulationOrders = $handler(new GetCifsIncidentsQuery());
4952

5053
$this->assertEquals([], $regulationOrders);
@@ -90,38 +93,40 @@ public function testGetAll(): void
9093
$period4Id = '0661e7ed-e549-7e4b-8000-945882a092c4';
9194
$period5Id = '066e2bff-d436-7f16-8000-57d9f6b99960';
9295

96+
$descriptionNoEntry = 'Interdiction d\'accès';
97+
$descriptionAlternateRoad = 'Route à alternance';
98+
9399
$incident1 = new CifsIncidentView(
94100
id: '2024T1:02d5eb61-9ca3-4e67-aacd-726f124382d0:0',
95101
creationTime: new \DateTimeImmutable('2023-11-01T00:00:00+00:00'),
96102
type: 'ROAD_CLOSED',
97-
subType: 'ROAD_BLOCKED_HAZARD',
98-
street: 'Rue des Arts',
103+
description: $descriptionNoEntry,
99104
direction: 'BOTH_DIRECTIONS',
100105
polyline: $polyline1Merged,
101106
startTime: new \DateTimeImmutable('2023-11-02T00:00:00+00:00'),
102107
endTime: new \DateTimeImmutable('2023-11-07T00:00:00+00:00'),
103108
schedule: [],
109+
subType: 'ROAD_BLOCKED_HAZARD',
104110
);
105111

106112
$incident1bis = new CifsIncidentView(
107113
id: '2024T1:066e98a9-0ce0-7e4b-8000-677c1eafc53d:0',
108114
creationTime: $incident1->creationTime,
109115
type: $incident1->type,
110-
subType: $incident1->subType,
111-
street: 'Zone Olympique',
116+
description: $descriptionNoEntry,
112117
direction: $incident1->direction,
113118
polyline: $polyline1bis,
114119
startTime: $incident1->startTime,
115120
endTime: new \DateTimeImmutable('2023-11-07T00:00:00+00:00'),
116121
schedule: $incident1->schedule,
122+
subType: $incident1->subType,
117123
);
118124

119125
$incident3 = new CifsIncidentView(
120126
id: \sprintf('2024T2:9698b212-705c-4c46-8968-63b5a55a4d66:%s', $period1Id),
121127
creationTime: new \DateTimeImmutable('2023-11-01T00:00:00+00:00'),
122128
type: 'HAZARD',
123-
subType: 'HAZARD_ON_ROAD_LANE_CLOSED',
124-
street: 'Avenue de Fonneuve',
129+
description: $descriptionAlternateRoad,
125130
direction: 'BOTH_DIRECTIONS',
126131
polyline: $polyline3,
127132
startTime: new \DateTimeImmutable('2023-11-02T00:00:00+00:00'),
@@ -148,14 +153,14 @@ public function testGetAll(): void
148153
],
149154
],
150155
],
156+
subType: 'HAZARD_ON_ROAD_LANE_CLOSED',
151157
);
152158

153159
$incident4 = new CifsIncidentView(
154160
id: \sprintf('2024T2:9698b212-705c-4c46-8968-63b5a55a4d66:%s', $period2Id),
155161
creationTime: $incident3->creationTime,
156162
type: $incident3->type,
157-
subType: $incident3->subType,
158-
street: $incident3->street,
163+
description: $incident3->description,
159164
direction: $incident3->direction,
160165
polyline: $incident3->polyline,
161166
startTime: new \DateTimeImmutable('2023-11-03T00:00:00+00:00'),
@@ -174,14 +179,14 @@ public function testGetAll(): void
174179
],
175180
],
176181
],
182+
subType: $incident3->subType,
177183
);
178184

179185
$incident5 = new CifsIncidentView(
180186
id: \sprintf('2024T2:9698b212-705c-4c46-8968-63b5a55a4d66:%s', $period3Id),
181187
creationTime: $incident3->creationTime,
182188
type: $incident3->type,
183-
subType: $incident3->subType,
184-
street: $incident3->street,
189+
description: $incident3->description,
185190
direction: $incident3->direction,
186191
polyline: $incident3->polyline,
187192
startTime: $incident4->startTime,
@@ -194,14 +199,14 @@ public function testGetAll(): void
194199
],
195200
],
196201
],
202+
subType: $incident3->subType,
197203
);
198204

199205
$incident6 = new CifsIncidentView(
200206
id: \sprintf('2024T2:9698b212-705c-4c46-8968-63b5a55a4d66:%s', $period4Id),
201207
creationTime: $incident3->creationTime,
202208
type: $incident3->type,
203-
subType: $incident3->subType,
204-
street: $incident3->street,
209+
description: $incident3->description,
205210
direction: $incident3->direction,
206211
polyline: $incident3->polyline,
207212
startTime: $incident4->startTime,
@@ -214,14 +219,14 @@ public function testGetAll(): void
214219
],
215220
],
216221
],
222+
subType: $incident3->subType,
217223
);
218224

219225
$incident7 = new CifsIncidentView(
220226
id: \sprintf('2024T2:9698b212-705c-4c46-8968-63b5a55a4d66:%s', $period5Id),
221227
creationTime: $incident3->creationTime,
222228
type: $incident3->type,
223-
subType: $incident3->subType,
224-
street: $incident3->street,
229+
description: $incident3->description,
225230
direction: $incident3->direction,
226231
polyline: $incident3->polyline,
227232
startTime: $incident4->startTime,
@@ -234,6 +239,7 @@ public function testGetAll(): void
234239
],
235240
],
236241
],
242+
subType: $incident3->subType,
237243
);
238244

239245
$regulationOrderRecord1 = $this->createMock(RegulationOrderRecord::class);
@@ -276,15 +282,20 @@ public function testGetAll(): void
276282
->with(new \DateTimeImmutable('2023-11-06 00:00:00'), 1)
277283
->willReturn(new \DateTimeImmutable('2023-11-07 00:00:00'));
278284

285+
$this->translator
286+
->expects(self::exactly(7))
287+
->method('trans')
288+
->with(self::logicalOr(
289+
self::equalTo('regulation.measure.type.noEntry'),
290+
self::equalTo('regulation.measure.type.alternateRoad'),
291+
))
292+
->willReturnCallback(fn (string $id) => $id === 'regulation.measure.type.noEntry' ? $descriptionNoEntry : $descriptionAlternateRoad);
293+
279294
$location1 = $this->createMock(Location::class);
280295
$location1
281296
->expects(self::once())
282297
->method('getUuid')
283298
->willReturn('02d5eb61-9ca3-4e67-aacd-726f124382d0');
284-
$location1
285-
->expects(self::once())
286-
->method('getCifsStreetLabel')
287-
->willReturn('Rue des Arts');
288299
$location1
289300
->expects(self::once())
290301
->method('getGeometry')
@@ -300,10 +311,6 @@ public function testGetAll(): void
300311
->expects(self::once())
301312
->method('getRawGeoJSON')
302313
->willReturn($rawGeoJSON);
303-
$location1bis
304-
->expects(self::once())
305-
->method('getCifsStreetLabel')
306-
->willReturn('Zone Olympique');
307314
$location1bis
308315
->expects(self::once())
309316
->method('getGeometry')
@@ -572,10 +579,6 @@ public function testGetAll(): void
572579
->expects(self::once())
573580
->method('getUuid')
574581
->willReturn('9698b212-705c-4c46-8968-63b5a55a4d66');
575-
$location2
576-
->expects(self::once())
577-
->method('getCifsStreetLabel')
578-
->willReturn('Avenue de Fonneuve');
579582
$location2
580583
->expects(self::once())
581584
->method('getGeometry')
@@ -621,7 +624,7 @@ public function testGetAll(): void
621624
$uuid2 => ['uuid' => $uuid2, 'overallStartDate' => $startDate2, 'overallEndDate' => $endDate2],
622625
]);
623626

624-
$handler = new GetCifsIncidentsQueryHandler($this->regulationOrderRecordRepository, $this->polylineMaker, $this->dateUtils);
627+
$handler = new GetCifsIncidentsQueryHandler($this->regulationOrderRecordRepository, $this->polylineMaker, $this->dateUtils, $this->translator);
625628
$incidents = $handler(new GetCifsIncidentsQuery());
626629
$this->assertEquals(
627630
[$incident1, $incident1bis, $incident3, $incident4, $incident5, $incident6, $incident7],
@@ -641,6 +644,7 @@ public function testFilters(): void
641644
$this->regulationOrderRecordRepository,
642645
$this->polylineMaker,
643646
$this->dateUtils,
647+
$this->translator,
644648
new CifsFilterSet(
645649
allowedSources: ['my_source'],
646650
excludedIdentifiers: ['identifier1'],

translations/messages.fr.xlf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,10 +2318,6 @@
23182318
<source>register.meta.subtitle</source>
23192319
<target>Vous pouvez créer votre compte pour votre commune ou collectivité.</target>
23202320
</trans-unit>
2321-
<trans-unit id="api.cifs.incident.description">
2322-
<source>api.cifs.incident.description</source>
2323-
<target>%street% : circulation interdite tous les jours pour tous les véhicules</target>
2324-
</trans-unit>
23252321
<trans-unit id="map.meta.title">
23262322
<source>map.meta.title</source>
23272323
<target>Carte</target>

0 commit comments

Comments
 (0)