-
- {{ form_row(form.startDate, {group_class: 'fr-input-group', row_attr: {class: 'fr-col-12 fr-col-md-5'}, attr: {class: 'fr-input'}}) }}
- {{ form_row(form.startTime, {group_class: 'fr-input-group', row_attr: {class: 'fr-col fr-mb-3w fr-col-md-6 fr-mt-1w'} }) }}
-
- {% if not form.isPermanent.vars.value %}
+ {% if form.isPermanent.vars.value %}
+
+ {{ form_row(form.startDate, {group_class: 'fr-input-group', row_attr: {class: 'fr-col-12 fr-col-md-5 fr-mb-3w'}, attr: {class: 'fr-input'}}) }}
+
+ {% else %}
+ {{ form_row(form.startDate, {group_class: 'fr-input-group', row_attr: {class: 'fr-col-12 fr-col-md-5'}, attr: {class: 'fr-input'}}) }}
+ {{ form_row(form.startTime, {group_class: 'fr-input-group', row_attr: {class: 'fr-col fr-mb-3w fr-col-md-6 fr-mt-1w'} }) }}
{{ form_row(form.endDate, {group_class: 'fr-input-group', row_attr: {class: 'fr-col-12 fr-col-md-5 '}, attr: {class: 'fr-input'}}) }}
{{ form_row(form.endTime, {group_class: 'fr-input-group', row_attr: {class: 'fr-col fr-mb-3w fr-col-md-6 fr-mt-1w'} }) }}
@@ -253,6 +255,7 @@
{{ form_row(form[roadType].toAbscissa, { row_attr: {class:'fr-col-12 fr-col-md-4'}, attr: {class: 'fr-input'}}) }}
+ {{ form_row(form[roadType].direction, { group_class: 'fr-select-group', widget_class: 'fr-select' }) }}
{% endmacro %}
diff --git a/tests/Integration/Infrastructure/Controller/Regulation/AddRegulationControllerTest.php b/tests/Integration/Infrastructure/Controller/Regulation/AddRegulationControllerTest.php
index 803b2d865..118da7d65 100644
--- a/tests/Integration/Infrastructure/Controller/Regulation/AddRegulationControllerTest.php
+++ b/tests/Integration/Infrastructure/Controller/Regulation/AddRegulationControllerTest.php
@@ -38,7 +38,7 @@ public function testAdd(): void
/** @var UserRepositoryInterface */
$userRepository = static::getContainer()->get(UserRepositoryInterface::class);
- $this->assertNull($userRepository->findOneByEmail($email)->getLastActiveAt());
+ $this->assertEquals(new \DateTimeImmutable('2024-06-07'), $userRepository->findOneByEmail($email)->getLastActiveAt());
// Get the raw values.
$values = $form->getPhpValues();
@@ -56,6 +56,7 @@ public function testAdd(): void
$crawler = $client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles());
$this->assertResponseStatusCodeSame(303);
+ // Filled with DateUtilsMock::getNow()
$this->assertEquals(new \DateTimeImmutable('2023-06-09'), $userRepository->findOneByEmail($email)->getLastActiveAt());
$client->followRedirect();
diff --git a/tests/Integration/Infrastructure/Controller/Regulation/DuplicateRegulationControllerTest.php b/tests/Integration/Infrastructure/Controller/Regulation/DuplicateRegulationControllerTest.php
index 668957bf4..d769137d2 100644
--- a/tests/Integration/Infrastructure/Controller/Regulation/DuplicateRegulationControllerTest.php
+++ b/tests/Integration/Infrastructure/Controller/Regulation/DuplicateRegulationControllerTest.php
@@ -28,7 +28,7 @@ public function testDuplicate(): void
// Measure
$this->assertSame('Circulation interdite', $measures->eq(0)->filter('h3')->text());
$this->assertSame('pour tous les véhicules', $measures->eq(0)->filter('.app-card__content li')->eq(0)->text());
- $this->assertSame('à partir du 09/06/2023 à 10h00', $measures->eq(0)->filter('.app-card__content li')->eq(1)->text()); // Date comes from DateUtilsMock
+ $this->assertSame('à partir du 11/03/2023 à 00h00', $measures->eq(0)->filter('.app-card__content li')->eq(1)->text());
$this->assertSame('Rue du Simplon à Paris 18e Arrondissement (75018)', $measures->eq(0)->filter('.app-card__content li')->eq(3)->text());
}
diff --git a/tests/Integration/Infrastructure/Controller/Regulation/Fragments/AddMeasureControllerTest.php b/tests/Integration/Infrastructure/Controller/Regulation/Fragments/AddMeasureControllerTest.php
index 4496078eb..7bca86a79 100644
--- a/tests/Integration/Infrastructure/Controller/Regulation/Fragments/AddMeasureControllerTest.php
+++ b/tests/Integration/Infrastructure/Controller/Regulation/Fragments/AddMeasureControllerTest.php
@@ -140,8 +140,6 @@ public function testAdd(): void
$values['measure_form']['periods'][0]['isPermanent'] = '1';
$values['measure_form']['periods'][0]['recurrenceType'] = 'certainDays';
$values['measure_form']['periods'][0]['startDate'] = '2023-10-30';
- $values['measure_form']['periods'][0]['startTime']['hour'] = '8';
- $values['measure_form']['periods'][0]['startTime']['minute'] = '0';
$values['measure_form']['periods'][0]['dailyRange']['applicableDays'] = ['monday'];
$values['measure_form']['periods'][0]['timeSlots'][0]['startTime']['hour'] = '8';
$values['measure_form']['periods'][0]['timeSlots'][0]['startTime']['minute'] = '0';
@@ -196,8 +194,6 @@ public function testGeocodingFailureFullRoad(): void
$values['measure_form']['locations'][0]['namedStreet']['cityLabel'] = 'La Madeleine (59110)';
$values['measure_form']['locations'][0]['namedStreet']['roadName'] = 'Rue de NOT_HANDLED_BY_MOCK';
$values['measure_form']['periods'][0]['startDate'] = '2023-10-30';
- $values['measure_form']['periods'][0]['startTime']['hour'] = '8';
- $values['measure_form']['periods'][0]['startTime']['minute'] = '0';
$crawler = $client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles());
$this->assertResponseStatusCodeSame(422);
@@ -229,8 +225,6 @@ public function testAddLaneWithBlankHouseNumbers(): void
$values['measure_form']['locations'][0]['namedStreet']['toHouseNumber'] = '';
$values['measure_form']['locations'][0]['namedStreet']['direction'] = DirectionEnum::BOTH->value;
$values['measure_form']['periods'][0]['startDate'] = '2023-10-30';
- $values['measure_form']['periods'][0]['startTime']['hour'] = '0';
- $values['measure_form']['periods'][0]['startTime']['minute'] = '0';
$crawler = $client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles());
@@ -334,8 +328,6 @@ public function testAddLaneWithUnknownHouseNumbers(): void
$values['measure_form']['locations'][0]['namedStreet']['toHouseNumber'] = '999'; // Mock will return no result
$values['measure_form']['locations'][0]['namedStreet']['direction'] = DirectionEnum::BOTH->value;
$values['measure_form']['periods'][0]['startDate'] = '2023-10-30';
- $values['measure_form']['periods'][0]['startTime']['hour'] = '0';
- $values['measure_form']['periods'][0]['startTime']['minute'] = '0';
$crawler = $client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles());
@@ -366,8 +358,6 @@ public function testAddLaneWithHouseNumbersOnMultipleSections(): void
$values['measure_form']['locations'][0]['namedStreet']['toHouseNumber'] = '44'; // Not on same section than 80
$values['measure_form']['locations'][0]['namedStreet']['direction'] = DirectionEnum::BOTH->value;
$values['measure_form']['periods'][0]['startDate'] = '2023-10-30';
- $values['measure_form']['periods'][0]['startTime']['hour'] = '0';
- $values['measure_form']['periods'][0]['startTime']['minute'] = '0';
$crawler = $client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles());
@@ -432,8 +422,6 @@ public function testAddNumberedRoad(array $locationForm, string $expectedText):
$values['measure_form']['vehicleSet']['allVehicles'] = 'yes';
$values['measure_form']['locations'][0] = $locationForm;
$values['measure_form']['periods'][0]['startDate'] = '2023-10-30';
- $values['measure_form']['periods'][0]['startTime']['hour'] = '0';
- $values['measure_form']['periods'][0]['startTime']['minute'] = '0';
$crawler = $client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles());
@@ -470,8 +458,6 @@ public function testAddDepartmentalRoadWithUnknownPointNumbers(): void
$values['measure_form']['locations'][0]['departmentalRoad']['fromAbscissa'] = 100;
$values['measure_form']['locations'][0]['departmentalRoad']['toAbscissa'] = 650;
$values['measure_form']['periods'][0]['startDate'] = '2023-10-30';
- $values['measure_form']['periods'][0]['startTime']['hour'] = '0';
- $values['measure_form']['periods'][0]['startTime']['minute'] = '0';
$crawler = $client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles());
@@ -504,8 +490,6 @@ public function testAddDepartmentalRoadWithStartAbscissaOutOfRange(): void
$values['measure_form']['locations'][0]['departmentalRoad']['fromAbscissa'] = 100000000;
$values['measure_form']['locations'][0]['departmentalRoad']['toAbscissa'] = 650;
$values['measure_form']['periods'][0]['startDate'] = '2023-10-30';
- $values['measure_form']['periods'][0]['startTime']['hour'] = '0';
- $values['measure_form']['periods'][0]['startTime']['minute'] = '0';
$crawler = $client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles());
@@ -538,8 +522,6 @@ public function testAddDepartmentalRoadWithEndAbscissaOutOfRange(): void
$values['measure_form']['locations'][0]['departmentalRoad']['fromAbscissa'] = 100;
$values['measure_form']['locations'][0]['departmentalRoad']['toAbscissa'] = 100000000;
$values['measure_form']['periods'][0]['startDate'] = '2023-10-30';
- $values['measure_form']['periods'][0]['startTime']['hour'] = '0';
- $values['measure_form']['periods'][0]['startTime']['minute'] = '0';
$crawler = $client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles());
@@ -869,7 +851,6 @@ public function testPermanentInvalidBlankPeriod(): void
$crawler = $client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles());
$this->assertResponseStatusCodeSame(422);
- $this->assertSame('Cette valeur ne doit pas être vide.', $crawler->filter('#measure_form_periods_0_startTime_error')->text());
$this->assertSame('Cette valeur ne doit pas être vide.', $crawler->filter('#measure_form_periods_0_startDate_error')->text());
}
diff --git a/tests/Integration/Infrastructure/Symfony/Command/RunMetabaseExportCommandTest.php b/tests/Integration/Infrastructure/Symfony/Command/RunMetabaseExportCommandTest.php
new file mode 100644
index 000000000..8c3102161
--- /dev/null
+++ b/tests/Integration/Infrastructure/Symfony/Command/RunMetabaseExportCommandTest.php
@@ -0,0 +1,38 @@
+get(RunMetabaseExportCommand::class);
+ $commandTester = new CommandTester($command);
+ $commandTester->execute([]);
+ $commandTester->assertCommandIsSuccessful();
+
+ /** @var \Doctrine\DBAL\Connection */
+ $metabaseConnection = $container->get('doctrine.dbal.metabase_connection');
+ $rows = $metabaseConnection->fetchAllAssociative('SELECT * FROM analytics_user_active');
+ $this->assertCount(3, $rows);
+ $this->assertEquals(['id', 'uploaded_at', 'last_active_at'], array_keys($rows[0]));
+
+ $this->assertSame('2023-06-09 00:00:00', $rows[0]['uploaded_at']);
+ $this->assertSame('2024-06-07 00:00:00', $rows[0]['last_active_at'])
+ ;
+ $this->assertSame('2023-06-09 00:00:00', $rows[1]['uploaded_at']);
+ $this->assertSame('2024-06-08 00:00:00', $rows[1]['last_active_at']);
+
+ $this->assertSame('2023-06-09 00:00:00', $rows[2]['uploaded_at']);
+ $this->assertSame(null, $rows[2]['last_active_at']);
+ }
+}
diff --git a/tests/Unit/Application/Regulation/Command/DuplicateMeasureCommandHandlerTest.php b/tests/Unit/Application/Regulation/Command/DuplicateMeasureCommandHandlerTest.php
index 1092b155c..a49067b69 100644
--- a/tests/Unit/Application/Regulation/Command/DuplicateMeasureCommandHandlerTest.php
+++ b/tests/Unit/Application/Regulation/Command/DuplicateMeasureCommandHandlerTest.php
@@ -180,6 +180,10 @@ public function testMeasureFullyDuplicated(): void
->expects(self::once())
->method('getNumberedRoad')
->willReturn($numberedRoad1);
+ $numberedRoad1
+ ->expects(self::once())
+ ->method('getDirection')
+ ->willReturn(DirectionEnum::BOTH->value);
$numberedRoad1
->expects(self::once())
->method('getAdministrator')
@@ -263,6 +267,7 @@ public function testMeasureFullyDuplicated(): void
$locationCommand2->roadType = RoadTypeEnum::DEPARTMENTAL_ROAD->value;
$numberedRoad = new SaveNumberedRoadCommand();
$numberedRoad->roadType = RoadTypeEnum::DEPARTMENTAL_ROAD->value;
+ $numberedRoad->direction = DirectionEnum::BOTH->value;
$numberedRoad->administrator = 'Ardèche';
$numberedRoad->roadNumber = 'D110';
$numberedRoad->fromPointNumber = '1';
diff --git a/tests/Unit/Application/Regulation/Command/Location/SaveNumberedRoadCommandHandlerTest.php b/tests/Unit/Application/Regulation/Command/Location/SaveNumberedRoadCommandHandlerTest.php
index c90f868a4..96bbc13b4 100644
--- a/tests/Unit/Application/Regulation/Command/Location/SaveNumberedRoadCommandHandlerTest.php
+++ b/tests/Unit/Application/Regulation/Command/Location/SaveNumberedRoadCommandHandlerTest.php
@@ -9,6 +9,7 @@
use App\Application\Regulation\Command\Location\SaveNumberedRoadCommandHandler;
use App\Domain\Geography\Coordinates;
use App\Domain\Geography\GeoJSON;
+use App\Domain\Regulation\Enum\DirectionEnum;
use App\Domain\Regulation\Location\Location;
use App\Domain\Regulation\Location\NumberedRoad;
use App\Domain\Regulation\Repository\NumberedRoadRepositoryInterface;
@@ -26,6 +27,7 @@ final class SaveNumberedRoadCommandHandlerTest extends TestCase
private string $toPointNumber;
private string $toSide;
private int $toAbscissa;
+ private string $direction;
private MockObject $idFactory;
private MockObject $numberedRoadRepository;
@@ -43,6 +45,7 @@ public function setUp(): void
$this->toPointNumber = '5';
$this->toSide = 'U';
$this->toAbscissa = 100;
+ $this->direction = DirectionEnum::BOTH->value;
$this->geometry = GeoJSON::toLineString([
Coordinates::fromLonLat(-1.935836, 47.347024),
@@ -73,6 +76,7 @@ public function testCreate(): void
new NumberedRoad(
uuid: '7fb74c5d-069b-4027-b994-7545bb0942d0',
location: $location,
+ direction: $this->direction,
administrator: $this->administrator,
roadNumber: $this->roadNumber,
fromPointNumber: $this->fromPointNumber,
@@ -93,6 +97,7 @@ public function testCreate(): void
$command = new SaveNumberedRoadCommand();
$command->location = $location;
+ $command->direction = $this->direction;
$command->administrator = $this->administrator;
$command->roadNumber = $this->roadNumber;
$command->fromPointNumber = $this->fromPointNumber;
@@ -114,6 +119,7 @@ public function testUpdate(): void
->expects(self::once())
->method('update')
->with(
+ $this->direction,
$this->administrator,
$this->roadNumber,
$this->fromPointNumber,
@@ -138,6 +144,7 @@ public function testUpdate(): void
);
$command = new SaveNumberedRoadCommand($numberedRoad);
+ $command->direction = $this->direction;
$command->administrator = $this->administrator;
$command->roadNumber = $this->roadNumber;
$command->fromPointNumber = $this->fromPointNumber;
diff --git a/tests/Unit/Application/Regulation/Command/Period/SavePeriodCommandHandlerTest.php b/tests/Unit/Application/Regulation/Command/Period/SavePeriodCommandHandlerTest.php
index ef5f567d5..d3ee64238 100644
--- a/tests/Unit/Application/Regulation/Command/Period/SavePeriodCommandHandlerTest.php
+++ b/tests/Unit/Application/Regulation/Command/Period/SavePeriodCommandHandlerTest.php
@@ -129,18 +129,13 @@ public function testCreate(): void
$this->assertSame($createdPeriod, $result);
}
- public function testCreateWithoutEndDate(): void
+ public function testCreateWithoutStartTimeAndEndDate(): void
{
$startDateTime = new \DateTimeImmutable('2023-05-22');
- $startTime = new \DateTimeImmutable('2023-05-22 10:00:00');
-
- $mergedStartDateTime = new \DateTimeImmutable('2023-05-22 10:00:00');
$this->dateUtils
- ->expects(self::once())
- ->method('mergeDateAndTime')
- ->withConsecutive([$startDateTime, $startTime])
- ->willReturnOnConsecutiveCalls($mergedStartDateTime);
+ ->expects(self::never())
+ ->method('mergeDateAndTime');
$this->idFactory
->expects(self::once())
@@ -164,7 +159,7 @@ public function testCreateWithoutEndDate(): void
new Period(
uuid: '7fb74c5d-069b-4027-b994-7545bb0942d0',
measure: $measure,
- startDateTime: $mergedStartDateTime,
+ startDateTime: $startDateTime,
endDateTime: null,
recurrenceType: PeriodRecurrenceTypeEnum::CERTAIN_DAYS->value,
),
@@ -203,10 +198,11 @@ public function testCreateWithoutEndDate(): void
->willReturnOnConsecutiveCalls($createdTimeSlot, $createdDailyRange);
$command = new SavePeriodCommand();
+ $command->isPermanent = true;
$command->measure = $measure;
$command->startDate = $startDateTime;
$command->endDate = null;
- $command->startTime = $startTime;
+ $command->startTime = null;
$command->endTime = null;
$command->recurrenceType = PeriodRecurrenceTypeEnum::CERTAIN_DAYS->value;
$command->dailyRange = $dailyRangeCommand;
diff --git a/tests/Unit/Domain/Regulation/Location/NumberedRoadTest.php b/tests/Unit/Domain/Regulation/Location/NumberedRoadTest.php
index 641632aa9..bb4a223d7 100644
--- a/tests/Unit/Domain/Regulation/Location/NumberedRoadTest.php
+++ b/tests/Unit/Domain/Regulation/Location/NumberedRoadTest.php
@@ -4,6 +4,7 @@
namespace App\Tests\Unit\Domain\Regulation\Location;
+use App\Domain\Regulation\Enum\DirectionEnum;
use App\Domain\Regulation\Location\Location;
use App\Domain\Regulation\Location\NumberedRoad;
use PHPUnit\Framework\TestCase;
@@ -17,6 +18,7 @@ public function testGetters(): void
$numberedRoad = new NumberedRoad(
uuid: '8785a4c2-8f0d-423e-bd5b-641f228df23b',
location: $location,
+ direction: DirectionEnum::BOTH->value,
administrator: 'Ardèche',
roadNumber: 'D110',
fromPointNumber: '14',
@@ -29,6 +31,7 @@ public function testGetters(): void
$this->assertSame('8785a4c2-8f0d-423e-bd5b-641f228df23b', $numberedRoad->getUuid());
$this->assertSame($location, $numberedRoad->getLocation());
+ $this->assertSame(DirectionEnum::BOTH->value, $numberedRoad->getDirection());
$this->assertSame('Ardèche', $numberedRoad->getAdministrator());
$this->assertSame('D110', $numberedRoad->getRoadNumber());
$this->assertSame('14', $numberedRoad->getFromPointNumber());
@@ -39,6 +42,7 @@ public function testGetters(): void
$this->assertSame('U', $numberedRoad->getToSide());
$numberedRoad->update(
+ DirectionEnum::B_TO_A->value,
'Ain',
'D16',
'10',
@@ -49,6 +53,7 @@ public function testGetters(): void
0,
);
+ $this->assertSame(DirectionEnum::B_TO_A->value, $numberedRoad->getDirection());
$this->assertSame('Ain', $numberedRoad->getAdministrator());
$this->assertSame('D16', $numberedRoad->getRoadNumber());
$this->assertSame('10', $numberedRoad->getFromPointNumber());
diff --git a/tests/Unit/Infrastructure/Adapter/RoadSectionMakerTest.php b/tests/Unit/Infrastructure/Adapter/RoadSectionMakerTest.php
index ac61346d9..9e2562dd4 100644
--- a/tests/Unit/Infrastructure/Adapter/RoadSectionMakerTest.php
+++ b/tests/Unit/Infrastructure/Adapter/RoadSectionMakerTest.php
@@ -12,12 +12,22 @@
use App\Application\LineSectionMakerInterface;
use App\Application\RoadGeocoderInterface;
use App\Domain\Geography\Coordinates;
+use App\Domain\Regulation\Enum\DirectionEnum;
use App\Domain\Regulation\Enum\RoadTypeEnum;
use App\Infrastructure\Adapter\RoadSectionMaker;
use PHPUnit\Framework\TestCase;
final class RoadSectionMakerTest extends TestCase
{
+ private $fromCoords;
+ private $toCoords;
+
+ protected function setUp(): void
+ {
+ $this->fromCoords = Coordinates::fromLonLat(1, 41);
+ $this->toCoords = Coordinates::fromLonLat(9, 10);
+ }
+
public function testComputeSection(): void
{
$fullDepartmentalRoadGeometry = 'geometry';
@@ -30,9 +40,7 @@ public function testComputeSection(): void
$toPointNumber = '5';
$toAbscissa = 150;
$toSide = 'U';
-
- $fromCoords = Coordinates::fromLonLat(1, 41);
- $toCoords = Coordinates::fromLonLat(9, 10);
+ $direction = DirectionEnum::BOTH->value;
$lineSectionMaker = $this->createMock(LineSectionMakerInterface::class);
$geocoder = $this->createMock(RoadGeocoderInterface::class);
@@ -48,12 +56,12 @@ public function testComputeSection(): void
[$roadType, $administrator, $roadNumber, $fromPointNumber, $fromSide, $fromAbscissa],
[$roadType, $administrator, $roadNumber, $toPointNumber, $toSide, $toAbscissa],
)
- ->willReturnOnConsecutiveCalls($fromCoords, $toCoords);
+ ->willReturnOnConsecutiveCalls($this->fromCoords, $this->toCoords);
$lineSectionMaker
->expects(self::once())
->method('computeSection')
- ->with($fullDepartmentalRoadGeometry, $fromCoords, $toCoords)
+ ->with($fullDepartmentalRoadGeometry, $this->fromCoords, $this->toCoords)
->willReturn('section');
$this->assertSame(
@@ -69,6 +77,7 @@ public function testComputeSection(): void
$toPointNumber,
$toSide,
$toAbscissa,
+ $direction,
),
);
}
@@ -87,6 +96,7 @@ public function testComputeSectionStartAbscissaOutOfRange(): void
$toPointNumber = '5';
$toAbscissa = 150;
$toSide = 'U';
+ $direction = DirectionEnum::BOTH->value;
$lineSectionMaker = $this->createMock(LineSectionMakerInterface::class);
$geocoder = $this->createMock(RoadGeocoderInterface::class);
@@ -116,6 +126,7 @@ public function testComputeSectionStartAbscissaOutOfRange(): void
$toPointNumber,
$toSide,
$toAbscissa,
+ $direction,
);
}
@@ -123,8 +134,6 @@ public function testComputeSectionEndAbscissaOutOfRange(): void
{
$this->expectException(EndAbscissaOutOfRangeException::class);
- $fromCoords = Coordinates::fromLonLat(1, 41);
-
$roadType = RoadTypeEnum::DEPARTMENTAL_ROAD->value;
$fullDepartmentalRoadGeometry = 'geometry';
$administrator = 'Ardèche';
@@ -135,6 +144,7 @@ public function testComputeSectionEndAbscissaOutOfRange(): void
$toPointNumber = '5';
$toAbscissa = 15000000;
$toSide = 'U';
+ $direction = DirectionEnum::BOTH->value;
$lineSectionMaker = $this->createMock(LineSectionMakerInterface::class);
$geocoder = $this->createMock(RoadGeocoderInterface::class);
@@ -147,9 +157,9 @@ public function testComputeSectionEndAbscissaOutOfRange(): void
$geocoder
->expects($matcher)
->method('computeReferencePoint')
- ->willReturnCallback(function () use ($matcher, $fromCoords, $roadType) {
+ ->willReturnCallback(function () use ($matcher, $roadType) {
if ($matcher->getInvocationCount() === 1) {
- return $fromCoords;
+ return $this->fromCoords;
}
throw new AbscissaOutOfRangeException($roadType);
@@ -170,6 +180,7 @@ public function testComputeSectionEndAbscissaOutOfRange(): void
$toPointNumber,
$toSide,
$toAbscissa,
+ $direction,
);
}
@@ -187,8 +198,7 @@ public function testComputeSectionToPointGeocodingError(): void
$toPointNumber = '5';
$toAbscissa = 150;
$toSide = 'U';
-
- $fromCoords = Coordinates::fromLonLat(1, 41);
+ $direction = DirectionEnum::BOTH->value;
$lineSectionMaker = $this->createMock(LineSectionMakerInterface::class);
$geocoder = $this->createMock(RoadGeocoderInterface::class);
@@ -201,9 +211,9 @@ public function testComputeSectionToPointGeocodingError(): void
$geocoder
->expects($matcher)
->method('computeReferencePoint')
- ->willReturnCallback(function () use ($matcher, $fromCoords) {
+ ->willReturnCallback(function () use ($matcher) {
if ($matcher->getInvocationCount() === 1) {
- return $fromCoords;
+ return $this->fromCoords;
}
throw new GeocodingFailureException('oops');
});
@@ -223,6 +233,7 @@ public function testComputeSectionToPointGeocodingError(): void
$toPointNumber,
$toSide,
$toAbscissa,
+ $direction,
);
}
@@ -240,9 +251,7 @@ public function testComputeSectionLineSectionGeocodingError(): void
$toPointNumber = '5';
$toAbscissa = 150;
$toSide = 'U';
-
- $fromCoords = Coordinates::fromLonLat(1, 41);
- $toCoords = Coordinates::fromLonLat(9, 10);
+ $direction = DirectionEnum::BOTH->value;
$lineSectionMaker = $this->createMock(LineSectionMakerInterface::class);
$geocoder = $this->createMock(RoadGeocoderInterface::class);
@@ -254,7 +263,7 @@ public function testComputeSectionLineSectionGeocodingError(): void
$geocoder
->expects(self::exactly(2))
->method('computeReferencePoint')
- ->willReturnOnConsecutiveCalls($fromCoords, $toCoords);
+ ->willReturnOnConsecutiveCalls($this->fromCoords, $this->toCoords);
$lineSectionMaker
->expects(self::once())
@@ -272,6 +281,86 @@ public function testComputeSectionLineSectionGeocodingError(): void
$toPointNumber,
$toSide,
$toAbscissa,
+ $direction,
);
}
+
+ private function provideTestComputeSectionDirection(): array
+ {
+ $this->setUp();
+
+ $fromCoords = $this->fromCoords;
+ $toCoords = $this->toCoords;
+
+ return [
+ 'both' => [
+ 'direction' => DirectionEnum::BOTH->value,
+ 'fromCoords' => $fromCoords,
+ 'toCoords' => $toCoords,
+ ],
+ 'ab' => [
+ 'direction' => DirectionEnum::A_TO_B->value,
+ 'fromCoords' => $fromCoords,
+ 'toCoords' => $toCoords,
+ ],
+ 'ba' => [
+ 'direction' => DirectionEnum::B_TO_A->value,
+ 'fromCoords' => $toCoords,
+ 'toCoords' => $fromCoords,
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider provideTestComputeSectionDirection
+ */
+ public function testComputeSectionDirection(string $direction, Coordinates $fromCoords, Coordinates $toCoords): void
+ {
+ $fullDepartmentalRoadGeometry = 'geometry';
+ $roadType = RoadTypeEnum::DEPARTMENTAL_ROAD->value;
+ $administrator = 'Ardèche';
+ $roadNumber = 'D110';
+ $fromPointNumber = '1';
+ $fromSide = 'U';
+ $fromAbscissa = 0;
+ $toPointNumber = '5';
+ $toAbscissa = 150;
+ $toSide = 'U';
+
+ $lineSectionMaker = $this->createMock(LineSectionMakerInterface::class);
+ $geocoder = $this->createMock(RoadGeocoderInterface::class);
+ $roadSectionMaker = new RoadSectionMaker(
+ $lineSectionMaker,
+ $geocoder,
+ );
+
+ $geocoder
+ ->expects(self::exactly(2))
+ ->method('computeReferencePoint')
+ ->withConsecutive(
+ [$roadType, $administrator, $roadNumber, $fromPointNumber, $fromSide, $fromAbscissa],
+ [$roadType, $administrator, $roadNumber, $toPointNumber, $toSide, $toAbscissa],
+ )
+ ->willReturnOnConsecutiveCalls($this->fromCoords, $this->toCoords);
+
+ $lineSectionMaker
+ ->expects(self::once())
+ ->method('computeSection')
+ ->with('geometry', $fromCoords, $toCoords)
+ ->willReturn('section');
+
+ $this->assertSame('section', $roadSectionMaker->computeSection(
+ $fullDepartmentalRoadGeometry,
+ $roadType,
+ $administrator,
+ $roadNumber,
+ $fromPointNumber,
+ $fromSide,
+ $fromAbscissa,
+ $toPointNumber,
+ $toSide,
+ $toAbscissa,
+ $direction,
+ ));
+ }
}
diff --git a/tools/metabase-export.sh b/tools/metabase-export.sh
deleted file mode 100755
index 4e56c92bd..000000000
--- a/tools/metabase-export.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-# Inspiré de : https://doc.incubateur.net/communaute/les-outils-de-la-communaute/autres-services/metabase/metabase#connecter-metabase-a-une-base-de-donnees-anonymisee
-set -euxo pipefail
-
-# URL de la DB DiaLog du point de vue de la DB Metabase (sera utilisé avec dblink)
-SRC_DATABASE_URL=$1
-
-# URL de la DB Metabase du point de vue de ce script
-DEST_DATABASE_URL=$2
-
-export PGOPTIONS="-c custom.src_database_url=${SRC_DATABASE_URL}"
-
-# ON_ERROR_STOP=1 s'assure que cette commande échoue (return code != 0) si le script SQL a des statements qui échouent.
-# (Par défaut avec -f on a toujours un return code 0 et un statement en échec n'empêche pas les suivants de s'exécuter.)
-# https://engineering.nordeus.com/psql-exit-on-first-error/
-psql $DEST_DATABASE_URL -v ON_ERROR_STOP=1 -f ./tools/metabase-export.sql
diff --git a/tools/metabase-export.sql b/tools/metabase-export.sql
deleted file mode 100644
index 4b2e50c04..000000000
--- a/tools/metabase-export.sql
+++ /dev/null
@@ -1,31 +0,0 @@
--- metabase-export.sql
--- Ce script est conçu pour être exécuté sur la base de données PostgreSQL de l'instance Metabase (destination).
--- Il consiste à extraire des données de la base applicative (source) pour les charger dans des tables Metabase.
-
--- Configuration générale
-CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-
--- CONNEXION À LA DB APPLICATIVE (source)
--- Voir : https://www.postgresql.org/docs/current/contrib-dblink-connect.html
-CREATE EXTENSION IF NOT EXISTS dblink;
-SELECT dblink_connect('src', current_setting('custom.src_database_url'));
-
--- COLLECTE DES DONNÉES D'INDICATEURS
-
--- # Utilisateurs actifs
--- À chaque exécution, on ajoute la liste des dates de dernière activité pour chaque utilisateur, assortie de la date d'exécution.
--- Dans Metabase cela permet de calculer le nombre d'utilisateurs actif au moment de chaque exécution.
--- (Par exemple avec un filtre : "[last_active_at] >= [uploaded_at] - 7 jours", puis en groupant sur le uploaded_at.)
-CREATE TABLE IF NOT EXISTS analytics_user_active (id UUID NOT NULL, uploaded_at TIMESTAMP(0), last_active_at TIMESTAMP(0), PRIMARY KEY(id));
-CREATE INDEX IF NOT EXISTS idx_analytics_user_active_uploaded_at ON analytics_user_active (uploaded_at);
-
-WITH params AS (
- -- Calculé 1 bonne fois pour toute pour que toutes les lignes utilisent exactement la même valeur à des fins de groupement dans Metabase
- SELECT NOW() as current_date
-)
-INSERT INTO analytics_user_active(id, uploaded_at, last_active_at)
-SELECT uuid_generate_v4() AS id, p.current_date AS uploaded_at, u.last_active_at AS last_active_at
-FROM
- dblink('src', 'SELECT last_active_at FROM "user"') AS u(last_active_at TIMESTAMP(0) WITH TIME ZONE),
- params AS p
-;
diff --git a/translations/messages.fr.xlf b/translations/messages.fr.xlf
index 0d9addd15..2bce6190b 100644
--- a/translations/messages.fr.xlf
+++ b/translations/messages.fr.xlf
@@ -677,24 +677,24 @@