Skip to content

Commit 66ff923

Browse files
chore(poc): add unit tests
1 parent c4893ff commit 66ff923

File tree

20 files changed

+400
-18
lines changed

20 files changed

+400
-18
lines changed

composer.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Application/Integration/EudonetParis/Command/ImportEudonetParisRegulationCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111

1212
final class ImportEudonetParisRegulationCommand implements CommandInterface
1313
{
14+
/**
15+
* @param SaveMeasureCommand[] $measureCommands
16+
*/
1417
public function __construct(
1518
public readonly SaveRegulationGeneralInfoCommand $generalInfoCommand,
16-
/** @var SaveMeasureCommand[] */
1719
public readonly array $measureCommands,
1820
) {
1921
$generalInfoCommand->source = RegulationOrderRecordSourceEnum::EUDONET_PARIS->value;

src/Application/Integration/Litteralis/Command/ImportLitteralisRegulationCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
final class ImportLitteralisRegulationCommand implements CommandInterface
1313
{
14+
/** @param SaveMeasureCommand[] $measureCommands */
1415
public function __construct(
1516
public SaveRegulationGeneralInfoCommand $generalInfoCommand,
16-
/** @var SaveMeasureCommand[] */
1717
public readonly array $measureCommands,
1818
public readonly ?string $downloadUrl = null,
1919
) {

src/Application/Regulation/Command/PublishRegulationCommandHandler.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace App\Application\Regulation\Command;
66

77
use App\Application\CommandBusInterface;
8-
use App\Application\Regulation\DatexGeneratorInterface;
98
use App\Domain\Regulation\Enum\ActionTypeEnum;
109
use App\Domain\Regulation\Enum\RegulationOrderRecordStatusEnum;
1110
use App\Domain\Regulation\Exception\RegulationOrderRecordCannotBePublishedException;
@@ -16,7 +15,6 @@ final class PublishRegulationCommandHandler
1615
public function __construct(
1716
private CanRegulationOrderRecordBePublished $canRegulationOrderRecordBePublished,
1817
private CommandBusInterface $commandBus,
19-
private DatexGeneratorInterface $datexGenerator,
2018
) {
2119
}
2220

@@ -31,7 +29,5 @@ public function __invoke(PublishRegulationCommand $command): void
3129
$this->commandBus->handle(new CreateRegulationOrderHistoryCommand($regulationOrder, ActionTypeEnum::PUBLISH->value));
3230

3331
$command->regulationOrderRecord->updateStatus(RegulationOrderRecordStatusEnum::PUBLISHED->value);
34-
35-
$this->datexGenerator->generate();
3632
}
3733
}

src/Infrastructure/Controller/Api/Regulations/DeleteRegulationController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use App\Application\Organization\Command\UpdateApiClientLastUsedAtCommand;
99
use App\Application\QueryBusInterface;
1010
use App\Application\Regulation\Command\DeleteRegulationCommand;
11+
use App\Application\Regulation\DatexGeneratorInterface;
1112
use App\Application\Regulation\Query\GetRegulationOrderRecordByIdentifierQuery;
1213
use App\Domain\Regulation\Exception\RegulationOrderRecordCannotBeDeletedException;
1314
use App\Domain\Regulation\Exception\RegulationOrderRecordNotFoundException;
@@ -25,6 +26,7 @@ public function __construct(
2526
private readonly CommandBusInterface $commandBus,
2627
private readonly QueryBusInterface $queryBus,
2728
private readonly Security $security,
29+
private readonly DatexGeneratorInterface $datexGenerator,
2830
) {
2931
}
3032

@@ -103,6 +105,8 @@ public function __invoke(string $identifier): JsonResponse
103105
], Response::HTTP_FORBIDDEN);
104106
}
105107

108+
$this->datexGenerator->generate();
109+
106110
return new JsonResponse(null, Response::HTTP_NO_CONTENT);
107111
}
108112
}

src/Infrastructure/Controller/Api/Regulations/PublishRegulationController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use App\Application\Organization\Command\UpdateApiClientLastUsedAtCommand;
99
use App\Application\QueryBusInterface;
1010
use App\Application\Regulation\Command\PublishRegulationCommand;
11+
use App\Application\Regulation\DatexGeneratorInterface;
1112
use App\Application\Regulation\Query\GetRegulationOrderRecordByIdentifierQuery;
1213
use App\Domain\Regulation\Enum\RegulationOrderRecordStatusEnum;
1314
use App\Domain\Regulation\Exception\RegulationOrderRecordCannotBePublishedException;
@@ -26,6 +27,7 @@ public function __construct(
2627
private readonly CommandBusInterface $commandBus,
2728
private readonly QueryBusInterface $queryBus,
2829
private readonly Security $security,
30+
private readonly DatexGeneratorInterface $datexGenerator,
2931
) {
3032
}
3133

@@ -106,6 +108,8 @@ public function __invoke(string $identifier): JsonResponse
106108
], Response::HTTP_BAD_REQUEST);
107109
}
108110

