From 504c62c1550c1145be9730fa9b0dd0981742b424 Mon Sep 17 00:00:00 2001 From: "ext.jeremy.guillot@maxicoffee.domains" Date: Wed, 12 Feb 2025 16:41:11 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20Renommage=20de=20GetManga=20=C3=A0=20Ge?= =?UTF-8?q?tMangaById=20+=20ajout=20de=20axios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 19 +++++++++++++------ package.json | 1 + .../Query/{GetManga.php => GetMangaById.php} | 4 ++-- ...ngaHandler.php => GetMangaByIdHandler.php} | 8 ++++---- .../State/Provider/GetMangaStateProvider.php | 10 +++++----- ...erTest.php => GetMangaByIdHandlerTest.php} | 18 +++++++++--------- 6 files changed, 34 insertions(+), 26 deletions(-) rename src/Domain/Manga/Application/Query/{GetManga.php => GetMangaById.php} (80%) rename src/Domain/Manga/Application/QueryHandler/{GetMangaHandler.php => GetMangaByIdHandler.php} (87%) rename tests/Domain/Manga/Application/QueryHandler/{GetMangaHandlerTest.php => GetMangaByIdHandlerTest.php} (85%) diff --git a/package-lock.json b/package-lock.json index 0a352c0..fdeba04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@fortawesome/react-fontawesome": "^0.2.2", "alpinejs": "^3.13.3", "autoprefixer": "^10.4.14", + "axios": "^1.7.9", "bootstrap": "^5.3.3", "postcss-loader": "^7.1.0", "puppeteer": "^22.10.0", @@ -4322,8 +4323,7 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "dev": true + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/autoprefixer": { "version": "10.4.19", @@ -4361,6 +4361,17 @@ "postcss": "^8.1.0" } }, + "node_modules/axios": { + "version": "1.7.9", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", + "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/b4a": { "version": "1.6.6", "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.6.tgz", @@ -5050,7 +5061,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "dependencies": { "delayed-stream": "~1.0.0" }, @@ -5730,7 +5740,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "dev": true, "engines": { "node": ">=0.4.0" } @@ -6462,7 +6471,6 @@ "version": "1.15.6", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", - "dev": true, "funding": [ { "type": "individual", @@ -6508,7 +6516,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dev": true, "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", diff --git a/package.json b/package.json index c9c1c6c..4f324d6 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@fortawesome/react-fontawesome": "^0.2.2", "alpinejs": "^3.13.3", "autoprefixer": "^10.4.14", + "axios": "^1.7.9", "bootstrap": "^5.3.3", "postcss-loader": "^7.1.0", "puppeteer": "^22.10.0", diff --git a/src/Domain/Manga/Application/Query/GetManga.php b/src/Domain/Manga/Application/Query/GetMangaById.php similarity index 80% rename from src/Domain/Manga/Application/Query/GetManga.php rename to src/Domain/Manga/Application/Query/GetMangaById.php index 130dbb7..47d5a8c 100644 --- a/src/Domain/Manga/Application/Query/GetManga.php +++ b/src/Domain/Manga/Application/Query/GetMangaById.php @@ -2,9 +2,9 @@ namespace App\Domain\Manga\Application\Query; -readonly class GetManga +readonly class GetMangaById { public function __construct( public string $id ) {} -} \ No newline at end of file +} diff --git a/src/Domain/Manga/Application/QueryHandler/GetMangaHandler.php b/src/Domain/Manga/Application/QueryHandler/GetMangaByIdHandler.php similarity index 87% rename from src/Domain/Manga/Application/QueryHandler/GetMangaHandler.php rename to src/Domain/Manga/Application/QueryHandler/GetMangaByIdHandler.php index 58e4343..f2aff97 100644 --- a/src/Domain/Manga/Application/QueryHandler/GetMangaHandler.php +++ b/src/Domain/Manga/Application/QueryHandler/GetMangaByIdHandler.php @@ -2,18 +2,18 @@ namespace App\Domain\Manga\Application\QueryHandler; -use App\Domain\Manga\Application\Query\GetManga; +use App\Domain\Manga\Application\Query\GetMangaById; use App\Domain\Manga\Application\Response\MangaResponse; use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface; use App\Domain\Manga\Domain\Exception\MangaNotFoundException; -readonly class GetMangaHandler +readonly class GetMangaByIdHandler { public function __construct( private MangaRepositoryInterface $mangaRepository ) {} - public function handle(GetManga $query): MangaResponse + public function handle(GetMangaById $query): MangaResponse { $manga = $this->mangaRepository->findById($query->id); @@ -35,4 +35,4 @@ readonly class GetMangaHandler rating: $manga->getRating() ); } -} \ No newline at end of file +} diff --git a/src/Domain/Manga/Infrastructure/ApiPlatform/State/Provider/GetMangaStateProvider.php b/src/Domain/Manga/Infrastructure/ApiPlatform/State/Provider/GetMangaStateProvider.php index 7df70e4..69d20b2 100644 --- a/src/Domain/Manga/Infrastructure/ApiPlatform/State/Provider/GetMangaStateProvider.php +++ b/src/Domain/Manga/Infrastructure/ApiPlatform/State/Provider/GetMangaStateProvider.php @@ -4,19 +4,19 @@ namespace App\Domain\Manga\Infrastructure\ApiPlatform\State\Provider; use ApiPlatform\Metadata\Operation; use ApiPlatform\State\ProviderInterface; -use App\Domain\Manga\Application\Query\GetManga; -use App\Domain\Manga\Application\QueryHandler\GetMangaHandler; +use App\Domain\Manga\Application\Query\GetMangaById; +use App\Domain\Manga\Application\QueryHandler\GetMangaByIdHandler; use App\Domain\Manga\Infrastructure\ApiPlatform\Dto\MangaDetail; readonly class GetMangaStateProvider implements ProviderInterface { public function __construct( - private GetMangaHandler $handler + private GetMangaByIdHandler $handler ) {} public function provide(Operation $operation, array $uriVariables = [], array $context = []): MangaDetail { - $query = new GetManga($uriVariables['id']); + $query = new GetMangaById($uriVariables['id']); $response = $this->handler->handle($query); return new MangaDetail( @@ -33,4 +33,4 @@ readonly class GetMangaStateProvider implements ProviderInterface rating: $response->rating ); } -} \ No newline at end of file +} diff --git a/tests/Domain/Manga/Application/QueryHandler/GetMangaHandlerTest.php b/tests/Domain/Manga/Application/QueryHandler/GetMangaByIdHandlerTest.php similarity index 85% rename from tests/Domain/Manga/Application/QueryHandler/GetMangaHandlerTest.php rename to tests/Domain/Manga/Application/QueryHandler/GetMangaByIdHandlerTest.php index f384687..93d2b5a 100644 --- a/tests/Domain/Manga/Application/QueryHandler/GetMangaHandlerTest.php +++ b/tests/Domain/Manga/Application/QueryHandler/GetMangaByIdHandlerTest.php @@ -2,8 +2,8 @@ namespace App\Tests\Domain\Manga\Application\QueryHandler; -use App\Domain\Manga\Application\Query\GetManga; -use App\Domain\Manga\Application\QueryHandler\GetMangaHandler; +use App\Domain\Manga\Application\Query\GetMangaById; +use App\Domain\Manga\Application\QueryHandler\GetMangaByIdHandler; use App\Domain\Manga\Domain\Exception\MangaNotFoundException; use App\Domain\Manga\Domain\Model\Manga; use App\Domain\Manga\Domain\Model\ValueObject\ExternalId; @@ -13,22 +13,22 @@ use App\Domain\Manga\Domain\Model\ValueObject\MangaTitle; use App\Tests\Domain\Manga\Adapter\InMemoryMangaRepository; use PHPUnit\Framework\TestCase; -class GetMangaHandlerTest extends TestCase +class GetMangaByIdHandlerTest extends TestCase { private InMemoryMangaRepository $repository; - private GetMangaHandler $handler; + private GetMangaByIdHandler $handler; protected function setUp(): void { $this->repository = new InMemoryMangaRepository(); - $this->handler = new GetMangaHandler($this->repository); + $this->handler = new GetMangaByIdHandler($this->repository); } public function testHandleThrowsExceptionWhenMangaNotFound(): void { $this->expectException(MangaNotFoundException::class); - - $query = new GetManga('non-existent-id'); + + $query = new GetMangaById('non-existent-id'); $this->handler->handle($query); } @@ -51,7 +51,7 @@ class GetMangaHandlerTest extends TestCase $this->repository->save($manga); // Act - $query = new GetManga('123'); + $query = new GetMangaById('123'); $response = $this->handler->handle($query); // Assert @@ -72,4 +72,4 @@ class GetMangaHandlerTest extends TestCase { $this->repository->clear(); } -} \ No newline at end of file +}