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",
|
||||
"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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Domain\Manga\Application\Query;
|
||||
|
||||
readonly class GetManga
|
||||
readonly class GetMangaById
|
||||
{
|
||||
public function __construct(
|
||||
public string $id
|
||||
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user