feat: Renommage de GetManga à GetMangaById + ajout de axios
This commit is contained in:
parent
666636e5bf
commit
504c62c155
19
package-lock.json
generated
19
package-lock.json
generated
@@ -12,6 +12,7 @@
|
|||||||
"@fortawesome/react-fontawesome": "^0.2.2",
|
"@fortawesome/react-fontawesome": "^0.2.2",
|
||||||
"alpinejs": "^3.13.3",
|
"alpinejs": "^3.13.3",
|
||||||
"autoprefixer": "^10.4.14",
|
"autoprefixer": "^10.4.14",
|
||||||
|
"axios": "^1.7.9",
|
||||||
"bootstrap": "^5.3.3",
|
"bootstrap": "^5.3.3",
|
||||||
"postcss-loader": "^7.1.0",
|
"postcss-loader": "^7.1.0",
|
||||||
"puppeteer": "^22.10.0",
|
"puppeteer": "^22.10.0",
|
||||||
@@ -4322,8 +4323,7 @@
|
|||||||
"node_modules/asynckit": {
|
"node_modules/asynckit": {
|
||||||
"version": "0.4.0",
|
"version": "0.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"node_modules/autoprefixer": {
|
"node_modules/autoprefixer": {
|
||||||
"version": "10.4.19",
|
"version": "10.4.19",
|
||||||
@@ -4361,6 +4361,17 @@
|
|||||||
"postcss": "^8.1.0"
|
"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": {
|
"node_modules/b4a": {
|
||||||
"version": "1.6.6",
|
"version": "1.6.6",
|
||||||
"resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.6.tgz",
|
"resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.6.tgz",
|
||||||
@@ -5050,7 +5061,6 @@
|
|||||||
"version": "1.0.8",
|
"version": "1.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"delayed-stream": "~1.0.0"
|
"delayed-stream": "~1.0.0"
|
||||||
},
|
},
|
||||||
@@ -5730,7 +5740,6 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.4.0"
|
"node": ">=0.4.0"
|
||||||
}
|
}
|
||||||
@@ -6462,7 +6471,6 @@
|
|||||||
"version": "1.15.6",
|
"version": "1.15.6",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
|
||||||
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
|
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
|
||||||
"dev": true,
|
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -6508,7 +6516,6 @@
|
|||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"asynckit": "^0.4.0",
|
"asynckit": "^0.4.0",
|
||||||
"combined-stream": "^1.0.8",
|
"combined-stream": "^1.0.8",
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"@fortawesome/react-fontawesome": "^0.2.2",
|
"@fortawesome/react-fontawesome": "^0.2.2",
|
||||||
"alpinejs": "^3.13.3",
|
"alpinejs": "^3.13.3",
|
||||||
"autoprefixer": "^10.4.14",
|
"autoprefixer": "^10.4.14",
|
||||||
|
"axios": "^1.7.9",
|
||||||
"bootstrap": "^5.3.3",
|
"bootstrap": "^5.3.3",
|
||||||
"postcss-loader": "^7.1.0",
|
"postcss-loader": "^7.1.0",
|
||||||
"puppeteer": "^22.10.0",
|
"puppeteer": "^22.10.0",
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Domain\Manga\Application\Query;
|
namespace App\Domain\Manga\Application\Query;
|
||||||
|
|
||||||
readonly class GetManga
|
readonly class GetMangaById
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public string $id
|
public string $id
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
@@ -2,18 +2,18 @@
|
|||||||
|
|
||||||
namespace App\Domain\Manga\Application\QueryHandler;
|
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\Application\Response\MangaResponse;
|
||||||
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
||||||
use App\Domain\Manga\Domain\Exception\MangaNotFoundException;
|
use App\Domain\Manga\Domain\Exception\MangaNotFoundException;
|
||||||
|
|
||||||
readonly class GetMangaHandler
|
readonly class GetMangaByIdHandler
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private MangaRepositoryInterface $mangaRepository
|
private MangaRepositoryInterface $mangaRepository
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function handle(GetManga $query): MangaResponse
|
public function handle(GetMangaById $query): MangaResponse
|
||||||
{
|
{
|
||||||
$manga = $this->mangaRepository->findById($query->id);
|
$manga = $this->mangaRepository->findById($query->id);
|
||||||
|
|
||||||
@@ -35,4 +35,4 @@ readonly class GetMangaHandler
|
|||||||
rating: $manga->getRating()
|
rating: $manga->getRating()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,19 +4,19 @@ namespace App\Domain\Manga\Infrastructure\ApiPlatform\State\Provider;
|
|||||||
|
|
||||||
use ApiPlatform\Metadata\Operation;
|
use ApiPlatform\Metadata\Operation;
|
||||||
use ApiPlatform\State\ProviderInterface;
|
use ApiPlatform\State\ProviderInterface;
|
||||||
use App\Domain\Manga\Application\Query\GetManga;
|
use App\Domain\Manga\Application\Query\GetMangaById;
|
||||||
use App\Domain\Manga\Application\QueryHandler\GetMangaHandler;
|
use App\Domain\Manga\Application\QueryHandler\GetMangaByIdHandler;
|
||||||
use App\Domain\Manga\Infrastructure\ApiPlatform\Dto\MangaDetail;
|
use App\Domain\Manga\Infrastructure\ApiPlatform\Dto\MangaDetail;
|
||||||
|
|
||||||
readonly class GetMangaStateProvider implements ProviderInterface
|
readonly class GetMangaStateProvider implements ProviderInterface
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private GetMangaHandler $handler
|
private GetMangaByIdHandler $handler
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): MangaDetail
|
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);
|
$response = $this->handler->handle($query);
|
||||||
|
|
||||||
return new MangaDetail(
|
return new MangaDetail(
|
||||||
@@ -33,4 +33,4 @@ readonly class GetMangaStateProvider implements ProviderInterface
|
|||||||
rating: $response->rating
|
rating: $response->rating
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Tests\Domain\Manga\Application\QueryHandler;
|
namespace App\Tests\Domain\Manga\Application\QueryHandler;
|
||||||
|
|
||||||
use App\Domain\Manga\Application\Query\GetManga;
|
use App\Domain\Manga\Application\Query\GetMangaById;
|
||||||
use App\Domain\Manga\Application\QueryHandler\GetMangaHandler;
|
use App\Domain\Manga\Application\QueryHandler\GetMangaByIdHandler;
|
||||||
use App\Domain\Manga\Domain\Exception\MangaNotFoundException;
|
use App\Domain\Manga\Domain\Exception\MangaNotFoundException;
|
||||||
use App\Domain\Manga\Domain\Model\Manga;
|
use App\Domain\Manga\Domain\Model\Manga;
|
||||||
use App\Domain\Manga\Domain\Model\ValueObject\ExternalId;
|
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 App\Tests\Domain\Manga\Adapter\InMemoryMangaRepository;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class GetMangaHandlerTest extends TestCase
|
class GetMangaByIdHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
private InMemoryMangaRepository $repository;
|
private InMemoryMangaRepository $repository;
|
||||||
private GetMangaHandler $handler;
|
private GetMangaByIdHandler $handler;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->repository = new InMemoryMangaRepository();
|
$this->repository = new InMemoryMangaRepository();
|
||||||
$this->handler = new GetMangaHandler($this->repository);
|
$this->handler = new GetMangaByIdHandler($this->repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHandleThrowsExceptionWhenMangaNotFound(): void
|
public function testHandleThrowsExceptionWhenMangaNotFound(): void
|
||||||
{
|
{
|
||||||
$this->expectException(MangaNotFoundException::class);
|
$this->expectException(MangaNotFoundException::class);
|
||||||
|
|
||||||
$query = new GetManga('non-existent-id');
|
$query = new GetMangaById('non-existent-id');
|
||||||
$this->handler->handle($query);
|
$this->handler->handle($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ class GetMangaHandlerTest extends TestCase
|
|||||||
$this->repository->save($manga);
|
$this->repository->save($manga);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
$query = new GetManga('123');
|
$query = new GetMangaById('123');
|
||||||
$response = $this->handler->handle($query);
|
$response = $this->handler->handle($query);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
@@ -72,4 +72,4 @@ class GetMangaHandlerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->repository->clear();
|
$this->repository->clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user