111+
$this->datexGenerator->generate();
112+
109113
return new JsonResponse([
110114
'identifier' => $regulationOrderRecord->getRegulationOrder()->getIdentifier(),
111115
'status' => RegulationOrderRecordStatusEnum::PUBLISHED->value,

src/Infrastructure/Controller/Regulation/DeleteRegulationController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use App\Application\CommandBusInterface;
88
use App\Application\QueryBusInterface;
99
use App\Application\Regulation\Command\DeleteRegulationCommand;
10+
use App\Application\Regulation\DatexGeneratorInterface;
1011
use App\Application\Regulation\Query\GetRegulationOrderRecordByUuidQuery;
1112
use App\Domain\Regulation\Exception\RegulationOrderRecordCannotBeDeletedException;
1213
use App\Domain\Regulation\Exception\RegulationOrderRecordNotFoundException;
@@ -29,6 +30,7 @@ public function __construct(
2930
private CommandBusInterface $commandBus,
3031
private QueryBusInterface $queryBus,
3132
private Security $security,
33+
private DatexGeneratorInterface $datexGenerator,
3234
) {
3335
}
3436

@@ -62,6 +64,8 @@ public function __invoke(Request $request, string $uuid): Response
6264
throw new AccessDeniedHttpException();
6365
}
6466

67+
$this->datexGenerator->generate();
68+
6569
$redirectQueryParams = $request->query->get('_redirectQueryParams')
6670
? json_decode($request->query->get('_redirectQueryParams'), true)
6771
: [];

src/Infrastructure/Controller/Regulation/PublishRegulationController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use App\Application\CommandBusInterface;
88
use App\Application\QueryBusInterface;
99
use App\Application\Regulation\Command\PublishRegulationCommand;
10+
use App\Application\Regulation\DatexGeneratorInterface;
1011
use App\Domain\Regulation\Exception\RegulationOrderRecordCannotBePublishedException;
1112
use App\Domain\Regulation\Specification\CanOrganizationAccessToRegulation;
1213
use App\Infrastructure\Security\Voter\RegulationOrderRecordVoter;
@@ -25,6 +26,7 @@ final class PublishRegulationController extends AbstractRegulationController
2526
public function __construct(
2627
private RouterInterface $router,
2728
private CommandBusInterface $commandBus,
29+
private DatexGeneratorInterface $datexGenerator,
2830
QueryBusInterface $queryBus,
2931
Security $security,
3032
CanOrganizationAccessToRegulation $canOrganizationAccessToRegulation,
@@ -53,6 +55,8 @@ public function __invoke(Request $request, string $uuid): Response
5355
throw new AccessDeniedHttpException();
5456
}
5557

58+
$this->datexGenerator->generate();
59+
5660
return new RedirectResponse(
5761
url: $this->router->generate('app_regulation_detail', [
5862
'uuid' => $uuid,

src/Infrastructure/Integration/BacIdf/BacIdfExecutor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use App\Application\CommandBusInterface;
88
use App\Application\DateUtilsInterface;
99
use App\Application\Integration\BacIdf\Exception\ImportBacIdfRegulationFailedException;
10+
use App\Application\Regulation\DatexGeneratorInterface;
1011
use App\Domain\Regulation\Enum\RegulationOrderRecordSourceEnum;
1112
use App\Domain\Regulation\Repository\RegulationOrderRecordRepositoryInterface;
1213
use App\Infrastructure\Integration\BacIdf\Exception\BacIdfException;
@@ -21,6 +22,7 @@ public function __construct(
2122
private CommandBusInterface $commandBus,
2223
private RegulationOrderRecordRepositoryInterface $regulationOrderRecordRepository,
2324
private DateUtilsInterface $dateUtils,
25+
private DatexGeneratorInterface $datexGenerator,
2426
) {
2527
}
2628

@@ -74,6 +76,8 @@ public function execute(): void
7476
}
7577
}
7678
}
79+
80+
$this->datexGenerator->generate();
7781
} catch (\Exception $exc) {
7882
$this->logger->error('exception', ['exc' => $exc]);
7983

src/Infrastructure/Integration/EudonetParis/EudonetParisExecutor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use App\Application\DateUtilsInterface;
99
use App\Application\Integration\EudonetParis\Exception\ImportEudonetParisRegulationFailedException;
1010
use App\Application\QueryBusInterface;
11+
use App\Application\Regulation\DatexGeneratorInterface;
1112
use App\Application\User\Query\GetOrganizationByUuidQuery;
1213
use App\Domain\Regulation\Enum\RegulationOrderRecordSourceEnum;
1314
use App\Domain\Regulation\Repository\RegulationOrderRecordRepositoryInterface;
@@ -26,6 +27,7 @@ public function __construct(
2627
private RegulationOrderRecordRepositoryInterface $regulationOrderRecordRepository,
2728
private string $eudonetParisOrgId,
2829
private DateUtilsInterface $dateUtils,
30+
private DatexGeneratorInterface $datexGenerator,
2931
) {
3032
}
3133

@@ -86,6 +88,8 @@ public function execute(\DateTimeInterface $laterThanUTC): void
8688

8789
$numberOfRegulationsInsideEudonet = $this->eudonetParisExtractor->getNumberOfRegulations();
8890
$numberOfMeasuresInsideEudonet = $this->eudonetParisExtractor->getNumberOfMeasures();
91+
92+
$this->datexGenerator->generate();
8993
} catch (\Exception $exc) {
9094
$this->logger->error($exc);
9195

0 commit comments

Comments
 (0)