2026-06-14 21:32:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-11-16 14:26:35 +01:00
|
|
|
namespace Tests\Feature\App\Http\Controllers\Fo\Customers;
|
|
|
|
|
|
2026-09-30 17:57:20 +02:00
|
|
|
use App\Dto\OrderDto;
|
2026-06-14 21:32:07 +02:00
|
|
|
use App\Models\Customer;
|
2026-09-30 17:57:20 +02:00
|
|
|
use App\Models\Employee;
|
|
|
|
|
use App\Models\Order;
|
2026-06-14 21:32:07 +02:00
|
|
|
use App\Models\Page;
|
2026-09-30 17:57:20 +02:00
|
|
|
use App\Models\Shop;
|
2026-06-14 21:32:07 +02:00
|
|
|
use App\Services\CrmService;
|
2026-11-16 15:49:48 +01:00
|
|
|
use Carbon\Carbon;
|
2026-09-30 17:57:20 +02:00
|
|
|
use Carbon\CarbonImmutable;
|
2026-06-14 21:32:07 +02:00
|
|
|
use Database\Seeders\ContentSeeder;
|
2026-09-30 17:57:20 +02:00
|
|
|
use Domain\Enums\Country;
|
|
|
|
|
use Domain\Enums\OrderStatus;
|
|
|
|
|
use Domain\Models\ValueObjects\Code;
|
|
|
|
|
use Domain\Models\ValueObjects\CrmCustomer;
|
|
|
|
|
use Domain\Models\ValueObjects\DeliveryAddress;
|
|
|
|
|
use Domain\Models\ValueObjects\Email;
|
|
|
|
|
use Domain\Models\ValueObjects\Matricule;
|
|
|
|
|
use Domain\Models\ValueObjects\OrderEmployee;
|
|
|
|
|
use Domain\Models\ValueObjects\OrderReference;
|
feat(employees): automated sync with Arcadia API, BO settings, Shopper value objects, and pagination migration
- Implement automated synchronization of employees via Arcadia API (EmployeeSyncService, SynchronizeEmployeesWithArcadiaApi, FetchAndUpsertArcadiaEmployees)
- Add Back-Office application settings for employee sites (Setting singleton, GetSettingsQuery, UpdateSettings, SettingsController, EmployeeSitesInputComponent.vue)
- Strongly type Employee attributes using Domain Value Objects (ShopperEstablishmentCode, ShopperSiteCode, ShopperServiceCode) and Eloquent Casts
- Migrate pagination from Domain to Shared\Pagination namespace across queries and inputs
- Remove legacy and dead CSV employee import/export code
- Restore Domain\Ports\Services\CsvGenerator interface for Regate order generation
- Add comprehensive Pest unit, integration, and feature test coverage
2026-10-01 17:26:30 +02:00
|
|
|
use Domain\Models\ValueObjects\ShopperEstablishmentCode;
|
|
|
|
|
use Domain\Models\ValueObjects\ShopperServiceCode;
|
|
|
|
|
use Domain\Models\ValueObjects\ShopperSiteCode;
|
2026-09-30 17:57:20 +02:00
|
|
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
2026-06-14 21:32:07 +02:00
|
|
|
use Illuminate\Support\Facades\App;
|
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
2026-09-30 17:57:20 +02:00
|
|
|
use Illuminate\Support\Facades\Date;
|
2026-06-14 21:32:07 +02:00
|
|
|
use Illuminate\Support\Facades\View;
|
2026-09-30 17:57:20 +02:00
|
|
|
use Money\Currency;
|
|
|
|
|
use Money\Money;
|
2026-11-17 12:15:39 +01:00
|
|
|
use Shared\Helpers\UuidHelper;
|
2026-09-30 17:57:20 +02:00
|
|
|
use Shared\ValueObjects\CrmHashcode;
|
2026-06-14 21:32:07 +02:00
|
|
|
|
|
|
|
|
describe('OrderController', function () {
|
2026-11-16 15:49:48 +01:00
|
|
|
beforeEach(function (): void {
|
|
|
|
|
$now = CarbonImmutable::parse('2026-06-15 10:00:00', 'Europe/Paris');
|
|
|
|
|
Date::setTestNow($now);
|
|
|
|
|
CarbonImmutable::setTestNow($now);
|
|
|
|
|
Carbon::setTestNow($now);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(function (): void {
|
|
|
|
|
Date::setTestNow();
|
|
|
|
|
CarbonImmutable::setTestNow();
|
|
|
|
|
Carbon::setTestNow();
|
|
|
|
|
});
|
|
|
|
|
|
2026-06-14 21:32:07 +02:00
|
|
|
it('can access get /compte/commandes', function () {
|
2026-09-30 17:57:20 +02:00
|
|
|
/** @var \Tests\TestCase $this */
|
2026-06-14 21:32:07 +02:00
|
|
|
// GIVEN
|
|
|
|
|
$this->seed(ContentSeeder::class);
|
|
|
|
|
View::share('PageList', Page::getCached()
|
|
|
|
|
->mapWithKeys(fn ($page) => [
|
|
|
|
|
$page->slug->value() => $page,
|
|
|
|
|
]));
|
|
|
|
|
Cache::flush();
|
|
|
|
|
$user = \Mockery::mock(Customer::class)->makePartial();
|
|
|
|
|
$user->shouldReceive('getAuthIdentifier')->andReturn(1);
|
2026-11-17 12:15:39 +01:00
|
|
|
$user->hashcode = new CrmHashcode(UuidHelper::v4());
|
2026-06-14 21:32:07 +02:00
|
|
|
$user->shouldReceive('getAuthPassword')->andReturn('dummy');
|
|
|
|
|
$this->actingAs($user, 'frontend');
|
|
|
|
|
$crmMock = \Mockery::mock(CrmService::class)->makePartial();
|
|
|
|
|
$crmMock->shouldReceive('getCustomerFromHashCode')->andReturn(null);
|
|
|
|
|
App::instance(CrmService::class, $crmMock);
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$response = $this->get('/compte/commandes');
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
$response->assertStatus(302);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('can access get /compte/commandes/1', function () {
|
2026-09-30 17:57:20 +02:00
|
|
|
/** @var \Tests\TestCase $this */
|
2026-06-14 21:32:07 +02:00
|
|
|
// GIVEN
|
|
|
|
|
$this->seed(ContentSeeder::class);
|
|
|
|
|
View::share('PageList', Page::getCached()
|
|
|
|
|
->mapWithKeys(fn ($page) => [
|
|
|
|
|
$page->slug->value() => $page,
|
|
|
|
|
]));
|
|
|
|
|
Cache::flush();
|
|
|
|
|
$user = \Mockery::mock(Customer::class)->makePartial();
|
|
|
|
|
$user->shouldReceive('getAuthIdentifier')->andReturn(1);
|
2026-11-17 12:15:39 +01:00
|
|
|
$user->hashcode = new CrmHashcode(UuidHelper::v4());
|
2026-06-14 21:32:07 +02:00
|
|
|
$user->shouldReceive('getAuthPassword')->andReturn('dummy');
|
|
|
|
|
$this->actingAs($user, 'frontend');
|
|
|
|
|
$crmMock = \Mockery::mock(CrmService::class)->makePartial();
|
|
|
|
|
$crmMock->shouldReceive('getCustomerFromHashCode')->andReturn(null);
|
|
|
|
|
App::instance(CrmService::class, $crmMock);
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$response = $this->get('/compte/commandes/1');
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
$response->assertStatus(404);
|
|
|
|
|
});
|
2026-09-30 17:57:20 +02:00
|
|
|
|
|
|
|
|
it('renders customer orders index with DTOs when verified', function () {
|
|
|
|
|
/** @var \Tests\TestCase $this */
|
|
|
|
|
// GIVEN
|
|
|
|
|
$this->seed(ContentSeeder::class);
|
|
|
|
|
View::share('PageList', Page::getCached()
|
|
|
|
|
->mapWithKeys(fn ($page) => [
|
|
|
|
|
$page->slug->value() => $page,
|
|
|
|
|
]));
|
|
|
|
|
Cache::flush();
|
|
|
|
|
|
2026-11-17 12:15:39 +01:00
|
|
|
$hashcode = new CrmHashcode(UuidHelper::v4());
|
2026-11-16 15:54:41 +01:00
|
|
|
$customer = Customer::query()->forceCreate([
|
2026-11-17 12:15:39 +01:00
|
|
|
'id' => UuidHelper::v7()->toString(),
|
2026-09-30 17:57:20 +02:00
|
|
|
'hashcode' => $hashcode->value,
|
|
|
|
|
'email' => new Email('verified@example.com'),
|
|
|
|
|
]);
|
|
|
|
|
|
2026-11-16 15:54:41 +01:00
|
|
|
Employee::query()->forceCreate([
|
2026-09-30 17:57:20 +02:00
|
|
|
'id' => 8881,
|
|
|
|
|
'customer_id' => $customer->id,
|
|
|
|
|
'matricule' => new Matricule('8888001'),
|
|
|
|
|
'nom' => 'Dupont',
|
|
|
|
|
'prenom' => 'Jean',
|
|
|
|
|
'code' => new Code('ABCDEF12'),
|
feat(employees): automated sync with Arcadia API, BO settings, Shopper value objects, and pagination migration
- Implement automated synchronization of employees via Arcadia API (EmployeeSyncService, SynchronizeEmployeesWithArcadiaApi, FetchAndUpsertArcadiaEmployees)
- Add Back-Office application settings for employee sites (Setting singleton, GetSettingsQuery, UpdateSettings, SettingsController, EmployeeSitesInputComponent.vue)
- Strongly type Employee attributes using Domain Value Objects (ShopperEstablishmentCode, ShopperSiteCode, ShopperServiceCode) and Eloquent Casts
- Migrate pagination from Domain to Shared\Pagination namespace across queries and inputs
- Remove legacy and dead CSV employee import/export code
- Restore Domain\Ports\Services\CsvGenerator interface for Regate order generation
- Add comprehensive Pest unit, integration, and feature test coverage
2026-10-01 17:26:30 +02:00
|
|
|
'etablissement' => 'ETAB',
|
|
|
|
|
'site' => 'SITE',
|
|
|
|
|
'service' => '101',
|
2026-09-30 17:57:20 +02:00
|
|
|
'created_at' => CarbonImmutable::now(),
|
|
|
|
|
'updated_at' => CarbonImmutable::now(),
|
|
|
|
|
]);
|
|
|
|
|
|
2026-10-27 16:09:39 +01:00
|
|
|
$shop = Shop::factory()->create();
|
2026-11-17 12:15:39 +01:00
|
|
|
$refUuid = UuidHelper::v7();
|
2026-10-27 16:09:39 +01:00
|
|
|
$reference = new OrderReference($refUuid);
|
|
|
|
|
$ref = (string) $reference;
|
2026-11-16 15:54:41 +01:00
|
|
|
Order::query()->forceCreate([
|
2026-11-17 12:15:39 +01:00
|
|
|
'id' => UuidHelper::v7()->toString(),
|
2026-09-30 17:57:20 +02:00
|
|
|
'shop_id' => $shop->id,
|
2026-10-27 16:09:39 +01:00
|
|
|
'reference' => $reference,
|
2026-09-30 17:57:20 +02:00
|
|
|
'status' => OrderStatus::VALIDATED->value,
|
|
|
|
|
'total' => new Money(5000, new Currency('EUR')),
|
2026-11-16 16:29:17 +01:00
|
|
|
'employee' => new OrderEmployee(
|
|
|
|
|
new Matricule('8888001'),
|
|
|
|
|
'Jean',
|
|
|
|
|
'Dupont',
|
|
|
|
|
new ShopperEstablishmentCode('FAC01'),
|
|
|
|
|
new ShopperSiteCode('SITE'),
|
|
|
|
|
new ShopperServiceCode('101'),
|
|
|
|
|
),
|
2026-09-30 17:57:20 +02:00
|
|
|
'delivery_address' => new DeliveryAddress('Shop Name', 'Address', '75000', 'Paris'),
|
|
|
|
|
'pickup_day' => Date::now()->toDateString(),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$crmCustomer = new CrmCustomer(
|
|
|
|
|
hashcode: $hashcode->value,
|
|
|
|
|
email: 'verified@example.com',
|
|
|
|
|
password: 'pwd',
|
|
|
|
|
firstname: 'Jean',
|
|
|
|
|
lastname: 'Dupont',
|
|
|
|
|
birthDate: null,
|
|
|
|
|
phone: '0123456789',
|
|
|
|
|
address: '10 rue test',
|
|
|
|
|
address2: null,
|
|
|
|
|
city: 'Paris',
|
|
|
|
|
postcode: '75000',
|
|
|
|
|
country: Country::france,
|
|
|
|
|
optIn: true,
|
|
|
|
|
status: true,
|
|
|
|
|
lastConnection: null,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$crmMock = \Mockery::mock(CrmService::class)->makePartial();
|
|
|
|
|
$crmMock->shouldReceive('getCustomerFromHashCode')->andReturn($crmCustomer);
|
|
|
|
|
App::instance(CrmService::class, $crmMock);
|
|
|
|
|
|
|
|
|
|
$this->actingAs($customer, 'frontend');
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$response = $this->get('/compte/commandes');
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($response->status())->toBe(200);
|
|
|
|
|
$response->assertViewIs('fo.customer.orders.index');
|
|
|
|
|
$response->assertViewHas('orders', function ($orders) use ($ref): bool {
|
2026-11-16 16:26:51 +01:00
|
|
|
if (! $orders instanceof LengthAwarePaginator || $orders->total() !== 1) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$first = $orders->items()[0] ?? null;
|
|
|
|
|
|
2026-11-16 16:29:17 +01:00
|
|
|
return is_object($first)
|
|
|
|
|
&& property_exists($first, 'reference')
|
|
|
|
|
&& ($first->reference instanceof \Stringable || is_string($first->reference))
|
|
|
|
|
&& (string) $first->reference === $ref;
|
2026-09-30 17:57:20 +02:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('renders customer order detail when owned by customer', function () {
|
|
|
|
|
/** @var \Tests\TestCase $this */
|
|
|
|
|
// GIVEN
|
|
|
|
|
$this->seed(ContentSeeder::class);
|
|
|
|
|
View::share('PageList', Page::getCached()
|
|
|
|
|
->mapWithKeys(fn ($page) => [
|
|
|
|
|
$page->slug->value() => $page,
|
|
|
|
|
]));
|
|
|
|
|
Cache::flush();
|
|
|
|
|
|
2026-11-17 12:15:39 +01:00
|
|
|
$hashcode = new CrmHashcode(UuidHelper::v4());
|
2026-11-16 15:54:41 +01:00
|
|
|
$customer = Customer::query()->forceCreate([
|
2026-11-17 12:15:39 +01:00
|
|
|
'id' => UuidHelper::v7()->toString(),
|
2026-09-30 17:57:20 +02:00
|
|
|
'hashcode' => $hashcode->value,
|
|
|
|
|
'email' => new Email('verified_show@example.com'),
|
|
|
|
|
]);
|
|
|
|
|
|
2026-11-16 15:54:41 +01:00
|
|
|
Employee::query()->forceCreate([
|
2026-09-30 17:57:20 +02:00
|
|
|
'id' => 8882,
|
|
|
|
|
'customer_id' => $customer->id,
|
|
|
|
|
'matricule' => new Matricule('8888002'),
|
|
|
|
|
'nom' => 'Martin',
|
|
|
|
|
'prenom' => 'Paul',
|
|
|
|
|
'code' => new Code('ABCDEF34'),
|
feat(employees): automated sync with Arcadia API, BO settings, Shopper value objects, and pagination migration
- Implement automated synchronization of employees via Arcadia API (EmployeeSyncService, SynchronizeEmployeesWithArcadiaApi, FetchAndUpsertArcadiaEmployees)
- Add Back-Office application settings for employee sites (Setting singleton, GetSettingsQuery, UpdateSettings, SettingsController, EmployeeSitesInputComponent.vue)
- Strongly type Employee attributes using Domain Value Objects (ShopperEstablishmentCode, ShopperSiteCode, ShopperServiceCode) and Eloquent Casts
- Migrate pagination from Domain to Shared\Pagination namespace across queries and inputs
- Remove legacy and dead CSV employee import/export code
- Restore Domain\Ports\Services\CsvGenerator interface for Regate order generation
- Add comprehensive Pest unit, integration, and feature test coverage
2026-10-01 17:26:30 +02:00
|
|
|
'etablissement' => 'ETAB',
|
|
|
|
|
'site' => 'SITE',
|
|
|
|
|
'service' => '101',
|
2026-09-30 17:57:20 +02:00
|
|
|
'created_at' => CarbonImmutable::now(),
|
|
|
|
|
'updated_at' => CarbonImmutable::now(),
|
|
|
|
|
]);
|
|
|
|
|
|
2026-10-27 16:09:39 +01:00
|
|
|
$shop = Shop::factory()->create();
|
2026-11-17 12:15:39 +01:00
|
|
|
$refUuid = UuidHelper::v7();
|
2026-10-27 16:09:39 +01:00
|
|
|
$reference = new OrderReference($refUuid);
|
|
|
|
|
$ref = (string) $reference;
|
2026-11-16 15:54:41 +01:00
|
|
|
$order = Order::query()->forceCreate([
|
2026-11-17 12:15:39 +01:00
|
|
|
'id' => UuidHelper::v7()->toString(),
|
2026-09-30 17:57:20 +02:00
|
|
|
'shop_id' => $shop->id,
|
2026-10-27 16:09:39 +01:00
|
|
|
'reference' => $reference,
|
2026-09-30 17:57:20 +02:00
|
|
|
'status' => OrderStatus::VALIDATED->value,
|
|
|
|
|
'total' => new Money(5000, new Currency('EUR')),
|
2026-11-16 16:29:17 +01:00
|
|
|
'employee' => new OrderEmployee(
|
|
|
|
|
new Matricule('8888002'),
|
|
|
|
|
'Paul',
|
|
|
|
|
'Martin',
|
|
|
|
|
new ShopperEstablishmentCode('FAC01'),
|
|
|
|
|
new ShopperSiteCode('SITE'),
|
|
|
|
|
new ShopperServiceCode('101'),
|
|
|
|
|
),
|
2026-09-30 17:57:20 +02:00
|
|
|
'delivery_address' => new DeliveryAddress('Shop Name', 'Address', '75000', 'Paris'),
|
|
|
|
|
'pickup_day' => Date::now()->toDateString(),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$crmCustomer = new CrmCustomer(
|
|
|
|
|
hashcode: $hashcode->value,
|
|
|
|
|
email: 'verified_show@example.com',
|
|
|
|
|
password: 'pwd',
|
|
|
|
|
firstname: 'Paul',
|
|
|
|
|
lastname: 'Martin',
|
|
|
|
|
birthDate: null,
|
|
|
|
|
phone: '0123456789',
|
|
|
|
|
address: '10 rue test',
|
|
|
|
|
address2: null,
|
|
|
|
|
city: 'Paris',
|
|
|
|
|
postcode: '75000',
|
|
|
|
|
country: Country::france,
|
|
|
|
|
optIn: true,
|
|
|
|
|
status: true,
|
|
|
|
|
lastConnection: null,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$crmMock = \Mockery::mock(CrmService::class)->makePartial();
|
|
|
|
|
$crmMock->shouldReceive('getCustomerFromHashCode')->andReturn($crmCustomer);
|
|
|
|
|
App::instance(CrmService::class, $crmMock);
|
|
|
|
|
|
|
|
|
|
$this->actingAs($customer, 'frontend');
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$response = $this->get("/compte/commandes/{$ref}");
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($response->status())->toBe(200);
|
|
|
|
|
$response->assertViewIs('fo.customer.orders.show');
|
|
|
|
|
$response->assertViewHas('order', fn ($orderData) => $orderData instanceof OrderDto && (string) $orderData->reference === $ref);
|
|
|
|
|
$response->assertViewHas('mapUrl');
|
|
|
|
|
});
|
2026-11-16 20:05:27 +01:00
|
|
|
|
|
|
|
|
it('forbids viewing technical PENDING or FAILED orders on GET /compte/commandes/{reference}', function (OrderStatus $status) {
|
|
|
|
|
/** @var \Tests\TestCase $this */
|
|
|
|
|
// GIVEN
|
|
|
|
|
$this->seed(ContentSeeder::class);
|
|
|
|
|
View::share('PageList', Page::getCached()
|
|
|
|
|
->mapWithKeys(fn ($page) => [
|
|
|
|
|
$page->slug->value() => $page,
|
|
|
|
|
]));
|
|
|
|
|
Cache::flush();
|
|
|
|
|
|
2026-11-17 12:15:39 +01:00
|
|
|
$hashcode = new CrmHashcode(UuidHelper::v4());
|
2026-11-16 20:05:27 +01:00
|
|
|
$customer = Customer::query()->forceCreate([
|
2026-11-17 12:15:39 +01:00
|
|
|
'id' => UuidHelper::v7()->toString(),
|
2026-11-16 20:05:27 +01:00
|
|
|
'hashcode' => $hashcode->value,
|
|
|
|
|
'email' => new Email('tech-order-' . $status->value . '@example.com'),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
Employee::query()->forceCreate([
|
|
|
|
|
'customer_id' => $customer->id,
|
|
|
|
|
'matricule' => new Matricule('8888003'),
|
|
|
|
|
'nom' => 'Martin',
|
|
|
|
|
'prenom' => 'Paul',
|
|
|
|
|
'code' => new Code('ABCDEF35'),
|
|
|
|
|
'etablissement' => 'ETAB',
|
|
|
|
|
'site' => 'SITE',
|
|
|
|
|
'service' => '101',
|
|
|
|
|
'created_at' => CarbonImmutable::now(),
|
|
|
|
|
'updated_at' => CarbonImmutable::now(),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$shop = Shop::factory()->create();
|
2026-11-17 12:15:39 +01:00
|
|
|
$reference = new OrderReference(UuidHelper::v7());
|
2026-11-16 20:05:27 +01:00
|
|
|
Order::query()->forceCreate([
|
2026-11-17 12:15:39 +01:00
|
|
|
'id' => UuidHelper::v7()->toString(),
|
2026-11-16 20:05:27 +01:00
|
|
|
'shop_id' => $shop->id,
|
|
|
|
|
'reference' => $reference,
|
|
|
|
|
'status' => $status->value,
|
|
|
|
|
'total' => new Money(5000, new Currency('EUR')),
|
|
|
|
|
'employee' => new OrderEmployee(
|
|
|
|
|
new Matricule('8888003'),
|
|
|
|
|
'Paul',
|
|
|
|
|
'Martin',
|
|
|
|
|
new ShopperEstablishmentCode('FAC01'),
|
|
|
|
|
new ShopperSiteCode('SITE'),
|
|
|
|
|
new ShopperServiceCode('101'),
|
|
|
|
|
),
|
|
|
|
|
'delivery_address' => new DeliveryAddress('Shop Name', 'Address', '75000', 'Paris'),
|
|
|
|
|
'pickup_day' => Date::now()->toDateString(),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$crmCustomer = new CrmCustomer(
|
|
|
|
|
hashcode: $hashcode->value,
|
|
|
|
|
email: 'tech-order-' . $status->value . '@example.com',
|
|
|
|
|
password: 'pwd',
|
|
|
|
|
firstname: 'Paul',
|
|
|
|
|
lastname: 'Martin',
|
|
|
|
|
birthDate: null,
|
|
|
|
|
phone: '0123456789',
|
|
|
|
|
address: '10 rue test',
|
|
|
|
|
address2: null,
|
|
|
|
|
city: 'Paris',
|
|
|
|
|
postcode: '75000',
|
|
|
|
|
country: Country::france,
|
|
|
|
|
optIn: true,
|
|
|
|
|
status: true,
|
|
|
|
|
lastConnection: null,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$crmMock = \Mockery::mock(CrmService::class)->makePartial();
|
|
|
|
|
$crmMock->shouldReceive('getCustomerFromHashCode')->andReturn($crmCustomer);
|
|
|
|
|
App::instance(CrmService::class, $crmMock);
|
|
|
|
|
|
|
|
|
|
$this->actingAs($customer, 'frontend');
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$response = $this->get('/compte/commandes/' . (string) $reference);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($response->status())->toBe(403);
|
|
|
|
|
})->with([
|
|
|
|
|
'pending' => [OrderStatus::PENDING],
|
|
|
|
|
'failed' => [OrderStatus::FAILED],
|
|
|
|
|
]);
|
2026-06-14 21:32:07 +02:00
|
|
|
});
|