diff --git a/app/Casts/DeliveryAddressCast.php b/app/Casts/DeliveryAddressCast.php index e3f4bf95..f456872e 100644 --- a/app/Casts/DeliveryAddressCast.php +++ b/app/Casts/DeliveryAddressCast.php @@ -8,7 +8,6 @@ use Domain\Models\ValueObjects\DeliveryAddress; use Illuminate\Contracts\Database\Eloquent\CastsAttributes; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Arr; -use InvalidArgumentException; /** @implements CastsAttributes */ class DeliveryAddressCast implements CastsAttributes @@ -30,7 +29,7 @@ class DeliveryAddressCast implements CastsAttributes } if (! is_string($value)) { - throw new InvalidArgumentException('The value must be a string.'); + throw new \InvalidArgumentException('The value must be a string.'); } $data = Arr::wrap(json_decode($value, true)); @@ -53,10 +52,10 @@ class DeliveryAddressCast implements CastsAttributes public function set(Model $model, string $key, mixed $value, array $attributes): string { if (! $value instanceof DeliveryAddress) { - throw new InvalidArgumentException('The value must be an instance of DeliveryAddress.'); + throw new \InvalidArgumentException('The value must be an instance of DeliveryAddress.'); } return json_encode($value->toArray(), JSON_UNESCAPED_UNICODE) ?: - throw new InvalidArgumentException('Cannot encode DeliveryAddress to JSON.'); + throw new \InvalidArgumentException('Cannot encode DeliveryAddress to JSON.'); } } diff --git a/app/Casts/DiscountValueCast.php b/app/Casts/DiscountValueCast.php index 5bb55d2d..6f6d144c 100644 --- a/app/Casts/DiscountValueCast.php +++ b/app/Casts/DiscountValueCast.php @@ -8,10 +8,8 @@ use Domain\Enums\DiscountType; use Domain\Models\ValueObjects\DiscountValue; use Illuminate\Contracts\Database\Eloquent\CastsAttributes; use Illuminate\Database\Eloquent\Model; -use InvalidArgumentException; use Money\Currency; use Money\Money; -use UnexpectedValueException; /** @implements CastsAttributes */ class DiscountValueCast implements CastsAttributes @@ -22,17 +20,17 @@ class DiscountValueCast implements CastsAttributes $typeRaw = $attributes['type'] ?? null; if ($typeRaw === null || (! is_int($typeRaw) && ! is_string($typeRaw))) { - throw new UnexpectedValueException('The discount type attribute is missing to cast the value.'); + throw new \UnexpectedValueException('The discount type attribute is missing to cast the value.'); } if ($value === null || (! is_int($value) && ! (is_string($value) && ctype_digit($value)))) { - throw new UnexpectedValueException('The discount value must be an integer or a numeric string.'); + throw new \UnexpectedValueException('The discount value must be an integer or a numeric string.'); } $type = DiscountType::tryFrom((int) $typeRaw); if ($type === null) { - throw new UnexpectedValueException("Unknown discount type raw value: {$typeRaw}"); + throw new \UnexpectedValueException("Unknown discount type raw value: {$typeRaw}"); } // Instanciation selon le type @@ -49,11 +47,11 @@ class DiscountValueCast implements CastsAttributes public function set(Model $model, string $key, mixed $value, array $attributes): int { if ($value === null) { - throw new InvalidArgumentException('The value cannot be null.'); + throw new \InvalidArgumentException('The value cannot be null.'); } if (! ($value instanceof DiscountValue)) { - throw new InvalidArgumentException('The value must be an instance of DiscountValue.'); + throw new \InvalidArgumentException('The value must be an instance of DiscountValue.'); } $discountValue = $value->value(); diff --git a/app/Casts/NutritionalValuesCast.php b/app/Casts/NutritionalValuesCast.php index 1c0a61e8..51d93b2f 100644 --- a/app/Casts/NutritionalValuesCast.php +++ b/app/Casts/NutritionalValuesCast.php @@ -8,7 +8,6 @@ use Domain\Models\ValueObjects\NutritionalValues; use Illuminate\Contracts\Database\Eloquent\CastsAttributes; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Arr; -use InvalidArgumentException; /** @implements CastsAttributes */ class NutritionalValuesCast implements CastsAttributes @@ -59,7 +58,7 @@ class NutritionalValuesCast implements CastsAttributes } if (! $value instanceof NutritionalValues) { - throw new InvalidArgumentException('The given value is not a NutritionalValues instance.'); + throw new \InvalidArgumentException('The given value is not a NutritionalValues instance.'); } return $value->toArray(); @@ -80,7 +79,7 @@ class NutritionalValuesCast implements CastsAttributes throw_if( $value !== null, - InvalidArgumentException::class, + \InvalidArgumentException::class, "Expected `{$key}` to be numeric of null" ); diff --git a/app/Casts/OrderEmployeeCast.php b/app/Casts/OrderEmployeeCast.php index 6abeec90..8ded1fb5 100644 --- a/app/Casts/OrderEmployeeCast.php +++ b/app/Casts/OrderEmployeeCast.php @@ -12,7 +12,6 @@ use Domain\Models\ValueObjects\ShopperSiteCode; use Illuminate\Contracts\Database\Eloquent\CastsAttributes; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Arr; -use InvalidArgumentException; /** @implements CastsAttributes */ class OrderEmployeeCast implements CastsAttributes @@ -25,7 +24,7 @@ class OrderEmployeeCast implements CastsAttributes } if (! is_string($value)) { - throw new InvalidArgumentException('The value must be a string.'); + throw new \InvalidArgumentException('The value must be a string.'); } $data = Arr::wrap(json_decode($value, true)); @@ -48,7 +47,7 @@ class OrderEmployeeCast implements CastsAttributes } if (! $value instanceof OrderEmployee) { - throw new InvalidArgumentException('The given value is not an instance of OrderEmployee.'); + throw new \InvalidArgumentException('The given value is not an instance of OrderEmployee.'); } return json_encode([ diff --git a/app/Casts/OrderLineProductCast.php b/app/Casts/OrderLineProductCast.php index 18241253..f98abc38 100644 --- a/app/Casts/OrderLineProductCast.php +++ b/app/Casts/OrderLineProductCast.php @@ -14,7 +14,6 @@ use Domain\Models\ValueObjects\ProductWeight; use Illuminate\Contracts\Database\Eloquent\CastsAttributes; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Arr; -use InvalidArgumentException; use Ramsey\Uuid\Uuid; use Symfony\Component\Uid\Uuid as SymfonyUuid; @@ -27,11 +26,11 @@ class OrderLineProductCast implements CastsAttributes public function get(Model $model, string $key, mixed $value, array $attributes): OrderLineProduct { if (is_null($value)) { - throw new InvalidArgumentException('The value cannot be null.'); + throw new \InvalidArgumentException('The value cannot be null.'); } if (! is_string($value)) { - throw new InvalidArgumentException('The value must be a string.'); + throw new \InvalidArgumentException('The value must be a string.'); } $data = Arr::wrap(json_decode($value, true)); @@ -67,7 +66,7 @@ class OrderLineProductCast implements CastsAttributes { if (! ($value instanceof OrderLineProduct)) { - throw new InvalidArgumentException('The given value is not an instance of OrderLineProduct.'); + throw new \InvalidArgumentException('The given value is not an instance of OrderLineProduct.'); } /** @var OrderLineProduct $value */ diff --git a/tests/Integration/WithApp/App/Actions/Ranges/CreateRangeTest.php b/tests/Integration/WithApp/App/Actions/Ranges/CreateRangeTest.php index 0590ae81..7d2064ea 100644 --- a/tests/Integration/WithApp/App/Actions/Ranges/CreateRangeTest.php +++ b/tests/Integration/WithApp/App/Actions/Ranges/CreateRangeTest.php @@ -10,12 +10,12 @@ use Domain\Models\ValueObjects\PictureMetadata; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Storage; -use InvalidArgumentException; uses(RefreshDatabase::class); describe('CreateRange action', function () { test('it creates and persists a range in database', function () { + /** @var \Tests\TestCase $this */ // GIVEN Storage::fake('public'); $action = new CreateRange(); @@ -56,6 +56,6 @@ describe('CreateRange action', function () { // WHEN & THEN expect(fn () => $action($invalidInput)) - ->toThrow(InvalidArgumentException::class); + ->toThrow(\InvalidArgumentException::class); }); }); diff --git a/tests/Integration/WithApp/App/Actions/Ranges/DeleteRangeTest.php b/tests/Integration/WithApp/App/Actions/Ranges/DeleteRangeTest.php index e012163b..6c433f09 100644 --- a/tests/Integration/WithApp/App/Actions/Ranges/DeleteRangeTest.php +++ b/tests/Integration/WithApp/App/Actions/Ranges/DeleteRangeTest.php @@ -7,12 +7,12 @@ use App\Actions\Ranges\DeleteRangeInput; use App\Contracts\ActionInput; use App\Models\Range; use Illuminate\Foundation\Testing\RefreshDatabase; -use InvalidArgumentException; uses(RefreshDatabase::class); describe('DeleteRange action', function () { test('it deletes an existing range from database', function () { + /** @var \Tests\TestCase $this */ // GIVEN $range = new Range(); $range->name = 'Gamme Temporaire'; @@ -43,6 +43,6 @@ describe('DeleteRange action', function () { // WHEN & THEN expect(fn () => $action($invalidInput)) - ->toThrow(InvalidArgumentException::class); + ->toThrow(\InvalidArgumentException::class); }); }); diff --git a/tests/Integration/WithApp/App/Actions/Ranges/UpdateRangeTest.php b/tests/Integration/WithApp/App/Actions/Ranges/UpdateRangeTest.php index 5fae6bd9..a0dfcdfd 100644 --- a/tests/Integration/WithApp/App/Actions/Ranges/UpdateRangeTest.php +++ b/tests/Integration/WithApp/App/Actions/Ranges/UpdateRangeTest.php @@ -10,12 +10,12 @@ use Domain\Models\ValueObjects\PictureMetadata; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Storage; -use InvalidArgumentException; uses(RefreshDatabase::class); describe('UpdateRange action', function () { test('it updates an existing range in database', function () { + /** @var \Tests\TestCase $this */ // GIVEN Storage::fake('public'); $range = new Range(); @@ -64,6 +64,6 @@ describe('UpdateRange action', function () { // WHEN & THEN expect(fn () => $action($invalidInput)) - ->toThrow(InvalidArgumentException::class); + ->toThrow(\InvalidArgumentException::class); }); }); diff --git a/tests/Integration/WithApp/App/Actions/Shops/CreateShopTest.php b/tests/Integration/WithApp/App/Actions/Shops/CreateShopTest.php index 5f9eefe8..d8c6cef3 100644 --- a/tests/Integration/WithApp/App/Actions/Shops/CreateShopTest.php +++ b/tests/Integration/WithApp/App/Actions/Shops/CreateShopTest.php @@ -9,7 +9,6 @@ use App\Models\Shop; use Domain\Models\ValueObjects\Coordinates; use Domain\Models\ValueObjects\PhoneNumber; use Illuminate\Foundation\Testing\RefreshDatabase; -use InvalidArgumentException; uses(RefreshDatabase::class); @@ -58,6 +57,6 @@ describe('CreateShop action', function () { // WHEN & THEN expect(fn () => $action($invalidInput)) - ->toThrow(InvalidArgumentException::class); + ->toThrow(\InvalidArgumentException::class); }); }); diff --git a/tests/Integration/WithApp/App/Actions/Shops/DeleteShopTest.php b/tests/Integration/WithApp/App/Actions/Shops/DeleteShopTest.php index a7e85799..9eb38171 100644 --- a/tests/Integration/WithApp/App/Actions/Shops/DeleteShopTest.php +++ b/tests/Integration/WithApp/App/Actions/Shops/DeleteShopTest.php @@ -7,7 +7,6 @@ use App\Actions\Shops\DeleteShopInput; use App\Contracts\ActionInput; use App\Models\Shop; use Illuminate\Foundation\Testing\RefreshDatabase; -use InvalidArgumentException; uses(RefreshDatabase::class); @@ -38,6 +37,6 @@ describe('DeleteShop action', function () { // WHEN & THEN expect(fn () => $action($invalidInput)) - ->toThrow(InvalidArgumentException::class); + ->toThrow(\InvalidArgumentException::class); }); }); diff --git a/tests/Integration/WithApp/App/Actions/Shops/UpdateShopPickupExceptionsTest.php b/tests/Integration/WithApp/App/Actions/Shops/UpdateShopPickupExceptionsTest.php index 8ebadc57..df17c93e 100644 --- a/tests/Integration/WithApp/App/Actions/Shops/UpdateShopPickupExceptionsTest.php +++ b/tests/Integration/WithApp/App/Actions/Shops/UpdateShopPickupExceptionsTest.php @@ -8,7 +8,6 @@ use App\Contracts\ActionInput; use App\Models\PickupException; use App\Models\Shop; use Illuminate\Foundation\Testing\RefreshDatabase; -use InvalidArgumentException; uses(RefreshDatabase::class); @@ -62,6 +61,6 @@ describe('UpdateShopPickupExceptions action', function () { // WHEN & THEN expect(fn () => $action($invalidInput)) - ->toThrow(InvalidArgumentException::class); + ->toThrow(\InvalidArgumentException::class); }); }); diff --git a/tests/Integration/WithApp/App/Actions/Shops/UpdateShopTest.php b/tests/Integration/WithApp/App/Actions/Shops/UpdateShopTest.php index db86fc29..23311324 100644 --- a/tests/Integration/WithApp/App/Actions/Shops/UpdateShopTest.php +++ b/tests/Integration/WithApp/App/Actions/Shops/UpdateShopTest.php @@ -9,7 +9,6 @@ use App\Models\Shop; use Domain\Models\ValueObjects\Coordinates; use Domain\Models\ValueObjects\PhoneNumber; use Illuminate\Foundation\Testing\RefreshDatabase; -use InvalidArgumentException; uses(RefreshDatabase::class); @@ -66,6 +65,6 @@ describe('UpdateShop action', function () { // WHEN & THEN expect(fn () => $action($invalidInput)) - ->toThrow(InvalidArgumentException::class); + ->toThrow(\InvalidArgumentException::class); }); }); diff --git a/tests/Integration/WithApp/App/Queries/Shops/GetShopQueryTest.php b/tests/Integration/WithApp/App/Queries/Shops/GetShopQueryTest.php index bf555fbd..e84cc5d0 100644 --- a/tests/Integration/WithApp/App/Queries/Shops/GetShopQueryTest.php +++ b/tests/Integration/WithApp/App/Queries/Shops/GetShopQueryTest.php @@ -13,7 +13,6 @@ use App\Queries\Shops\GetShopQueryInput; use Carbon\Carbon; use Domain\Enums\RepeatFrequency; use Illuminate\Database\Eloquent\ModelNotFoundException; -use InvalidArgumentException; describe('GetShopQuery', function (): void { it('returns the default shop mapped as ShopDto with pickup exceptions', function (): void { @@ -77,6 +76,6 @@ describe('GetShopQuery', function (): void { expect( /** @phpstan-ignore argument.type */ fn () => $query($invalidInput) - )->toThrow(InvalidArgumentException::class); + )->toThrow(\InvalidArgumentException::class); }); }); diff --git a/tests/Unit/App/Actions/Discounts/CreateDiscountInputTest.php b/tests/Unit/App/Actions/Discounts/CreateDiscountInputTest.php index 7aa7f5ac..6456490b 100644 --- a/tests/Unit/App/Actions/Discounts/CreateDiscountInputTest.php +++ b/tests/Unit/App/Actions/Discounts/CreateDiscountInputTest.php @@ -8,7 +8,6 @@ use App\Actions\Discounts\CreateDiscountInput; use Domain\Enums\DiscountType; use Domain\Models\ValueObjects\DatePeriod; use Domain\Models\ValueObjects\DiscountValue; -use InvalidArgumentException; use Money\Currency; use Money\Money; @@ -67,7 +66,7 @@ describe('CreateDiscountInput', function (): void { is_old_price_displayed: true, )) // THEN - ->toThrow(InvalidArgumentException::class, 'The discount value type must match the discount type.'); + ->toThrow(\InvalidArgumentException::class, 'The discount value type must match the discount type.'); }); it('throws when associatedProductsIds contains non-string items', function (): void { @@ -83,6 +82,6 @@ describe('CreateDiscountInput', function (): void { associatedProductsIds: [123], // @phpstan-ignore argument.type )) // THEN - ->toThrow(InvalidArgumentException::class); + ->toThrow(\InvalidArgumentException::class); }); }); diff --git a/tests/Unit/App/Actions/Discounts/UpdateDiscountInputTest.php b/tests/Unit/App/Actions/Discounts/UpdateDiscountInputTest.php index f8673968..0cfb6731 100644 --- a/tests/Unit/App/Actions/Discounts/UpdateDiscountInputTest.php +++ b/tests/Unit/App/Actions/Discounts/UpdateDiscountInputTest.php @@ -9,7 +9,6 @@ use App\Models\Discount; use Domain\Enums\DiscountType; use Domain\Models\ValueObjects\DatePeriod; use Domain\Models\ValueObjects\DiscountValue; -use InvalidArgumentException; use Money\Currency; use Money\Money; @@ -75,7 +74,7 @@ describe('UpdateDiscountInput', function (): void { is_old_price_displayed: true, )) // THEN - ->toThrow(InvalidArgumentException::class, 'The discount value type must match the discount type.'); + ->toThrow(\InvalidArgumentException::class, 'The discount value type must match the discount type.'); }); it('throws when associatedProductsIds contains non-string items', function (): void { @@ -93,6 +92,6 @@ describe('UpdateDiscountInput', function (): void { associatedProductsIds: [123], // @phpstan-ignore argument.type )) // THEN - ->toThrow(InvalidArgumentException::class); + ->toThrow(\InvalidArgumentException::class); }); }); diff --git a/tests/Unit/App/Actions/Ranges/CreateRangeInputTest.php b/tests/Unit/App/Actions/Ranges/CreateRangeInputTest.php index d177dd6b..6855b9f1 100644 --- a/tests/Unit/App/Actions/Ranges/CreateRangeInputTest.php +++ b/tests/Unit/App/Actions/Ranges/CreateRangeInputTest.php @@ -5,7 +5,6 @@ declare(strict_types=1); use App\Actions\Ranges\CreateRangeInput; use Domain\Models\ValueObjects\PictureMetadata; use Illuminate\Http\UploadedFile; -use InvalidArgumentException; describe('CreateRangeInput', function () { test('it can be instantiated with valid data without picture', function () { @@ -62,7 +61,7 @@ describe('CreateRangeInput', function () { picture: null, pictureMetadata: new PictureMetadata(), status: true, - ))->toThrow(InvalidArgumentException::class, 'The range name cannot be empty.'); + ))->toThrow(\InvalidArgumentException::class, 'The range name cannot be empty.'); }); test('it throws when name is shorter than 2 characters', function () { @@ -76,7 +75,7 @@ describe('CreateRangeInput', function () { picture: null, pictureMetadata: new PictureMetadata(), status: true, - ))->toThrow(InvalidArgumentException::class, 'The range name must be at least 2 characters.'); + ))->toThrow(\InvalidArgumentException::class, 'The range name must be at least 2 characters.'); }); test('it throws when name exceeds 45 characters', function () { @@ -90,7 +89,7 @@ describe('CreateRangeInput', function () { picture: null, pictureMetadata: new PictureMetadata(), status: true, - ))->toThrow(InvalidArgumentException::class, 'The range name cannot exceed 45 characters.'); + ))->toThrow(\InvalidArgumentException::class, 'The range name cannot exceed 45 characters.'); }); test('it throws when picture is provided without alt', function () { @@ -105,7 +104,7 @@ describe('CreateRangeInput', function () { picture: $picture, pictureMetadata: $pictureMetadata, status: true, - ))->toThrow(InvalidArgumentException::class, 'Picture alt is required when picture is provided.'); + ))->toThrow(\InvalidArgumentException::class, 'Picture alt is required when picture is provided.'); }); test('it throws when picture is provided without title', function () { @@ -120,6 +119,6 @@ describe('CreateRangeInput', function () { picture: $picture, pictureMetadata: $pictureMetadata, status: true, - ))->toThrow(InvalidArgumentException::class, 'Picture title is required when picture is provided.'); + ))->toThrow(\InvalidArgumentException::class, 'Picture title is required when picture is provided.'); }); }); diff --git a/tests/Unit/App/Actions/Ranges/UpdateRangeInputTest.php b/tests/Unit/App/Actions/Ranges/UpdateRangeInputTest.php index 26f535b8..76c9b49d 100644 --- a/tests/Unit/App/Actions/Ranges/UpdateRangeInputTest.php +++ b/tests/Unit/App/Actions/Ranges/UpdateRangeInputTest.php @@ -6,7 +6,6 @@ use App\Actions\Ranges\UpdateRangeInput; use App\Models\Range; use Domain\Models\ValueObjects\PictureMetadata; use Illuminate\Http\UploadedFile; -use InvalidArgumentException; describe('UpdateRangeInput', function () { test('it can be instantiated with valid data', function () { @@ -46,7 +45,7 @@ describe('UpdateRangeInput', function () { picture: null, pictureMetadata: new PictureMetadata(), status: true, - ))->toThrow(InvalidArgumentException::class, 'The range name cannot be empty.'); + ))->toThrow(\InvalidArgumentException::class, 'The range name cannot be empty.'); }); test('it throws when picture is provided without alt or title', function () { @@ -62,6 +61,6 @@ describe('UpdateRangeInput', function () { picture: $picture, pictureMetadata: new PictureMetadata(alt: null, title: 'Title'), status: true, - ))->toThrow(InvalidArgumentException::class, 'Picture alt is required when picture is provided.'); + ))->toThrow(\InvalidArgumentException::class, 'Picture alt is required when picture is provided.'); }); }); diff --git a/tests/Unit/App/Actions/Shops/CreateShopInputTest.php b/tests/Unit/App/Actions/Shops/CreateShopInputTest.php index 9b85a886..7a92f4fc 100644 --- a/tests/Unit/App/Actions/Shops/CreateShopInputTest.php +++ b/tests/Unit/App/Actions/Shops/CreateShopInputTest.php @@ -5,7 +5,6 @@ declare(strict_types=1); use App\Actions\Shops\CreateShopInput; use Domain\Models\ValueObjects\Coordinates; use Domain\Models\ValueObjects\PhoneNumber; -use InvalidArgumentException; describe('CreateShopInput', function () { test('it can be instantiated with valid data', function () { @@ -67,7 +66,7 @@ describe('CreateShopInput', function () { phone: null, coordinates: null, default: false, - ))->toThrow(InvalidArgumentException::class, 'Shop name cannot be empty.'); + ))->toThrow(\InvalidArgumentException::class, 'Shop name cannot be empty.'); }); test('it throws when address is empty', function () { @@ -80,7 +79,7 @@ describe('CreateShopInput', function () { phone: null, coordinates: null, default: false, - ))->toThrow(InvalidArgumentException::class, 'Shop address cannot be empty.'); + ))->toThrow(\InvalidArgumentException::class, 'Shop address cannot be empty.'); }); test('it throws when postcode is empty', function () { @@ -93,7 +92,7 @@ describe('CreateShopInput', function () { phone: null, coordinates: null, default: false, - ))->toThrow(InvalidArgumentException::class, 'Shop postcode cannot be empty.'); + ))->toThrow(\InvalidArgumentException::class, 'Shop postcode cannot be empty.'); }); test('it throws when city is empty', function () { @@ -106,7 +105,7 @@ describe('CreateShopInput', function () { phone: null, coordinates: null, default: false, - ))->toThrow(InvalidArgumentException::class, 'Shop city cannot be empty.'); + ))->toThrow(\InvalidArgumentException::class, 'Shop city cannot be empty.'); }); test('it throws when name exceeds 255 characters', function () { @@ -119,6 +118,6 @@ describe('CreateShopInput', function () { phone: null, coordinates: null, default: false, - ))->toThrow(InvalidArgumentException::class, 'Shop name cannot exceed 255 characters.'); + ))->toThrow(\InvalidArgumentException::class, 'Shop name cannot exceed 255 characters.'); }); }); diff --git a/tests/Unit/App/Actions/Shops/UpdateShopInputTest.php b/tests/Unit/App/Actions/Shops/UpdateShopInputTest.php index 8af2d4ee..7a17ec02 100644 --- a/tests/Unit/App/Actions/Shops/UpdateShopInputTest.php +++ b/tests/Unit/App/Actions/Shops/UpdateShopInputTest.php @@ -6,7 +6,6 @@ use App\Actions\Shops\UpdateShopInput; use App\Models\Shop; use Domain\Models\ValueObjects\Coordinates; use Domain\Models\ValueObjects\PhoneNumber; -use InvalidArgumentException; describe('UpdateShopInput', function () { test('it can be instantiated with valid data', function () { @@ -57,7 +56,7 @@ describe('UpdateShopInput', function () { phone: null, coordinates: null, default: false, - ))->toThrow(InvalidArgumentException::class, 'Shop name cannot be empty.'); + ))->toThrow(\InvalidArgumentException::class, 'Shop name cannot be empty.'); }); test('it throws when address is empty', function () { @@ -74,7 +73,7 @@ describe('UpdateShopInput', function () { phone: null, coordinates: null, default: false, - ))->toThrow(InvalidArgumentException::class, 'Shop address cannot be empty.'); + ))->toThrow(\InvalidArgumentException::class, 'Shop address cannot be empty.'); }); test('it throws when postcode is empty', function () { @@ -91,7 +90,7 @@ describe('UpdateShopInput', function () { phone: null, coordinates: null, default: false, - ))->toThrow(InvalidArgumentException::class, 'Shop postcode cannot be empty.'); + ))->toThrow(\InvalidArgumentException::class, 'Shop postcode cannot be empty.'); }); test('it throws when city is empty', function () { @@ -108,7 +107,7 @@ describe('UpdateShopInput', function () { phone: null, coordinates: null, default: false, - ))->toThrow(InvalidArgumentException::class, 'Shop city cannot be empty.'); + ))->toThrow(\InvalidArgumentException::class, 'Shop city cannot be empty.'); }); test('it throws when name exceeds 255 characters', function () { @@ -125,6 +124,6 @@ describe('UpdateShopInput', function () { phone: null, coordinates: null, default: false, - ))->toThrow(InvalidArgumentException::class, 'Shop name cannot exceed 255 characters.'); + ))->toThrow(\InvalidArgumentException::class, 'Shop name cannot exceed 255 characters.'); }); }); diff --git a/tests/Unit/App/Actions/Shops/UpdateShopPickupExceptionsInputTest.php b/tests/Unit/App/Actions/Shops/UpdateShopPickupExceptionsInputTest.php index 37fc369c..1c00d986 100644 --- a/tests/Unit/App/Actions/Shops/UpdateShopPickupExceptionsInputTest.php +++ b/tests/Unit/App/Actions/Shops/UpdateShopPickupExceptionsInputTest.php @@ -4,7 +4,6 @@ declare(strict_types=1); use App\Actions\Shops\UpdateShopPickupExceptionsInput; use App\Models\Shop; -use InvalidArgumentException; describe('UpdateShopPickupExceptionsInput', function () { test('it can be instantiated with shop and valid sync data', function () { @@ -57,7 +56,7 @@ describe('UpdateShopPickupExceptionsInput', function () { // WHEN & THEN /** @phpstan-ignore-next-line */ expect(fn () => new UpdateShopPickupExceptionsInput(shop: $shop, syncData: $invalidSyncData)) - ->toThrow(InvalidArgumentException::class, 'Each sync item must be an array.'); + ->toThrow(\InvalidArgumentException::class, 'Each sync item must be an array.'); }); test('it throws when replacement_date key is missing', function () { @@ -72,7 +71,7 @@ describe('UpdateShopPickupExceptionsInput', function () { // WHEN & THEN /** @phpstan-ignore-next-line */ expect(fn () => new UpdateShopPickupExceptionsInput(shop: $shop, syncData: $invalidSyncData)) - ->toThrow(InvalidArgumentException::class, 'Sync item must contain replacement_date key.'); + ->toThrow(\InvalidArgumentException::class, 'Sync item must contain replacement_date key.'); }); test('it throws when order_deadline_at key is missing', function () { @@ -87,7 +86,7 @@ describe('UpdateShopPickupExceptionsInput', function () { // WHEN & THEN /** @phpstan-ignore-next-line */ expect(fn () => new UpdateShopPickupExceptionsInput(shop: $shop, syncData: $invalidSyncData)) - ->toThrow(InvalidArgumentException::class, 'Sync item must contain order_deadline_at key.'); + ->toThrow(\InvalidArgumentException::class, 'Sync item must contain order_deadline_at key.'); }); test('it throws when replacement_date is not string or null', function () { @@ -103,7 +102,7 @@ describe('UpdateShopPickupExceptionsInput', function () { // WHEN & THEN /** @phpstan-ignore-next-line */ expect(fn () => new UpdateShopPickupExceptionsInput(shop: $shop, syncData: $invalidSyncData)) - ->toThrow(InvalidArgumentException::class, 'replacement_date must be a string or null.'); + ->toThrow(\InvalidArgumentException::class, 'replacement_date must be a string or null.'); }); test('it throws when order_deadline_at is not string or null', function () { @@ -119,7 +118,7 @@ describe('UpdateShopPickupExceptionsInput', function () { // WHEN & THEN /** @phpstan-ignore-next-line */ expect(fn () => new UpdateShopPickupExceptionsInput(shop: $shop, syncData: $invalidSyncData)) - ->toThrow(InvalidArgumentException::class, 'order_deadline_at must be a string or null.'); + ->toThrow(\InvalidArgumentException::class, 'order_deadline_at must be a string or null.'); }); test('it throws when order_deadline_at is set but replacement_date is null', function () { @@ -134,7 +133,7 @@ describe('UpdateShopPickupExceptionsInput', function () { // WHEN & THEN expect(fn () => new UpdateShopPickupExceptionsInput(shop: $shop, syncData: $invalidSyncData)) - ->toThrow(InvalidArgumentException::class, 'A replacement date is required when an order deadline is set.'); + ->toThrow(\InvalidArgumentException::class, 'A replacement date is required when an order deadline is set.'); }); test('it throws when order_deadline_at is after replacement_date', function () { @@ -149,7 +148,7 @@ describe('UpdateShopPickupExceptionsInput', function () { // WHEN & THEN expect(fn () => new UpdateShopPickupExceptionsInput(shop: $shop, syncData: $invalidSyncData)) - ->toThrow(InvalidArgumentException::class, 'Order deadline must be strictly before the replacement date.'); + ->toThrow(\InvalidArgumentException::class, 'Order deadline must be strictly before the replacement date.'); }); test('it throws when order_deadline_at is equal to replacement_date', function () { @@ -164,6 +163,6 @@ describe('UpdateShopPickupExceptionsInput', function () { // WHEN & THEN expect(fn () => new UpdateShopPickupExceptionsInput(shop: $shop, syncData: $invalidSyncData)) - ->toThrow(InvalidArgumentException::class, 'Order deadline must be strictly before the replacement date.'); + ->toThrow(\InvalidArgumentException::class, 'Order deadline must be strictly before the replacement date.'); }); }); diff --git a/tests/Unit/Domain/Models/ValueObjects/PictureMetadataTest.php b/tests/Unit/Domain/Models/ValueObjects/PictureMetadataTest.php index 53dad58d..1cb03777 100644 --- a/tests/Unit/Domain/Models/ValueObjects/PictureMetadataTest.php +++ b/tests/Unit/Domain/Models/ValueObjects/PictureMetadataTest.php @@ -3,7 +3,6 @@ declare(strict_types=1); use Domain\Models\ValueObjects\PictureMetadata; -use InvalidArgumentException; describe('PictureMetadata Value Object', function () { test('it can be instantiated with null values', function () { @@ -34,7 +33,7 @@ describe('PictureMetadata Value Object', function () { // WHEN & THEN expect(fn () => new PictureMetadata(alt: $invalidAlt)) - ->toThrow(InvalidArgumentException::class, 'Picture alt cannot be empty when provided.'); + ->toThrow(\InvalidArgumentException::class, 'Picture alt cannot be empty when provided.'); }); test('it throws when alt is shorter than 4 characters', function () { @@ -43,7 +42,7 @@ describe('PictureMetadata Value Object', function () { // WHEN & THEN expect(fn () => new PictureMetadata(alt: $shortAlt)) - ->toThrow(InvalidArgumentException::class, 'Picture alt must be at least 4 characters.'); + ->toThrow(\InvalidArgumentException::class, 'Picture alt must be at least 4 characters.'); }); test('it throws when alt exceeds 75 characters', function () { @@ -52,7 +51,7 @@ describe('PictureMetadata Value Object', function () { // WHEN & THEN expect(fn () => new PictureMetadata(alt: $longAlt)) - ->toThrow(InvalidArgumentException::class, 'Picture alt cannot exceed 75 characters.'); + ->toThrow(\InvalidArgumentException::class, 'Picture alt cannot exceed 75 characters.'); }); test('it throws when title is empty string', function () { @@ -61,7 +60,7 @@ describe('PictureMetadata Value Object', function () { // WHEN & THEN expect(fn () => new PictureMetadata(title: $invalidTitle)) - ->toThrow(InvalidArgumentException::class, 'Picture title cannot be empty when provided.'); + ->toThrow(\InvalidArgumentException::class, 'Picture title cannot be empty when provided.'); }); test('it throws when title is shorter than 4 characters', function () { @@ -70,7 +69,7 @@ describe('PictureMetadata Value Object', function () { // WHEN & THEN expect(fn () => new PictureMetadata(title: $shortTitle)) - ->toThrow(InvalidArgumentException::class, 'Picture title must be at least 4 characters.'); + ->toThrow(\InvalidArgumentException::class, 'Picture title must be at least 4 characters.'); }); test('it throws when title exceeds 75 characters', function () { @@ -79,6 +78,6 @@ describe('PictureMetadata Value Object', function () { // WHEN & THEN expect(fn () => new PictureMetadata(title: $longTitle)) - ->toThrow(InvalidArgumentException::class, 'Picture title cannot exceed 75 characters.'); + ->toThrow(\InvalidArgumentException::class, 'Picture title cannot exceed 75 characters.'); }); }); diff --git a/tests/Unit/Domain/Models/ValueObjects/SlugTest.php b/tests/Unit/Domain/Models/ValueObjects/SlugTest.php index d2ad1a35..6e817f55 100644 --- a/tests/Unit/Domain/Models/ValueObjects/SlugTest.php +++ b/tests/Unit/Domain/Models/ValueObjects/SlugTest.php @@ -3,7 +3,6 @@ declare(strict_types=1); use Domain\Models\ValueObjects\Slug; -use InvalidArgumentException; describe('Slug Value Object', function () { test('it can be instantiated with a valid slug', function () { @@ -24,7 +23,7 @@ describe('Slug Value Object', function () { // WHEN & THEN expect(fn () => new Slug($empty)) - ->toThrow(InvalidArgumentException::class, 'Slug cannot be empty.'); + ->toThrow(\InvalidArgumentException::class, 'Slug cannot be empty.'); }); test('it throws when slug exceeds 255 characters', function () { @@ -33,7 +32,7 @@ describe('Slug Value Object', function () { // WHEN & THEN expect(fn () => new Slug($long)) - ->toThrow(InvalidArgumentException::class, 'Slug cannot exceed 255 characters.'); + ->toThrow(\InvalidArgumentException::class, 'Slug cannot exceed 255 characters.'); }); test('it throws when slug format is invalid', function () { @@ -42,7 +41,7 @@ describe('Slug Value Object', function () { // WHEN & THEN expect(fn () => new Slug($invalid)) - ->toThrow(InvalidArgumentException::class, 'Slug format is invalid.'); + ->toThrow(\InvalidArgumentException::class, 'Slug format is invalid.'); }); test('it creates slug from raw string with fromString', function () { @@ -63,6 +62,6 @@ describe('Slug Value Object', function () { // WHEN & THEN expect(fn () => Slug::fromString($raw)) - ->toThrow(InvalidArgumentException::class, 'Cannot generate a valid slug from given string.'); + ->toThrow(\InvalidArgumentException::class, 'Cannot generate a valid slug from given string.'); }); }); diff --git a/tests/Unit/Infra/Adapters/Services/AppCustomerAuthServiceTest.php b/tests/Unit/Infra/Adapters/Services/AppCustomerAuthServiceTest.php index 2b71dfc8..e263dddf 100644 --- a/tests/Unit/Infra/Adapters/Services/AppCustomerAuthServiceTest.php +++ b/tests/Unit/Infra/Adapters/Services/AppCustomerAuthServiceTest.php @@ -17,7 +17,6 @@ use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Contracts\Auth\StatefulGuard; use Illuminate\Contracts\Debug\ExceptionHandler; use Infrastructure\Adapters\Services\AppCustomerAuthService; -use InvalidArgumentException; use Mockery; use Ramsey\Uuid\Uuid; use stdClass; @@ -99,7 +98,7 @@ describe('AppCustomerAuthService', function (): void { $action = fn () => $service->logIn($invalidCustomer); // THEN - expect($action)->toThrow(InvalidArgumentException::class, 'Expected an instance of Authenticatable and Customer for logging in'); + expect($action)->toThrow(\InvalidArgumentException::class, 'Expected an instance of Authenticatable and Customer for logging in'); }); it('logs out', function (): void { @@ -204,7 +203,7 @@ describe('AppCustomerAuthService', function (): void { $action = fn () => $service->getCustomer(); // THEN - expect($action)->toThrow(InvalidArgumentException::class, 'Auth service needs a frontend guard'); + expect($action)->toThrow(\InvalidArgumentException::class, 'Auth service needs a frontend guard'); }); it('gets customer as mandatory', function (): void {