test(uuid): migrate test suite to UuidHelper and add missing describe blocks
This commit is contained in:
parent
75784ae719
commit
d9edcd7f6b
117 changed files with 1838 additions and 1821 deletions
|
|
@ -29,7 +29,7 @@ use Illuminate\Support\Facades\App;
|
|||
use Illuminate\Support\Facades\Date;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
use function Pest\Laravel\get;
|
||||
|
||||
|
|
@ -57,9 +57,9 @@ describe('Bo\OrdersController', function (): void {
|
|||
// GIVEN
|
||||
$shop = Shop::factory()->create(['name' => 'Boutique Test']);
|
||||
Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(2500, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -91,9 +91,9 @@ describe('Bo\OrdersController', function (): void {
|
|||
$shop = Shop::factory()->create(['name' => 'Boutique Pagination']);
|
||||
for ($i = 0; $i < 30; $i++) {
|
||||
Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(2500, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -123,12 +123,12 @@ describe('Bo\OrdersController', function (): void {
|
|||
it('can filter index by search term', function (): void {
|
||||
/** @var \Tests\TestCase $this */
|
||||
// GIVEN
|
||||
$refUuid = Uuid::uuid7();
|
||||
$refUuid = UuidHelper::v7();
|
||||
$reference = new OrderReference($refUuid);
|
||||
$ref = (string) $reference;
|
||||
$shop = Shop::factory()->create(['name' => 'UniqueShopSearch']);
|
||||
Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => $reference,
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
|
|
@ -163,9 +163,9 @@ describe('Bo\OrdersController', function (): void {
|
|||
// GIVEN
|
||||
$shop = Shop::factory()->create();
|
||||
$olderOrder = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7(Date::now()->subHours(2))->toString(),
|
||||
'id' => UuidHelper::v7(Date::now()->subHours(2))->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(1000, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -180,9 +180,9 @@ describe('Bo\OrdersController', function (): void {
|
|||
'pickup_day' => Date::now()->addDays(7)->toDateString(),
|
||||
]);
|
||||
$newerOrder = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7(Date::now())->toString(),
|
||||
'id' => UuidHelper::v7(Date::now())->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(2000, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -213,9 +213,9 @@ describe('Bo\OrdersController', function (): void {
|
|||
// GIVEN
|
||||
$shop = Shop::factory()->create();
|
||||
$todayOrder = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7(Date::now())->toString(),
|
||||
'id' => UuidHelper::v7(Date::now())->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(3000, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -230,9 +230,9 @@ describe('Bo\OrdersController', function (): void {
|
|||
'pickup_day' => Date::now()->addDays(7)->toDateString(),
|
||||
]);
|
||||
$pastOrder = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7(Date::now()->subDays(3))->toString(),
|
||||
'id' => UuidHelper::v7(Date::now()->subDays(3))->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(4000, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -264,8 +264,8 @@ describe('Bo\OrdersController', function (): void {
|
|||
// GIVEN
|
||||
$shop = Shop::factory()->create();
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
'email' => new Email('customer@example.com'),
|
||||
]);
|
||||
Employee::query()->forceCreate([
|
||||
|
|
@ -287,9 +287,9 @@ describe('Bo\OrdersController', function (): void {
|
|||
App::instance(CrmService::class, $crmMock);
|
||||
|
||||
$order = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(4000, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -318,9 +318,9 @@ describe('Bo\OrdersController', function (): void {
|
|||
// GIVEN
|
||||
$shop = Shop::factory()->create();
|
||||
$order = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(2000, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -364,9 +364,9 @@ describe('Bo\OrdersController', function (): void {
|
|||
// GIVEN
|
||||
$shop = Shop::factory()->create();
|
||||
$order = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::CANCELED->value,
|
||||
'total' => new Money(2000, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -392,9 +392,9 @@ describe('Bo\OrdersController', function (): void {
|
|||
// GIVEN
|
||||
$shop = Shop::factory()->create();
|
||||
$validated = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(2500, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -409,9 +409,9 @@ describe('Bo\OrdersController', function (): void {
|
|||
'pickup_day' => Date::now()->toDateString(),
|
||||
]);
|
||||
$failed = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::FAILED->value,
|
||||
'total' => new Money(1500, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use Infrastructure\Adapters\Repositories\SessionBasketRepository;
|
|||
use Infrastructure\Adapters\Serializers\BasketSerializer;
|
||||
use Infrastructure\Adapters\Services\AppSessionService;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('BasketController', function () {
|
||||
it('can access post /ajax/basket/add', function () {
|
||||
|
|
@ -111,9 +111,9 @@ describe('BasketController', function () {
|
|||
Cache::flush();
|
||||
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'email' => new Email('basket-nplusone@example.com'),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
]);
|
||||
|
||||
$range = new Range();
|
||||
|
|
@ -156,7 +156,7 @@ describe('BasketController', function () {
|
|||
$product->save();
|
||||
|
||||
$basket->addOrUpdate(new BasketProduct(
|
||||
id: new ProductId(Uuid::fromString((string) $product->id)),
|
||||
id: new ProductId(UuidHelper::fromString((string) $product->id)),
|
||||
name: $product->name,
|
||||
qty: 1,
|
||||
unitPriceHt: Money::EUR(1000),
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use Database\Seeders\ContentSeeder;
|
|||
use Domain\Models\ValueObjects\Email;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('PickupController', function (): void {
|
||||
|
|
@ -46,7 +46,7 @@ describe('PickupController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('employee@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
$this->withoutMiddleware([
|
||||
|
|
@ -74,7 +74,7 @@ describe('PickupController', function (): void {
|
|||
$shop = Shop::factory()->create();
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('employee2@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
$this->withoutMiddleware([
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use Domain\Models\ValueObjects\Email;
|
|||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('ProductsController (Ajax)', function () {
|
||||
|
|
@ -79,7 +79,7 @@ describe('ProductsController (Ajax)', function () {
|
|||
Cache::flush();
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test1@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ describe('ProductsController (Ajax)', function () {
|
|||
Cache::flush();
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test2@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use Illuminate\Support\Facades\Date;
|
|||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\Str;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('LoginController', function () {
|
||||
|
|
@ -119,7 +119,7 @@ describe('LoginController', function () {
|
|||
Cache::flush();
|
||||
$user = \Mockery::mock(Customer::class)->makePartial();
|
||||
$user->shouldReceive('getAuthIdentifier')->andReturn(1);
|
||||
$user->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$user->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$user->shouldReceive('getAuthPassword')->andReturn('dummy');
|
||||
$this->actingAs($user, 'frontend');
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use Illuminate\Http\RedirectResponse;
|
|||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\ViewErrorBag;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ describe('RegisterController', function () {
|
|||
/** @var \Tests\TestCase $this */
|
||||
// GIVEN
|
||||
$customer = new Customer(['email' => new Email('existing@example.com')]);
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->saveOrFail();
|
||||
|
||||
$employee = new Employee();
|
||||
|
|
@ -105,7 +105,7 @@ describe('RegisterController', function () {
|
|||
/** @var \Tests\TestCase $this */
|
||||
// GIVEN
|
||||
$customer = new Customer(['email' => new Email('john.doe@example.com')]);
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->saveOrFail();
|
||||
|
||||
$input = new RegisterCustomerInput(
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use Illuminate\Support\Facades\App;
|
|||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('CustomerController', function () {
|
||||
|
|
@ -48,7 +48,7 @@ describe('CustomerController', function () {
|
|||
Cache::flush();
|
||||
$user = \Mockery::mock(Customer::class)->makePartial();
|
||||
$user->shouldReceive('getAuthIdentifier')->andReturn(1);
|
||||
$user->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$user->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$user->shouldReceive('getAuthPassword')->andReturn('dummy');
|
||||
$this->actingAs($user, 'frontend');
|
||||
$crmMock = \Mockery::mock(CrmService::class)->makePartial();
|
||||
|
|
@ -73,7 +73,7 @@ describe('CustomerController', function () {
|
|||
Cache::flush();
|
||||
$user = \Mockery::mock(Customer::class)->makePartial();
|
||||
$user->shouldReceive('getAuthIdentifier')->andReturn(1);
|
||||
$user->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$user->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$user->shouldReceive('getAuthPassword')->andReturn('dummy');
|
||||
$this->actingAs($user, 'frontend');
|
||||
$crmMock = \Mockery::mock(CrmService::class)->makePartial();
|
||||
|
|
@ -98,7 +98,7 @@ describe('CustomerController', function () {
|
|||
Cache::flush();
|
||||
$user = \Mockery::mock(Customer::class)->makePartial();
|
||||
$user->shouldReceive('getAuthIdentifier')->andReturn(1);
|
||||
$user->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$user->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$user->shouldReceive('getAuthPassword')->andReturn('dummy');
|
||||
$this->actingAs($user, 'frontend');
|
||||
$crmMock = \Mockery::mock(CrmService::class)->makePartial();
|
||||
|
|
@ -122,9 +122,9 @@ describe('CustomerController', function () {
|
|||
]));
|
||||
Cache::flush();
|
||||
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => $hashcode->value,
|
||||
'email' => new Email('jean.dupont@example.com'),
|
||||
]);
|
||||
|
|
@ -188,9 +188,9 @@ describe('CustomerController', function () {
|
|||
]));
|
||||
Cache::flush();
|
||||
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => $hashcode->value,
|
||||
'email' => new Email('jean.dupont@example.com'),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ use Illuminate\Support\Facades\Date;
|
|||
use Illuminate\Support\Facades\View;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('OrderController', function () {
|
||||
|
|
@ -61,7 +61,7 @@ describe('OrderController', function () {
|
|||
Cache::flush();
|
||||
$user = \Mockery::mock(Customer::class)->makePartial();
|
||||
$user->shouldReceive('getAuthIdentifier')->andReturn(1);
|
||||
$user->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$user->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$user->shouldReceive('getAuthPassword')->andReturn('dummy');
|
||||
$this->actingAs($user, 'frontend');
|
||||
$crmMock = \Mockery::mock(CrmService::class)->makePartial();
|
||||
|
|
@ -86,7 +86,7 @@ describe('OrderController', function () {
|
|||
Cache::flush();
|
||||
$user = \Mockery::mock(Customer::class)->makePartial();
|
||||
$user->shouldReceive('getAuthIdentifier')->andReturn(1);
|
||||
$user->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$user->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$user->shouldReceive('getAuthPassword')->andReturn('dummy');
|
||||
$this->actingAs($user, 'frontend');
|
||||
$crmMock = \Mockery::mock(CrmService::class)->makePartial();
|
||||
|
|
@ -110,9 +110,9 @@ describe('OrderController', function () {
|
|||
]));
|
||||
Cache::flush();
|
||||
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => $hashcode->value,
|
||||
'email' => new Email('verified@example.com'),
|
||||
]);
|
||||
|
|
@ -132,11 +132,11 @@ describe('OrderController', function () {
|
|||
]);
|
||||
|
||||
$shop = Shop::factory()->create();
|
||||
$refUuid = Uuid::uuid7();
|
||||
$refUuid = UuidHelper::v7();
|
||||
$reference = new OrderReference($refUuid);
|
||||
$ref = (string) $reference;
|
||||
Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => $reference,
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
|
|
@ -207,9 +207,9 @@ describe('OrderController', function () {
|
|||
]));
|
||||
Cache::flush();
|
||||
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => $hashcode->value,
|
||||
'email' => new Email('verified_show@example.com'),
|
||||
]);
|
||||
|
|
@ -229,11 +229,11 @@ describe('OrderController', function () {
|
|||
]);
|
||||
|
||||
$shop = Shop::factory()->create();
|
||||
$refUuid = Uuid::uuid7();
|
||||
$refUuid = UuidHelper::v7();
|
||||
$reference = new OrderReference($refUuid);
|
||||
$ref = (string) $reference;
|
||||
$order = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => $reference,
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
|
|
@ -294,9 +294,9 @@ describe('OrderController', function () {
|
|||
]));
|
||||
Cache::flush();
|
||||
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => $hashcode->value,
|
||||
'email' => new Email('tech-order-' . $status->value . '@example.com'),
|
||||
]);
|
||||
|
|
@ -315,9 +315,9 @@ describe('OrderController', function () {
|
|||
]);
|
||||
|
||||
$shop = Shop::factory()->create();
|
||||
$reference = new OrderReference(Uuid::uuid7());
|
||||
$reference = new OrderReference(UuidHelper::v7());
|
||||
Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => $reference,
|
||||
'status' => $status->value,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use Database\Seeders\ContentSeeder;
|
|||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('PasswordController', function () {
|
||||
|
|
@ -26,7 +26,7 @@ describe('PasswordController', function () {
|
|||
Cache::flush();
|
||||
$user = \Mockery::mock(Customer::class)->makePartial();
|
||||
$user->shouldReceive('getAuthIdentifier')->andReturn(1);
|
||||
$user->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$user->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$user->shouldReceive('getAuthPassword')->andReturn('dummy');
|
||||
$this->actingAs($user, 'frontend');
|
||||
$crmMock = \Mockery::mock(CrmService::class)->makePartial();
|
||||
|
|
@ -51,7 +51,7 @@ describe('PasswordController', function () {
|
|||
Cache::flush();
|
||||
$user = \Mockery::mock(Customer::class)->makePartial();
|
||||
$user->shouldReceive('getAuthIdentifier')->andReturn(1);
|
||||
$user->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$user->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$user->shouldReceive('getAuthPassword')->andReturn('dummy');
|
||||
$this->actingAs($user, 'frontend');
|
||||
$crmMock = \Mockery::mock(CrmService::class)->makePartial();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use App\Services\CrmService;
|
|||
use Database\Seeders\ContentSeeder;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('NewsletterController', function () {
|
||||
it('can access get /unsubscribe with valid hashcode', function () {
|
||||
|
|
@ -23,7 +23,7 @@ describe('NewsletterController', function () {
|
|||
$page->slug->value() => $page,
|
||||
]));
|
||||
Cache::flush();
|
||||
$hashcode = Uuid::uuid4()->toString();
|
||||
$hashcode = UuidHelper::v4()->toString();
|
||||
|
||||
// WHEN
|
||||
$response = $this->get('/unsubscribe?hashcode=' . $hashcode);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use Illuminate\Support\Facades\Config;
|
|||
use Illuminate\Support\Facades\Queue;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Mockery\MockInterface;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Uwil\Storage\Contracts\StorageService;
|
||||
use Uwil\Storage\Lib\ValueObjects\DiskName;
|
||||
use Uwil\Storage\Lib\ValueObjects\StorageFilePath;
|
||||
|
|
@ -81,7 +81,7 @@ describe('ContactController', function (): void {
|
|||
'last_name' => 'Dupont',
|
||||
'email' => 'jean.dupont@gmail.com',
|
||||
'subject' => 'Question',
|
||||
'order_ref' => (string) new OrderReference(Uuid::uuid7()),
|
||||
'order_ref' => (string) new OrderReference(UuidHelper::v7()),
|
||||
'message' => 'Bonjour, ceci est un message de test qui contient au moins vingt caractères.',
|
||||
'ok_cgv' => '1',
|
||||
];
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use Illuminate\Support\Carbon;
|
|||
use Illuminate\Support\Facades\Date;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Uwil\Storage\Lib\ValueObjects\StorageFilePath;
|
||||
|
||||
describe('HomeController', function () {
|
||||
|
|
@ -84,7 +84,7 @@ describe('HomeController', function () {
|
|||
$slide->save();
|
||||
|
||||
$product = new Product();
|
||||
$product->id = (string) Uuid::uuid7();
|
||||
$product->id = (string) UuidHelper::v7();
|
||||
$product->name = 'Poulet Fermier';
|
||||
$product->brand = ProductBrand::loue;
|
||||
$product->slug = 'poulet-fermier';
|
||||
|
|
@ -171,7 +171,7 @@ describe('HomeController', function () {
|
|||
$discount->save();
|
||||
|
||||
$promoProduct = new Product();
|
||||
$promoProduct->id = (string) Uuid::uuid7();
|
||||
$promoProduct->id = (string) UuidHelper::v7();
|
||||
$promoProduct->name = 'Foie Gras Promo';
|
||||
$promoProduct->brand = ProductBrand::loue;
|
||||
$promoProduct->slug = 'foie-gras-promo';
|
||||
|
|
@ -193,7 +193,7 @@ describe('HomeController', function () {
|
|||
$promoProduct->save();
|
||||
|
||||
$regularProduct = new Product();
|
||||
$regularProduct->id = (string) Uuid::uuid7();
|
||||
$regularProduct->id = (string) UuidHelper::v7();
|
||||
$regularProduct->name = 'Poulet Standard';
|
||||
$regularProduct->brand = ProductBrand::loue;
|
||||
$regularProduct->slug = 'poulet-standard';
|
||||
|
|
@ -246,7 +246,7 @@ describe('HomeController', function () {
|
|||
$range->save();
|
||||
|
||||
$product = new Product();
|
||||
$product->id = (string) Uuid::uuid7();
|
||||
$product->id = (string) UuidHelper::v7();
|
||||
$product->name = 'Poulet Sûr';
|
||||
$product->brand = ProductBrand::loue;
|
||||
$product->slug = 'poulet-sur';
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use Domain\Models\ValueObjects\Email;
|
|||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
use Tests\TestCase;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
|
@ -53,7 +53,7 @@ function characterizationCustomer(string $email): Customer
|
|||
{
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email($email);
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
|
||||
return $customer;
|
||||
|
|
|
|||
|
|
@ -83,8 +83,8 @@ use Illuminate\Support\Facades\Notification;
|
|||
use Illuminate\Support\Facades\View;
|
||||
use Mockery\MockInterface;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Sentry\State\HubInterface;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('TunnelController', function (): void {
|
||||
|
|
@ -219,7 +219,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -229,7 +229,7 @@ describe('TunnelController', function (): void {
|
|||
]);
|
||||
Gate::before(fn () => true);
|
||||
|
||||
$basket = new Basket(new BasketId(Uuid::uuid7()));
|
||||
$basket = new Basket(new BasketId(UuidHelper::v7()));
|
||||
$this->mock(Executor::class, function (MockInterface $mock) use ($basket): void {
|
||||
$mock->shouldReceive('execute')
|
||||
->once()
|
||||
|
|
@ -261,7 +261,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -295,7 +295,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -351,7 +351,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -376,7 +376,7 @@ describe('TunnelController', function (): void {
|
|||
$this->mock(ShopperRepository::class, function (MockInterface $mock) use ($shopper): void {
|
||||
$mock->shouldReceive('getByIdOrFail')->andReturn($shopper);
|
||||
});
|
||||
$basket = new Basket(new BasketId(Uuid::uuid7()));
|
||||
$basket = new Basket(new BasketId(UuidHelper::v7()));
|
||||
$builder = \Mockery::mock(OrderBuilderWithBasket::class);
|
||||
$builder->shouldReceive('getBasket')->andReturn($basket);
|
||||
$this->mock(OrderTunnelService::class, function (MockInterface $mock) use ($builder): void {
|
||||
|
|
@ -412,7 +412,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -437,7 +437,7 @@ describe('TunnelController', function (): void {
|
|||
$this->mock(ShopperRepository::class, function (MockInterface $mock) use ($shopper): void {
|
||||
$mock->shouldReceive('getByIdOrFail')->andReturn($shopper);
|
||||
});
|
||||
$basket = new Basket(new BasketId(Uuid::uuid7()));
|
||||
$basket = new Basket(new BasketId(UuidHelper::v7()));
|
||||
$builder = \Mockery::mock(OrderBuilderWithBasket::class);
|
||||
$builder->shouldReceive('getBasket')->andReturn($basket);
|
||||
$this->mock(OrderTunnelService::class, function (MockInterface $mock) use ($builder): void {
|
||||
|
|
@ -473,7 +473,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -483,7 +483,7 @@ describe('TunnelController', function (): void {
|
|||
]);
|
||||
Gate::before(fn () => true);
|
||||
|
||||
$basket = new Basket(new BasketId(Uuid::uuid7()));
|
||||
$basket = new Basket(new BasketId(UuidHelper::v7()));
|
||||
$builder = \Mockery::mock(OrderBuilderCompleted::class);
|
||||
$slot = new PickupTimeSlot(now(), new \DateInterval('PT1H'));
|
||||
$builder->shouldReceive('getPickupTimeSlot')->andReturn($slot);
|
||||
|
|
@ -534,7 +534,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -544,8 +544,8 @@ describe('TunnelController', function (): void {
|
|||
]);
|
||||
Gate::before(fn () => true);
|
||||
|
||||
$orderId = new OrderId(Uuid::uuid7());
|
||||
$orderReference = new OrderReference(Uuid::uuid7());
|
||||
$orderId = new OrderId(UuidHelper::v7());
|
||||
$orderReference = new OrderReference(UuidHelper::v7());
|
||||
$this->mock(Executor::class, function (MockInterface $mock) use ($orderId, $orderReference): void {
|
||||
$mock->shouldReceive('execute')
|
||||
->once()
|
||||
|
|
@ -582,7 +582,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('regate-export-fail@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -592,8 +592,8 @@ describe('TunnelController', function (): void {
|
|||
]);
|
||||
Gate::before(fn () => true);
|
||||
|
||||
$orderId = new OrderId(Uuid::uuid7());
|
||||
$orderReference = new OrderReference(Uuid::uuid7());
|
||||
$orderId = new OrderId(UuidHelper::v7());
|
||||
$orderReference = new OrderReference(UuidHelper::v7());
|
||||
$this->mock(Executor::class, function (MockInterface $mock) use ($orderId, $orderReference): void {
|
||||
$mock->shouldReceive('execute')
|
||||
->once()
|
||||
|
|
@ -631,7 +631,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('confirm-sql-fail@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -641,8 +641,8 @@ describe('TunnelController', function (): void {
|
|||
]);
|
||||
Gate::before(fn () => true);
|
||||
|
||||
$orderId = new OrderId(Uuid::uuid7());
|
||||
$orderReference = new OrderReference(Uuid::uuid7());
|
||||
$orderId = new OrderId(UuidHelper::v7());
|
||||
$orderReference = new OrderReference(UuidHelper::v7());
|
||||
$this->mock(Executor::class, function (MockInterface $mock) use ($orderId, $orderReference): void {
|
||||
$mock->shouldReceive('execute')
|
||||
->once()
|
||||
|
|
@ -680,7 +680,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -720,7 +720,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -760,7 +760,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -802,7 +802,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -844,7 +844,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -882,7 +882,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test-inactive@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -921,7 +921,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('test@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -939,7 +939,7 @@ describe('TunnelController', function (): void {
|
|||
$shop->default = true;
|
||||
$shop->save();
|
||||
|
||||
$orderReference = new OrderReference(Uuid::uuid7());
|
||||
$orderReference = new OrderReference(UuidHelper::v7());
|
||||
$order = new Order();
|
||||
$order->reference = $orderReference;
|
||||
$order->total = Money::EUR(3000);
|
||||
|
|
@ -986,7 +986,7 @@ describe('TunnelController', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('regate-fail@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
||||
|
|
@ -1039,10 +1039,10 @@ describe('TunnelController', function (): void {
|
|||
]));
|
||||
Cache::flush();
|
||||
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
/** @var Customer $customer */
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'email' => new Email('e2e-success@example.com'),
|
||||
'hashcode' => $hashcode,
|
||||
]);
|
||||
|
|
@ -1179,10 +1179,10 @@ describe('TunnelController', function (): void {
|
|||
]));
|
||||
Cache::flush();
|
||||
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
/** @var Customer $customer */
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'email' => new Email('e2e-fail@example.com'),
|
||||
'hashcode' => $hashcode,
|
||||
]);
|
||||
|
|
@ -1332,10 +1332,10 @@ describe('TunnelController', function (): void {
|
|||
]));
|
||||
Cache::flush();
|
||||
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
/** @var Customer $customer */
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'email' => new Email('e2e-lock@example.com'),
|
||||
'hashcode' => $hashcode,
|
||||
]);
|
||||
|
|
@ -1473,10 +1473,10 @@ describe('TunnelController', function (): void {
|
|||
]));
|
||||
Cache::flush();
|
||||
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
/** @var Customer $customer */
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'email' => new Email('e2e-attempt@example.com'),
|
||||
'hashcode' => $hashcode,
|
||||
]);
|
||||
|
|
@ -1616,10 +1616,10 @@ describe('TunnelController', function (): void {
|
|||
]));
|
||||
Cache::flush();
|
||||
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
/** @var Customer $customer */
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'email' => new Email('e2e-attempt-ko@example.com'),
|
||||
'hashcode' => $hashcode,
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ use Infrastructure\Adapters\Repositories\EloquentProductRepository;
|
|||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Psr\Log\NullLogger;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Concurrency\Lock;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
function makeAddBasketRequest(): AddBasketRequest
|
||||
{
|
||||
|
|
@ -50,9 +50,9 @@ describe('AddBasketRequest', function () {
|
|||
'picture_title' => '',
|
||||
]);
|
||||
$product = Product::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'name' => 'Test',
|
||||
'slug' => Uuid::uuid7()->toString(),
|
||||
'slug' => UuidHelper::v7()->toString(),
|
||||
'brand' => ProductBrand::cases()[0]->value,
|
||||
'description' => 'Test',
|
||||
'price' => new Money(100, new Currency('EUR')),
|
||||
|
|
@ -90,7 +90,7 @@ describe('AddBasketRequest', function () {
|
|||
$request->initialize();
|
||||
|
||||
// WHEN
|
||||
$request->merge(['rowId' => Uuid::uuid7()->toString()]);
|
||||
$request->merge(['rowId' => UuidHelper::v7()->toString()]);
|
||||
|
||||
// THEN
|
||||
expect($request->authorize())->toBeFalse();
|
||||
|
|
@ -106,9 +106,9 @@ describe('AddBasketRequest', function () {
|
|||
'picture_title' => '',
|
||||
]);
|
||||
$product = Product::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'name' => 'Test',
|
||||
'slug' => Uuid::uuid7()->toString(),
|
||||
'slug' => UuidHelper::v7()->toString(),
|
||||
'brand' => ProductBrand::cases()[0]->value,
|
||||
'description' => 'Test',
|
||||
'price' => new Money(100, new Currency('EUR')),
|
||||
|
|
@ -150,9 +150,9 @@ describe('AddBasketRequest', function () {
|
|||
'picture_title' => '',
|
||||
]);
|
||||
$product = Product::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'name' => 'Test',
|
||||
'slug' => Uuid::uuid7()->toString(),
|
||||
'slug' => UuidHelper::v7()->toString(),
|
||||
'brand' => ProductBrand::cases()[0]->value,
|
||||
'description' => 'Test',
|
||||
'price' => new Money(100, new Currency('EUR')),
|
||||
|
|
@ -203,7 +203,7 @@ describe('AddBasketRequest', function () {
|
|||
|
||||
it('can get product id as value object', function () {
|
||||
// GIVEN
|
||||
$uuid = Uuid::uuid7()->toString();
|
||||
$uuid = UuidHelper::v7()->toString();
|
||||
$request = makeAddBasketRequest();
|
||||
$request->initialize();
|
||||
$request->merge(['rowId' => $uuid]);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace Tests\Feature\App\Http\Requests\Basket;
|
|||
|
||||
use App\Http\Requests\Basket\RemoveBasketRequest;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('RemoveBasketRequest', function () {
|
||||
it('authorizes always', function () {
|
||||
|
|
@ -25,7 +25,7 @@ describe('RemoveBasketRequest', function () {
|
|||
$request = new RemoveBasketRequest();
|
||||
$request->initialize();
|
||||
$request->merge([
|
||||
'rowId' => Uuid::uuid7()->toString(),
|
||||
'rowId' => UuidHelper::v7()->toString(),
|
||||
'qty' => 1,
|
||||
]);
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ describe('RemoveBasketRequest', function () {
|
|||
|
||||
it('can get product id as value object', function () {
|
||||
// GIVEN
|
||||
$uuid = Uuid::uuid7()->toString();
|
||||
$uuid = UuidHelper::v7()->toString();
|
||||
$request = new RemoveBasketRequest();
|
||||
$request->initialize();
|
||||
$request->merge(['rowId' => $uuid]);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use Illuminate\Session\ArraySessionHandler;
|
|||
use Illuminate\Session\Store;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Infrastructure\Adapters\Services\AppAdminAuthService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
use function Pest\Laravel\actingAs;
|
||||
use function Pest\Laravel\get;
|
||||
|
|
@ -42,7 +42,7 @@ describe('IndexShopRequest', function (): void {
|
|||
|
||||
// WHEN
|
||||
$invalid = Validator::make(['pickup-exception' => 'not-a-uuid'], $rules);
|
||||
$valid = Validator::make(['pickup-exception' => Uuid::uuid7()->toString()], $rules);
|
||||
$valid = Validator::make(['pickup-exception' => UuidHelper::v7()->toString()], $rules);
|
||||
|
||||
// THEN
|
||||
expect($invalid->errors()->has('pickup-exception'))->toBeTrue()
|
||||
|
|
@ -53,7 +53,7 @@ describe('IndexShopRequest', function (): void {
|
|||
// GIVEN
|
||||
$admin = User::factory()->createOne(['role' => UserRole::SuperAdmin]);
|
||||
actingAs($admin, 'backend');
|
||||
$uuid = Uuid::uuid7()->toString();
|
||||
$uuid = UuidHelper::v7()->toString();
|
||||
|
||||
// WHEN
|
||||
$withFilter = get(route('bo.shops.index', ['pickup-exception' => $uuid]));
|
||||
|
|
@ -74,7 +74,7 @@ describe('IndexShopRequest', function (): void {
|
|||
// GIVEN
|
||||
$authService = \Mockery::mock(AppAdminAuthService::class);
|
||||
$session = new Store('test', new ArraySessionHandler(120));
|
||||
$uuidV7 = Uuid::uuid7()->toString();
|
||||
$uuidV7 = UuidHelper::v7()->toString();
|
||||
|
||||
$session->put(IndexShopRequest::SESSION_KEY, $uuidV7);
|
||||
$request = new IndexShopRequest($authService);
|
||||
|
|
@ -90,7 +90,7 @@ describe('IndexShopRequest', function (): void {
|
|||
->and((string) $request->getPickupExceptionId())->toBe($uuidV7);
|
||||
|
||||
// GIVEN
|
||||
$session->put(IndexShopRequest::SESSION_KEY, Uuid::uuid4()->toString());
|
||||
$session->put(IndexShopRequest::SESSION_KEY, UuidHelper::v4()->toString());
|
||||
|
||||
// WHEN & THEN
|
||||
expect($request->toPickupExceptionId())->toBeNull();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use Illuminate\Support\Carbon;
|
|||
use Illuminate\Support\Facades\Date;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Infrastructure\Adapters\Services\AppCustomerAuthService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('RegisterRequest', function (): void {
|
||||
|
|
@ -84,7 +84,7 @@ describe('RegisterRequest', function (): void {
|
|||
it('rejects matricule and code when employee already has a customer_id', function (): void {
|
||||
// GIVEN
|
||||
$customer = new Customer(['email' => new Email('existing@example.com')]);
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->saveOrFail();
|
||||
|
||||
$employee = new Employee();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Domain\Models\ValueObjects\OrderReference;
|
|||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('ContactFormRequest', function () {
|
||||
it('validates correct rules', function () {
|
||||
|
|
@ -23,7 +23,7 @@ describe('ContactFormRequest', function () {
|
|||
'first_name' => 'John',
|
||||
'email' => 'john.doe@gmail.com',
|
||||
'subject' => 'Help with my order',
|
||||
'order_ref' => (string) new OrderReference(Uuid::uuid7()),
|
||||
'order_ref' => (string) new OrderReference(UuidHelper::v7()),
|
||||
'message' => 'This is a message that is longer than 20 characters.',
|
||||
'ok_cgv' => true,
|
||||
]);
|
||||
|
|
@ -108,7 +108,7 @@ describe('ContactFormRequest', function () {
|
|||
|
||||
it('converts to action input without file', function () {
|
||||
// GIVEN
|
||||
$orderRef = new OrderReference(Uuid::uuid7());
|
||||
$orderRef = new OrderReference(UuidHelper::v7());
|
||||
$request = new ContactFormRequest();
|
||||
$request->initialize();
|
||||
$request->merge([
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use App\Models\Customer;
|
|||
use Domain\Models\ValueObjects\Entities\ShopperId;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Infrastructure\Adapters\Services\AppCustomerAuthService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('ConfirmOrderRequest', function (): void {
|
||||
it('authorizes only when customer auth service returns true', function (): void {
|
||||
|
|
@ -47,7 +47,7 @@ describe('ConfirmOrderRequest', function (): void {
|
|||
|
||||
it('maps to PlacePendingOrderInput', function (): void {
|
||||
// GIVEN
|
||||
$shopperId = new ShopperId(Uuid::uuid7());
|
||||
$shopperId = new ShopperId(UuidHelper::v7());
|
||||
$customer = new Customer();
|
||||
$customer->id = $shopperId->value->toString();
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use Domain\Ports\Repositories\ShopperRepository;
|
|||
use Domain\Services\OrderTunnelService;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Infrastructure\Adapters\Services\AppCustomerAuthService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
const VALID_TIMESLOT_DATE = '2023-10-15';
|
||||
|
||||
|
|
@ -88,11 +88,11 @@ describe('PickTimeSlotRequest', function (): void {
|
|||
|
||||
it('fails basketTotal validation when weekly limit is exceeded', function (): void {
|
||||
// GIVEN
|
||||
$shopperId = new ShopperId(Uuid::uuid7());
|
||||
$shopperId = new ShopperId(UuidHelper::v7());
|
||||
$customer = new Customer();
|
||||
$customer->id = $shopperId->value->toString();
|
||||
|
||||
$basket = new Basket(new BasketId(Uuid::uuid7()), []);
|
||||
$basket = new Basket(new BasketId(UuidHelper::v7()), []);
|
||||
$shopper = new Shopper(
|
||||
$shopperId,
|
||||
new Email('shopper@example.com'),
|
||||
|
|
@ -160,7 +160,7 @@ describe('PickTimeSlotRequest', function (): void {
|
|||
|
||||
it('maps to ApplyPickTimeSlotInput', function (): void {
|
||||
// GIVEN
|
||||
$shopperId = new ShopperId(Uuid::uuid7());
|
||||
$shopperId = new ShopperId(UuidHelper::v7());
|
||||
$customer = new Customer();
|
||||
$customer->id = $shopperId->value->toString();
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use Domain\Services\BasketService;
|
|||
use Domain\Services\OrderTunnelService;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Infrastructure\Adapters\Services\AppCustomerAuthService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('ValidateSummaryRequest', function (): void {
|
||||
it('authorizes only when customer auth service returns true', function (): void {
|
||||
|
|
@ -40,7 +40,7 @@ describe('ValidateSummaryRequest', function (): void {
|
|||
|
||||
it('fails basketTotal validation when order limit is exceeded', function (): void {
|
||||
// GIVEN
|
||||
$basket = new Basket(new BasketId(Uuid::uuid7()), []);
|
||||
$basket = new Basket(new BasketId(UuidHelper::v7()), []);
|
||||
|
||||
$authService = \Mockery::mock(AppCustomerAuthService::class);
|
||||
$basketService = \Mockery::mock(BasketService::class);
|
||||
|
|
@ -70,11 +70,11 @@ describe('ValidateSummaryRequest', function (): void {
|
|||
|
||||
it('maps to InitializeOrderTunnelInput', function (): void {
|
||||
// GIVEN
|
||||
$shopperId = new ShopperId(Uuid::uuid7());
|
||||
$shopperId = new ShopperId(UuidHelper::v7());
|
||||
$customer = new Customer();
|
||||
$customer->id = $shopperId->value->toString();
|
||||
|
||||
$basket = new Basket(new BasketId(Uuid::uuid7()), []);
|
||||
$basket = new Basket(new BasketId(UuidHelper::v7()), []);
|
||||
$authService = \Mockery::mock(AppCustomerAuthService::class);
|
||||
$authService->shouldReceive('getCustomerAsMandatory')->once()->andReturn($customer);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace Tests\Feature\App\Http\Requests\Fo;
|
|||
|
||||
use App\Http\Requests\Fo\UnsubscribeNewsletterRequest;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('UnsubscribeNewsletterRequest', function () {
|
||||
it('validates correct rules', function () {
|
||||
|
|
@ -14,7 +14,7 @@ describe('UnsubscribeNewsletterRequest', function () {
|
|||
$request = new UnsubscribeNewsletterRequest();
|
||||
$request->initialize();
|
||||
$request->merge([
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
]);
|
||||
|
||||
// WHEN
|
||||
|
|
@ -58,7 +58,7 @@ describe('UnsubscribeNewsletterRequest', function () {
|
|||
// GIVEN
|
||||
$request = new UnsubscribeNewsletterRequest();
|
||||
$request->initialize();
|
||||
$uuid = Uuid::uuid4();
|
||||
$uuid = UuidHelper::v4();
|
||||
$request->merge([
|
||||
'hashcode' => $uuid->toString(),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ use Illuminate\Support\Facades\Notification;
|
|||
use Illuminate\Support\Str;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('SendMissingOrderReminderJob', function (): void {
|
||||
it('dispatches MissingOrderReminderNotification once per week with precomputed cutoff and ICS content', function (): void {
|
||||
|
|
@ -134,7 +134,7 @@ describe('SendMissingOrderReminderJob', function (): void {
|
|||
]);
|
||||
|
||||
$exception = new PickupExceptionOnDate(
|
||||
id: new PickupExceptionId(Uuid::uuid7()),
|
||||
id: new PickupExceptionId(UuidHelper::v7()),
|
||||
date: CarbonImmutable::parse('2026-11-20', 'Europe/Paris'),
|
||||
label: 'Fermeture exceptionnelle',
|
||||
repeatable: false,
|
||||
|
|
@ -194,9 +194,9 @@ describe('SendMissingOrderReminderJob', function (): void {
|
|||
]);
|
||||
|
||||
Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(2500, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -229,7 +229,7 @@ describe('SendMissingOrderReminderJob', function (): void {
|
|||
]);
|
||||
|
||||
$exception = new PickupExceptionOnDate(
|
||||
id: new PickupExceptionId(Uuid::uuid7()),
|
||||
id: new PickupExceptionId(UuidHelper::v7()),
|
||||
date: CarbonImmutable::parse('2026-11-20', 'Europe/Paris'),
|
||||
label: 'Décalage jeudi',
|
||||
repeatable: false,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ use Money\Currency;
|
|||
use Money\Money;
|
||||
use Money\MoneyFormatter;
|
||||
use Psr\Log\NullLogger;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('SendReminderMail job', function (): void {
|
||||
it('sends today reminder once and marks orders as reminded idempotently', function (): void {
|
||||
|
|
@ -60,9 +60,9 @@ describe('SendReminderMail job', function (): void {
|
|||
]);
|
||||
|
||||
$order = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(3000, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -126,9 +126,9 @@ describe('SendReminderMail job', function (): void {
|
|||
]);
|
||||
|
||||
$order = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(3000, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
|
|||
|
|
@ -22,13 +22,13 @@ use Illuminate\Support\Facades\Config;
|
|||
use Illuminate\Support\Facades\Mail;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
function makeOrderPlacedEvent(): AnOrderHasBeenPlaced
|
||||
{
|
||||
return new AnOrderHasBeenPlaced(
|
||||
orderId: new OrderId(Uuid::uuid7()),
|
||||
reference: new OrderReference(Uuid::uuid7()),
|
||||
orderId: new OrderId(UuidHelper::v7()),
|
||||
reference: new OrderReference(UuidHelper::v7()),
|
||||
totalTtc: new Money(1500, new Currency('EUR')),
|
||||
byMatricule: new Matricule('1234567'),
|
||||
employee: new OrderEmployee(
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ use Domain\Models\ValueObjects\ShopperSiteCode;
|
|||
use Illuminate\Support\Facades\Notification;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
function makeCustomerOrderPlacedEvent(string $matricule): AnOrderHasBeenPlaced
|
||||
{
|
||||
return new AnOrderHasBeenPlaced(
|
||||
orderId: new OrderId(Uuid::uuid7()),
|
||||
reference: new OrderReference(Uuid::uuid7()),
|
||||
orderId: new OrderId(UuidHelper::v7()),
|
||||
reference: new OrderReference(UuidHelper::v7()),
|
||||
totalTtc: new Money(1500, new Currency('EUR')),
|
||||
byMatricule: new Matricule($matricule),
|
||||
employee: new OrderEmployee(
|
||||
|
|
|
|||
|
|
@ -13,32 +13,34 @@ use Illuminate\Auth\Events\Login;
|
|||
use Illuminate\Support\Facades\Date;
|
||||
use Infrastructure\Adapters\Events\LaravelDomainEventDispatcher;
|
||||
use Psr\Log\NullLogger;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Concurrency\Lock;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
it('updates customer last_login_at via Executor when Login event is handled', function (): void {
|
||||
// GIVEN
|
||||
Date::setTestNow('2026-11-14 14:00:00');
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('login@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->last_login_at = null;
|
||||
$customer->saveOrFail();
|
||||
describe('UpdateCustomerLastLogin', function (): void {
|
||||
it('updates customer last_login_at via Executor when Login event is handled', function (): void {
|
||||
// GIVEN
|
||||
Date::setTestNow('2026-11-14 14:00:00');
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('login@example.com');
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->last_login_at = null;
|
||||
$customer->saveOrFail();
|
||||
|
||||
$executor = new ActionExecutorService(
|
||||
lock: \Mockery::mock(Lock::class),
|
||||
logger: new NullLogger(),
|
||||
eventDispatcher: new LaravelDomainEventDispatcher(),
|
||||
);
|
||||
$listener = new UpdateCustomerLastLogin($executor, new UpdateCustomerLastLoginAction());
|
||||
$executor = new ActionExecutorService(
|
||||
lock: \Mockery::mock(Lock::class),
|
||||
logger: new NullLogger(),
|
||||
eventDispatcher: new LaravelDomainEventDispatcher(),
|
||||
);
|
||||
$listener = new UpdateCustomerLastLogin($executor, new UpdateCustomerLastLoginAction());
|
||||
|
||||
// WHEN
|
||||
$listener->handle(new Login('frontend', $customer, false));
|
||||
// WHEN
|
||||
$listener->handle(new Login('frontend', $customer, false));
|
||||
|
||||
// THEN
|
||||
$customer->refresh();
|
||||
expect($customer->last_login_at?->format('Y-m-d H:i:s'))->toBe('2026-11-14 14:00:00');
|
||||
// THEN
|
||||
$customer->refresh();
|
||||
expect($customer->last_login_at?->format('Y-m-d H:i:s'))->toBe('2026-11-14 14:00:00');
|
||||
|
||||
Date::setTestNow();
|
||||
Date::setTestNow();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ use Illuminate\Session\ArraySessionHandler;
|
|||
use Illuminate\Session\Store;
|
||||
use Infrastructure\Adapters\Repositories\SessionBasketRepository;
|
||||
use Infrastructure\Adapters\Serializers\BasketSerializer;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
covers(SessionBasketRepository::class);
|
||||
|
||||
describe('SessionBasketRepository', function (): void {
|
||||
it('returns null if session is empty', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$session = new Store('test', new ArraySessionHandler(120));
|
||||
$repo = new SessionBasketRepository($session, 'basket_key', new BasketSerializer());
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ describe('SessionBasketRepository', function (): void {
|
|||
|
||||
it('persists and retrieves a basket using real Store and BasketSerializer', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId, []);
|
||||
$session = new Store('test', new ArraySessionHandler(120));
|
||||
$repo = new SessionBasketRepository($session, 'basket_key', new BasketSerializer());
|
||||
|
|
@ -47,7 +47,7 @@ describe('SessionBasketRepository', function (): void {
|
|||
|
||||
it('returns null if session data is invalid json', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$session = new Store('test', new ArraySessionHandler(120));
|
||||
$session->put('basket_key' . $basketId->value->toString(), 'invalid-json');
|
||||
$repo = new SessionBasketRepository($session, 'basket_key', new BasketSerializer());
|
||||
|
|
@ -61,7 +61,7 @@ describe('SessionBasketRepository', function (): void {
|
|||
|
||||
it('returns null if deserialization throws exception', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$session = new Store('test', new ArraySessionHandler(120));
|
||||
$session->put('basket_key' . $basketId->value->toString(), '{"invalid":"payload"}');
|
||||
$repo = new SessionBasketRepository($session, 'basket_key', new BasketSerializer());
|
||||
|
|
@ -75,7 +75,7 @@ describe('SessionBasketRepository', function (): void {
|
|||
|
||||
it('deletes basket from session', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId, []);
|
||||
$session = new Store('test', new ArraySessionHandler(120));
|
||||
$repo = new SessionBasketRepository($session, 'basket_key', new BasketSerializer());
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use Domain\Models\ValueObjects\Entities\ShopperId;
|
|||
use Illuminate\Session\ArraySessionHandler;
|
||||
use Illuminate\Session\Store;
|
||||
use Infrastructure\Adapters\Services\SessionOrderBuilderManager;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('SessionOrderBuilderManager', function (): void {
|
||||
it('throws exception if session key is empty', function (): void {
|
||||
|
|
@ -29,8 +29,8 @@ describe('SessionOrderBuilderManager', function (): void {
|
|||
// GIVEN
|
||||
$session = new Store('test', new ArraySessionHandler(120));
|
||||
$builder = OrderBuilder::fromBasket(
|
||||
new Basket(new BasketId(Uuid::uuid7()), []),
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new Basket(new BasketId(UuidHelper::v7()), []),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
);
|
||||
$session->put('builder_key', $builder);
|
||||
$manager = new SessionOrderBuilderManager($session, 'builder_key');
|
||||
|
|
@ -71,8 +71,8 @@ describe('SessionOrderBuilderManager', function (): void {
|
|||
// GIVEN
|
||||
$session = new Store('test', new ArraySessionHandler(120));
|
||||
$builder = OrderBuilder::fromBasket(
|
||||
new Basket(new BasketId(Uuid::uuid7()), []),
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new Basket(new BasketId(UuidHelper::v7()), []),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
);
|
||||
$manager = new SessionOrderBuilderManager($session, 'builder_key');
|
||||
|
||||
|
|
@ -88,8 +88,8 @@ describe('SessionOrderBuilderManager', function (): void {
|
|||
// GIVEN
|
||||
$session = new Store('test', new ArraySessionHandler(120));
|
||||
$builder = OrderBuilder::fromBasket(
|
||||
new Basket(new BasketId(Uuid::uuid7()), []),
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new Basket(new BasketId(UuidHelper::v7()), []),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
);
|
||||
$session->put('builder_key', $builder);
|
||||
$manager = new SessionOrderBuilderManager($session, 'builder_key');
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
use Illuminate\Support\Arr;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Uwil\Storage\Lib\ValueObjects\StorageFilePath;
|
||||
|
||||
covers(OrderLineProductCast::class);
|
||||
|
|
@ -49,7 +49,7 @@ describe('OrderLineProductCast', function () {
|
|||
// GIVEN
|
||||
$cast = new OrderLineProductCast();
|
||||
$model = \Mockery::mock(Model::class);
|
||||
$uuid = Uuid::uuid7()->toString();
|
||||
$uuid = UuidHelper::v7()->toString();
|
||||
|
||||
$json = json_encode([
|
||||
'inco_id' => 123,
|
||||
|
|
@ -83,7 +83,7 @@ describe('OrderLineProductCast', function () {
|
|||
// GIVEN
|
||||
$cast = new OrderLineProductCast();
|
||||
$model = \Mockery::mock(Model::class);
|
||||
$uuid = Uuid::uuid7()->toString();
|
||||
$uuid = UuidHelper::v7()->toString();
|
||||
|
||||
$json = json_encode([
|
||||
'inco_id' => 123,
|
||||
|
|
@ -131,7 +131,7 @@ describe('OrderLineProductCast', function () {
|
|||
|
||||
$product = new OrderLineProduct(
|
||||
incoId: new IncoId(123),
|
||||
originalId: new ProductId(Uuid::uuid7()),
|
||||
originalId: new ProductId(UuidHelper::v7()),
|
||||
name: 'Product Name',
|
||||
weight: new ProductWeight(1000, false),
|
||||
brand: ProductBrand::cases()[0], // Pick first enum case
|
||||
|
|
|
|||
|
|
@ -7,87 +7,88 @@ namespace Tests\Integration\WithApp\App\Casts;
|
|||
use App\Casts\OrderReferenceCast;
|
||||
use Domain\Models\ValueObjects\OrderReference;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
it('gets a reference', function () {
|
||||
// GIVEN
|
||||
$cast = new OrderReferenceCast();
|
||||
$model = \Mockery::mock(Model::class);
|
||||
$uuid = Uuid::uuid7();
|
||||
$value = UuidHelper::toBase58($uuid);
|
||||
describe('OrderReferenceCast', function (): void {
|
||||
it('gets a reference', function () {
|
||||
// GIVEN
|
||||
$cast = new OrderReferenceCast();
|
||||
$model = \Mockery::mock(Model::class);
|
||||
$uuid = UuidHelper::v7();
|
||||
$value = UuidHelper::toBase58($uuid);
|
||||
|
||||
// WHEN
|
||||
$reference = $cast->get($model, 'reference', $value, []);
|
||||
// WHEN
|
||||
$reference = $cast->get($model, 'reference', $value, []);
|
||||
|
||||
// THEN
|
||||
expect((string) $reference)->toBe($value)
|
||||
->and($reference->value->equals($uuid))->toBeTrue();
|
||||
});
|
||||
|
||||
it('gets a reference from raw uuid string', function () {
|
||||
// GIVEN
|
||||
$cast = new OrderReferenceCast();
|
||||
$model = \Mockery::mock(Model::class);
|
||||
$uuid = Uuid::uuid7();
|
||||
$value = $uuid->toString();
|
||||
|
||||
// WHEN
|
||||
$reference = $cast->get($model, 'reference', $value, []);
|
||||
|
||||
// THEN
|
||||
expect((string) $reference)->toBe(UuidHelper::toBase58($uuid))
|
||||
->and($reference->value->equals($uuid))->toBeTrue();
|
||||
});
|
||||
|
||||
it('throws exception when getting invalid reference', function () {
|
||||
// GIVEN
|
||||
$cast = new OrderReferenceCast();
|
||||
$model = \Mockery::mock(Model::class);
|
||||
|
||||
// WHEN
|
||||
$cast->get($model, 'reference', 123, []);
|
||||
|
||||
// THEN
|
||||
})->throws(\UnexpectedValueException::class, 'OrderReference cannot be null.');
|
||||
|
||||
it('throws exception when getting null reference', function () {
|
||||
// GIVEN
|
||||
$cast = new OrderReferenceCast();
|
||||
$model = \Mockery::mock(Model::class);
|
||||
|
||||
// WHEN
|
||||
$cast->get($model, 'reference', null, []);
|
||||
|
||||
// THEN
|
||||
})->throws(\UnexpectedValueException::class, 'OrderReference cannot be null.');
|
||||
|
||||
it('throws exception when setting invalid reference type', function () {
|
||||
// GIVEN
|
||||
$cast = new OrderReferenceCast();
|
||||
$model = \Mockery::mock(Model::class);
|
||||
$value = UuidHelper::toBase58(Uuid::uuid7());
|
||||
|
||||
// WHEN
|
||||
/** @phpstan-ignore argument.type */
|
||||
$cast->set($model, 'reference', $value, []);
|
||||
|
||||
// THEN
|
||||
})->throws(
|
||||
\UnexpectedValueException::class,
|
||||
'The given value is not an instance of OrderReference.'
|
||||
);
|
||||
|
||||
it('sets a reference', function () {
|
||||
// GIVEN
|
||||
$cast = new OrderReferenceCast();
|
||||
$model = \Mockery::mock(Model::class);
|
||||
$uuid = Uuid::uuid7();
|
||||
$reference = new OrderReference($uuid);
|
||||
|
||||
// WHEN
|
||||
$value = $cast->set($model, 'reference', $reference, []);
|
||||
|
||||
// THEN
|
||||
expect($value)->toBe(UuidHelper::toBase58($uuid));
|
||||
// THEN
|
||||
expect((string) $reference)->toBe($value)
|
||||
->and($reference->value->equals($uuid))->toBeTrue();
|
||||
});
|
||||
|
||||
it('gets a reference from raw uuid string', function () {
|
||||
// GIVEN
|
||||
$cast = new OrderReferenceCast();
|
||||
$model = \Mockery::mock(Model::class);
|
||||
$uuid = UuidHelper::v7();
|
||||
$value = $uuid->toString();
|
||||
|
||||
// WHEN
|
||||
$reference = $cast->get($model, 'reference', $value, []);
|
||||
|
||||
// THEN
|
||||
expect((string) $reference)->toBe(UuidHelper::toBase58($uuid))
|
||||
->and($reference->value->equals($uuid))->toBeTrue();
|
||||
});
|
||||
|
||||
it('throws exception when getting invalid reference', function () {
|
||||
// GIVEN
|
||||
$cast = new OrderReferenceCast();
|
||||
$model = \Mockery::mock(Model::class);
|
||||
|
||||
// WHEN
|
||||
$cast->get($model, 'reference', 123, []);
|
||||
|
||||
// THEN
|
||||
})->throws(\UnexpectedValueException::class, 'OrderReference cannot be null.');
|
||||
|
||||
it('throws exception when getting null reference', function () {
|
||||
// GIVEN
|
||||
$cast = new OrderReferenceCast();
|
||||
$model = \Mockery::mock(Model::class);
|
||||
|
||||
// WHEN
|
||||
$cast->get($model, 'reference', null, []);
|
||||
|
||||
// THEN
|
||||
})->throws(\UnexpectedValueException::class, 'OrderReference cannot be null.');
|
||||
|
||||
it('throws exception when setting invalid reference type', function () {
|
||||
// GIVEN
|
||||
$cast = new OrderReferenceCast();
|
||||
$model = \Mockery::mock(Model::class);
|
||||
$value = UuidHelper::toBase58(UuidHelper::v7());
|
||||
|
||||
// WHEN
|
||||
/** @phpstan-ignore argument.type */
|
||||
$cast->set($model, 'reference', $value, []);
|
||||
|
||||
// THEN
|
||||
})->throws(
|
||||
\UnexpectedValueException::class,
|
||||
'The given value is not an instance of OrderReference.'
|
||||
);
|
||||
|
||||
it('sets a reference', function () {
|
||||
// GIVEN
|
||||
$cast = new OrderReferenceCast();
|
||||
$model = \Mockery::mock(Model::class);
|
||||
$uuid = UuidHelper::v7();
|
||||
$reference = new OrderReference($uuid);
|
||||
|
||||
// WHEN
|
||||
$value = $cast->set($model, 'reference', $reference, []);
|
||||
|
||||
// THEN
|
||||
expect($value)->toBe(UuidHelper::toBase58($uuid));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ use Infrastructure\Adapters\Services\AppSessionService;
|
|||
use Infrastructure\Adapters\Services\SessionOrderBuilderManager;
|
||||
use Money\Money;
|
||||
use Psr\Log\NullLogger;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
function makeBasketProductFixture(bool $status = true, bool $withInco = true): Product
|
||||
{
|
||||
|
|
@ -112,8 +112,8 @@ describe('AddToBasket action', function (): void {
|
|||
$repository = new SessionBasketRepository($session, 'basket_', new BasketSerializer());
|
||||
$builderManager = new SessionOrderBuilderManager($session, 'order_tunnel_builder_session');
|
||||
$builderManager->save(OrderBuilder::fromBasket(
|
||||
new Basket(new BasketId(Uuid::uuid7()), []),
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new Basket(new BasketId(UuidHelper::v7()), []),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
));
|
||||
|
||||
$dispatcher = new LaravelDomainEventDispatcher();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ use Infrastructure\Adapters\Services\AppSessionService;
|
|||
use Infrastructure\Adapters\Services\SessionOrderBuilderManager;
|
||||
use Money\Money;
|
||||
use Psr\Log\NullLogger;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('EmptyBasket action', function (): void {
|
||||
it('removes all items from session basket and clears order builder', function (): void {
|
||||
|
|
@ -82,8 +82,8 @@ describe('EmptyBasket action', function (): void {
|
|||
$basketSvc->add($product->getId(), 2);
|
||||
|
||||
$builderManager->save(OrderBuilder::fromBasket(
|
||||
new Basket(new BasketId(Uuid::uuid7()), []),
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new Basket(new BasketId(UuidHelper::v7()), []),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
));
|
||||
|
||||
$executor = new ActionExecutorService(
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ use Infrastructure\Adapters\Services\AppSessionService;
|
|||
use Infrastructure\Adapters\Services\SessionOrderBuilderManager;
|
||||
use Money\Money;
|
||||
use Psr\Log\NullLogger;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
function makeRemovableProductFixture(): Product
|
||||
{
|
||||
|
|
@ -120,8 +120,8 @@ describe('RemoveFromBasket action', function (): void {
|
|||
$basketSvc->add($product2->getId(), 2);
|
||||
|
||||
$builderManager->save(OrderBuilder::fromBasket(
|
||||
new Basket(new BasketId(Uuid::uuid7()), []),
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new Basket(new BasketId(UuidHelper::v7()), []),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
));
|
||||
|
||||
$executor = new ActionExecutorService(
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use App\Lib\PrivateS3Disk;
|
|||
use Domain\Models\ValueObjects\AttachedFile;
|
||||
use Domain\Models\ValueObjects\OrderReference;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Uwil\Storage\Contracts\StorageService;
|
||||
use Uwil\Storage\Lib\ValueObjects\DiskName;
|
||||
use Uwil\Storage\Lib\ValueObjects\StorageFilePath;
|
||||
|
|
@ -22,7 +22,7 @@ describe('SubmitContactForm action', function (): void {
|
|||
$storage = \Mockery::mock(StorageService::class);
|
||||
$storage->shouldNotReceive('storeUploadedOntoDisk');
|
||||
$action = new SubmitContactForm($storage, new PrivateS3Disk());
|
||||
$orderRef = new OrderReference(Uuid::uuid7());
|
||||
$orderRef = new OrderReference(UuidHelper::v7());
|
||||
$input = new SubmitContactFormInput(
|
||||
lastName: 'Doe',
|
||||
firstName: 'John',
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@ use App\Cqs\Actions\Crm\UnsubscribeFromNewsletter;
|
|||
use App\Cqs\Actions\Crm\UnsubscribeFromNewsletterInput;
|
||||
use App\Cqs\Actions\Crm\UnsubscribeFromNewsletterOutput;
|
||||
use App\Services\CrmService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('UnsubscribeFromNewsletter action', function (): void {
|
||||
it('returns SUCCESS when CRM service unsubscribes the customer', function (): void {
|
||||
// GIVEN
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
|
||||
/** @var \App\Services\CrmService&\Mockery\MockInterface $crmService */
|
||||
$crmService = \Mockery::mock(CrmService::class);
|
||||
|
|
@ -34,7 +34,7 @@ describe('UnsubscribeFromNewsletter action', function (): void {
|
|||
|
||||
it('returns FAILURE when CRM service returns false', function (): void {
|
||||
// GIVEN
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
|
||||
/** @var \App\Services\CrmService&\Mockery\MockInterface $crmService */
|
||||
$crmService = \Mockery::mock(CrmService::class);
|
||||
|
|
@ -54,7 +54,7 @@ describe('UnsubscribeFromNewsletter action', function (): void {
|
|||
|
||||
it('returns FAILURE without throwing when CRM service throws an exception', function (): void {
|
||||
// GIVEN
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
|
||||
/** @var \App\Services\CrmService&\Mockery\MockInterface $crmService */
|
||||
$crmService = \Mockery::mock(CrmService::class);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use Domain\Models\ValueObjects\CrmCustomer;
|
|||
use Domain\Models\ValueObjects\Email;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Infrastructure\Adapters\Services\AppCustomerAuthService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
function makePasswordTestCrmCustomer(string $hashcode, string $email): CrmCustomer
|
||||
|
|
@ -42,7 +42,7 @@ describe('UpdateCustomerPassword action', function (): void {
|
|||
it('changes password in CRM for authenticated customer', function (): void {
|
||||
/** @var \Tests\TestCase $this */
|
||||
// GIVEN
|
||||
$hashcodeUuid = Uuid::uuid4();
|
||||
$hashcodeUuid = UuidHelper::v4();
|
||||
$hashcode = $hashcodeUuid->toString();
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('claire.dupuis@example.com');
|
||||
|
|
@ -79,7 +79,7 @@ describe('UpdateCustomerPassword action', function (): void {
|
|||
// GIVEN
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('missing.crm@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->saveOrFail();
|
||||
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
|
@ -104,7 +104,7 @@ describe('UpdateCustomerPassword action', function (): void {
|
|||
it('returns false output when changePassword throws an unexpected exception', function (): void {
|
||||
/** @var \Tests\TestCase $this */
|
||||
// GIVEN
|
||||
$hashcodeUuid = Uuid::uuid4();
|
||||
$hashcodeUuid = UuidHelper::v4();
|
||||
$hashcode = $hashcodeUuid->toString();
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('pwd.error@example.com');
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use Domain\Models\ValueObjects\Email;
|
|||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Infrastructure\Adapters\Services\AppCustomerAuthService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
function makeCrmCustomerDto(string $hashcode, string $email): CrmCustomer
|
||||
|
|
@ -43,7 +43,7 @@ describe('UpdateCustomer action', function (): void {
|
|||
it('updates customer information in CRM for the authenticated customer', function (): void {
|
||||
/** @var \Tests\TestCase $this */
|
||||
// GIVEN
|
||||
$hashcodeUuid = Uuid::uuid4();
|
||||
$hashcodeUuid = UuidHelper::v4();
|
||||
$hashcode = $hashcodeUuid->toString();
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('jeanne.martin@example.com');
|
||||
|
|
@ -97,7 +97,7 @@ describe('UpdateCustomer action', function (): void {
|
|||
it('omits nullable phone and address when null and propagates validation exceptions', function (): void {
|
||||
/** @var \Tests\TestCase $this */
|
||||
// GIVEN
|
||||
$hashcodeUuid = Uuid::uuid4();
|
||||
$hashcodeUuid = UuidHelper::v4();
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('no.phone@example.com');
|
||||
$customer->hashcode = new CrmHashcode($hashcodeUuid);
|
||||
|
|
@ -144,7 +144,7 @@ describe('UpdateCustomer action', function (): void {
|
|||
// GIVEN
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('err.crm@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->saveOrFail();
|
||||
|
||||
$this->actingAs($customer, 'frontend');
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ use Illuminate\Validation\ValidationException;
|
|||
use Infrastructure\Adapters\Events\LaravelDomainEventDispatcher;
|
||||
use Infrastructure\Adapters\Services\AppCustomerAuthService;
|
||||
use Psr\Log\NullLogger;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Concurrency\Lock;
|
||||
use Shared\Concurrency\LockTimeoutException;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('RegisterCustomer action', function (): void {
|
||||
|
|
@ -62,7 +62,7 @@ describe('RegisterCustomer action', function (): void {
|
|||
$employee->service = new ShopperServiceCode('1');
|
||||
$employee->saveOrFail();
|
||||
|
||||
$crmReturnedHashcode = Uuid::uuid4()->toString();
|
||||
$crmReturnedHashcode = UuidHelper::v4()->toString();
|
||||
|
||||
$crmService = \Mockery::mock(CrmService::class);
|
||||
$crmService->shouldReceive('persist')
|
||||
|
|
@ -138,7 +138,7 @@ describe('RegisterCustomer action', function (): void {
|
|||
it('returns EMPLOYEE_ALREADY_REGISTERED when employee already has a customer_id', function (): void {
|
||||
// GIVEN
|
||||
$existingCustomer = new Customer(['email' => new Email('already@example.com')]);
|
||||
$existingCustomer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$existingCustomer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$existingCustomer->saveOrFail();
|
||||
|
||||
$matricule = new Matricule('5678901');
|
||||
|
|
@ -576,7 +576,7 @@ describe('RegisterCustomer action', function (): void {
|
|||
$employee->service = new ShopperServiceCode('1');
|
||||
$employee->saveOrFail();
|
||||
|
||||
$crmReturnedHashcode = Uuid::uuid4()->toString();
|
||||
$crmReturnedHashcode = UuidHelper::v4()->toString();
|
||||
|
||||
$crmService = \Mockery::mock(CrmService::class);
|
||||
$crmService->shouldReceive('persist')->once()->andReturn(new CrmCustomer(
|
||||
|
|
@ -645,7 +645,7 @@ describe('RegisterCustomer action', function (): void {
|
|||
$employee->service = new ShopperServiceCode('1');
|
||||
$employee->saveOrFail();
|
||||
|
||||
$crmUuid = Uuid::uuid4();
|
||||
$crmUuid = UuidHelper::v4();
|
||||
$crmReturnedHashcode = $crmUuid->toString();
|
||||
|
||||
$crmService = \Mockery::mock(CrmService::class);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use App\Cqs\Actions\Customers\UpdateCustomerLastLoginInput;
|
|||
use App\Models\Customer;
|
||||
use Domain\Models\ValueObjects\Email;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('UpdateCustomerLastLogin action', function (): void {
|
||||
|
|
@ -19,7 +19,7 @@ describe('UpdateCustomerLastLogin action', function (): void {
|
|||
Date::setTestNow('2026-11-14 10:30:00');
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('customer@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->last_login_at = null;
|
||||
$customer->saveOrFail();
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ use Infrastructure\Adapters\Services\EloquentEmployeeStatisticsService;
|
|||
use Infrastructure\Adapters\Services\SessionOrderBuilderManager;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('ApplyPickTimeSlot action', function (): void {
|
||||
|
|
@ -73,7 +73,7 @@ describe('ApplyPickTimeSlot action', function (): void {
|
|||
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('slot.buyer@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->saveOrFail();
|
||||
|
||||
$employee = new Employee();
|
||||
|
|
@ -88,8 +88,8 @@ describe('ApplyPickTimeSlot action', function (): void {
|
|||
$employee->service = new ShopperServiceCode('01');
|
||||
$employee->saveOrFail();
|
||||
|
||||
$productId = new ProductId(Uuid::uuid7());
|
||||
$basket = new Basket(new BasketId(Uuid::uuid7()), [
|
||||
$productId = new ProductId(UuidHelper::v7());
|
||||
$basket = new Basket(new BasketId(UuidHelper::v7()), [
|
||||
$productId->value->toString() => new BasketProduct(
|
||||
id: $productId,
|
||||
name: 'Filet de Poulet',
|
||||
|
|
|
|||
|
|
@ -21,16 +21,16 @@ use Domain\Services\OrderService;
|
|||
use Infrastructure\Adapters\Repositories\EloquentOrderRepository;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
function makeCancelOrderFixture(OrderStatus $status = OrderStatus::VALIDATED): Order
|
||||
{
|
||||
$shop = Shop::factory()->create();
|
||||
|
||||
return Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => $status->value,
|
||||
'total' => new Money(2500, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -63,7 +63,7 @@ describe('CancelOrder action', function (): void {
|
|||
it('returns NOT_FOUND when the order does not exist in database', function (): void {
|
||||
// GIVEN
|
||||
$missingOrder = new Order();
|
||||
$missingOrder->id = Uuid::uuid7()->toString();
|
||||
$missingOrder->id = UuidHelper::v7()->toString();
|
||||
|
||||
$action = new CancelOrder(new OrderService(new EloquentOrderRepository()));
|
||||
|
||||
|
|
|
|||
|
|
@ -19,16 +19,16 @@ use Domain\Models\ValueObjects\ShopperServiceCode;
|
|||
use Domain\Models\ValueObjects\ShopperSiteCode;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('ClaimTodayOrderReminder action', function (): void {
|
||||
it('claims an unreminded validated order atomically and rejects duplicate claims', function (): void {
|
||||
// GIVEN
|
||||
$shop = Shop::factory()->create();
|
||||
$order = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(2000, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use Infrastructure\Adapters\Events\LaravelDomainEventDispatcher;
|
|||
use Infrastructure\Adapters\Locks\LaravelCacheLock;
|
||||
use Infrastructure\Adapters\Repositories\EloquentOrderRepository;
|
||||
use Psr\Log\NullLogger;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('FailStalePendingOrders', function (): void {
|
||||
afterEach(function (): void {
|
||||
|
|
@ -38,10 +38,10 @@ describe('FailStalePendingOrders', function (): void {
|
|||
|
||||
$shop = Shop::factory()->create();
|
||||
|
||||
$stalePendingId = Uuid::uuid7()->toString();
|
||||
$freshPendingId = Uuid::uuid7()->toString();
|
||||
$staleWaitingId = Uuid::uuid7()->toString();
|
||||
$staleValidatedId = Uuid::uuid7()->toString();
|
||||
$stalePendingId = UuidHelper::v7()->toString();
|
||||
$freshPendingId = UuidHelper::v7()->toString();
|
||||
$staleWaitingId = UuidHelper::v7()->toString();
|
||||
$staleValidatedId = UuidHelper::v7()->toString();
|
||||
|
||||
$baseRow = [
|
||||
'shop_id' => $shop->id,
|
||||
|
|
@ -61,25 +61,25 @@ describe('FailStalePendingOrders', function (): void {
|
|||
DB::table('orders')->insert([
|
||||
array_merge($baseRow, [
|
||||
'id' => $stalePendingId,
|
||||
'reference' => (string) new OrderReference(Uuid::uuid7()),
|
||||
'reference' => (string) new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::PENDING->value,
|
||||
'updated_at' => $now->subMinutes(15)->toDateTimeString(),
|
||||
]),
|
||||
array_merge($baseRow, [
|
||||
'id' => $freshPendingId,
|
||||
'reference' => (string) new OrderReference(Uuid::uuid7()),
|
||||
'reference' => (string) new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::PENDING->value,
|
||||
'updated_at' => $now->subMinutes(4)->toDateTimeString(),
|
||||
]),
|
||||
array_merge($baseRow, [
|
||||
'id' => $staleWaitingId,
|
||||
'reference' => (string) new OrderReference(Uuid::uuid7()),
|
||||
'reference' => (string) new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::WAITING->value,
|
||||
'updated_at' => $now->subHours(2)->toDateTimeString(),
|
||||
]),
|
||||
array_merge($baseRow, [
|
||||
'id' => $staleValidatedId,
|
||||
'reference' => (string) new OrderReference(Uuid::uuid7()),
|
||||
'reference' => (string) new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'updated_at' => $now->subHours(2)->toDateTimeString(),
|
||||
]),
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ use Infrastructure\Adapters\Services\EloquentEmployeeStatisticsService;
|
|||
use Infrastructure\Adapters\Services\SessionOrderBuilderManager;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('InitializeOrderTunnel action', function (): void {
|
||||
it('stores OrderBuilderWithBasket in session for the shopper and basket', function (): void {
|
||||
|
|
@ -67,8 +67,8 @@ describe('InitializeOrderTunnel action', function (): void {
|
|||
new DatabaseTunnelAttemptTrackerService($session, 'order_tunnel_attempt_id'),
|
||||
);
|
||||
|
||||
$productId = new ProductId(Uuid::uuid7());
|
||||
$basket = new Basket(new BasketId(Uuid::uuid7()), [
|
||||
$productId = new ProductId(UuidHelper::v7());
|
||||
$basket = new Basket(new BasketId(UuidHelper::v7()), [
|
||||
$productId->value->toString() => new BasketProduct(
|
||||
id: $productId,
|
||||
name: 'Poulet Rôti',
|
||||
|
|
@ -91,9 +91,9 @@ describe('InitializeOrderTunnel action', function (): void {
|
|||
]);
|
||||
/** @var Customer $customer */
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'email' => new Email('init-tunnel@example.com'),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
]);
|
||||
$shopperId = $customer->getId();
|
||||
|
||||
|
|
|
|||
|
|
@ -82,9 +82,9 @@ use Infrastructure\Adapters\Services\SessionOrderBuilderManager;
|
|||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Psr\Log\NullLogger;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Concurrency\Lock;
|
||||
use Shared\Concurrency\LockTimeoutException;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('Order placement two-step CQS actions', function (): void {
|
||||
|
|
@ -128,9 +128,9 @@ describe('Order placement two-step CQS actions', function (): void {
|
|||
): array {
|
||||
/** @var Customer $customer */
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'email' => new Email('buyer-' . uniqid() . '@example.com'),
|
||||
'hashcode' => new CrmHashcode(Uuid::uuid4()),
|
||||
'hashcode' => new CrmHashcode(UuidHelper::v4()),
|
||||
]);
|
||||
|
||||
/** @var int $sequence */
|
||||
|
|
@ -389,9 +389,9 @@ describe('Order placement two-step CQS actions', function (): void {
|
|||
$ctx = buildOrderPlacementScenario(priceCents: 6000, qty: 1);
|
||||
|
||||
Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $ctx['shop']->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::PENDING->value,
|
||||
'total' => Money::EUR(16000),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -472,7 +472,7 @@ describe('Order placement two-step CQS actions', function (): void {
|
|||
|
||||
it('executes ExportOrderToRegate without opening a DB transaction and returns LOCK_TIMEOUT when lock fails', function (): void {
|
||||
// GIVEN
|
||||
$orderId = new OrderId(Uuid::uuid7());
|
||||
$orderId = new OrderId(UuidHelper::v7());
|
||||
$input = new ExportOrderToRegateInput($orderId);
|
||||
$levelBeforeExecute = DB::transactionLevel();
|
||||
$levelInsideAction = null;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use Domain\Models\ValueObjects\ShopperServiceCode;
|
|||
use Domain\Models\ValueObjects\ShopperSiteCode;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('ReleaseTodayOrderReminder action', function (): void {
|
||||
it('releases reminded_at only when timestamp matches the claim timestamp', function (): void {
|
||||
|
|
@ -28,9 +28,9 @@ describe('ReleaseTodayOrderReminder action', function (): void {
|
|||
$otherAt = CarbonImmutable::parse('2026-11-20 10:05:00');
|
||||
$shop = Shop::factory()->create();
|
||||
$order = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(2000, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ use Domain\Ports\Services\SessionService;
|
|||
use Domain\Services\BasketService;
|
||||
use Mockery;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\DDD\DomainEventDispatcher;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Uwil\Storage\Lib\ValueObjects\StorageFilePath;
|
||||
|
||||
function makeBasketServiceWithBasket(?Basket $basket): BasketService
|
||||
{
|
||||
$basketId = $basket !== null ? $basket->id : new BasketId(Uuid::uuid7());
|
||||
$basketId = $basket !== null ? $basket->id : new BasketId(UuidHelper::v7());
|
||||
$sessionId = new SessionId($basketId->value);
|
||||
|
||||
$sessionService = Mockery::mock(SessionService::class);
|
||||
|
|
@ -135,10 +135,10 @@ describe('GetBasketQuery', function (): void {
|
|||
$unpublishedProduct->price = Money::EUR(1000);
|
||||
$unpublishedProduct->save();
|
||||
|
||||
$publishedId = new ProductId(Uuid::fromString($publishedProduct->id));
|
||||
$unpublishedId = new ProductId(Uuid::fromString($unpublishedProduct->id));
|
||||
$publishedId = new ProductId(UuidHelper::fromString($publishedProduct->id));
|
||||
$unpublishedId = new ProductId(UuidHelper::fromString($unpublishedProduct->id));
|
||||
|
||||
$basket = new Basket(new BasketId(Uuid::uuid7()), [
|
||||
$basket = new Basket(new BasketId(UuidHelper::v7()), [
|
||||
makeBasketProductItem($publishedId, 'Poulet Publié', 2),
|
||||
makeBasketProductItem($unpublishedId, 'Poulet Dépublié', 1),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use App\Cqs\Queries\Customers\GetCustomerByEmailQueryInput;
|
|||
use App\Models\Customer;
|
||||
use Domain\Models\ValueObjects\Email;
|
||||
use Domain\Models\ValueObjects\Entities\ShopperId;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('GetCustomerByEmailQuery', function (): void {
|
||||
|
|
@ -17,7 +17,7 @@ describe('GetCustomerByEmailQuery', function (): void {
|
|||
// GIVEN
|
||||
$email = new Email('john.doe@example.com');
|
||||
$customer = new Customer(['email' => $email]);
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
|
||||
$query = new GetCustomerByEmailQuery();
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use Illuminate\Session\Store;
|
|||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\Pagination\PageNumber;
|
||||
use Shared\Pagination\PageSize;
|
||||
use Shared\Pagination\Pagination;
|
||||
|
|
@ -56,9 +56,9 @@ describe('GetBoPaginatedOrdersQuery', function (): void {
|
|||
): Order {
|
||||
$order = new Order();
|
||||
if ($createdAt !== null) {
|
||||
$order->id = (string) Uuid::uuid7($createdAt);
|
||||
$order->id = (string) UuidHelper::v7($createdAt);
|
||||
}
|
||||
$order->reference = new OrderReference(Uuid::uuid7());
|
||||
$order->reference = new OrderReference(UuidHelper::v7());
|
||||
$order->total = Money::EUR(2500);
|
||||
$order->status = $status;
|
||||
$order->pickup_day = Carbon::instance($pickupDay);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use Domain\Models\ValueObjects\ShopperSiteCode;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\Pagination\PageNumber;
|
||||
use Shared\Pagination\PageSize;
|
||||
use Shared\Pagination\Pagination;
|
||||
|
|
@ -42,7 +42,7 @@ describe('GetBoTodayOrdersQuery', function (): void {
|
|||
|
||||
$createOrder = static function (OrderStatus $status) use ($shop): Order {
|
||||
$order = new Order();
|
||||
$order->reference = new OrderReference(Uuid::uuid7());
|
||||
$order->reference = new OrderReference(UuidHelper::v7());
|
||||
$order->total = Money::EUR(2000);
|
||||
$order->status = $status;
|
||||
$order->pickup_day = Date::now()->addDays(4);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use Domain\Models\ValueObjects\ShopperServiceCode;
|
|||
use Domain\Models\ValueObjects\ShopperSiteCode;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\Pagination\PageNumber;
|
||||
use Shared\Pagination\PageSize;
|
||||
use Shared\Pagination\Pagination;
|
||||
|
|
@ -37,7 +37,7 @@ describe('GetFoCustomerPaginatedOrdersQuery', function (): void {
|
|||
$createCustomer = function (): Customer {
|
||||
$customer = new Customer();
|
||||
$customer->email = new Email('customer-' . uniqid() . '@example.com');
|
||||
$customer->hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$customer->hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->save();
|
||||
|
||||
return $customer;
|
||||
|
|
@ -72,7 +72,7 @@ describe('GetFoCustomerPaginatedOrdersQuery', function (): void {
|
|||
|
||||
$createOrder = function (Shop $shop, string $matricule): Order {
|
||||
$order = new Order();
|
||||
$order->reference = new OrderReference(Uuid::uuid7());
|
||||
$order->reference = new OrderReference(UuidHelper::v7());
|
||||
$order->total = Money::EUR(2500);
|
||||
$order->status = OrderStatus::WAITING;
|
||||
$order->pickup_day = Carbon::now()->addDays(2);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use Domain\Models\ValueObjects\ShopperEstablishmentCode;
|
|||
use Domain\Models\ValueObjects\ShopperServiceCode;
|
||||
use Domain\Models\ValueObjects\ShopperSiteCode;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('GetTunnelOrderConfirmedQuery', function (): void {
|
||||
it('returns order confirmed output with step, orderDto, shopDto and mapUrl', function (): void {
|
||||
|
|
@ -32,7 +32,7 @@ describe('GetTunnelOrderConfirmedQuery', function (): void {
|
|||
$shop->default = true;
|
||||
$shop->save();
|
||||
|
||||
$reference = new OrderReference(Uuid::uuid7());
|
||||
$reference = new OrderReference(UuidHelper::v7());
|
||||
|
||||
$order = new Order();
|
||||
$order->reference = $reference;
|
||||
|
|
@ -70,7 +70,7 @@ describe('GetTunnelOrderConfirmedQuery', function (): void {
|
|||
|
||||
it('throws UnexpectedValueException when order has no shop', function (): void {
|
||||
// GIVEN
|
||||
$reference = new OrderReference(Uuid::uuid7());
|
||||
$reference = new OrderReference(UuidHelper::v7());
|
||||
|
||||
$order = new Order();
|
||||
$order->reference = $reference;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use Domain\Enums\Units\InvoicingUnit;
|
|||
use Domain\Enums\Units\OrderUnit;
|
||||
use Infrastructure\Adapters\Repositories\EloquentProductRepository;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
function createTestProductForIncoQuery(): Product
|
||||
{
|
||||
|
|
@ -41,7 +41,7 @@ function createTestProductForIncoQuery(): Product
|
|||
'description' => 'Description test',
|
||||
'status' => true,
|
||||
]);
|
||||
$product->id = Uuid::uuid7()->toString();
|
||||
$product->id = UuidHelper::v7()->toString();
|
||||
$product->order = random_int(1, 999999);
|
||||
$product->price = Money::EUR(1000);
|
||||
$product->short_description = 'Court';
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use Domain\Models\ValueObjects\Entities\ProductId;
|
|||
use Domain\Models\ValueObjects\Slug;
|
||||
use Infrastructure\Adapters\Repositories\EloquentProductRepository;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
afterEach(function (): void {
|
||||
CarbonImmutable::setTestNow();
|
||||
|
|
@ -95,7 +95,7 @@ describe('GetProductWithPricingQuery', function (): void {
|
|||
->and($bySlug?->pricing->discountedPriceHt->getAmount())->toBe('1500');
|
||||
|
||||
// WHEN: by ProductId
|
||||
$byId = $query(new GetProductQueryInput(new ProductId(Uuid::fromString($product->id))));
|
||||
$byId = $query(new GetProductQueryInput(new ProductId(UuidHelper::fromString($product->id))));
|
||||
|
||||
// THEN
|
||||
expect($byId)->toBeInstanceOf(ProductWithPricingDto::class)
|
||||
|
|
@ -109,7 +109,7 @@ describe('GetProductWithPricingQuery', function (): void {
|
|||
|
||||
// WHEN
|
||||
$bySlug = $query(new GetProductQueryInput(new Slug('non-existent-slug-' . uniqid())));
|
||||
$byId = $query(new GetProductQueryInput(new ProductId(Uuid::uuid7())));
|
||||
$byId = $query(new GetProductQueryInput(new ProductId(UuidHelper::v7())));
|
||||
|
||||
// THEN
|
||||
expect($bySlug)->toBeNull()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use Domain\Services\PickupSchedulingService;
|
|||
use Illuminate\Support\Carbon;
|
||||
use Infrastructure\Adapters\Repositories\EloquentPickupExceptionRepository;
|
||||
use Infrastructure\Adapters\Repositories\EloquentShopRepository;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
afterEach(function (): void {
|
||||
CarbonImmutable::setTestNow();
|
||||
|
|
@ -31,7 +31,7 @@ describe('GetAvailableTimeslotsQuery', function (): void {
|
|||
new PickupSchedulingService(new EloquentPickupExceptionRepository()),
|
||||
new EloquentShopRepository(),
|
||||
);
|
||||
$input = new GetAvailableTimeslotsQueryInput(new ShopId(Uuid::uuid7()));
|
||||
$input = new GetAvailableTimeslotsQueryInput(new ShopId(UuidHelper::v7()));
|
||||
|
||||
// WHEN
|
||||
$result = $query($input);
|
||||
|
|
@ -57,7 +57,7 @@ describe('GetAvailableTimeslotsQuery', function (): void {
|
|||
new PickupSchedulingService(new EloquentPickupExceptionRepository()),
|
||||
new EloquentShopRepository(),
|
||||
);
|
||||
$input = new GetAvailableTimeslotsQueryInput(new ShopId(Uuid::fromString($shop->id)));
|
||||
$input = new GetAvailableTimeslotsQueryInput(new ShopId(UuidHelper::fromString($shop->id)));
|
||||
|
||||
// WHEN
|
||||
$result = $query($input);
|
||||
|
|
@ -100,7 +100,7 @@ describe('GetAvailableTimeslotsQuery', function (): void {
|
|||
new PickupSchedulingService(new EloquentPickupExceptionRepository()),
|
||||
new EloquentShopRepository(),
|
||||
);
|
||||
$input = new GetAvailableTimeslotsQueryInput(new ShopId(Uuid::fromString($shop->id)));
|
||||
$input = new GetAvailableTimeslotsQueryInput(new ShopId(UuidHelper::fromString($shop->id)));
|
||||
|
||||
// WHEN
|
||||
$result = $query($input);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use Domain\Models\ValueObjects\ShopperServiceCode;
|
|||
use Domain\Models\ValueObjects\ShopperSiteCode;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
beforeEach(function (): void {
|
||||
$now = CarbonImmutable::parse('2026-06-15 10:00:00', 'Europe/Paris');
|
||||
|
|
@ -47,9 +47,9 @@ describe('OrderLineDto Integration', function (): void {
|
|||
// GIVEN
|
||||
$shop = Shop::factory()->create();
|
||||
$order = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => Money::EUR(4154),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -66,7 +66,7 @@ describe('OrderLineDto Integration', function (): void {
|
|||
|
||||
$orderLineProduct = new OrderLineProduct(
|
||||
incoId: new IncoId(999),
|
||||
originalId: new ProductId(Uuid::uuid7()),
|
||||
originalId: new ProductId(UuidHelper::v7()),
|
||||
name: 'Terrine de Foie Gras de Canard mi-cuit 500g',
|
||||
weight: new ProductWeight(500, false),
|
||||
brand: ProductBrand::loue,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use Domain\Enums\Units\InvoicingUnit;
|
|||
use Domain\Enums\Units\OrderUnit;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
function createOrderableTestProduct(
|
||||
Range $range,
|
||||
|
|
@ -34,7 +34,7 @@ function createOrderableTestProduct(
|
|||
'orderable_start' => $orderableStart,
|
||||
'orderable_end' => $orderableEnd,
|
||||
]);
|
||||
$product->id = Uuid::uuid7()->toString();
|
||||
$product->id = UuidHelper::v7()->toString();
|
||||
$product->order = random_int(1, 999999);
|
||||
$product->price = Money::EUR(1000);
|
||||
$product->short_description = 'Description courte';
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use LDC\LDCCRM\Models\ClientModel;
|
|||
use LDC\LDCCRM\Models\Customer;
|
||||
use LDC\LDCCRM\Transport\ApiInterface;
|
||||
use LDC\LDCCRM\Utils;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('CrmService', function (): void {
|
||||
|
|
@ -32,7 +32,7 @@ describe('CrmService', function (): void {
|
|||
$crmApi = \Mockery::mock(CrmApiV4::class);
|
||||
$cacheRepository = \Mockery::mock(CacheRepository::class);
|
||||
|
||||
$uuidObj = Uuid::uuid4();
|
||||
$uuidObj = UuidHelper::v4();
|
||||
$uuid = $uuidObj->toString();
|
||||
|
||||
$libCustomer = new Customer([
|
||||
|
|
@ -105,7 +105,7 @@ describe('CrmService', function (): void {
|
|||
$cacheKey = 'crm_customer_email_' . hash('sha256', $email);
|
||||
|
||||
$expectedCustomer = new CrmCustomer(
|
||||
hashcode: (string) Uuid::uuid4(),
|
||||
hashcode: (string) UuidHelper::v4(),
|
||||
email: $email,
|
||||
password: 'Secret123!',
|
||||
firstname: 'Jane',
|
||||
|
|
@ -142,7 +142,7 @@ describe('CrmService', function (): void {
|
|||
$crmApi = \Mockery::mock(CrmApiV4::class);
|
||||
$cacheRepository = \Mockery::mock(CacheRepository::class);
|
||||
|
||||
$uuid = Uuid::uuid4();
|
||||
$uuid = UuidHelper::v4();
|
||||
$cacheKey = "crm_customer_hashcode_{$uuid}";
|
||||
|
||||
$cacheRepository->shouldReceive('remember')
|
||||
|
|
@ -171,7 +171,7 @@ describe('CrmService', function (): void {
|
|||
$crmApi = \Mockery::mock(CrmApiV4::class);
|
||||
$cacheRepository = \Mockery::mock(CacheRepository::class);
|
||||
|
||||
$uuid = (string) Uuid::uuid4();
|
||||
$uuid = (string) UuidHelper::v4();
|
||||
|
||||
$customer = new CrmCustomer(
|
||||
hashcode: $uuid,
|
||||
|
|
@ -224,7 +224,7 @@ describe('CrmService', function (): void {
|
|||
$crmApi = \Mockery::mock(CrmApiV4::class);
|
||||
$cacheRepository = new ArrayCacheRepository(new ArrayStore());
|
||||
|
||||
$uuid = Uuid::uuid4();
|
||||
$uuid = UuidHelper::v4();
|
||||
$email = 'error@example.com';
|
||||
$hashKey = "crm_customer_hashcode_{$uuid}";
|
||||
$emailKey = 'crm_customer_email_' . hash('sha256', $email);
|
||||
|
|
@ -256,7 +256,7 @@ describe('CrmService', function (): void {
|
|||
// GIVEN
|
||||
$crmApi = \Mockery::mock(CrmApiV4::class);
|
||||
$cacheRepository = \Mockery::mock(CacheRepository::class);
|
||||
$uuid = Uuid::uuid4();
|
||||
$uuid = UuidHelper::v4();
|
||||
$expectedHashKey = "crm_customer_hashcode_{$uuid->toString()}";
|
||||
|
||||
$cacheRepository->shouldReceive('get')->with($expectedHashKey)->once()->andReturnNull();
|
||||
|
|
@ -288,7 +288,7 @@ describe('CrmService', function (): void {
|
|||
// GIVEN
|
||||
$crmApi = \Mockery::mock(CrmApiV4::class);
|
||||
$cacheRepository = new ArrayCacheRepository(new ArrayStore());
|
||||
$uuid = Uuid::uuid4();
|
||||
$uuid = UuidHelper::v4();
|
||||
|
||||
$apiException = \Mockery::mock(ApiErrorException::class);
|
||||
$apiException->shouldReceive('getApiError')->andReturn(ApiError::modelNotFound);
|
||||
|
|
@ -311,7 +311,7 @@ describe('CrmService', function (): void {
|
|||
// GIVEN
|
||||
$crmApi = \Mockery::mock(CrmApiV4::class);
|
||||
$cacheRepository = new ArrayCacheRepository(new ArrayStore());
|
||||
$uuid = Uuid::uuid4();
|
||||
$uuid = UuidHelper::v4();
|
||||
|
||||
$apiInterface = \Mockery::mock(ApiInterface::class);
|
||||
$apiInterface->shouldReceive('call')->once()->andThrow(new CrmException('CRM delete error'));
|
||||
|
|
@ -330,7 +330,7 @@ describe('CrmService', function (): void {
|
|||
/** @var CrmApiV4&\Mockery\MockInterface $crmApi */
|
||||
$crmApi = \Mockery::mock(CrmApiV4::class);
|
||||
$cacheRepository = new ArrayCacheRepository(new ArrayStore());
|
||||
$uuid = Uuid::uuid4();
|
||||
$uuid = UuidHelper::v4();
|
||||
$email = new Email('Rollback@Example.com');
|
||||
$hashKey = "crm_customer_hashcode_{$uuid->toString()}";
|
||||
$emailKey = 'crm_customer_email_' . hash('sha256', 'rollback@example.com');
|
||||
|
|
@ -388,7 +388,7 @@ describe('CrmService', function (): void {
|
|||
/** @var CrmApiV4&\Mockery\MockInterface $crmApi */
|
||||
$crmApi = \Mockery::mock(CrmApiV4::class);
|
||||
$cacheRepository = new ArrayCacheRepository(new ArrayStore());
|
||||
$uuid = Uuid::uuid4();
|
||||
$uuid = UuidHelper::v4();
|
||||
$hashKey = "crm_customer_hashcode_{$uuid->toString()}";
|
||||
$emailKey = 'crm_customer_email_' . hash('sha256', 'cached@example.com');
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use Illuminate\Mail\PendingMail;
|
|||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('MailRegateService', function (): void {
|
||||
it('generates expected CSV rows and sends RegateOrderMail to configured regate address', function (): void {
|
||||
|
|
@ -27,7 +27,7 @@ describe('MailRegateService', function (): void {
|
|||
Mail::fake();
|
||||
Config::set('mail.to.regate', 'regate@example.com');
|
||||
|
||||
$uuid = Uuid::uuid7();
|
||||
$uuid = UuidHelper::v7();
|
||||
$reference = new OrderReference($uuid);
|
||||
$orderReferenceValue = (string) $reference;
|
||||
$employeeMatricule = new Matricule('1234567');
|
||||
|
|
@ -104,7 +104,7 @@ describe('MailRegateService', function (): void {
|
|||
// GIVEN
|
||||
Config::set('mail.to.regate', 'regate@example.com');
|
||||
|
||||
$reference = new OrderReference(Uuid::uuid7());
|
||||
$reference = new OrderReference(UuidHelper::v7());
|
||||
$employeeMatricule = new Matricule('1234567');
|
||||
$pickupDay = CarbonImmutable::parse('2025-01-01');
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use Domain\Models\ValueObjects\ShopperSiteCode;
|
|||
use Illuminate\Support\Facades\Date;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
covers(OrderOwnershipService::class);
|
||||
|
||||
|
|
@ -44,8 +44,8 @@ describe('OrderOwnershipService', function () {
|
|||
it('returns true if order is owned by customer', function () {
|
||||
// GIVEN
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
'email' => new Email('owner@example.com'),
|
||||
]);
|
||||
|
||||
|
|
@ -64,8 +64,8 @@ describe('OrderOwnershipService', function () {
|
|||
]);
|
||||
|
||||
$order = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(1000, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -91,8 +91,8 @@ describe('OrderOwnershipService', function () {
|
|||
it('returns false if order is not owned by customer', function () {
|
||||
// GIVEN
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
'email' => new Email('notowner@example.com'),
|
||||
]);
|
||||
|
||||
|
|
@ -111,8 +111,8 @@ describe('OrderOwnershipService', function () {
|
|||
]);
|
||||
|
||||
$order = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(1000, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -138,14 +138,14 @@ describe('OrderOwnershipService', function () {
|
|||
it('returns false if customer has no employee', function () {
|
||||
// GIVEN
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
'email' => new Email('noemp@example.com'),
|
||||
]);
|
||||
|
||||
$order = Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => new Money(1000, new Currency('EUR')),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ use Domain\Models\ValueObjects\ShopperSiteCode;
|
|||
use Illuminate\Support\Facades\Date;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
covers(StatsService::class);
|
||||
|
||||
|
|
@ -80,8 +80,8 @@ describe('StatsService', function (): void {
|
|||
int $totalCents = 1000,
|
||||
): Order {
|
||||
return Order::query()->forceCreate([
|
||||
'id' => Uuid::uuid7($createdAt)->toString(),
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'id' => UuidHelper::v7($createdAt)->toString(),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => $status->value,
|
||||
'total' => new Money($totalCents, new Currency('EUR')),
|
||||
'pickup_day' => $pickupDay,
|
||||
|
|
@ -103,8 +103,8 @@ describe('StatsService', function (): void {
|
|||
expect($service->getMembershipPercentage())->toBe(0.0);
|
||||
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
'email' => new Email('member@example.com'),
|
||||
]);
|
||||
$createEmployee(101, '1000101', $customer);
|
||||
|
|
@ -126,8 +126,8 @@ describe('StatsService', function (): void {
|
|||
$inRange = $now->subDays(3);
|
||||
$outRange = $now->subDays(20);
|
||||
$customer1 = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
'email' => new Email('range1@example.com'),
|
||||
]);
|
||||
$createEmployee(201, '1000201', $customer1, $inRange);
|
||||
|
|
@ -152,8 +152,8 @@ describe('StatsService', function (): void {
|
|||
$service = new StatsService(new Currency('EUR'));
|
||||
$now = CarbonImmutable::now();
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
'email' => new Email('stats@example.com'),
|
||||
]);
|
||||
$createEmployee(301, '1000301', $customer, $now->subDays(3));
|
||||
|
|
@ -175,7 +175,7 @@ describe('StatsService', function (): void {
|
|||
|
||||
$productVo = new OrderLineProduct(
|
||||
incoId: new IncoId(1),
|
||||
originalId: new ProductId(Uuid::uuid7()),
|
||||
originalId: new ProductId(UuidHelper::v7()),
|
||||
name: 'Poulet',
|
||||
weight: new ProductWeight(1000, false),
|
||||
brand: ProductBrand::loue,
|
||||
|
|
@ -225,8 +225,8 @@ describe('StatsService', function (): void {
|
|||
$service = new StatsService(new Currency('EUR'));
|
||||
$now = CarbonImmutable::now();
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
'email' => new Email('attempts-stats@example.com'),
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,61 +7,63 @@ namespace Tests\Integration\WithApp\Infra\Adapters\Directories;
|
|||
use App\Models\Shop;
|
||||
use Domain\Models\ValueObjects\Entities\ShopId;
|
||||
use Infrastructure\Adapters\Directories\EloquentShopDirectory;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
it('retrieves all available shops', function () {
|
||||
// GIVEN
|
||||
Shop::query()->forceCreate([
|
||||
'name' => 'Shop 1',
|
||||
'address' => 'Addr 1',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
Shop::query()->forceCreate([
|
||||
'name' => 'Shop 2',
|
||||
'address' => 'Addr 2',
|
||||
'postcode' => '75001',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
$directory = new EloquentShopDirectory();
|
||||
describe('EloquentShopDirectory', function (): void {
|
||||
it('retrieves all available shops', function () {
|
||||
// GIVEN
|
||||
Shop::query()->forceCreate([
|
||||
'name' => 'Shop 1',
|
||||
'address' => 'Addr 1',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
Shop::query()->forceCreate([
|
||||
'name' => 'Shop 2',
|
||||
'address' => 'Addr 2',
|
||||
'postcode' => '75001',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
$directory = new EloquentShopDirectory();
|
||||
|
||||
// WHEN
|
||||
$shops = $directory->getAll();
|
||||
// WHEN
|
||||
$shops = $directory->getAll();
|
||||
|
||||
// THEN
|
||||
expect($shops)->toHaveCount(2);
|
||||
});
|
||||
|
||||
it('finds a shop by its identifier', function () {
|
||||
// GIVEN
|
||||
$model = Shop::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'name' => 'Shop X',
|
||||
'address' => 'Addr X',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
$directory = new EloquentShopDirectory();
|
||||
|
||||
// WHEN
|
||||
$shop = $directory->find(new ShopId(Uuid::fromString($model->id)));
|
||||
|
||||
// THEN
|
||||
expect($shop)->not->toBeNull()
|
||||
->and($shop?->id->value->toString())->toBe($model->id)
|
||||
->and($shop?->name)->toBe($model->name);
|
||||
});
|
||||
|
||||
it('returns null if shop by id is not found', function () {
|
||||
// GIVEN
|
||||
$directory = new EloquentShopDirectory();
|
||||
|
||||
// WHEN
|
||||
$shop = $directory->find(new ShopId(Uuid::uuid7()));
|
||||
|
||||
// THEN
|
||||
expect($shop)->toBeNull();
|
||||
// THEN
|
||||
expect($shops)->toHaveCount(2);
|
||||
});
|
||||
|
||||
it('finds a shop by its identifier', function () {
|
||||
// GIVEN
|
||||
$model = Shop::query()->forceCreate([
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'name' => 'Shop X',
|
||||
'address' => 'Addr X',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
$directory = new EloquentShopDirectory();
|
||||
|
||||
// WHEN
|
||||
$shop = $directory->find(new ShopId(UuidHelper::fromString($model->id)));
|
||||
|
||||
// THEN
|
||||
expect($shop)->not->toBeNull()
|
||||
->and($shop?->id->value->toString())->toBe($model->id)
|
||||
->and($shop?->name)->toBe($model->name);
|
||||
});
|
||||
|
||||
it('returns null if shop by id is not found', function () {
|
||||
// GIVEN
|
||||
$directory = new EloquentShopDirectory();
|
||||
|
||||
// WHEN
|
||||
$shop = $directory->find(new ShopId(UuidHelper::v7()));
|
||||
|
||||
// THEN
|
||||
expect($shop)->toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,144 +10,146 @@ use Domain\Models\Entities\Order as DomainOrder;
|
|||
use Domain\Models\ValueObjects\Entities\OrderId;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Infrastructure\Adapters\Repositories\EloquentOrderRepository;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
it('returns null when finding a non-existent order by id', function () {
|
||||
// GIVEN
|
||||
$repo = new EloquentOrderRepository();
|
||||
$orderId = new OrderId(Uuid::fromString('018e4567-e89b-72d3-a456-426614174001'));
|
||||
describe('EloquentOrderRepository', function (): void {
|
||||
it('returns null when finding a non-existent order by id', function () {
|
||||
// GIVEN
|
||||
$repo = new EloquentOrderRepository();
|
||||
$orderId = new OrderId(UuidHelper::fromString('018e4567-e89b-72d3-a456-426614174001'));
|
||||
|
||||
// WHEN
|
||||
$result = $repo->find($orderId);
|
||||
// WHEN
|
||||
$result = $repo->find($orderId);
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
it('updates an existing order in the repository', function () {
|
||||
// GIVEN
|
||||
$shopId = Uuid::uuid7()->toString();
|
||||
DB::table('shops')->insertOrIgnore(['id' => $shopId, 'name' => 'Shop 1', 'postcode' => '75000', 'city' => 'Paris', 'address' => 'Addr']);
|
||||
|
||||
DB::table('orders')->insert([
|
||||
'id' => '018e4567-e89b-72d3-a456-426614174002',
|
||||
'shop_id' => $shopId,
|
||||
'reference' => Uuid::uuid7()->toString(),
|
||||
'employee' => json_encode([
|
||||
'matricule' => '1234567',
|
||||
'firstname' => 'Jean',
|
||||
'lastname' => 'Dupont',
|
||||
'facility' => 'FAC01',
|
||||
'site' => 'HQ',
|
||||
'service' => '101',
|
||||
]),
|
||||
'delivery_address' => '{}',
|
||||
'pickup_day' => '2023-01-05',
|
||||
'status' => OrderStatus::WAITING->value,
|
||||
'total' => 1000,
|
||||
]);
|
||||
|
||||
$repo = new EloquentOrderRepository();
|
||||
|
||||
$domainOrder = $repo->find(new OrderId(Uuid::fromString('018e4567-e89b-72d3-a456-426614174002')));
|
||||
Assert::isInstanceOf($domainOrder, DomainOrder::class);
|
||||
$domainOrder->status = OrderStatus::VALIDATED;
|
||||
|
||||
// WHEN
|
||||
$repo->persist($domainOrder);
|
||||
|
||||
// THEN
|
||||
/** @var object{status: int}|null $updatedOrder */
|
||||
$updatedOrder = DB::table('orders')->where('id', '018e4567-e89b-72d3-a456-426614174002')->first();
|
||||
expect($updatedOrder?->status)->toBe(OrderStatus::VALIDATED->value);
|
||||
});
|
||||
|
||||
it('finds an order for update inside a transaction', function (): void {
|
||||
// GIVEN
|
||||
$shopId = Uuid::uuid7()->toString();
|
||||
$orderId = Uuid::uuid7()->toString();
|
||||
DB::table('shops')->insertOrIgnore(['id' => $shopId, 'name' => 'Shop Lock', 'postcode' => '75000', 'city' => 'Paris', 'address' => 'Addr']);
|
||||
DB::table('orders')->insert([
|
||||
'id' => $orderId,
|
||||
'shop_id' => $shopId,
|
||||
'reference' => Uuid::uuid7()->toString(),
|
||||
'employee' => json_encode([
|
||||
'matricule' => '1234567',
|
||||
'firstname' => 'Jean',
|
||||
'lastname' => 'Dupont',
|
||||
'facility' => 'FAC01',
|
||||
'site' => 'HQ',
|
||||
'service' => '101',
|
||||
]),
|
||||
'delivery_address' => '{}',
|
||||
'pickup_day' => '2026-11-20',
|
||||
'status' => OrderStatus::PENDING->value,
|
||||
'total' => 1000,
|
||||
]);
|
||||
|
||||
$repo = new EloquentOrderRepository();
|
||||
|
||||
// WHEN
|
||||
$found = DB::transaction(static fn () => $repo->findForUpdate(new OrderId(Uuid::fromString($orderId))));
|
||||
|
||||
// THEN
|
||||
expect($found)->toBeInstanceOf(DomainOrder::class)
|
||||
->and($found?->status)->toBe(OrderStatus::PENDING);
|
||||
});
|
||||
|
||||
it('returns only stale PENDING order ids older than cutoff', function (): void {
|
||||
// GIVEN
|
||||
$shopId = Uuid::uuid7()->toString();
|
||||
$staleId = Uuid::uuid7()->toString();
|
||||
$freshId = Uuid::uuid7()->toString();
|
||||
$staleWaiting = Uuid::uuid7()->toString();
|
||||
$now = CarbonImmutable::parse('2026-11-16 12:00:00', 'UTC');
|
||||
|
||||
DB::table('shops')->insertOrIgnore(['id' => $shopId, 'name' => 'Shop Stale', 'postcode' => '75000', 'city' => 'Paris', 'address' => 'Addr']);
|
||||
|
||||
$baseRow = [
|
||||
'shop_id' => $shopId,
|
||||
'employee' => json_encode([
|
||||
'matricule' => '1234567',
|
||||
'firstname' => 'Jean',
|
||||
'lastname' => 'Dupont',
|
||||
'facility' => 'FAC01',
|
||||
'site' => 'HQ',
|
||||
'service' => '101',
|
||||
]),
|
||||
'delivery_address' => '{}',
|
||||
'pickup_day' => '2026-11-20',
|
||||
'total' => 1000,
|
||||
];
|
||||
|
||||
DB::table('orders')->insert([
|
||||
array_merge($baseRow, [
|
||||
'id' => $staleId,
|
||||
'reference' => Uuid::uuid7()->toString(),
|
||||
'status' => OrderStatus::PENDING->value,
|
||||
'updated_at' => $now->subMinutes(15)->toDateTimeString(),
|
||||
]),
|
||||
array_merge($baseRow, [
|
||||
'id' => $freshId,
|
||||
'reference' => Uuid::uuid7()->toString(),
|
||||
'status' => OrderStatus::PENDING->value,
|
||||
'updated_at' => $now->subMinutes(5)->toDateTimeString(),
|
||||
]),
|
||||
array_merge($baseRow, [
|
||||
'id' => $staleWaiting,
|
||||
'reference' => Uuid::uuid7()->toString(),
|
||||
'status' => OrderStatus::WAITING->value,
|
||||
'updated_at' => $now->subMinutes(30)->toDateTimeString(),
|
||||
]),
|
||||
]);
|
||||
|
||||
$repo = new EloquentOrderRepository();
|
||||
|
||||
// WHEN
|
||||
$staleIds = $repo->findStalePendingOrderIds($now->subMinutes(10));
|
||||
|
||||
// THEN
|
||||
expect($staleIds)->toHaveCount(1)
|
||||
->and($staleIds[0]->value->toString())->toBe($staleId);
|
||||
// THEN
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
it('updates an existing order in the repository', function () {
|
||||
// GIVEN
|
||||
$shopId = UuidHelper::v7()->toString();
|
||||
DB::table('shops')->insertOrIgnore(['id' => $shopId, 'name' => 'Shop 1', 'postcode' => '75000', 'city' => 'Paris', 'address' => 'Addr']);
|
||||
|
||||
DB::table('orders')->insert([
|
||||
'id' => '018e4567-e89b-72d3-a456-426614174002',
|
||||
'shop_id' => $shopId,
|
||||
'reference' => UuidHelper::v7()->toString(),
|
||||
'employee' => json_encode([
|
||||
'matricule' => '1234567',
|
||||
'firstname' => 'Jean',
|
||||
'lastname' => 'Dupont',
|
||||
'facility' => 'FAC01',
|
||||
'site' => 'HQ',
|
||||
'service' => '101',
|
||||
]),
|
||||
'delivery_address' => '{}',
|
||||
'pickup_day' => '2023-01-05',
|
||||
'status' => OrderStatus::WAITING->value,
|
||||
'total' => 1000,
|
||||
]);
|
||||
|
||||
$repo = new EloquentOrderRepository();
|
||||
|
||||
$domainOrder = $repo->find(new OrderId(UuidHelper::fromString('018e4567-e89b-72d3-a456-426614174002')));
|
||||
Assert::isInstanceOf($domainOrder, DomainOrder::class);
|
||||
$domainOrder->status = OrderStatus::VALIDATED;
|
||||
|
||||
// WHEN
|
||||
$repo->persist($domainOrder);
|
||||
|
||||
// THEN
|
||||
/** @var object{status: int}|null $updatedOrder */
|
||||
$updatedOrder = DB::table('orders')->where('id', '018e4567-e89b-72d3-a456-426614174002')->first();
|
||||
expect($updatedOrder?->status)->toBe(OrderStatus::VALIDATED->value);
|
||||
});
|
||||
|
||||
it('finds an order for update inside a transaction', function (): void {
|
||||
// GIVEN
|
||||
$shopId = UuidHelper::v7()->toString();
|
||||
$orderId = UuidHelper::v7()->toString();
|
||||
DB::table('shops')->insertOrIgnore(['id' => $shopId, 'name' => 'Shop Lock', 'postcode' => '75000', 'city' => 'Paris', 'address' => 'Addr']);
|
||||
DB::table('orders')->insert([
|
||||
'id' => $orderId,
|
||||
'shop_id' => $shopId,
|
||||
'reference' => UuidHelper::v7()->toString(),
|
||||
'employee' => json_encode([
|
||||
'matricule' => '1234567',
|
||||
'firstname' => 'Jean',
|
||||
'lastname' => 'Dupont',
|
||||
'facility' => 'FAC01',
|
||||
'site' => 'HQ',
|
||||
'service' => '101',
|
||||
]),
|
||||
'delivery_address' => '{}',
|
||||
'pickup_day' => '2026-11-20',
|
||||
'status' => OrderStatus::PENDING->value,
|
||||
'total' => 1000,
|
||||
]);
|
||||
|
||||
$repo = new EloquentOrderRepository();
|
||||
|
||||
// WHEN
|
||||
$found = DB::transaction(static fn () => $repo->findForUpdate(new OrderId(UuidHelper::fromString($orderId))));
|
||||
|
||||
// THEN
|
||||
expect($found)->toBeInstanceOf(DomainOrder::class)
|
||||
->and($found?->status)->toBe(OrderStatus::PENDING);
|
||||
});
|
||||
|
||||
it('returns only stale PENDING order ids older than cutoff', function (): void {
|
||||
// GIVEN
|
||||
$shopId = UuidHelper::v7()->toString();
|
||||
$staleId = UuidHelper::v7()->toString();
|
||||
$freshId = UuidHelper::v7()->toString();
|
||||
$staleWaiting = UuidHelper::v7()->toString();
|
||||
$now = CarbonImmutable::parse('2026-11-16 12:00:00', 'UTC');
|
||||
|
||||
DB::table('shops')->insertOrIgnore(['id' => $shopId, 'name' => 'Shop Stale', 'postcode' => '75000', 'city' => 'Paris', 'address' => 'Addr']);
|
||||
|
||||
$baseRow = [
|
||||
'shop_id' => $shopId,
|
||||
'employee' => json_encode([
|
||||
'matricule' => '1234567',
|
||||
'firstname' => 'Jean',
|
||||
'lastname' => 'Dupont',
|
||||
'facility' => 'FAC01',
|
||||
'site' => 'HQ',
|
||||
'service' => '101',
|
||||
]),
|
||||
'delivery_address' => '{}',
|
||||
'pickup_day' => '2026-11-20',
|
||||
'total' => 1000,
|
||||
];
|
||||
|
||||
DB::table('orders')->insert([
|
||||
array_merge($baseRow, [
|
||||
'id' => $staleId,
|
||||
'reference' => UuidHelper::v7()->toString(),
|
||||
'status' => OrderStatus::PENDING->value,
|
||||
'updated_at' => $now->subMinutes(15)->toDateTimeString(),
|
||||
]),
|
||||
array_merge($baseRow, [
|
||||
'id' => $freshId,
|
||||
'reference' => UuidHelper::v7()->toString(),
|
||||
'status' => OrderStatus::PENDING->value,
|
||||
'updated_at' => $now->subMinutes(5)->toDateTimeString(),
|
||||
]),
|
||||
array_merge($baseRow, [
|
||||
'id' => $staleWaiting,
|
||||
'reference' => UuidHelper::v7()->toString(),
|
||||
'status' => OrderStatus::WAITING->value,
|
||||
'updated_at' => $now->subMinutes(30)->toDateTimeString(),
|
||||
]),
|
||||
]);
|
||||
|
||||
$repo = new EloquentOrderRepository();
|
||||
|
||||
// WHEN
|
||||
$staleIds = $repo->findStalePendingOrderIds($now->subMinutes(10));
|
||||
|
||||
// THEN
|
||||
expect($staleIds)->toHaveCount(1)
|
||||
->and($staleIds[0]->value->toString())->toBe($staleId);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,110 +11,112 @@ use Domain\Enums\RepeatFrequency;
|
|||
use Domain\Models\ValueObjects\Entities\ShopId;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Infrastructure\Adapters\Repositories\EloquentPickupExceptionRepository;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
it('retrieves exceptions within a period for a shop', function () {
|
||||
// GIVEN
|
||||
$shopUuid = Uuid::uuid7();
|
||||
$shop = Shop::query()->forceCreate([
|
||||
'id' => $shopUuid->toString(),
|
||||
'name' => 'Shop 1',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'address' => 'Addr',
|
||||
]);
|
||||
describe('EloquentPickupExceptionRepository', function (): void {
|
||||
it('retrieves exceptions within a period for a shop', function () {
|
||||
// GIVEN
|
||||
$shopUuid = UuidHelper::v7();
|
||||
$shop = Shop::query()->forceCreate([
|
||||
'id' => $shopUuid->toString(),
|
||||
'name' => 'Shop 1',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'address' => 'Addr',
|
||||
]);
|
||||
|
||||
$exUuid = Uuid::uuid7();
|
||||
$ex1 = PickupException::query()->forceCreate([
|
||||
'id' => $exUuid->toString(),
|
||||
'date' => '2023-01-10',
|
||||
'label' => 'Fermé',
|
||||
'repeatable' => false,
|
||||
'repeat_frequency' => RepeatFrequency::WEEKLY->value,
|
||||
'auto_updated' => false,
|
||||
]);
|
||||
$exUuid = UuidHelper::v7();
|
||||
$ex1 = PickupException::query()->forceCreate([
|
||||
'id' => $exUuid->toString(),
|
||||
'date' => '2023-01-10',
|
||||
'label' => 'Fermé',
|
||||
'repeatable' => false,
|
||||
'repeat_frequency' => RepeatFrequency::WEEKLY->value,
|
||||
'auto_updated' => false,
|
||||
]);
|
||||
|
||||
DB::table('shop_pickup_exception')->insert([
|
||||
'shop_id' => $shop->id,
|
||||
'pickup_exception_id' => $ex1->id,
|
||||
'replacement_date' => '2023-01-11',
|
||||
'order_deadline_at' => '2023-01-09 10:00:00',
|
||||
]);
|
||||
DB::table('shop_pickup_exception')->insert([
|
||||
'shop_id' => $shop->id,
|
||||
'pickup_exception_id' => $ex1->id,
|
||||
'replacement_date' => '2023-01-11',
|
||||
'order_deadline_at' => '2023-01-09 10:00:00',
|
||||
]);
|
||||
|
||||
$shopId = new ShopId($shopUuid);
|
||||
$period = CarbonPeriod::create('2023-01-01', '2023-01-31');
|
||||
$shopId = new ShopId($shopUuid);
|
||||
$period = CarbonPeriod::create('2023-01-01', '2023-01-31');
|
||||
|
||||
$repo = new EloquentPickupExceptionRepository();
|
||||
$repo = new EloquentPickupExceptionRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->getExceptionsForShop($shopId, $period);
|
||||
// WHEN
|
||||
$result = $repo->getExceptionsForShop($shopId, $period);
|
||||
|
||||
// THEN
|
||||
expect($result)->toHaveCount(1)
|
||||
->and($result[0]->exception->id->value->toString())->toBe($exUuid->toString())
|
||||
->and($result[0]->replacementDate?->format('Y-m-d'))->toBe('2023-01-11')
|
||||
->and($result[0]->orderDeadlineAt?->format('Y-m-d H:i:s'))->toBe('2023-01-09 10:00:00');
|
||||
});
|
||||
|
||||
it('retrieves all exceptions', function () {
|
||||
// GIVEN
|
||||
$exUuid = Uuid::uuid7();
|
||||
PickupException::query()->forceCreate([
|
||||
'id' => $exUuid->toString(),
|
||||
'date' => '2023-01-10',
|
||||
'label' => 'Fermé',
|
||||
'repeatable' => false,
|
||||
'repeat_frequency' => RepeatFrequency::WEEKLY->value,
|
||||
'auto_updated' => false,
|
||||
]);
|
||||
|
||||
$repo = new EloquentPickupExceptionRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->getAllExceptions();
|
||||
|
||||
// THEN
|
||||
expect($result)->toHaveCount(1)
|
||||
->and($result[0]->id->value->toString())->toBe($exUuid->toString());
|
||||
});
|
||||
|
||||
it('retrieves exceptions associated with a shop', function () {
|
||||
// GIVEN
|
||||
$shopUuid = Uuid::uuid7();
|
||||
$shop = Shop::query()->forceCreate([
|
||||
'id' => $shopUuid->toString(),
|
||||
'name' => 'Shop 1',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'address' => 'Addr',
|
||||
]);
|
||||
|
||||
$exUuid = Uuid::uuid7();
|
||||
$ex1 = PickupException::query()->forceCreate([
|
||||
'id' => $exUuid->toString(),
|
||||
'date' => '2023-01-10',
|
||||
'label' => 'Fermé',
|
||||
'repeatable' => false,
|
||||
'repeat_frequency' => RepeatFrequency::WEEKLY->value,
|
||||
'auto_updated' => false,
|
||||
]);
|
||||
|
||||
DB::table('shop_pickup_exception')->insert([
|
||||
'shop_id' => $shop->id,
|
||||
'pickup_exception_id' => $ex1->id,
|
||||
'replacement_date' => '2023-01-11',
|
||||
'order_deadline_at' => '2023-01-09 10:00:00',
|
||||
]);
|
||||
|
||||
$shopId = new ShopId($shopUuid);
|
||||
|
||||
$repo = new EloquentPickupExceptionRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->getExceptionsAssociatedWithShop($shopId);
|
||||
|
||||
// THEN
|
||||
expect($result)->toHaveCount(1)
|
||||
->and($result[0]->exception->id->value->toString())->toBe($exUuid->toString())
|
||||
->and($result[0]->replacementDate?->format('Y-m-d'))->toBe('2023-01-11');
|
||||
// THEN
|
||||
expect($result)->toHaveCount(1)
|
||||
->and($result[0]->exception->id->value->toString())->toBe($exUuid->toString())
|
||||
->and($result[0]->replacementDate?->format('Y-m-d'))->toBe('2023-01-11')
|
||||
->and($result[0]->orderDeadlineAt?->format('Y-m-d H:i:s'))->toBe('2023-01-09 10:00:00');
|
||||
});
|
||||
|
||||
it('retrieves all exceptions', function () {
|
||||
// GIVEN
|
||||
$exUuid = UuidHelper::v7();
|
||||
PickupException::query()->forceCreate([
|
||||
'id' => $exUuid->toString(),
|
||||
'date' => '2023-01-10',
|
||||
'label' => 'Fermé',
|
||||
'repeatable' => false,
|
||||
'repeat_frequency' => RepeatFrequency::WEEKLY->value,
|
||||
'auto_updated' => false,
|
||||
]);
|
||||
|
||||
$repo = new EloquentPickupExceptionRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->getAllExceptions();
|
||||
|
||||
// THEN
|
||||
expect($result)->toHaveCount(1)
|
||||
->and($result[0]->id->value->toString())->toBe($exUuid->toString());
|
||||
});
|
||||
|
||||
it('retrieves exceptions associated with a shop', function () {
|
||||
// GIVEN
|
||||
$shopUuid = UuidHelper::v7();
|
||||
$shop = Shop::query()->forceCreate([
|
||||
'id' => $shopUuid->toString(),
|
||||
'name' => 'Shop 1',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'address' => 'Addr',
|
||||
]);
|
||||
|
||||
$exUuid = UuidHelper::v7();
|
||||
$ex1 = PickupException::query()->forceCreate([
|
||||
'id' => $exUuid->toString(),
|
||||
'date' => '2023-01-10',
|
||||
'label' => 'Fermé',
|
||||
'repeatable' => false,
|
||||
'repeat_frequency' => RepeatFrequency::WEEKLY->value,
|
||||
'auto_updated' => false,
|
||||
]);
|
||||
|
||||
DB::table('shop_pickup_exception')->insert([
|
||||
'shop_id' => $shop->id,
|
||||
'pickup_exception_id' => $ex1->id,
|
||||
'replacement_date' => '2023-01-11',
|
||||
'order_deadline_at' => '2023-01-09 10:00:00',
|
||||
]);
|
||||
|
||||
$shopId = new ShopId($shopUuid);
|
||||
|
||||
$repo = new EloquentPickupExceptionRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->getExceptionsAssociatedWithShop($shopId);
|
||||
|
||||
// THEN
|
||||
expect($result)->toHaveCount(1)
|
||||
->and($result[0]->exception->id->value->toString())->toBe($exUuid->toString())
|
||||
->and($result[0]->replacementDate?->format('Y-m-d'))->toBe('2023-01-11');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use Illuminate\Support\Facades\DB;
|
|||
use Infrastructure\Adapters\Repositories\EloquentProductRepository;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
function createRepoTestProductRange(): int
|
||||
{
|
||||
|
|
@ -28,234 +28,236 @@ function createRepoTestProductRange(): int
|
|||
return $range->id;
|
||||
}
|
||||
|
||||
it('retrieves a basket product', function () {
|
||||
// GIVEN
|
||||
$uuid = Uuid::uuid7()->toString();
|
||||
$currency = new Currency('EUR');
|
||||
$rangeId = createRepoTestProductRange();
|
||||
describe('EloquentProductRepository', function (): void {
|
||||
it('retrieves a basket product', function () {
|
||||
// GIVEN
|
||||
$uuid = UuidHelper::v7()->toString();
|
||||
$currency = new Currency('EUR');
|
||||
$rangeId = createRepoTestProductRange();
|
||||
|
||||
Product::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'name' => 'Product Name',
|
||||
'tax_rate' => 1,
|
||||
'weight' => 1000,
|
||||
'brand' => 'none',
|
||||
'order_unit' => OrderUnit::PCE->value,
|
||||
'invoicing_unit' => 'PCE',
|
||||
'sell_unit' => 'PCE',
|
||||
'range_id' => $rangeId,
|
||||
'slug' => 'product-name',
|
||||
'picture' => 'pic.jpg',
|
||||
'picture_alt' => '',
|
||||
'picture_title' => '',
|
||||
'picture_large_alt' => '',
|
||||
'picture_large_title' => '',
|
||||
'description' => 'Desc',
|
||||
'weight_variable' => false,
|
||||
'status' => 1,
|
||||
'price' => new Money(100, $currency),
|
||||
]);
|
||||
DB::table('product_incos')->insert(['product_id' => $uuid, 'no_art' => 12345]);
|
||||
Product::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'name' => 'Product Name',
|
||||
'tax_rate' => 1,
|
||||
'weight' => 1000,
|
||||
'brand' => 'none',
|
||||
'order_unit' => OrderUnit::PCE->value,
|
||||
'invoicing_unit' => 'PCE',
|
||||
'sell_unit' => 'PCE',
|
||||
'range_id' => $rangeId,
|
||||
'slug' => 'product-name',
|
||||
'picture' => 'pic.jpg',
|
||||
'picture_alt' => '',
|
||||
'picture_title' => '',
|
||||
'picture_large_alt' => '',
|
||||
'picture_large_title' => '',
|
||||
'description' => 'Desc',
|
||||
'weight_variable' => false,
|
||||
'status' => 1,
|
||||
'price' => new Money(100, $currency),
|
||||
]);
|
||||
DB::table('product_incos')->insert(['product_id' => $uuid, 'no_art' => 12345]);
|
||||
|
||||
$id = new ProductId(Uuid::fromString($uuid));
|
||||
$id = new ProductId(UuidHelper::fromString($uuid));
|
||||
|
||||
$repo = new EloquentProductRepository();
|
||||
$repo = new EloquentProductRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->getBasketProduct($id, 2);
|
||||
// WHEN
|
||||
$result = $repo->getBasketProduct($id, 2);
|
||||
|
||||
// THEN
|
||||
expect($result->name)->toBe('Product Name')
|
||||
->and($result->qty)->toBe(2);
|
||||
});
|
||||
|
||||
it('throws UnorderableProductException when retrieving a basket product without inco', function (): void {
|
||||
// GIVEN
|
||||
$uuid = Uuid::uuid7()->toString();
|
||||
$currency = new Currency('EUR');
|
||||
$rangeId = createRepoTestProductRange();
|
||||
|
||||
Product::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'name' => 'Product Without Inco',
|
||||
'tax_rate' => 1,
|
||||
'weight' => 1000,
|
||||
'brand' => 'none',
|
||||
'order_unit' => OrderUnit::PCE->value,
|
||||
'invoicing_unit' => 'PCE',
|
||||
'sell_unit' => 'PCE',
|
||||
'range_id' => $rangeId,
|
||||
'slug' => 'product-without-inco',
|
||||
'picture' => 'pic.jpg',
|
||||
'picture_alt' => '',
|
||||
'picture_title' => '',
|
||||
'picture_large_alt' => '',
|
||||
'picture_large_title' => '',
|
||||
'description' => 'Desc',
|
||||
'weight_variable' => false,
|
||||
'status' => 1,
|
||||
'price' => new Money(100, $currency),
|
||||
]);
|
||||
|
||||
$id = new ProductId(Uuid::fromString($uuid));
|
||||
$repo = new EloquentProductRepository();
|
||||
|
||||
// WHEN
|
||||
$action = fn () => $repo->getBasketProduct($id, 1);
|
||||
|
||||
// THEN
|
||||
expect($action)->toThrow(UnorderableProductException::class);
|
||||
});
|
||||
|
||||
it('throws UnorderableProductException when retrieving an unpublished basket product', function (): void {
|
||||
// GIVEN
|
||||
$uuid = Uuid::uuid7()->toString();
|
||||
$currency = new Currency('EUR');
|
||||
$rangeId = createRepoTestProductRange();
|
||||
|
||||
Product::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'name' => 'Unpublished Product',
|
||||
'tax_rate' => 1,
|
||||
'weight' => 1000,
|
||||
'brand' => 'none',
|
||||
'order_unit' => OrderUnit::PCE->value,
|
||||
'invoicing_unit' => 'PCE',
|
||||
'sell_unit' => 'PCE',
|
||||
'range_id' => $rangeId,
|
||||
'slug' => 'unpublished-product',
|
||||
'picture' => 'pic.jpg',
|
||||
'picture_alt' => '',
|
||||
'picture_title' => '',
|
||||
'picture_large_alt' => '',
|
||||
'picture_large_title' => '',
|
||||
'description' => 'Desc',
|
||||
'weight_variable' => false,
|
||||
'status' => 0,
|
||||
'price' => new Money(100, $currency),
|
||||
]);
|
||||
DB::table('product_incos')->insert(['product_id' => $uuid, 'no_art' => 12345]);
|
||||
|
||||
$id = new ProductId(Uuid::fromString($uuid));
|
||||
$repo = new EloquentProductRepository();
|
||||
|
||||
// WHEN
|
||||
$action = fn () => $repo->getBasketProduct($id, 1);
|
||||
|
||||
// THEN
|
||||
expect($action)->toThrow(UnorderableProductException::class);
|
||||
});
|
||||
|
||||
it('throws UnorderableProductException when retrieving a basket product outside orderable dates', function (): void {
|
||||
// GIVEN
|
||||
$expiredUuid = Uuid::uuid7()->toString();
|
||||
$futureUuid = Uuid::uuid7()->toString();
|
||||
$currency = new Currency('EUR');
|
||||
$rangeId = createRepoTestProductRange();
|
||||
|
||||
Product::query()->forceCreate([
|
||||
'id' => $expiredUuid,
|
||||
'name' => 'Expired Product',
|
||||
'tax_rate' => 1,
|
||||
'weight' => 1000,
|
||||
'brand' => 'none',
|
||||
'order_unit' => OrderUnit::PCE->value,
|
||||
'invoicing_unit' => 'PCE',
|
||||
'sell_unit' => 'PCE',
|
||||
'range_id' => $rangeId,
|
||||
'slug' => 'expired-product',
|
||||
'picture' => 'pic.jpg',
|
||||
'picture_alt' => '',
|
||||
'picture_title' => '',
|
||||
'picture_large_alt' => '',
|
||||
'picture_large_title' => '',
|
||||
'description' => 'Desc',
|
||||
'weight_variable' => false,
|
||||
'status' => 1,
|
||||
'orderable_end' => now()->subDay(),
|
||||
'price' => new Money(100, $currency),
|
||||
]);
|
||||
DB::table('product_incos')->insert(['product_id' => $expiredUuid, 'no_art' => 12345]);
|
||||
|
||||
Product::query()->forceCreate([
|
||||
'id' => $futureUuid,
|
||||
'name' => 'Future Product',
|
||||
'tax_rate' => 1,
|
||||
'weight' => 1000,
|
||||
'brand' => 'none',
|
||||
'order_unit' => OrderUnit::PCE->value,
|
||||
'invoicing_unit' => 'PCE',
|
||||
'sell_unit' => 'PCE',
|
||||
'range_id' => $rangeId,
|
||||
'slug' => 'future-product',
|
||||
'picture' => 'pic.jpg',
|
||||
'picture_alt' => '',
|
||||
'picture_title' => '',
|
||||
'picture_large_alt' => '',
|
||||
'picture_large_title' => '',
|
||||
'description' => 'Desc',
|
||||
'weight_variable' => false,
|
||||
'status' => 1,
|
||||
'orderable_start' => now()->addDay(),
|
||||
'price' => new Money(100, $currency),
|
||||
]);
|
||||
DB::table('product_incos')->insert(['product_id' => $futureUuid, 'no_art' => 12346]);
|
||||
|
||||
$repo = new EloquentProductRepository();
|
||||
|
||||
// WHEN
|
||||
$expiredAction = fn () => $repo->getBasketProduct(new ProductId(Uuid::fromString($expiredUuid)), 1);
|
||||
$futureAction = fn () => $repo->getBasketProduct(new ProductId(Uuid::fromString($futureUuid)), 1);
|
||||
|
||||
// THEN
|
||||
expect($expiredAction)->toThrow(UnorderableProductException::class)
|
||||
->and($futureAction)->toThrow(UnorderableProductException::class);
|
||||
});
|
||||
|
||||
it('finds a product by id', function () {
|
||||
// GIVEN
|
||||
$uuid = Uuid::uuid7()->toString();
|
||||
$rangeId = createRepoTestProductRange();
|
||||
|
||||
Product::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'name' => 'Product Name',
|
||||
'tax_rate' => 1,
|
||||
'weight' => 1000,
|
||||
'brand' => 'none',
|
||||
'slug' => 'product-name',
|
||||
'invoicing_unit' => 'PCE',
|
||||
'sell_unit' => 'PCE',
|
||||
'range_id' => $rangeId,
|
||||
'picture_alt' => '',
|
||||
'picture_title' => '',
|
||||
'picture_large_alt' => '',
|
||||
'picture_large_title' => '',
|
||||
'description' => '',
|
||||
'status' => 1,
|
||||
'price' => new Money(100, new Currency('EUR')),
|
||||
]);
|
||||
|
||||
$id = new ProductId(Uuid::fromString($uuid));
|
||||
|
||||
$repo = new EloquentProductRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->find($id);
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeInstanceOf(DomainProduct::class);
|
||||
});
|
||||
|
||||
it('returns null if product by id is not found', function () {
|
||||
// GIVEN
|
||||
$id = new ProductId(Uuid::uuid7());
|
||||
|
||||
$repo = new EloquentProductRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->find($id);
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeNull();
|
||||
// THEN
|
||||
expect($result->name)->toBe('Product Name')
|
||||
->and($result->qty)->toBe(2);
|
||||
});
|
||||
|
||||
it('throws UnorderableProductException when retrieving a basket product without inco', function (): void {
|
||||
// GIVEN
|
||||
$uuid = UuidHelper::v7()->toString();
|
||||
$currency = new Currency('EUR');
|
||||
$rangeId = createRepoTestProductRange();
|
||||
|
||||
Product::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'name' => 'Product Without Inco',
|
||||
'tax_rate' => 1,
|
||||
'weight' => 1000,
|
||||
'brand' => 'none',
|
||||
'order_unit' => OrderUnit::PCE->value,
|
||||
'invoicing_unit' => 'PCE',
|
||||
'sell_unit' => 'PCE',
|
||||
'range_id' => $rangeId,
|
||||
'slug' => 'product-without-inco',
|
||||
'picture' => 'pic.jpg',
|
||||
'picture_alt' => '',
|
||||
'picture_title' => '',
|
||||
'picture_large_alt' => '',
|
||||
'picture_large_title' => '',
|
||||
'description' => 'Desc',
|
||||
'weight_variable' => false,
|
||||
'status' => 1,
|
||||
'price' => new Money(100, $currency),
|
||||
]);
|
||||
|
||||
$id = new ProductId(UuidHelper::fromString($uuid));
|
||||
$repo = new EloquentProductRepository();
|
||||
|
||||
// WHEN
|
||||
$action = fn () => $repo->getBasketProduct($id, 1);
|
||||
|
||||
// THEN
|
||||
expect($action)->toThrow(UnorderableProductException::class);
|
||||
});
|
||||
|
||||
it('throws UnorderableProductException when retrieving an unpublished basket product', function (): void {
|
||||
// GIVEN
|
||||
$uuid = UuidHelper::v7()->toString();
|
||||
$currency = new Currency('EUR');
|
||||
$rangeId = createRepoTestProductRange();
|
||||
|
||||
Product::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'name' => 'Unpublished Product',
|
||||
'tax_rate' => 1,
|
||||
'weight' => 1000,
|
||||
'brand' => 'none',
|
||||
'order_unit' => OrderUnit::PCE->value,
|
||||
'invoicing_unit' => 'PCE',
|
||||
'sell_unit' => 'PCE',
|
||||
'range_id' => $rangeId,
|
||||
'slug' => 'unpublished-product',
|
||||
'picture' => 'pic.jpg',
|
||||
'picture_alt' => '',
|
||||
'picture_title' => '',
|
||||
'picture_large_alt' => '',
|
||||
'picture_large_title' => '',
|
||||
'description' => 'Desc',
|
||||
'weight_variable' => false,
|
||||
'status' => 0,
|
||||
'price' => new Money(100, $currency),
|
||||
]);
|
||||
DB::table('product_incos')->insert(['product_id' => $uuid, 'no_art' => 12345]);
|
||||
|
||||
$id = new ProductId(UuidHelper::fromString($uuid));
|
||||
$repo = new EloquentProductRepository();
|
||||
|
||||
// WHEN
|
||||
$action = fn () => $repo->getBasketProduct($id, 1);
|
||||
|
||||
// THEN
|
||||
expect($action)->toThrow(UnorderableProductException::class);
|
||||
});
|
||||
|
||||
it('throws UnorderableProductException when retrieving a basket product outside orderable dates', function (): void {
|
||||
// GIVEN
|
||||
$expiredUuid = UuidHelper::v7()->toString();
|
||||
$futureUuid = UuidHelper::v7()->toString();
|
||||
$currency = new Currency('EUR');
|
||||
$rangeId = createRepoTestProductRange();
|
||||
|
||||
Product::query()->forceCreate([
|
||||
'id' => $expiredUuid,
|
||||
'name' => 'Expired Product',
|
||||
'tax_rate' => 1,
|
||||
'weight' => 1000,
|
||||
'brand' => 'none',
|
||||
'order_unit' => OrderUnit::PCE->value,
|
||||
'invoicing_unit' => 'PCE',
|
||||
'sell_unit' => 'PCE',
|
||||
'range_id' => $rangeId,
|
||||
'slug' => 'expired-product',
|
||||
'picture' => 'pic.jpg',
|
||||
'picture_alt' => '',
|
||||
'picture_title' => '',
|
||||
'picture_large_alt' => '',
|
||||
'picture_large_title' => '',
|
||||
'description' => 'Desc',
|
||||
'weight_variable' => false,
|
||||
'status' => 1,
|
||||
'orderable_end' => now()->subDay(),
|
||||
'price' => new Money(100, $currency),
|
||||
]);
|
||||
DB::table('product_incos')->insert(['product_id' => $expiredUuid, 'no_art' => 12345]);
|
||||
|
||||
Product::query()->forceCreate([
|
||||
'id' => $futureUuid,
|
||||
'name' => 'Future Product',
|
||||
'tax_rate' => 1,
|
||||
'weight' => 1000,
|
||||
'brand' => 'none',
|
||||
'order_unit' => OrderUnit::PCE->value,
|
||||
'invoicing_unit' => 'PCE',
|
||||
'sell_unit' => 'PCE',
|
||||
'range_id' => $rangeId,
|
||||
'slug' => 'future-product',
|
||||
'picture' => 'pic.jpg',
|
||||
'picture_alt' => '',
|
||||
'picture_title' => '',
|
||||
'picture_large_alt' => '',
|
||||
'picture_large_title' => '',
|
||||
'description' => 'Desc',
|
||||
'weight_variable' => false,
|
||||
'status' => 1,
|
||||
'orderable_start' => now()->addDay(),
|
||||
'price' => new Money(100, $currency),
|
||||
]);
|
||||
DB::table('product_incos')->insert(['product_id' => $futureUuid, 'no_art' => 12346]);
|
||||
|
||||
$repo = new EloquentProductRepository();
|
||||
|
||||
// WHEN
|
||||
$expiredAction = fn () => $repo->getBasketProduct(new ProductId(UuidHelper::fromString($expiredUuid)), 1);
|
||||
$futureAction = fn () => $repo->getBasketProduct(new ProductId(UuidHelper::fromString($futureUuid)), 1);
|
||||
|
||||
// THEN
|
||||
expect($expiredAction)->toThrow(UnorderableProductException::class)
|
||||
->and($futureAction)->toThrow(UnorderableProductException::class);
|
||||
});
|
||||
|
||||
it('finds a product by id', function () {
|
||||
// GIVEN
|
||||
$uuid = UuidHelper::v7()->toString();
|
||||
$rangeId = createRepoTestProductRange();
|
||||
|
||||
Product::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'name' => 'Product Name',
|
||||
'tax_rate' => 1,
|
||||
'weight' => 1000,
|
||||
'brand' => 'none',
|
||||
'slug' => 'product-name',
|
||||
'invoicing_unit' => 'PCE',
|
||||
'sell_unit' => 'PCE',
|
||||
'range_id' => $rangeId,
|
||||
'picture_alt' => '',
|
||||
'picture_title' => '',
|
||||
'picture_large_alt' => '',
|
||||
'picture_large_title' => '',
|
||||
'description' => '',
|
||||
'status' => 1,
|
||||
'price' => new Money(100, new Currency('EUR')),
|
||||
]);
|
||||
|
||||
$id = new ProductId(UuidHelper::fromString($uuid));
|
||||
|
||||
$repo = new EloquentProductRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->find($id);
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeInstanceOf(DomainProduct::class);
|
||||
});
|
||||
|
||||
it('returns null if product by id is not found', function () {
|
||||
// GIVEN
|
||||
$id = new ProductId(UuidHelper::v7());
|
||||
|
||||
$repo = new EloquentProductRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->find($id);
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,182 +14,184 @@ use Domain\Models\ValueObjects\ShopperSiteCode;
|
|||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Infrastructure\Adapters\Repositories\EloquentShopRepository;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
it('finds exception shop for a matricule', function () {
|
||||
// GIVEN
|
||||
$shop = Shop::query()->forceCreate([
|
||||
'name' => 'Shop X',
|
||||
'address' => 'Addr X',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
describe('EloquentShopRepository', function (): void {
|
||||
it('finds exception shop for a matricule', function () {
|
||||
// GIVEN
|
||||
$shop = Shop::query()->forceCreate([
|
||||
'name' => 'Shop X',
|
||||
'address' => 'Addr X',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
|
||||
Employee::query()->forceCreate([
|
||||
'matricule' => new Matricule('1234567'),
|
||||
'nom' => 'Doe',
|
||||
'prenom' => 'John',
|
||||
'etablissement' => 'ETAB',
|
||||
'site' => 'SITE',
|
||||
'service' => '101',
|
||||
'code' => new Code('ABCDEFGH'),
|
||||
]);
|
||||
DB::table('shop_employee_exception')->insert([
|
||||
'matricule' => '1234567',
|
||||
'shop_id' => $shop->id,
|
||||
]);
|
||||
Employee::query()->forceCreate([
|
||||
'matricule' => new Matricule('1234567'),
|
||||
'nom' => 'Doe',
|
||||
'prenom' => 'John',
|
||||
'etablissement' => 'ETAB',
|
||||
'site' => 'SITE',
|
||||
'service' => '101',
|
||||
'code' => new Code('ABCDEFGH'),
|
||||
]);
|
||||
DB::table('shop_employee_exception')->insert([
|
||||
'matricule' => '1234567',
|
||||
'shop_id' => $shop->id,
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopRepository();
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->findExceptionShopFor(new Matricule('1234567'));
|
||||
// WHEN
|
||||
$result = $repo->findExceptionShopFor(new Matricule('1234567'));
|
||||
|
||||
// THEN
|
||||
expect($result)->not->toBeNull()
|
||||
->and($result?->id->value->toString())->toBe($shop->id);
|
||||
});
|
||||
|
||||
it('returns null if exception shop is not found', function () {
|
||||
// GIVEN
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->findExceptionShopFor(new Matricule('9999999'));
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
it('finds shop for site and service', function () {
|
||||
// GIVEN
|
||||
$shop = Shop::query()->forceCreate([
|
||||
'name' => 'Shop Y',
|
||||
'address' => 'Addr Y',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
|
||||
DB::table('shop_employees')->insert([
|
||||
'site_code' => 'PA',
|
||||
'service_code' => '101',
|
||||
'shop_id' => $shop->id,
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->findShopForSiteAndService(new ShopperSiteCode('PA'), new ShopperServiceCode('101'));
|
||||
|
||||
// THEN
|
||||
expect($result)->not->toBeNull()
|
||||
->and($result?->id->value->toString())->toBe($shop->id);
|
||||
});
|
||||
|
||||
it('finds shop for site and null service', function () {
|
||||
// GIVEN
|
||||
$shop = Shop::query()->forceCreate([
|
||||
'name' => 'Shop Z',
|
||||
'address' => 'Addr Z',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
|
||||
DB::table('shop_employees')->insert([
|
||||
'site_code' => 'LY',
|
||||
'service_code' => null,
|
||||
'shop_id' => $shop->id,
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->findShopForSiteAndService(new ShopperSiteCode('LY'), null);
|
||||
|
||||
// THEN
|
||||
expect($result)->not->toBeNull()
|
||||
->and($result?->id->value->toString())->toBe($shop->id);
|
||||
});
|
||||
|
||||
it('returns null if shop for site and service is not found', function () {
|
||||
// GIVEN
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->findShopForSiteAndService(new ShopperSiteCode('ZZ'), new ShopperServiceCode('999'));
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
it('finds shop by id', function () {
|
||||
// GIVEN
|
||||
$shop = Shop::query()->forceCreate([
|
||||
'name' => 'Shop 1',
|
||||
'address' => 'Addr 1',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->find(new ShopId(Uuid::fromString($shop->id)));
|
||||
|
||||
// THEN
|
||||
expect($result)->not->toBeNull()
|
||||
->and($result?->id->value->toString())->toBe($shop->id);
|
||||
});
|
||||
|
||||
it('returns null if shop by id is not found', function () {
|
||||
// GIVEN
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->find(new ShopId(Uuid::uuid7()));
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
it('retrieves default shop', function () {
|
||||
// GIVEN
|
||||
Shop::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'name' => 'Shop 1',
|
||||
'address' => 'Addr 1',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
$defaultShop = Shop::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'name' => 'Shop Default',
|
||||
'address' => 'Addr Default',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => true,
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->getDefaultShop();
|
||||
|
||||
// THEN
|
||||
expect($result->id->value->toString())->toBe($defaultShop->id);
|
||||
});
|
||||
|
||||
it('throws exception if default shop is not found', function () {
|
||||
// GIVEN
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$action = fn () => $repo->getDefaultShop();
|
||||
|
||||
// THEN
|
||||
expect($action)->toThrow(ModelNotFoundException::class);
|
||||
// THEN
|
||||
expect($result)->not->toBeNull()
|
||||
->and($result?->id->value->toString())->toBe($shop->id);
|
||||
});
|
||||
|
||||
it('returns null if exception shop is not found', function () {
|
||||
// GIVEN
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->findExceptionShopFor(new Matricule('9999999'));
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
it('finds shop for site and service', function () {
|
||||
// GIVEN
|
||||
$shop = Shop::query()->forceCreate([
|
||||
'name' => 'Shop Y',
|
||||
'address' => 'Addr Y',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
|
||||
DB::table('shop_employees')->insert([
|
||||
'site_code' => 'PA',
|
||||
'service_code' => '101',
|
||||
'shop_id' => $shop->id,
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->findShopForSiteAndService(new ShopperSiteCode('PA'), new ShopperServiceCode('101'));
|
||||
|
||||
// THEN
|
||||
expect($result)->not->toBeNull()
|
||||
->and($result?->id->value->toString())->toBe($shop->id);
|
||||
});
|
||||
|
||||
it('finds shop for site and null service', function () {
|
||||
// GIVEN
|
||||
$shop = Shop::query()->forceCreate([
|
||||
'name' => 'Shop Z',
|
||||
'address' => 'Addr Z',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
|
||||
DB::table('shop_employees')->insert([
|
||||
'site_code' => 'LY',
|
||||
'service_code' => null,
|
||||
'shop_id' => $shop->id,
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->findShopForSiteAndService(new ShopperSiteCode('LY'), null);
|
||||
|
||||
// THEN
|
||||
expect($result)->not->toBeNull()
|
||||
->and($result?->id->value->toString())->toBe($shop->id);
|
||||
});
|
||||
|
||||
it('returns null if shop for site and service is not found', function () {
|
||||
// GIVEN
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->findShopForSiteAndService(new ShopperSiteCode('ZZ'), new ShopperServiceCode('999'));
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
it('finds shop by id', function () {
|
||||
// GIVEN
|
||||
$shop = Shop::query()->forceCreate([
|
||||
'name' => 'Shop 1',
|
||||
'address' => 'Addr 1',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->find(new ShopId(UuidHelper::fromString($shop->id)));
|
||||
|
||||
// THEN
|
||||
expect($result)->not->toBeNull()
|
||||
->and($result?->id->value->toString())->toBe($shop->id);
|
||||
});
|
||||
|
||||
it('returns null if shop by id is not found', function () {
|
||||
// GIVEN
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->find(new ShopId(UuidHelper::v7()));
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
it('retrieves default shop', function () {
|
||||
// GIVEN
|
||||
Shop::query()->forceCreate([
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'name' => 'Shop 1',
|
||||
'address' => 'Addr 1',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => false,
|
||||
]);
|
||||
$defaultShop = Shop::query()->forceCreate([
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'name' => 'Shop Default',
|
||||
'address' => 'Addr Default',
|
||||
'postcode' => '75000',
|
||||
'city' => 'Paris',
|
||||
'default' => true,
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->getDefaultShop();
|
||||
|
||||
// THEN
|
||||
expect($result->id->value->toString())->toBe($defaultShop->id);
|
||||
});
|
||||
|
||||
it('throws exception if default shop is not found', function () {
|
||||
// GIVEN
|
||||
$repo = new EloquentShopRepository();
|
||||
|
||||
// WHEN
|
||||
$action = fn () => $repo->getDefaultShop();
|
||||
|
||||
// THEN
|
||||
expect($action)->toThrow(ModelNotFoundException::class);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,164 +16,166 @@ use Domain\Models\ValueObjects\ShopperEstablishmentCode;
|
|||
use Domain\Models\ValueObjects\ShopperServiceCode;
|
||||
use Domain\Models\ValueObjects\ShopperSiteCode;
|
||||
use Infrastructure\Adapters\Repositories\EloquentShopperRepository;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
it('retrieves shopper by id', function () {
|
||||
// GIVEN
|
||||
$uuid = Uuid::uuid7()->toString();
|
||||
describe('EloquentShopperRepository', function (): void {
|
||||
it('retrieves shopper by id', function () {
|
||||
// GIVEN
|
||||
$uuid = UuidHelper::v7()->toString();
|
||||
|
||||
Customer::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'email' => new Email('test@example.com'),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
]);
|
||||
Customer::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'email' => new Email('test@example.com'),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
]);
|
||||
|
||||
Employee::query()->forceCreate([
|
||||
'customer_id' => $uuid,
|
||||
'matricule' => new Matricule('1234567'),
|
||||
'nom' => 'Doe',
|
||||
'prenom' => 'John',
|
||||
'etablissement' => 'ETAB',
|
||||
'site' => 'SITE',
|
||||
'service' => '101',
|
||||
'code' => new Code('ABCDEFGH'),
|
||||
]);
|
||||
Employee::query()->forceCreate([
|
||||
'customer_id' => $uuid,
|
||||
'matricule' => new Matricule('1234567'),
|
||||
'nom' => 'Doe',
|
||||
'prenom' => 'John',
|
||||
'etablissement' => 'ETAB',
|
||||
'site' => 'SITE',
|
||||
'service' => '101',
|
||||
'code' => new Code('ABCDEFGH'),
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopperRepository();
|
||||
$repo = new EloquentShopperRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->find(new ShopperId(Uuid::fromString($uuid)));
|
||||
// WHEN
|
||||
$result = $repo->find(new ShopperId(UuidHelper::fromString($uuid)));
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeInstanceOf(Shopper::class)
|
||||
->and($result?->email->value)->toBe('test@example.com');
|
||||
});
|
||||
|
||||
it('returns null if shopper not found by id', function () {
|
||||
// GIVEN
|
||||
$repo = new EloquentShopperRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->find(new ShopperId(Uuid::uuid7()));
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
it('returns null if customer exists but has no employee', function () {
|
||||
// GIVEN
|
||||
$uuid = Uuid::uuid7()->toString();
|
||||
|
||||
Customer::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'email' => new Email('test@example.com'),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopperRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->find(new ShopperId(Uuid::fromString($uuid)));
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
it('retrieves shopper by id or fails', function () {
|
||||
// GIVEN
|
||||
$uuid = Uuid::uuid7()->toString();
|
||||
|
||||
Customer::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'email' => new Email('test@example.com'),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
]);
|
||||
|
||||
Employee::query()->forceCreate([
|
||||
'customer_id' => $uuid,
|
||||
'matricule' => new Matricule('1234569'),
|
||||
'nom' => 'Doe',
|
||||
'prenom' => 'John',
|
||||
'etablissement' => 'ETAB',
|
||||
'site' => 'SITE',
|
||||
'service' => '101',
|
||||
'code' => new Code('ABCDEFGH'),
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopperRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->getByIdOrFail(new ShopperId(Uuid::fromString($uuid)));
|
||||
|
||||
// THEN
|
||||
expect($result->id()->value->toString())->toBe($uuid)
|
||||
->and($result->matricule->value)->toBe('1234569');
|
||||
});
|
||||
|
||||
it('throws exception if shopper not found in getByIdOrFail', function () {
|
||||
// GIVEN
|
||||
$repo = new EloquentShopperRepository();
|
||||
$id = Uuid::uuid7();
|
||||
|
||||
// WHEN
|
||||
$action = fn () => $repo->getByIdOrFail(new ShopperId($id));
|
||||
|
||||
// THEN
|
||||
expect($action)->toThrow(\DomainException::class, "Shopper with id '{$id->toString()}' not found or is not linked to any employee.");
|
||||
});
|
||||
|
||||
it('persists updates to both customer and associated employee', function () {
|
||||
// GIVEN
|
||||
$uuid = Uuid::uuid7()->toString();
|
||||
$shopperId = new ShopperId(Uuid::fromString($uuid));
|
||||
|
||||
Customer::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'email' => new Email('before@example.com'),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
]);
|
||||
|
||||
Employee::query()->forceCreate([
|
||||
'customer_id' => $uuid,
|
||||
'matricule' => new Matricule('1234567'),
|
||||
'nom' => 'Doe',
|
||||
'prenom' => 'John',
|
||||
'start_date' => '2026-01-01',
|
||||
'end_date' => null,
|
||||
'etablissement' => 'ETAB01',
|
||||
'site' => 'SITE',
|
||||
'service' => '101',
|
||||
'code' => new Code('ABCDEFGH'),
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopperRepository();
|
||||
$updatedShopper = new Shopper(
|
||||
id: $shopperId,
|
||||
email: new Email('after@example.com'),
|
||||
matricule: new Matricule('7654321'),
|
||||
nom: 'Martin',
|
||||
prenom: 'Claire',
|
||||
startDate: CarbonImmutable::parse('2026-02-01'),
|
||||
endDate: CarbonImmutable::parse('2026-12-31'),
|
||||
etablissement: new ShopperEstablishmentCode('ETAB02'),
|
||||
site: new ShopperSiteCode('PA'),
|
||||
service: new ShopperServiceCode('202'),
|
||||
);
|
||||
|
||||
// WHEN
|
||||
$repo->persist($updatedShopper);
|
||||
|
||||
// THEN
|
||||
$reloaded = $repo->find($shopperId);
|
||||
|
||||
expect($reloaded)->toBeInstanceOf(Shopper::class)
|
||||
->and($reloaded?->email->value)->toBe('after@example.com')
|
||||
->and($reloaded?->matricule->value)->toBe('7654321')
|
||||
->and($reloaded?->nom)->toBe('Martin')
|
||||
->and($reloaded?->prenom)->toBe('Claire')
|
||||
->and($reloaded?->startDate->format('Y-m-d'))->toBe('2026-02-01')
|
||||
->and($reloaded?->endDate?->format('Y-m-d'))->toBe('2026-12-31')
|
||||
->and($reloaded?->etablissement->value)->toBe('ETAB02')
|
||||
->and($reloaded?->site->value)->toBe('PA')
|
||||
->and($reloaded?->service->value)->toBe('202');
|
||||
// THEN
|
||||
expect($result)->toBeInstanceOf(Shopper::class)
|
||||
->and($result?->email->value)->toBe('test@example.com');
|
||||
});
|
||||
|
||||
it('returns null if shopper not found by id', function () {
|
||||
// GIVEN
|
||||
$repo = new EloquentShopperRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->find(new ShopperId(UuidHelper::v7()));
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
it('returns null if customer exists but has no employee', function () {
|
||||
// GIVEN
|
||||
$uuid = UuidHelper::v7()->toString();
|
||||
|
||||
Customer::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'email' => new Email('test@example.com'),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopperRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->find(new ShopperId(UuidHelper::fromString($uuid)));
|
||||
|
||||
// THEN
|
||||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
it('retrieves shopper by id or fails', function () {
|
||||
// GIVEN
|
||||
$uuid = UuidHelper::v7()->toString();
|
||||
|
||||
Customer::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'email' => new Email('test@example.com'),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
]);
|
||||
|
||||
Employee::query()->forceCreate([
|
||||
'customer_id' => $uuid,
|
||||
'matricule' => new Matricule('1234569'),
|
||||
'nom' => 'Doe',
|
||||
'prenom' => 'John',
|
||||
'etablissement' => 'ETAB',
|
||||
'site' => 'SITE',
|
||||
'service' => '101',
|
||||
'code' => new Code('ABCDEFGH'),
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopperRepository();
|
||||
|
||||
// WHEN
|
||||
$result = $repo->getByIdOrFail(new ShopperId(UuidHelper::fromString($uuid)));
|
||||
|
||||
// THEN
|
||||
expect($result->id()->value->toString())->toBe($uuid)
|
||||
->and($result->matricule->value)->toBe('1234569');
|
||||
});
|
||||
|
||||
it('throws exception if shopper not found in getByIdOrFail', function () {
|
||||
// GIVEN
|
||||
$repo = new EloquentShopperRepository();
|
||||
$id = UuidHelper::v7();
|
||||
|
||||
// WHEN
|
||||
$action = fn () => $repo->getByIdOrFail(new ShopperId($id));
|
||||
|
||||
// THEN
|
||||
expect($action)->toThrow(\DomainException::class, "Shopper with id '{$id->toString()}' not found or is not linked to any employee.");
|
||||
});
|
||||
|
||||
it('persists updates to both customer and associated employee', function () {
|
||||
// GIVEN
|
||||
$uuid = UuidHelper::v7()->toString();
|
||||
$shopperId = new ShopperId(UuidHelper::fromString($uuid));
|
||||
|
||||
Customer::query()->forceCreate([
|
||||
'id' => $uuid,
|
||||
'email' => new Email('before@example.com'),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
]);
|
||||
|
||||
Employee::query()->forceCreate([
|
||||
'customer_id' => $uuid,
|
||||
'matricule' => new Matricule('1234567'),
|
||||
'nom' => 'Doe',
|
||||
'prenom' => 'John',
|
||||
'start_date' => '2026-01-01',
|
||||
'end_date' => null,
|
||||
'etablissement' => 'ETAB01',
|
||||
'site' => 'SITE',
|
||||
'service' => '101',
|
||||
'code' => new Code('ABCDEFGH'),
|
||||
]);
|
||||
|
||||
$repo = new EloquentShopperRepository();
|
||||
$updatedShopper = new Shopper(
|
||||
id: $shopperId,
|
||||
email: new Email('after@example.com'),
|
||||
matricule: new Matricule('7654321'),
|
||||
nom: 'Martin',
|
||||
prenom: 'Claire',
|
||||
startDate: CarbonImmutable::parse('2026-02-01'),
|
||||
endDate: CarbonImmutable::parse('2026-12-31'),
|
||||
etablissement: new ShopperEstablishmentCode('ETAB02'),
|
||||
site: new ShopperSiteCode('PA'),
|
||||
service: new ShopperServiceCode('202'),
|
||||
);
|
||||
|
||||
// WHEN
|
||||
$repo->persist($updatedShopper);
|
||||
|
||||
// THEN
|
||||
$reloaded = $repo->find($shopperId);
|
||||
|
||||
expect($reloaded)->toBeInstanceOf(Shopper::class)
|
||||
->and($reloaded?->email->value)->toBe('after@example.com')
|
||||
->and($reloaded?->matricule->value)->toBe('7654321')
|
||||
->and($reloaded?->nom)->toBe('Martin')
|
||||
->and($reloaded?->prenom)->toBe('Claire')
|
||||
->and($reloaded?->startDate->format('Y-m-d'))->toBe('2026-02-01')
|
||||
->and($reloaded?->endDate?->format('Y-m-d'))->toBe('2026-12-31')
|
||||
->and($reloaded?->etablissement->value)->toBe('ETAB02')
|
||||
->and($reloaded?->site->value)->toBe('PA')
|
||||
->and($reloaded?->service->value)->toBe('202');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use Infrastructure\Adapters\Repositories\SessionBasketRepository;
|
|||
use Infrastructure\Adapters\Serializers\BasketSerializer;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Uwil\Storage\Lib\ValueObjects\StorageFilePath;
|
||||
|
||||
describe('SessionBasketRepository', function () {
|
||||
|
|
@ -34,7 +34,7 @@ describe('SessionBasketRepository', function () {
|
|||
|
||||
it('returns null when session is empty', function () {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
|
||||
// WHEN
|
||||
$basket = getRepository()->find($basketId);
|
||||
|
|
@ -45,7 +45,7 @@ describe('SessionBasketRepository', function () {
|
|||
|
||||
it('can save a basket into the session and retrieve it identically', function (BasketProduct $product) {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId, [$product->id->value->toString() => $product]);
|
||||
$repository = getRepository();
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ describe('SessionBasketRepository', function () {
|
|||
->and($retrievedProduct->options)->toBe($product->options);
|
||||
})->with([
|
||||
'Full product' => fn () => new BasketProduct(
|
||||
id: new ProductId(Uuid::uuid7()),
|
||||
id: new ProductId(UuidHelper::v7()),
|
||||
name: 'Poulet Rôti',
|
||||
qty: 2,
|
||||
unitPriceHt: new Money(1200, new Currency('EUR')),
|
||||
|
|
@ -97,7 +97,7 @@ describe('SessionBasketRepository', function () {
|
|||
options: ['cut' => 'halves']
|
||||
),
|
||||
'Minimal product without optional fields' => fn () => new BasketProduct(
|
||||
id: new ProductId(Uuid::uuid7()),
|
||||
id: new ProductId(UuidHelper::v7()),
|
||||
name: 'Pâtes',
|
||||
qty: 1,
|
||||
unitPriceHt: new Money(200, new Currency('EUR')),
|
||||
|
|
@ -120,7 +120,7 @@ describe('SessionBasketRepository', function () {
|
|||
it('can destroy the basket from the session', function () {
|
||||
// GIVEN
|
||||
$repository = getRepository();
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId, []);
|
||||
$repository->persist($basket);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use Illuminate\Contracts\Auth\Authenticatable;
|
|||
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||
use Infrastructure\Adapters\Services\AppCustomerAuthService;
|
||||
use Mockery;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Shared\ValueObjects\CrmHashcode;
|
||||
|
||||
describe('AppCustomerAuthService', function (): void {
|
||||
|
|
@ -65,7 +65,7 @@ describe('AppCustomerAuthService', function (): void {
|
|||
$guard = Mockery::spy(StatefulGuard::class);
|
||||
$crmService = Mockery::mock(CrmService::class);
|
||||
$customer = new Customer();
|
||||
$customer->id = (string) Uuid::uuid7();
|
||||
$customer->id = (string) UuidHelper::v7();
|
||||
|
||||
$service = new AppCustomerAuthService($guard, $crmService);
|
||||
|
||||
|
|
@ -251,7 +251,7 @@ describe('AppCustomerAuthService', function (): void {
|
|||
$guard = Mockery::mock(StatefulGuard::class);
|
||||
$crmService = Mockery::mock(CrmService::class);
|
||||
$customer = new Customer();
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->hashcode = $hashcode;
|
||||
|
||||
// DO NOT MOCK CrmCustomer
|
||||
|
|
@ -289,7 +289,7 @@ describe('AppCustomerAuthService', function (): void {
|
|||
$guard = Mockery::mock(StatefulGuard::class);
|
||||
$crmService = Mockery::mock(CrmService::class);
|
||||
$customer = new Customer();
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->hashcode = $hashcode;
|
||||
|
||||
$crmService->shouldReceive('getCustomerFromHashCode')->with($customer->hashcode)->andReturn(null);
|
||||
|
|
@ -308,7 +308,7 @@ describe('AppCustomerAuthService', function (): void {
|
|||
$guard = Mockery::mock(StatefulGuard::class);
|
||||
$crmService = Mockery::mock(CrmService::class);
|
||||
$customer = new Customer();
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->hashcode = $hashcode;
|
||||
|
||||
$crmCustomer = new CrmCustomer(
|
||||
|
|
@ -349,7 +349,7 @@ describe('AppCustomerAuthService', function (): void {
|
|||
$guard = Mockery::mock(StatefulGuard::class);
|
||||
$crmService = Mockery::mock(CrmService::class);
|
||||
$customer = new Customer();
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->hashcode = $hashcode;
|
||||
|
||||
$crmService->shouldReceive('getCustomerFromHashCode')->with($customer->hashcode)->andReturn(null);
|
||||
|
|
@ -368,7 +368,7 @@ describe('AppCustomerAuthService', function (): void {
|
|||
$guard = Mockery::mock(StatefulGuard::class);
|
||||
$crmService = Mockery::mock(CrmService::class);
|
||||
$customer = new Customer();
|
||||
$hashcode = new CrmHashcode(Uuid::uuid4());
|
||||
$hashcode = new CrmHashcode(UuidHelper::v4());
|
||||
$customer->hashcode = $hashcode;
|
||||
|
||||
$exception = new CrmServiceException('Crm Error');
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ namespace Tests\Integration\WithApp\Infra\Adapters\Services;
|
|||
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Infrastructure\Adapters\Services\AppSessionService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('AppSessionService', function (): void {
|
||||
|
|
@ -43,7 +42,7 @@ describe('AppSessionService', function (): void {
|
|||
it('hydrates an existing UUID string already stored in Session under the configured key', function (): void {
|
||||
// GIVEN
|
||||
$sessionKey = 'test_session_id';
|
||||
$existingUuid = Uuid::uuid7()->toString();
|
||||
$existingUuid = UuidHelper::v7()->toString();
|
||||
Session::put($sessionKey, $existingUuid);
|
||||
$service = new AppSessionService($sessionKey);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use Illuminate\Support\Facades\Date;
|
|||
use Illuminate\Support\Facades\Session;
|
||||
use Infrastructure\Adapters\Services\DatabaseTunnelAttemptTrackerService;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
covers(DatabaseTunnelAttemptTrackerService::class);
|
||||
|
||||
|
|
@ -46,11 +46,11 @@ describe('DatabaseTunnelAttemptTrackerService', function (): void {
|
|||
|
||||
/** @var Customer $customer */
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
'email' => new Email('attempt-reuse@example.com'),
|
||||
]);
|
||||
$shopperId = new ShopperId(Uuid::fromString($customer->id));
|
||||
$shopperId = new ShopperId(UuidHelper::fromString($customer->id));
|
||||
|
||||
// WHEN
|
||||
$tracker->recordEntry($shopperId);
|
||||
|
|
@ -82,16 +82,16 @@ describe('DatabaseTunnelAttemptTrackerService', function (): void {
|
|||
|
||||
/** @var Customer $customer */
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
'email' => new Email('attempt-convert@example.com'),
|
||||
]);
|
||||
$shopperId = new ShopperId(Uuid::fromString($customer->id));
|
||||
$shopperId = new ShopperId(UuidHelper::fromString($customer->id));
|
||||
|
||||
$orderId = Uuid::uuid7()->toString();
|
||||
$orderId = UuidHelper::v7()->toString();
|
||||
Order::query()->forceCreate([
|
||||
'id' => $orderId,
|
||||
'reference' => new OrderReference(Uuid::uuid7()),
|
||||
'reference' => new OrderReference(UuidHelper::v7()),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => Money::EUR(1500),
|
||||
'employee' => new OrderEmployee(
|
||||
|
|
@ -108,7 +108,7 @@ describe('DatabaseTunnelAttemptTrackerService', function (): void {
|
|||
$tracker->recordEntry($shopperId);
|
||||
|
||||
// WHEN
|
||||
$tracker->markConverted(new OrderId(Uuid::fromString($orderId)));
|
||||
$tracker->markConverted(new OrderId(UuidHelper::fromString($orderId)));
|
||||
|
||||
// THEN
|
||||
expect($session->has('order_tunnel_attempt_id'))->toBeFalse();
|
||||
|
|
@ -131,14 +131,14 @@ describe('DatabaseTunnelAttemptTrackerService', function (): void {
|
|||
|
||||
/** @var Customer $customer */
|
||||
$customer = Customer::query()->forceCreate([
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'hashcode' => Uuid::uuid4()->toString(),
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'hashcode' => UuidHelper::v4()->toString(),
|
||||
'email' => new Email('attempt-clear@example.com'),
|
||||
]);
|
||||
$tracker->recordEntry(new ShopperId(Uuid::fromString($customer->id)));
|
||||
$tracker->recordEntry(new ShopperId(UuidHelper::fromString($customer->id)));
|
||||
|
||||
// WHEN
|
||||
$listener->handle(new BasketRemoved(new BasketId(Uuid::uuid7())));
|
||||
$listener->handle(new BasketRemoved(new BasketId(UuidHelper::v7())));
|
||||
|
||||
// THEN
|
||||
expect($session->has('order_tunnel_attempt_id'))->toBeFalse()
|
||||
|
|
|
|||
|
|
@ -10,102 +10,104 @@ use Domain\Enums\OrderStatus;
|
|||
use Domain\Models\ValueObjects\Matricule;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Infrastructure\Adapters\Services\EloquentEmployeeStatisticsService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
it('retrieves the weekly order total for a given employee', function () {
|
||||
// GIVEN
|
||||
$shop = Shop::factory()->create();
|
||||
describe('EloquentEmployeeStatisticsService', function (): void {
|
||||
it('retrieves the weekly order total for a given employee', function () {
|
||||
// GIVEN
|
||||
$shop = Shop::factory()->create();
|
||||
|
||||
DB::table('orders')->insert([
|
||||
'id' => '018e4567-e89b-72d3-a456-426614174000',
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => Uuid::uuid7()->toString(),
|
||||
'employee' => json_encode([
|
||||
'matricule' => '1234567',
|
||||
'firstname' => 'Jean',
|
||||
'lastname' => 'Dupont',
|
||||
'facility' => 'Main Facility',
|
||||
'site' => 'HQ',
|
||||
'service' => 'IT',
|
||||
]),
|
||||
'delivery_address' => '{}',
|
||||
'pickup_day' => '2023-01-05',
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => 1500, // 15.00 EUR
|
||||
]);
|
||||
DB::table('orders')->insert([
|
||||
'id' => '018e4567-e89b-72d3-a456-426614174000',
|
||||
'shop_id' => $shop->id,
|
||||
'reference' => UuidHelper::v7()->toString(),
|
||||
'employee' => json_encode([
|
||||
'matricule' => '1234567',
|
||||
'firstname' => 'Jean',
|
||||
'lastname' => 'Dupont',
|
||||
'facility' => 'Main Facility',
|
||||
'site' => 'HQ',
|
||||
'service' => 'IT',
|
||||
]),
|
||||
'delivery_address' => '{}',
|
||||
'pickup_day' => '2023-01-05',
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => 1500, // 15.00 EUR
|
||||
]);
|
||||
|
||||
$service = new EloquentEmployeeStatisticsService();
|
||||
$start = CarbonImmutable::parse('2023-01-01');
|
||||
$end = CarbonImmutable::parse('2023-01-07');
|
||||
$service = new EloquentEmployeeStatisticsService();
|
||||
$start = CarbonImmutable::parse('2023-01-01');
|
||||
$end = CarbonImmutable::parse('2023-01-07');
|
||||
|
||||
// WHEN
|
||||
$result = $service->getWeeklyTotalForEmployee(new Matricule('1234567'), $start, $end);
|
||||
// WHEN
|
||||
$result = $service->getWeeklyTotalForEmployee(new Matricule('1234567'), $start, $end);
|
||||
|
||||
// THEN
|
||||
expect($result->getAmount())->toBe('1500')
|
||||
->and($result->getCurrency()->getCode())->toBe('EUR');
|
||||
});
|
||||
|
||||
it('includes VALIDATED and PENDING orders and excludes WAITING, FAILED, and CANCELED orders in weekly total', function (): void {
|
||||
// GIVEN
|
||||
$shop = Shop::factory()->create();
|
||||
|
||||
$baseRow = [
|
||||
'shop_id' => $shop->id,
|
||||
'employee' => json_encode([
|
||||
'matricule' => '1234567',
|
||||
'firstname' => 'Jean',
|
||||
'lastname' => 'Dupont',
|
||||
'facility' => 'Main Facility',
|
||||
'site' => 'HQ',
|
||||
'service' => 'IT',
|
||||
]),
|
||||
'delivery_address' => '{}',
|
||||
'pickup_day' => '2023-01-05',
|
||||
];
|
||||
|
||||
DB::table('orders')->insert([
|
||||
array_merge($baseRow, [
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'reference' => Uuid::uuid7()->toString(),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => 1000,
|
||||
]),
|
||||
array_merge($baseRow, [
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'reference' => Uuid::uuid7()->toString(),
|
||||
'status' => OrderStatus::PENDING->value,
|
||||
'total' => 2500,
|
||||
]),
|
||||
array_merge($baseRow, [
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'reference' => Uuid::uuid7()->toString(),
|
||||
'status' => OrderStatus::WAITING->value,
|
||||
'total' => 4000,
|
||||
]),
|
||||
array_merge($baseRow, [
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'reference' => Uuid::uuid7()->toString(),
|
||||
'status' => OrderStatus::FAILED->value,
|
||||
'total' => 5000,
|
||||
]),
|
||||
array_merge($baseRow, [
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'reference' => Uuid::uuid7()->toString(),
|
||||
'status' => OrderStatus::CANCELED->value,
|
||||
'total' => 9000,
|
||||
]),
|
||||
]);
|
||||
|
||||
$service = new EloquentEmployeeStatisticsService();
|
||||
|
||||
// WHEN
|
||||
$result = $service->getWeeklyTotalForEmployee(
|
||||
new Matricule('1234567'),
|
||||
CarbonImmutable::parse('2023-01-01'),
|
||||
CarbonImmutable::parse('2023-01-07')
|
||||
);
|
||||
|
||||
// THEN
|
||||
expect($result->getAmount())->toBe('3500');
|
||||
// THEN
|
||||
expect($result->getAmount())->toBe('1500')
|
||||
->and($result->getCurrency()->getCode())->toBe('EUR');
|
||||
});
|
||||
|
||||
it('includes VALIDATED and PENDING orders and excludes WAITING, FAILED, and CANCELED orders in weekly total', function (): void {
|
||||
// GIVEN
|
||||
$shop = Shop::factory()->create();
|
||||
|
||||
$baseRow = [
|
||||
'shop_id' => $shop->id,
|
||||
'employee' => json_encode([
|
||||
'matricule' => '1234567',
|
||||
'firstname' => 'Jean',
|
||||
'lastname' => 'Dupont',
|
||||
'facility' => 'Main Facility',
|
||||
'site' => 'HQ',
|
||||
'service' => 'IT',
|
||||
]),
|
||||
'delivery_address' => '{}',
|
||||
'pickup_day' => '2023-01-05',
|
||||
];
|
||||
|
||||
DB::table('orders')->insert([
|
||||
array_merge($baseRow, [
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'reference' => UuidHelper::v7()->toString(),
|
||||
'status' => OrderStatus::VALIDATED->value,
|
||||
'total' => 1000,
|
||||
]),
|
||||
array_merge($baseRow, [
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'reference' => UuidHelper::v7()->toString(),
|
||||
'status' => OrderStatus::PENDING->value,
|
||||
'total' => 2500,
|
||||
]),
|
||||
array_merge($baseRow, [
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'reference' => UuidHelper::v7()->toString(),
|
||||
'status' => OrderStatus::WAITING->value,
|
||||
'total' => 4000,
|
||||
]),
|
||||
array_merge($baseRow, [
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'reference' => UuidHelper::v7()->toString(),
|
||||
'status' => OrderStatus::FAILED->value,
|
||||
'total' => 5000,
|
||||
]),
|
||||
array_merge($baseRow, [
|
||||
'id' => UuidHelper::v7()->toString(),
|
||||
'reference' => UuidHelper::v7()->toString(),
|
||||
'status' => OrderStatus::CANCELED->value,
|
||||
'total' => 9000,
|
||||
]),
|
||||
]);
|
||||
|
||||
$service = new EloquentEmployeeStatisticsService();
|
||||
|
||||
// WHEN
|
||||
$result = $service->getWeeklyTotalForEmployee(
|
||||
new Matricule('1234567'),
|
||||
CarbonImmutable::parse('2023-01-01'),
|
||||
CarbonImmutable::parse('2023-01-07')
|
||||
);
|
||||
|
||||
// THEN
|
||||
expect($result->getAmount())->toBe('3500');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ use Domain\Models\ValueObjects\Entities\ShopId;
|
|||
use Domain\Models\ValueObjects\Entities\ShopperId;
|
||||
use Domain\Models\ValueObjects\PickupTimeSlot;
|
||||
use Domain\Services\OrderTunnelService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('ApplyPickTimeSlot', function (): void {
|
||||
it('applies time slot to order builder via OrderTunnelService', function (): void {
|
||||
// GIVEN
|
||||
$shopperId = new ShopperId(Uuid::uuid7());
|
||||
$shopperId = new ShopperId(UuidHelper::v7());
|
||||
$timeslot = CarbonImmutable::parse('2026-10-15');
|
||||
$input = new ApplyPickTimeSlotInput(
|
||||
shopperId: $shopperId,
|
||||
|
|
@ -28,7 +28,7 @@ describe('ApplyPickTimeSlot', function (): void {
|
|||
|
||||
$builder = \Mockery::mock(OrderBuilderWithBasket::class);
|
||||
$shop = new Shop(
|
||||
id: new ShopId(Uuid::uuid7()),
|
||||
id: new ShopId(UuidHelper::v7()),
|
||||
name: 'Shop 1',
|
||||
address: '1 rue Test',
|
||||
postcode: '75001',
|
||||
|
|
@ -66,7 +66,7 @@ describe('ApplyPickTimeSlot', function (): void {
|
|||
|
||||
it('returns unavailable output when no time slot matches', function (): void {
|
||||
// GIVEN
|
||||
$shopperId = new ShopperId(Uuid::uuid7());
|
||||
$shopperId = new ShopperId(UuidHelper::v7());
|
||||
$timeslot = CarbonImmutable::parse('2026-10-15');
|
||||
$input = new ApplyPickTimeSlotInput(
|
||||
shopperId: $shopperId,
|
||||
|
|
@ -75,7 +75,7 @@ describe('ApplyPickTimeSlot', function (): void {
|
|||
|
||||
$builder = \Mockery::mock(OrderBuilderWithBasket::class);
|
||||
$shop = new Shop(
|
||||
id: new ShopId(Uuid::uuid7()),
|
||||
id: new ShopId(UuidHelper::v7()),
|
||||
name: 'Shop 1',
|
||||
address: '1 rue Test',
|
||||
postcode: '75001',
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ use App\Cqs\Actions\Orders\CancelOrderOutput;
|
|||
use App\Models\Order;
|
||||
use Domain\Models\ValueObjects\Entities\OrderId;
|
||||
use Domain\Services\OrderService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('CancelOrder', function (): void {
|
||||
it('cancels the order and returns CANCELLED when OrderService succeeds', function (): void {
|
||||
// GIVEN
|
||||
$orderId = new OrderId(Uuid::uuid7());
|
||||
$orderId = new OrderId(UuidHelper::v7());
|
||||
$order = new Order();
|
||||
$order->id = $orderId->value->toString();
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ describe('CancelOrder', function (): void {
|
|||
|
||||
it('returns NOT_FOUND when OrderService throws DomainException', function (): void {
|
||||
// GIVEN
|
||||
$orderId = new OrderId(Uuid::uuid7());
|
||||
$orderId = new OrderId(UuidHelper::v7());
|
||||
$order = new Order();
|
||||
$order->id = $orderId->value->toString();
|
||||
|
||||
|
|
|
|||
|
|
@ -44,18 +44,18 @@ use Domain\Models\ValueObjects\ShopperSiteCode;
|
|||
use Domain\Ports\Repositories\BasketRepository;
|
||||
use Domain\Services\OrderTunnelService;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('PlacePendingOrder', function (): void {
|
||||
it('places a pending order and returns id and reference via OrderTunnelService', function (): void {
|
||||
// GIVEN
|
||||
$input = new PlacePendingOrderInput();
|
||||
$orderId = new OrderId(Uuid::uuid7());
|
||||
$orderReference = new OrderReference(Uuid::uuid7());
|
||||
$orderId = new OrderId(UuidHelper::v7());
|
||||
$orderReference = new OrderReference(UuidHelper::v7());
|
||||
$builder = \Mockery::mock(OrderBuilderCompleted::class);
|
||||
$order = new Order(
|
||||
id: $orderId,
|
||||
shopId: new ShopId(Uuid::uuid7()),
|
||||
shopId: new ShopId(UuidHelper::v7()),
|
||||
reference: $orderReference,
|
||||
employee: new OrderEmployee(
|
||||
matricule: new Matricule('1234567'),
|
||||
|
|
@ -163,7 +163,7 @@ describe('PlacePendingOrder', function (): void {
|
|||
// GIVEN
|
||||
$input = new PlacePendingOrderInput();
|
||||
$builder = \Mockery::mock(OrderBuilderCompleted::class);
|
||||
$refreshedBasket = new Basket(new BasketId(Uuid::uuid7()), []);
|
||||
$refreshedBasket = new Basket(new BasketId(UuidHelper::v7()), []);
|
||||
/** @var \Mockery\MockInterface&OrderTunnelService $orderTunnelService */
|
||||
$orderTunnelService = \Mockery::mock(OrderTunnelService::class);
|
||||
$orderTunnelService->shouldReceive('getBuilderCompletedOrFail')->once()->andReturn($builder);
|
||||
|
|
@ -191,7 +191,7 @@ describe('PlacePendingOrder', function (): void {
|
|||
|
||||
it('builds shopper lock key and returns LOCK_TIMEOUT output on lock timeout', function (): void {
|
||||
// GIVEN
|
||||
$shopperId = new ShopperId(Uuid::uuid7());
|
||||
$shopperId = new ShopperId(UuidHelper::v7());
|
||||
$input = new PlacePendingOrderInput(shopperId: $shopperId);
|
||||
/** @var \Mockery\MockInterface&OrderTunnelService $orderTunnelService */
|
||||
$orderTunnelService = \Mockery::mock(OrderTunnelService::class);
|
||||
|
|
@ -213,7 +213,7 @@ describe('PlacePendingOrder', function (): void {
|
|||
describe('ExportOrderToRegate, ConfirmPlacedOrder and FailPendingOrder', function (): void {
|
||||
it('exports order via OrderTunnelService and handles lock timeout', function (): void {
|
||||
// GIVEN
|
||||
$orderId = new OrderId(Uuid::uuid7());
|
||||
$orderId = new OrderId(UuidHelper::v7());
|
||||
$input = new ExportOrderToRegateInput($orderId);
|
||||
|
||||
/** @var \Mockery\MockInterface&OrderTunnelService $orderTunnelService */
|
||||
|
|
@ -233,11 +233,11 @@ describe('ExportOrderToRegate, ConfirmPlacedOrder and FailPendingOrder', functio
|
|||
|
||||
it('confirms a placed order and fails a pending order', function (): void {
|
||||
// GIVEN
|
||||
$orderId = new OrderId(Uuid::uuid7());
|
||||
$orderId = new OrderId(UuidHelper::v7());
|
||||
$order = new Order(
|
||||
id: $orderId,
|
||||
shopId: new ShopId(Uuid::uuid7()),
|
||||
reference: new OrderReference(Uuid::uuid7()),
|
||||
shopId: new ShopId(UuidHelper::v7()),
|
||||
reference: new OrderReference(UuidHelper::v7()),
|
||||
employee: new OrderEmployee(
|
||||
matricule: new Matricule('1234567'),
|
||||
firstname: 'Jean',
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ namespace Tests\Unit\App\Cqs\Actions\ProductIncos;
|
|||
|
||||
use App\Cqs\Actions\ProductIncos\AssociateProductIncoInput;
|
||||
use Domain\Models\ValueObjects\Entities\ProductId;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('AssociateProductIncoInput', function (): void {
|
||||
it('creates input successfully with valid parameters', function (): void {
|
||||
// GIVEN
|
||||
$productId = new ProductId(Uuid::uuid7());
|
||||
$productId = new ProductId(UuidHelper::v7());
|
||||
$noArt = 27996;
|
||||
|
||||
// WHEN
|
||||
|
|
@ -24,7 +24,7 @@ describe('AssociateProductIncoInput', function (): void {
|
|||
|
||||
it('throws when no_art is less than 1', function (): void {
|
||||
// GIVEN
|
||||
$productId = new ProductId(Uuid::uuid7());
|
||||
$productId = new ProductId(UuidHelper::v7());
|
||||
$noArt = 0;
|
||||
|
||||
// WHEN & THEN
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ use Domain\Enums\OrderTunnelStep;
|
|||
use Domain\Models\Entities\Basket;
|
||||
use Domain\Models\ValueObjects\Entities\BasketId;
|
||||
use Domain\Services\BasketService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('GetBasketSummaryQuery', function (): void {
|
||||
it('returns basket summary output with step REVIEW and basket', function (): void {
|
||||
// GIVEN
|
||||
$basket = new Basket(new BasketId(Uuid::uuid7()));
|
||||
$basket = new Basket(new BasketId(UuidHelper::v7()));
|
||||
$basketService = \Mockery::mock(BasketService::class);
|
||||
$basketService->shouldReceive('getBasket')
|
||||
->once()
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ use Domain\Models\ValueObjects\Entities\BasketId;
|
|||
use Domain\Models\ValueObjects\Entities\ShopId;
|
||||
use Domain\Ports\Repositories\ShopRepository;
|
||||
use Domain\Services\OrderTunnelService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
describe('GetOrderConfirmationQuery', function (): void {
|
||||
it('returns order confirmation output with step, basket, builder and shop', function (): void {
|
||||
// GIVEN
|
||||
$shopId = new ShopId(Uuid::uuid7());
|
||||
$basket = new Basket(new BasketId(Uuid::uuid7()));
|
||||
$shopId = new ShopId(UuidHelper::v7());
|
||||
$basket = new Basket(new BasketId(UuidHelper::v7()));
|
||||
$builder = \Mockery::mock(OrderBuilderCompleted::class);
|
||||
$builder->shouldReceive('getBasket')->once()->andReturn($basket);
|
||||
$builder->shouldReceive('getShopId')->once()->andReturn($shopId);
|
||||
|
|
@ -60,8 +60,8 @@ describe('GetOrderConfirmationQuery', function (): void {
|
|||
|
||||
it('throws NotFoundHttpException when shop is not found', function (): void {
|
||||
// GIVEN
|
||||
$shopId = new ShopId(Uuid::uuid7());
|
||||
$basket = new Basket(new BasketId(Uuid::uuid7()));
|
||||
$shopId = new ShopId(UuidHelper::v7());
|
||||
$basket = new Basket(new BasketId(UuidHelper::v7()));
|
||||
$builder = \Mockery::mock(OrderBuilderCompleted::class);
|
||||
$builder->shouldReceive('getBasket')->once()->andReturn($basket);
|
||||
$builder->shouldReceive('getShopId')->once()->andReturn($shopId);
|
||||
|
|
|
|||
|
|
@ -15,16 +15,16 @@ use Domain\Models\ValueObjects\Entities\ShopId;
|
|||
use Domain\Models\ValueObjects\Entities\ShopperId;
|
||||
use Domain\Models\ValueObjects\PickupTimeSlot;
|
||||
use Domain\Services\OrderTunnelService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('GetPickTimeSlotQuery', function (): void {
|
||||
it('returns pick time slot output with step BOOKING, shop, mapUrl and timeslots', function (): void {
|
||||
// GIVEN
|
||||
$shopperId = new ShopperId(Uuid::uuid7());
|
||||
$shopperId = new ShopperId(UuidHelper::v7());
|
||||
$input = new GetPickTimeSlotQueryInput($shopperId);
|
||||
|
||||
$shop = new Shop(
|
||||
id: new ShopId(Uuid::uuid7()),
|
||||
id: new ShopId(UuidHelper::v7()),
|
||||
name: 'Shop 1',
|
||||
address: '1 rue Test',
|
||||
postcode: '75001',
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ namespace Tests\Unit\App\Dto;
|
|||
use App\Dto\ShopDto;
|
||||
use Domain\Models\Entities\Shop;
|
||||
use Domain\Models\ValueObjects\Entities\ShopId;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('ShopDto', function (): void {
|
||||
it('creates a DTO from domain Shop entity', function (): void {
|
||||
// GIVEN
|
||||
$uuid = Uuid::uuid7();
|
||||
$uuid = UuidHelper::v7();
|
||||
$shopId = new ShopId($uuid);
|
||||
$domainShop = new Shop(
|
||||
id: $shopId,
|
||||
|
|
|
|||
|
|
@ -26,13 +26,13 @@ use Domain\Ports\Repositories\ProductRepository;
|
|||
use Domain\Ports\Services\SessionService;
|
||||
use Domain\Services\BasketService;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\DDD\DomainEventDispatcher;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('EmptyBasketOnOrderPlaced', function (): void {
|
||||
it('empties the basket when an order has been placed', function (): void {
|
||||
// GIVEN
|
||||
$sessionUuid = Uuid::uuid7();
|
||||
$sessionUuid = UuidHelper::v7();
|
||||
$basket = new Basket(new BasketId($sessionUuid));
|
||||
|
||||
/** @var BasketRepository&\Mockery\MockInterface $basketRepository */
|
||||
|
|
@ -54,8 +54,8 @@ describe('EmptyBasketOnOrderPlaced', function (): void {
|
|||
|
||||
$listener = new EmptyBasketOnOrderPlaced($basketService);
|
||||
$event = new AnOrderHasBeenPlaced(
|
||||
orderId: new OrderId(Uuid::uuid7()),
|
||||
reference: new OrderReference(Uuid::uuid7()),
|
||||
orderId: new OrderId(UuidHelper::v7()),
|
||||
reference: new OrderReference(UuidHelper::v7()),
|
||||
totalTtc: Money::EUR(1000),
|
||||
byMatricule: new Matricule('1234567'),
|
||||
employee: new OrderEmployee(
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Domain\Events\BasketHasBeenModified;
|
|||
use Domain\Events\BasketRemoved;
|
||||
use Domain\Models\ValueObjects\Entities\BasketId;
|
||||
use Domain\Ports\Services\OrderBuilderSessionManager;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('InvalidateOrderBuilderOnBasketChange', function (): void {
|
||||
it('clears the order builder session manager when basket is modified', function (): void {
|
||||
|
|
@ -17,7 +17,7 @@ describe('InvalidateOrderBuilderOnBasketChange', function (): void {
|
|||
/** @var OrderBuilderSessionManager&\Mockery\MockInterface $manager */
|
||||
$manager = \Mockery::spy(OrderBuilderSessionManager::class);
|
||||
$listener = new InvalidateOrderBuilderOnBasketChange($manager);
|
||||
$event = new BasketHasBeenModified(new BasketId(Uuid::uuid7()));
|
||||
$event = new BasketHasBeenModified(new BasketId(UuidHelper::v7()));
|
||||
|
||||
// WHEN
|
||||
$listener->handle($event);
|
||||
|
|
@ -31,7 +31,7 @@ describe('InvalidateOrderBuilderOnBasketChange', function (): void {
|
|||
/** @var OrderBuilderSessionManager&\Mockery\MockInterface $manager */
|
||||
$manager = \Mockery::spy(OrderBuilderSessionManager::class);
|
||||
$listener = new InvalidateOrderBuilderOnBasketChange($manager);
|
||||
$event = new BasketRemoved(new BasketId(Uuid::uuid7()));
|
||||
$event = new BasketRemoved(new BasketId(UuidHelper::v7()));
|
||||
|
||||
// WHEN
|
||||
$listener->handle($event);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use Domain\Models\Entities\Product as DomainProduct;
|
|||
use Domain\Models\ValueObjects\Entities\ProductId;
|
||||
use Domain\Ports\Repositories\ProductRepository;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('ProductPolicy', function () {
|
||||
function getProductPolicy(?ProductRepository $repo = null): ProductPolicy
|
||||
|
|
@ -29,7 +29,7 @@ describe('ProductPolicy', function () {
|
|||
function createDomainProduct(bool $status = true): DomainProduct
|
||||
{
|
||||
return new DomainProduct(
|
||||
new ProductId(Uuid::uuid7()),
|
||||
new ProductId(UuidHelper::v7()),
|
||||
Money::EUR(100),
|
||||
TaxRate::TVA_20,
|
||||
null,
|
||||
|
|
@ -254,7 +254,7 @@ describe('ProductPolicy', function () {
|
|||
test('viewPublished returns false when product not found in domain repo', function () {
|
||||
// GIVEN
|
||||
$product = \Mockery::mock(Product::class);
|
||||
$productId = new ProductId(Uuid::uuid7());
|
||||
$productId = new ProductId(UuidHelper::v7());
|
||||
$product->shouldReceive('getId')->andReturn($productId);
|
||||
|
||||
$repo = \Mockery::mock(ProductRepository::class);
|
||||
|
|
@ -271,7 +271,7 @@ describe('ProductPolicy', function () {
|
|||
test('viewPublished returns true when product found and is published', function () {
|
||||
// GIVEN
|
||||
$product = \Mockery::mock(Product::class);
|
||||
$productId = new ProductId(Uuid::uuid7());
|
||||
$productId = new ProductId(UuidHelper::v7());
|
||||
$product->shouldReceive('getId')->andReturn($productId);
|
||||
|
||||
$domainProduct = createDomainProduct(status: true);
|
||||
|
|
@ -290,7 +290,7 @@ describe('ProductPolicy', function () {
|
|||
test('viewPublished returns false when product found and is not published', function () {
|
||||
// GIVEN
|
||||
$product = \Mockery::mock(Product::class);
|
||||
$productId = new ProductId(Uuid::uuid7());
|
||||
$productId = new ProductId(UuidHelper::v7());
|
||||
$product->shouldReceive('getId')->andReturn($productId);
|
||||
|
||||
$domainProduct = createDomainProduct(status: false);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use Domain\Models\ValueObjects\BasketProduct;
|
|||
use Domain\Models\ValueObjects\DiscountRate;
|
||||
use Domain\Models\ValueObjects\Entities\ProductId;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
covers(BasketPolicy::class);
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ function createDummyBasketProductDto(bool $isPublished = true): BasketProductDto
|
|||
{
|
||||
return new BasketProductDto(
|
||||
product: new BasketProduct(
|
||||
new ProductId(Uuid::uuid7()),
|
||||
new ProductId(UuidHelper::v7()),
|
||||
'Dummy',
|
||||
1,
|
||||
Money::EUR(1000),
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ use Domain\Models\ValueObjects\Entities\BasketId;
|
|||
use Domain\Models\ValueObjects\Entities\ShopId;
|
||||
use Domain\Models\ValueObjects\Entities\ShopperId;
|
||||
use Domain\Models\ValueObjects\PickupTimeSlot;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('OrderBuilder', function (): void {
|
||||
it('initializes from basket as an immutable BasketOrderBuilder', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId);
|
||||
$customerId = new ShopperId(Uuid::uuid7());
|
||||
$customerId = new ShopperId(UuidHelper::v7());
|
||||
|
||||
// WHEN
|
||||
$builder = OrderBuilder::fromBasket($basket, $customerId);
|
||||
|
|
@ -37,10 +37,10 @@ describe('OrderBuilder', function (): void {
|
|||
|
||||
it('returns a new immutable CompletedOrderBuilder when applying a timeslot', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId);
|
||||
$customerId = new ShopperId(Uuid::uuid7());
|
||||
$shopId = new ShopId(Uuid::uuid7());
|
||||
$customerId = new ShopperId(UuidHelper::v7());
|
||||
$shopId = new ShopId(UuidHelper::v7());
|
||||
$timeSlot = new PickupTimeSlot(new \DateTimeImmutable(), new \DateInterval('PT1H'));
|
||||
|
||||
$builder = OrderBuilder::fromBasket($basket, $customerId);
|
||||
|
|
@ -63,11 +63,11 @@ describe('OrderBuilder', function (): void {
|
|||
|
||||
it('returns a new immutable CompletedOrderBuilder when updating the timeslot', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId);
|
||||
$customerId = new ShopperId(Uuid::uuid7());
|
||||
$firstShop = new ShopId(Uuid::uuid7());
|
||||
$secondShop = new ShopId(Uuid::uuid7());
|
||||
$customerId = new ShopperId(UuidHelper::v7());
|
||||
$firstShop = new ShopId(UuidHelper::v7());
|
||||
$secondShop = new ShopId(UuidHelper::v7());
|
||||
$firstSlot = new PickupTimeSlot(new \DateTimeImmutable('+1 day'), new \DateInterval('PT1H'));
|
||||
$secondSlot = new PickupTimeSlot(new \DateTimeImmutable('+2 days'), new \DateInterval('PT1H'));
|
||||
$firstStep = OrderBuilder::fromBasket($basket, $customerId)->withPickupTimeSlot($firstShop, $firstSlot);
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ use Domain\Models\ValueObjects\ShopperServiceCode;
|
|||
use Domain\Models\ValueObjects\ShopperSiteCode;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('AnOrderHasBeenPlaced', function () {
|
||||
it('creates an event when valid', function () {
|
||||
// GIVEN
|
||||
$uuid = Uuid::uuid7();
|
||||
$uuid = UuidHelper::v7();
|
||||
$orderId = new OrderId($uuid);
|
||||
$reference = new OrderReference(Uuid::uuid7());
|
||||
$reference = new OrderReference(UuidHelper::v7());
|
||||
$totalTtc = new Money(1000, new Currency('EUR'));
|
||||
$matricule = new Matricule('1234567');
|
||||
$employee = new OrderEmployee(
|
||||
|
|
@ -52,9 +52,9 @@ describe('AnOrderHasBeenPlaced', function () {
|
|||
|
||||
it('throws exception if lines are empty', function () {
|
||||
// GIVEN
|
||||
$uuid = Uuid::uuid7();
|
||||
$uuid = UuidHelper::v7();
|
||||
$orderId = new OrderId($uuid);
|
||||
$reference = new OrderReference(Uuid::uuid7());
|
||||
$reference = new OrderReference(UuidHelper::v7());
|
||||
$totalTtc = new Money(1000, new Currency('EUR'));
|
||||
$matricule = new Matricule('1234567');
|
||||
$employee = new OrderEmployee(
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ namespace Tests\Unit\Domain\Events;
|
|||
|
||||
use Domain\Events\BasketHasBeenModified;
|
||||
use Domain\Models\ValueObjects\Entities\BasketId;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('BasketHasBeenModified', function (): void {
|
||||
it('stores the basket id and implements Event', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
|
||||
// WHEN
|
||||
$event = new BasketHasBeenModified($basketId);
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ namespace Tests\Unit\Domain\Events;
|
|||
|
||||
use Domain\Events\BasketRemoved;
|
||||
use Domain\Models\ValueObjects\Entities\BasketId;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('BasketRemoved', function (): void {
|
||||
it('stores the basket id and implements Event', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
|
||||
// WHEN
|
||||
$event = new BasketRemoved($basketId);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use Domain\Models\ValueObjects\OrderLineProduct;
|
|||
use Domain\Models\ValueObjects\ProductWeight;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('OrderPlacedLine', function () {
|
||||
it('creates OrderPlacedLine correctly', function () {
|
||||
|
|
@ -54,7 +54,7 @@ describe('OrderPlacedLine', function () {
|
|||
// GIVEN
|
||||
$product = new OrderLineProduct(
|
||||
incoId: new IncoId(42),
|
||||
originalId: new ProductId(Uuid::uuid7()),
|
||||
originalId: new ProductId(UuidHelper::v7()),
|
||||
name: 'Poulet rôti',
|
||||
weight: new ProductWeight(1000, false),
|
||||
brand: ProductBrand::none,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use Domain\Models\ValueObjects\Entities\BasketId;
|
|||
use Domain\Models\ValueObjects\Entities\ProductId;
|
||||
use Domain\Models\ValueObjects\IncoId;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Uwil\Storage\Lib\ValueObjects\StorageFilePath;
|
||||
|
||||
describe('Basket and BasketProduct', function (): void {
|
||||
|
|
@ -28,7 +28,7 @@ describe('Basket and BasketProduct', function (): void {
|
|||
function getNewBasketProduct(array $overrides = []): BasketProduct
|
||||
{
|
||||
return new BasketProduct(
|
||||
id: $overrides['id'] ?? new ProductId(Uuid::fromString('019e9e37-f2a1-74ef-b9c2-66d222470128')),
|
||||
id: $overrides['id'] ?? new ProductId(UuidHelper::fromString('019e9e37-f2a1-74ef-b9c2-66d222470128')),
|
||||
name: 'Poulet Rôti',
|
||||
qty: $overrides['qty'] ?? 2,
|
||||
unitPriceHt: Money::EUR(1000),
|
||||
|
|
@ -50,7 +50,7 @@ describe('Basket and BasketProduct', function (): void {
|
|||
|
||||
it('can instantiate a basket product with all new typed properties', function (): void {
|
||||
// GIVEN
|
||||
$productId = new ProductId(Uuid::fromString('019e9e37-f2a1-74ef-b9c2-66d222470128'));
|
||||
$productId = new ProductId(UuidHelper::fromString('019e9e37-f2a1-74ef-b9c2-66d222470128'));
|
||||
$brand = ProductBrand::marie;
|
||||
$orderUnit = OrderUnit::PCE;
|
||||
$price = Money::EUR(1000);
|
||||
|
|
@ -100,9 +100,9 @@ describe('Basket and BasketProduct', function (): void {
|
|||
|
||||
it('can clone a basket product with new quantity and keep properties', function (): void {
|
||||
// GIVEN
|
||||
$productId = new ProductId(Uuid::fromString('019e9e37-f2a1-74ef-b9c2-66d222470128'));
|
||||
$productId = new ProductId(UuidHelper::fromString('019e9e37-f2a1-74ef-b9c2-66d222470128'));
|
||||
$item = getNewBasketProduct(['id' => $productId, 'qty' => 2]);
|
||||
$basketId = new BasketId(Uuid::fromString('019e9e37-f2a1-74ef-b9c2-66d222470128'));
|
||||
$basketId = new BasketId(UuidHelper::fromString('019e9e37-f2a1-74ef-b9c2-66d222470128'));
|
||||
$basket = new Basket($basketId);
|
||||
|
||||
// WHEN
|
||||
|
|
@ -133,7 +133,7 @@ describe('Basket and BasketProduct', function (): void {
|
|||
describe('Basket additional coverage', function (): void {
|
||||
it('throws if item is not BasketProduct', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
// WHEN
|
||||
$action = fn () => (new \ReflectionClass(Basket::class))->newInstance($basketId, ['not-an-item']);
|
||||
// THEN
|
||||
|
|
@ -142,7 +142,7 @@ describe('Basket additional coverage', function (): void {
|
|||
|
||||
it('returns id', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId);
|
||||
// WHEN
|
||||
$id = $basket->id();
|
||||
|
|
@ -152,9 +152,9 @@ describe('Basket additional coverage', function (): void {
|
|||
|
||||
it('removes item completely if quantity is greater or equal', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId);
|
||||
$productId = new ProductId(Uuid::uuid7());
|
||||
$productId = new ProductId(UuidHelper::v7());
|
||||
|
||||
$item = getNewBasketProduct(['id' => $productId, 'qty' => 2]);
|
||||
$basket->addOrUpdate($item);
|
||||
|
|
@ -168,9 +168,9 @@ describe('Basket additional coverage', function (): void {
|
|||
|
||||
it('decreases quantity when removing', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId);
|
||||
$productId = new ProductId(Uuid::uuid7());
|
||||
$productId = new ProductId(UuidHelper::v7());
|
||||
|
||||
$item = getNewBasketProduct(['id' => $productId, 'qty' => 5]);
|
||||
$basket->addOrUpdate($item);
|
||||
|
|
@ -184,9 +184,9 @@ describe('Basket additional coverage', function (): void {
|
|||
|
||||
it('throws when removing less than 1', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId);
|
||||
$productId = new ProductId(Uuid::uuid7());
|
||||
$productId = new ProductId(UuidHelper::v7());
|
||||
|
||||
// WHEN
|
||||
$action = fn () => $basket->remove($productId, 0);
|
||||
|
|
@ -196,9 +196,9 @@ describe('Basket additional coverage', function (): void {
|
|||
|
||||
it('throws when removing non-existing item', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId);
|
||||
$productId = new ProductId(Uuid::uuid7());
|
||||
$productId = new ProductId(UuidHelper::v7());
|
||||
|
||||
// WHEN
|
||||
$action = fn () => $basket->remove($productId, 1);
|
||||
|
|
@ -208,9 +208,9 @@ describe('Basket additional coverage', function (): void {
|
|||
|
||||
it('removes line directly', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId);
|
||||
$productId = new ProductId(Uuid::uuid7());
|
||||
$productId = new ProductId(UuidHelper::v7());
|
||||
|
||||
$item = getNewBasketProduct(['id' => $productId, 'qty' => 5]);
|
||||
$basket->addOrUpdate($item);
|
||||
|
|
@ -224,9 +224,9 @@ describe('Basket additional coverage', function (): void {
|
|||
|
||||
it('throws when removeLine on non-existing item', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId);
|
||||
$productId = new ProductId(Uuid::uuid7());
|
||||
$productId = new ProductId(UuidHelper::v7());
|
||||
|
||||
// WHEN
|
||||
$action = fn () => $basket->removeLine($productId);
|
||||
|
|
@ -236,9 +236,9 @@ describe('Basket additional coverage', function (): void {
|
|||
|
||||
it('computes totals', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId);
|
||||
$productId = new ProductId(Uuid::uuid7());
|
||||
$productId = new ProductId(UuidHelper::v7());
|
||||
|
||||
$item = getNewBasketProduct(['id' => $productId, 'qty' => 1]);
|
||||
$basket->addOrUpdate($item);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ use Domain\Models\ValueObjects\ShopperEstablishmentCode;
|
|||
use Domain\Models\ValueObjects\ShopperServiceCode;
|
||||
use Domain\Models\ValueObjects\ShopperSiteCode;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
use Uwil\Storage\Lib\ValueObjects\StorageFilePath;
|
||||
|
||||
/**
|
||||
|
|
@ -55,7 +55,7 @@ function makeOrderLine(array $overrides = []): OrderLine
|
|||
{
|
||||
$product = new OrderLineProduct(
|
||||
incoId: new IncoId(1),
|
||||
originalId: new ProductId(Uuid::uuid7()),
|
||||
originalId: new ProductId(UuidHelper::v7()),
|
||||
name: $overrides['productName'] ?? 'Poulet Rôti',
|
||||
weight: new ProductWeight(1600, false),
|
||||
brand: ProductBrand::none,
|
||||
|
|
@ -95,10 +95,10 @@ function makeOrderLine(array $overrides = []): OrderLine
|
|||
function makeOrder(array $overrides = []): Order
|
||||
{
|
||||
return new Order(
|
||||
id: $overrides['id'] ?? new OrderId(Uuid::uuid7()),
|
||||
shopId: $overrides['shopId'] ?? new ShopId(Uuid::uuid7()),
|
||||
id: $overrides['id'] ?? new OrderId(UuidHelper::v7()),
|
||||
shopId: $overrides['shopId'] ?? new ShopId(UuidHelper::v7()),
|
||||
reference: $overrides['reference'] ?? new OrderReference(
|
||||
Uuid::uuid7()
|
||||
UuidHelper::v7()
|
||||
),
|
||||
employee: $overrides['employee'] ?? new OrderEmployee(
|
||||
matricule: new Matricule('1234567'),
|
||||
|
|
@ -261,11 +261,11 @@ describe('Order - id', function (): void {
|
|||
describe('Order - fromBasket factory', function (): void {
|
||||
it('creates an order from a basket with all lines mapped', function (): void {
|
||||
// GIVEN
|
||||
$basketId = new BasketId(Uuid::uuid7());
|
||||
$basketId = new BasketId(UuidHelper::v7());
|
||||
$basket = new Basket($basketId);
|
||||
|
||||
$basketProduct = new BasketProduct(
|
||||
id: new ProductId(Uuid::uuid7()),
|
||||
id: new ProductId(UuidHelper::v7()),
|
||||
name: 'Poulet Rôti',
|
||||
qty: 2,
|
||||
unitPriceHt: Money::EUR(1000),
|
||||
|
|
@ -284,15 +284,15 @@ describe('Order - fromBasket factory', function (): void {
|
|||
);
|
||||
$basket->addOrUpdate($basketProduct);
|
||||
|
||||
$orderId = new OrderId(Uuid::uuid7());
|
||||
$reference = new OrderReference(Uuid::uuid7());
|
||||
$orderId = new OrderId(UuidHelper::v7());
|
||||
$reference = new OrderReference(UuidHelper::v7());
|
||||
$pickupTimeSlot = new PickupTimeSlot(
|
||||
new \DateTimeImmutable('+1 day 10:00'),
|
||||
new \DateInterval('PT10M')
|
||||
);
|
||||
|
||||
$shopper = new Shopper(
|
||||
id: new ShopperId(Uuid::uuid7()),
|
||||
id: new ShopperId(UuidHelper::v7()),
|
||||
email: new Email('jean.dupont@example.com'),
|
||||
matricule: new Matricule('1234567'),
|
||||
nom: 'Dupont',
|
||||
|
|
@ -305,7 +305,7 @@ describe('Order - fromBasket factory', function (): void {
|
|||
);
|
||||
|
||||
$shop = new Shop(
|
||||
id: new ShopId(Uuid::uuid7()),
|
||||
id: new ShopId(UuidHelper::v7()),
|
||||
name: 'Cocotte Lyon',
|
||||
address: '12 rue de la Paix',
|
||||
postcode: '69001',
|
||||
|
|
@ -330,9 +330,9 @@ describe('Order - fromBasket factory', function (): void {
|
|||
|
||||
it('creates an order in PENDING status via pendingFromBasket and validates it to VALIDATED', function (): void {
|
||||
// GIVEN
|
||||
$basket = new Basket(new BasketId(Uuid::uuid7()), [
|
||||
$basket = new Basket(new BasketId(UuidHelper::v7()), [
|
||||
new BasketProduct(
|
||||
id: new ProductId(Uuid::uuid7()),
|
||||
id: new ProductId(UuidHelper::v7()),
|
||||
name: 'Poulet Rôti',
|
||||
qty: 1,
|
||||
unitPriceHt: Money::EUR(1000),
|
||||
|
|
@ -351,7 +351,7 @@ describe('Order - fromBasket factory', function (): void {
|
|||
),
|
||||
]);
|
||||
$shopper = new Shopper(
|
||||
id: new ShopperId(Uuid::uuid7()),
|
||||
id: new ShopperId(UuidHelper::v7()),
|
||||
email: new Email('jean.dupont@example.com'),
|
||||
matricule: new Matricule('1234567'),
|
||||
nom: 'Dupont',
|
||||
|
|
@ -363,7 +363,7 @@ describe('Order - fromBasket factory', function (): void {
|
|||
service: new ShopperServiceCode('101')
|
||||
);
|
||||
$shop = new Shop(
|
||||
id: new ShopId(Uuid::uuid7()),
|
||||
id: new ShopId(UuidHelper::v7()),
|
||||
name: 'Cocotte Lyon',
|
||||
address: '12 rue de la Paix',
|
||||
postcode: '69001',
|
||||
|
|
@ -373,8 +373,8 @@ describe('Order - fromBasket factory', function (): void {
|
|||
|
||||
// WHEN
|
||||
$order = Order::pendingFromBasket(
|
||||
new OrderId(Uuid::uuid7()),
|
||||
new OrderReference(Uuid::uuid7()),
|
||||
new OrderId(UuidHelper::v7()),
|
||||
new OrderReference(UuidHelper::v7()),
|
||||
$basket,
|
||||
new PickupTimeSlot(new \DateTimeImmutable('+1 day 10:00'), new \DateInterval('PT10M')),
|
||||
$shopper,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Carbon\CarbonImmutable;
|
|||
use Domain\Enums\RepeatFrequency;
|
||||
use Domain\Models\Entities\PickupExceptionOnDate;
|
||||
use Domain\Models\ValueObjects\Entities\PickupExceptionId;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
beforeEach(function (): void {
|
||||
$now = CarbonImmutable::parse('2026-06-15 10:00:00', 'Europe/Paris');
|
||||
|
|
@ -25,7 +25,7 @@ afterEach(function (): void {
|
|||
describe('PickupExceptionOnDate', function (): void {
|
||||
it('can instantiate correctly', function (): void {
|
||||
// GIVEN
|
||||
$id = new PickupExceptionId(Uuid::uuid7());
|
||||
$id = new PickupExceptionId(UuidHelper::v7());
|
||||
$date = CarbonImmutable::now();
|
||||
$label = 'Férié';
|
||||
$repeatable = true;
|
||||
|
|
@ -58,7 +58,7 @@ describe('PickupExceptionOnDate', function (): void {
|
|||
$mondayDate = CarbonImmutable::parse('2025-01-06'); // 2025-01-06 is Monday
|
||||
|
||||
$fridayException = new PickupExceptionOnDate(
|
||||
new PickupExceptionId(Uuid::uuid7()),
|
||||
new PickupExceptionId(UuidHelper::v7()),
|
||||
$fridayDate,
|
||||
'Friday holiday',
|
||||
false,
|
||||
|
|
@ -67,7 +67,7 @@ describe('PickupExceptionOnDate', function (): void {
|
|||
);
|
||||
|
||||
$mondayException = new PickupExceptionOnDate(
|
||||
new PickupExceptionId(Uuid::uuid7()),
|
||||
new PickupExceptionId(UuidHelper::v7()),
|
||||
$mondayDate,
|
||||
'Monday holiday',
|
||||
false,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use Domain\Models\ValueObjects\DiscountValue;
|
|||
use Domain\Models\ValueObjects\Entities\ProductId;
|
||||
use Domain\Models\ValueObjects\ProductWeight;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
function makeProduct(
|
||||
?Money $price = null,
|
||||
|
|
@ -29,7 +29,7 @@ function makeProduct(
|
|||
bool $hasInco = true
|
||||
): Product {
|
||||
return new Product(
|
||||
id: new ProductId(Uuid::uuid7()),
|
||||
id: new ProductId(UuidHelper::v7()),
|
||||
price: $price ?? Money::EUR(1000),
|
||||
tax_rate: $taxRate,
|
||||
product_weight: $weight,
|
||||
|
|
@ -57,7 +57,7 @@ afterEach(function (): void {
|
|||
describe('Product', function (): void {
|
||||
it('can instantiate correctly', function (): void {
|
||||
// GIVEN
|
||||
$id = new ProductId(Uuid::uuid7());
|
||||
$id = new ProductId(UuidHelper::v7());
|
||||
$price = Money::EUR(1000);
|
||||
$taxRate = TaxRate::TVA_5_5;
|
||||
$weight = new ProductWeight(500, false);
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ namespace Tests\Unit\Domain\Models\Entities;
|
|||
|
||||
use Domain\Models\Entities\Shop;
|
||||
use Domain\Models\ValueObjects\Entities\ShopId;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('Shop', function (): void {
|
||||
it('can instantiate correctly', function (): void {
|
||||
// GIVEN
|
||||
$id = new ShopId(Uuid::uuid7());
|
||||
$id = new ShopId(UuidHelper::v7());
|
||||
$name = 'Boutique';
|
||||
$address = '123 Rue de Paris';
|
||||
$postcode = '75001';
|
||||
|
|
@ -49,7 +49,7 @@ describe('Shop', function (): void {
|
|||
|
||||
it('throws exception if name is empty', function (): void {
|
||||
// GIVEN
|
||||
$id = new ShopId(Uuid::uuid7());
|
||||
$id = new ShopId(UuidHelper::v7());
|
||||
|
||||
// WHEN
|
||||
$action = fn () => new Shop($id, '', 'Address', '12345', 'City');
|
||||
|
|
@ -60,7 +60,7 @@ describe('Shop', function (): void {
|
|||
|
||||
it('throws exception if address is empty', function (): void {
|
||||
// GIVEN
|
||||
$id = new ShopId(Uuid::uuid7());
|
||||
$id = new ShopId(UuidHelper::v7());
|
||||
|
||||
// WHEN
|
||||
$action = fn () => new Shop($id, 'Name', '', '12345', 'City');
|
||||
|
|
@ -71,7 +71,7 @@ describe('Shop', function (): void {
|
|||
|
||||
it('throws exception if postcode is empty', function (): void {
|
||||
// GIVEN
|
||||
$id = new ShopId(Uuid::uuid7());
|
||||
$id = new ShopId(UuidHelper::v7());
|
||||
|
||||
// WHEN
|
||||
$action = fn () => new Shop($id, 'Name', 'Address', '', 'City');
|
||||
|
|
@ -82,7 +82,7 @@ describe('Shop', function (): void {
|
|||
|
||||
it('throws exception if city is empty', function (): void {
|
||||
// GIVEN
|
||||
$id = new ShopId(Uuid::uuid7());
|
||||
$id = new ShopId(UuidHelper::v7());
|
||||
|
||||
// WHEN
|
||||
$action = fn () => new Shop($id, 'Name', 'Address', '12345', '');
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ use Domain\Models\ValueObjects\Matricule;
|
|||
use Domain\Models\ValueObjects\ShopperEstablishmentCode;
|
||||
use Domain\Models\ValueObjects\ShopperServiceCode;
|
||||
use Domain\Models\ValueObjects\ShopperSiteCode;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('Shopper', function (): void {
|
||||
it('can instantiate correctly and check active status (active)', function (): void {
|
||||
// GIVEN
|
||||
$id = new ShopperId(Uuid::uuid7());
|
||||
$id = new ShopperId(UuidHelper::v7());
|
||||
$email = new Email('test@example.com');
|
||||
$matricule = new Matricule('1234567');
|
||||
$startDate = CarbonImmutable::now()->subDay();
|
||||
|
|
@ -60,7 +60,7 @@ describe('Shopper', function (): void {
|
|||
|
||||
// WHEN
|
||||
$entity = new Shopper(
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
new Email('test@example.com'),
|
||||
new Matricule('1234567'),
|
||||
'Nom',
|
||||
|
|
@ -82,7 +82,7 @@ describe('Shopper', function (): void {
|
|||
|
||||
// WHEN
|
||||
$entity = new Shopper(
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
new Email('test@example.com'),
|
||||
new Matricule('1234567'),
|
||||
'Nom',
|
||||
|
|
@ -104,7 +104,7 @@ describe('Shopper', function (): void {
|
|||
|
||||
// WHEN
|
||||
$entity = new Shopper(
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
new Email('test@example.com'),
|
||||
new Matricule('1234567'),
|
||||
'Nom',
|
||||
|
|
@ -127,7 +127,7 @@ describe('Shopper', function (): void {
|
|||
|
||||
// WHEN
|
||||
$entity = new Shopper(
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
new Email('test@example.com'),
|
||||
new Matricule('1234567'),
|
||||
'Nom',
|
||||
|
|
@ -151,7 +151,7 @@ describe('Shopper', function (): void {
|
|||
try {
|
||||
// WHEN
|
||||
$entity = new Shopper(
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
new Email('test@example.com'),
|
||||
new Matricule('1234567'),
|
||||
'Nom',
|
||||
|
|
@ -178,7 +178,7 @@ describe('Shopper', function (): void {
|
|||
try {
|
||||
// WHEN
|
||||
$entity = new Shopper(
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
new Email('test@example.com'),
|
||||
new Matricule('1234567'),
|
||||
'Nom',
|
||||
|
|
@ -203,7 +203,7 @@ describe('Shopper', function (): void {
|
|||
|
||||
try {
|
||||
$entity = new Shopper(
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
new Email('test@example.com'),
|
||||
new Matricule('1234567'),
|
||||
'Nom',
|
||||
|
|
@ -228,7 +228,7 @@ describe('Shopper', function (): void {
|
|||
|
||||
try {
|
||||
$entity = new Shopper(
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
new Email('test@example.com'),
|
||||
new Matricule('1234567'),
|
||||
'Nom',
|
||||
|
|
@ -250,7 +250,7 @@ describe('Shopper', function (): void {
|
|||
it('throws exception if nom is empty', function (): void {
|
||||
// WHEN
|
||||
$action = fn () => new Shopper(
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
new Email('test@example.com'),
|
||||
new Matricule('1234567'),
|
||||
'',
|
||||
|
|
@ -269,7 +269,7 @@ describe('Shopper', function (): void {
|
|||
it('throws exception if prenom is empty', function (): void {
|
||||
// WHEN
|
||||
$action = fn () => new Shopper(
|
||||
new ShopperId(Uuid::uuid7()),
|
||||
new ShopperId(UuidHelper::v7()),
|
||||
new Email('test@example.com'),
|
||||
new Matricule('1234567'),
|
||||
'Nom',
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use Domain\Models\ValueObjects\DiscountRate;
|
|||
use Domain\Models\ValueObjects\Entities\ProductId;
|
||||
use Money\Currency;
|
||||
use Money\Money;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('BasketProduct', function () {
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ describe('BasketProduct', function () {
|
|||
function getNewProduct(array $overrides = []): BasketProduct
|
||||
{
|
||||
return new BasketProduct(
|
||||
id: new ProductId(Uuid::uuid7()),
|
||||
id: new ProductId(UuidHelper::v7()),
|
||||
name: $overrides['name'] ?? 'Product Name',
|
||||
qty: $overrides['qty'] ?? 1,
|
||||
unitPriceHt: $overrides['unitPriceHt'] ?? getMoney(100),
|
||||
|
|
@ -59,7 +59,7 @@ describe('BasketProduct', function () {
|
|||
|
||||
it('can instantiate', function () {
|
||||
// GIVEN
|
||||
$id = new ProductId(Uuid::uuid7());
|
||||
$id = new ProductId(UuidHelper::v7());
|
||||
$name = 'Product Name';
|
||||
$qty = 2;
|
||||
$unitPriceHt = getMoney(100);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace Tests\Unit\Domain\Models\ValueObjects;
|
|||
|
||||
use Domain\Models\ValueObjects\ContactFormData;
|
||||
use Domain\Models\ValueObjects\OrderReference;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
describe('ContactFormData', function () {
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ describe('ContactFormData', function () {
|
|||
$email = 'john@example.com';
|
||||
$subject = 'Inquiry';
|
||||
$message = 'This is a message.';
|
||||
$orderRef = new OrderReference(Uuid::uuid7());
|
||||
$orderRef = new OrderReference(UuidHelper::v7());
|
||||
$file = null;
|
||||
|
||||
// WHEN
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use Domain\Enums\RepeatFrequency;
|
|||
use Domain\Models\Entities\PickupExceptionOnDate;
|
||||
use Domain\Models\ValueObjects\EditablePickupExceptionForShop;
|
||||
use Domain\Models\ValueObjects\Entities\PickupExceptionId;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Helpers\UuidHelper;
|
||||
|
||||
beforeEach(function (): void {
|
||||
$now = CarbonImmutable::parse('2026-06-15 10:00:00', 'Europe/Paris');
|
||||
|
|
@ -27,7 +27,7 @@ describe('EditablePickupExceptionForShop', function (): void {
|
|||
it('can instantiate and clones the exception', function (): void {
|
||||
// GIVEN
|
||||
$exception = new PickupExceptionOnDate(
|
||||
new PickupExceptionId(Uuid::uuid7()),
|
||||
new PickupExceptionId(UuidHelper::v7()),
|
||||
CarbonImmutable::now(),
|
||||
'Label',
|
||||
true,
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue