Skip to content

Commit d9df538

Browse files
committed
new fixtures
1 parent 01c23f9 commit d9df538

File tree

51 files changed

+286
-296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+286
-296
lines changed

src/Application/Regulation/Command/DuplicateMeasureCommandHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public function __invoke(DuplicateMeasureCommand $command): Measure
2727
$measure = $command->measure;
2828
$originalRegulationOrderRecord = $command->originalRegulationOrderRecord;
2929
$originalRegulationOrder = $originalRegulationOrderRecord->getRegulationOrder();
30-
3130
$periodCommands = [];
3231
$locationCommands = [];
3332

@@ -59,6 +58,7 @@ public function __invoke(DuplicateMeasureCommand $command): Measure
5958

6059
foreach ($measure->getLocations() as $location) {
6160
$cmd = new SaveLocationCommand();
61+
$cmd->organization = $originalRegulationOrderRecord->getOrganization();
6262
$cmd->roadType = $location->getRoadType();
6363

6464
if ($numberedRoad = $location->getNumberedRoad()) {

src/Application/Regulation/Command/Location/SaveLocationCommand.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
use App\Domain\Regulation\Enum\RoadTypeEnum;
99
use App\Domain\Regulation\Location\Location;
1010
use App\Domain\Regulation\Measure;
11+
use App\Domain\User\Organization;
1112

1213
final class SaveLocationCommand implements CommandInterface
1314
{
1415
public ?string $roadType = null;
1516
public ?Measure $measure = null;
17+
public ?Organization $organization = null;
1618
public ?SaveNumberedRoadCommand $departmentalRoad = null;
1719
public ?SaveNumberedRoadCommand $nationalRoad = null;
1820
public ?SaveNamedStreetCommand $namedStreet = null;
@@ -24,6 +26,10 @@ public function __construct(
2426
) {
2527
$this->roadType = $location?->getRoadType();
2628

29+
if ($location) {
30+
$this->organization = $location->getMeasure()->getRegulationOrder()->getRegulationOrderRecord()->getOrganization();
31+
}
32+
2733
if ($location?->getNamedStreet()) {
2834
$this->namedStreet = new SaveNamedStreetCommand($location->getNamedStreet());
2935
}

src/Application/Regulation/Command/Location/SaveLocationCommandHandler.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use App\Application\QueryBusInterface;
1111
use App\Domain\Regulation\Location\Location;
1212
use App\Domain\Regulation\Repository\LocationRepositoryInterface;
13+
use App\Domain\Regulation\Repository\RegulationOrderRepositoryInterface;
1314
use App\Domain\Regulation\Specification\CanOrganizationInterveneOnGeometry;
1415

1516
final class SaveLocationCommandHandler
@@ -18,6 +19,7 @@ public function __construct(
1819
private CommandBusInterface $commandBus,
1920
private QueryBusInterface $queryBus,
2021
private LocationRepositoryInterface $locationRepository,
22+
private RegulationOrderRepositoryInterface $regulationOrderRepository,
2123
private IdFactoryInterface $idFactory,
2224
private CanOrganizationInterveneOnGeometry $canOrganizationInterveneOnGeometry,
2325
) {
@@ -28,13 +30,13 @@ public function __invoke(SaveLocationCommand $command): Location
2830
$command->clean();
2931
$roadCommand = $command->getRoadCommand();
3032
$roadCommand->clean();
33+
$organization = $command->organization;
3134

3235
// Update location
3336

3437
if ($location = $command->location) {
3538
$roadCommand->setLocation($location);
3639
$geometry = $this->queryBus->handle($roadCommand->getGeometryQuery());
37-
$organization = $location->getMeasure()->getRegulationOrder()->getRegulationOrderRecord()->getOrganization();
3840

3941
if (!$this->canOrganizationInterveneOnGeometry->isSatisfiedBy($organization->getUuid(), $geometry)) {
4042
throw new OrganizationCannotInterveneOnGeometryException();
@@ -52,7 +54,6 @@ public function __invoke(SaveLocationCommand $command): Location
5254

5355
// Create location
5456
$geometry = $this->queryBus->handle($roadCommand->getGeometryQuery());
55-
$organization = $command->measure->getRegulationOrder()->getRegulationOrderRecord()->getOrganization();
5657

5758
if (!$this->canOrganizationInterveneOnGeometry->isSatisfiedBy($organization->getUuid(), $geometry)) {
5859
throw new OrganizationCannotInterveneOnGeometryException();

src/Application/Regulation/Command/SaveMeasureCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ public static function create(
5454
$command->periods[] = new SavePeriodCommand($period);
5555
}
5656
} else {
57-
$command->addLocation(new SaveLocationCommand());
57+
$locationCommand = new SaveLocationCommand();
58+
$locationCommand->organization = $regulationOrder?->getRegulationOrderRecord()->getOrganization();
59+
60+
$command->addLocation($locationCommand);
5861
$command->periods[] = new SavePeriodCommand();
5962
}
6063

src/Infrastructure/Persistence/Doctrine/Fixtures/InvitationFixture.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function load(ObjectManager $manager): void
2626
role: OrganizationRolesEnum::ROLE_ORGA_CONTRIBUTOR->value,
2727
createdAt: new \DateTimeImmutable('2025-02-12'),
2828
owner: $this->getReference('otherOrgUser', User::class),
29-
organization: $this->getReference('otherOrg', Organization::class),
29+
organization: $this->getReference('regionIdfOrg', Organization::class),
3030
);
3131

3232
$invitationAlreadyJoined = new Invitation(
@@ -35,8 +35,8 @@ public function load(ObjectManager $manager): void
3535
3636
role: OrganizationRolesEnum::ROLE_ORGA_CONTRIBUTOR->value,
3737
createdAt: new \DateTimeImmutable('2025-02-12'),
38-
owner: $this->getReference('mainOrgAdmin', User::class),
39-
organization: $this->getReference('mainOrg', Organization::class),
38+
owner: $this->getReference('department93Admin', User::class),
39+
organization: $this->getReference('seineSaintDenisOrg', Organization::class),
4040
);
4141

4242
$manager->persist($invitation);

src/Infrastructure/Persistence/Doctrine/Fixtures/LocationFixture.php

Lines changed: 43 additions & 47 deletions
Large diffs are not rendered by default.

src/Infrastructure/Persistence/Doctrine/Fixtures/OrganizationFixture.php

Lines changed: 20 additions & 54 deletions
Large diffs are not rendered by default.

src/Infrastructure/Persistence/Doctrine/Fixtures/RegulationOrderRecordFixture.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function load(ObjectManager $manager): void
4949
RegulationOrderRecordStatusEnum::DRAFT->value,
5050
$this->getReference('typicalRegulationOrder', RegulationOrder::class),
5151
new \DateTime('2022-01-10'),
52-
$this->getReference('mainOrg', Organization::class),
52+
$this->getReference('seineSaintDenisOrg', Organization::class),
5353
);
5454

5555
$publishedRegulationOrderRecord = new RegulationOrderRecord(
@@ -58,7 +58,7 @@ public function load(ObjectManager $manager): void
5858
RegulationOrderRecordStatusEnum::PUBLISHED->value,
5959
$this->getReference('publishedRegulationOrder', RegulationOrder::class),
6060
new \DateTime('2022-01-10'),
61-
$this->getReference('mainOrg', Organization::class),
61+
$this->getReference('seineSaintDenisOrg', Organization::class),
6262
);
6363

6464
$regulationOrderRecordPermanent = new RegulationOrderRecord(
@@ -67,7 +67,7 @@ public function load(ObjectManager $manager): void
6767
RegulationOrderRecordStatusEnum::DRAFT->value,
6868
$this->getReference('regulationOrderPermanent', RegulationOrder::class),
6969
new \DateTime('2022-01-11'),
70-
$this->getReference('mainOrg', Organization::class),
70+
$this->getReference('seineSaintDenisOrg', Organization::class),
7171
);
7272

7373
$fullCityRegulationOrderRecord = new RegulationOrderRecord(
@@ -76,7 +76,7 @@ public function load(ObjectManager $manager): void
7676
RegulationOrderRecordStatusEnum::DRAFT->value,
7777
$this->getReference('fullCityRegulationOrder', RegulationOrder::class),
7878
new \DateTime('2022-01-11'),
79-
$this->getReference('mainOrg', Organization::class),
79+
$this->getReference('seineSaintDenisOrg', Organization::class),
8080
);
8181

8282
$regulationOrderRecordNoLocations = new RegulationOrderRecord(
@@ -85,7 +85,7 @@ public function load(ObjectManager $manager): void
8585
RegulationOrderRecordStatusEnum::DRAFT->value,
8686
$this->getReference('regulationOrderNoLocations', RegulationOrder::class),
8787
new \DateTime('2022-01-10'),
88-
$this->getReference('mainOrg', Organization::class),
88+
$this->getReference('seineSaintDenisOrg', Organization::class),
8989
);
9090

9191
$regulationOrderRecordNoMeasures = new RegulationOrderRecord(
@@ -94,7 +94,7 @@ public function load(ObjectManager $manager): void
9494
RegulationOrderRecordStatusEnum::DRAFT->value,
9595
$this->getReference('regulationOrderNoMeasures', RegulationOrder::class),
9696
new \DateTime('2022-01-10'),
97-
$this->getReference('mainOrg', Organization::class),
97+
$this->getReference('seineSaintDenisOrg', Organization::class),
9898
);
9999

100100
$regulationOrderRecordCifs = new RegulationOrderRecord(
@@ -103,7 +103,7 @@ public function load(ObjectManager $manager): void
103103
RegulationOrderRecordStatusEnum::PUBLISHED->value,
104104
$this->getReference('regulationOrderCifs', RegulationOrder::class),
105105
new \DateTime('2023-09-06'),
106-
$this->getReference('mainOrg', Organization::class),
106+
$this->getReference('seineSaintDenisOrg', Organization::class),
107107
);
108108

109109
$outDatedRegulationOrderRecordCifs = new RegulationOrderRecord(
@@ -112,7 +112,7 @@ public function load(ObjectManager $manager): void
112112
RegulationOrderRecordStatusEnum::PUBLISHED->value,
113113
$this->getReference('outDatedRegulationOrderCifs', RegulationOrder::class),
114114
new \DateTime('2021-11-02'),
115-
$this->getReference('otherOrg', Organization::class),
115+
$this->getReference('regionIdfOrg', Organization::class),
116116
);
117117

118118
$rawGeoJSONRegulationOrderRecord = new RegulationOrderRecord(
@@ -121,7 +121,7 @@ public function load(ObjectManager $manager): void
121121
RegulationOrderRecordStatusEnum::DRAFT->value,
122122
$this->getReference('rawGeoJSONRegulationOrder', RegulationOrder::class),
123123
new \DateTime('2020-06-05'),
124-
$this->getReference('mainOrg', Organization::class),
124+
$this->getReference('seineSaintDenisOrg', Organization::class),
125125
);
126126

127127
$litteralisRegulationOrderRecord = new RegulationOrderRecord(
@@ -130,7 +130,7 @@ public function load(ObjectManager $manager): void
130130
RegulationOrderRecordStatusEnum::PUBLISHED->value,
131131
$this->getReference('litteralisRegulationOrder', RegulationOrder::class),
132132
new \DateTime('2024-09-05'),
133-
$this->getReference('mainOrg', Organization::class),
133+
$this->getReference('seineSaintDenisOrg', Organization::class),
134134
);
135135

136136
$winterMaintenanceRegulationOrderRecord = new RegulationOrderRecord(
@@ -139,7 +139,7 @@ public function load(ObjectManager $manager): void
139139
RegulationOrderRecordStatusEnum::DRAFT->value,
140140
$this->getReference('winterMaintenanceRegulationOrder', RegulationOrder::class),
141141
new \DateTime('2025-01-08'),
142-
$this->getReference('mainOrg', Organization::class),
142+
$this->getReference('seineSaintDenisOrg', Organization::class),
143143
);
144144

145145
$manager->persist($typicalRegulationOrderRecord);

src/Infrastructure/Persistence/Doctrine/Fixtures/SigningAuthorityFixture.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function load(ObjectManager $manager): void
1919
name: 'Monsieur le maire de Savenay',
2020
placeOfSignature: 'Savenay',
2121
signatoryName: 'Monsieur X, Maire de Savenay',
22-
organization: $this->getReference('mainOrg', Organization::class),
22+
organization: $this->getReference('seineSaintDenisOrg', Organization::class),
2323
roadName: '3 rue de la Concertation',
2424
cityCode: '75018',
2525
cityLabel: 'Paris',

src/Infrastructure/Persistence/Doctrine/Fixtures/TokenFixture.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ public function load(ObjectManager $manager): void
3535
'8edb17c6-9346-4e64-8a0d-bf1e4762802c',
3636
'forgotPasswordToken',
3737
TokenTypeEnum::FORGOT_PASSWORD->value,
38-
$this->getReference('mainOrgUser', User::class),
38+
$this->getReference('department93User', User::class),
3939
new \DateTime('2025-08-26 09:00:00'),
4040
);
4141

4242
$expiredForgotPasswordToken = new Token(
4343
'57b8d6cc-1b7b-4204-8a38-da30359a936e',
4444
'expiredForgotPasswordToken',
4545
TokenTypeEnum::FORGOT_PASSWORD->value,
46-
$this->getReference('mainOrgUser', User::class),
46+
$this->getReference('department93User', User::class),
4747
new \DateTime('2023-01-01 19:00:00'),
4848
);
4949

0 commit comments

Comments
 (0)