Refactored the codebase to change the namespaces of various actions and queries from `App\Actions` to `App\Cqs\Actions` and `App\Queries` to `App\Cqs\Queries`. This restructuring improves organization and clarity in the codebase.
52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\App\Cqs\Queries\ProductIncos;
|
|
|
|
use App\Cqs\Queries\ProductIncos\GetArcadiaIncoPreviewQuery;
|
|
use App\Cqs\Queries\ProductIncos\GetArcadiaIncoPreviewQueryInput;
|
|
use App\Dto\ArcadiaIncoPreviewDto;
|
|
use App\Services\ArcadiaIncoService;
|
|
|
|
describe('GetArcadiaIncoPreviewQuery', function (): void {
|
|
it('executes preview query successfully', function (): void {
|
|
// GIVEN
|
|
$service = \Mockery::mock(ArcadiaIncoService::class);
|
|
$previewDto = new ArcadiaIncoPreviewDto(
|
|
noArt: 27996,
|
|
name: 'POULET JAUNE',
|
|
libelle: 'Poulet Jaune PAC',
|
|
brand: 'Le Gaulois',
|
|
nutriscore: 'A',
|
|
servings: '4/5',
|
|
allergens: 'Aucun',
|
|
ingredients: '<p>Poulet</p>',
|
|
energyKcal: 149.0,
|
|
energyKj: 623.0
|
|
);
|
|
|
|
$service->shouldReceive('getPreview')
|
|
->once()
|
|
->with(27996)
|
|
->andReturn($previewDto);
|
|
|
|
$query = new GetArcadiaIncoPreviewQuery($service);
|
|
$input = new GetArcadiaIncoPreviewQueryInput(noArt: 27996);
|
|
|
|
// WHEN
|
|
$result = $query($input);
|
|
|
|
// THEN
|
|
expect($result)->toBe($previewDto);
|
|
});
|
|
|
|
it('throws when noArt is less than 1', function (): void {
|
|
// GIVEN
|
|
$invalidNoArt = 0;
|
|
|
|
// WHEN & THEN
|
|
expect(fn () => new GetArcadiaIncoPreviewQueryInput(noArt: $invalidNoArt))
|
|
->toThrow(\InvalidArgumentException::class);
|
|
});
|
|
});
|