ldc-cocotte/tests/Integration/WithApp/App/Services/OrderServiceTest.php
Jérémy Munsch 3b3997d547
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-27 09:58:44 +01:00

90 lines
2.4 KiB
PHP

<?php
declare(strict_types=1);
use App\Contracts\Directories\OrderDirectory;
use App\Models\Customer;
use App\Models\Order;
use App\Services\OrderService;
use Illuminate\Pagination\LengthAwarePaginator;
use Ramsey\Uuid\Uuid;
covers(OrderService::class);
describe('OrderService', function () {
afterEach(function () {
\Mockery::close();
});
it('paginates orders for a customer', function () {
// GIVEN
$orderDirectory = \Mockery::mock(OrderDirectory::class);
$customer = new Customer();
$customer->id = (string) Uuid::uuid7();
$pagination = new \Pagination(0, 15);
$paginator = new LengthAwarePaginator([], 0, 15);
$orderDirectory->shouldReceive('getPaginatedOrdersOf')
->with($customer, $pagination, true)
->once()
->andReturn($paginator);
$service = new OrderService($orderDirectory);
// WHEN
$result = $service->paginateOrdersFor($customer, $pagination);
// THEN
expect($result)->toBe($paginator);
});
it('returns true if order is owned by customer', function () {
// GIVEN
$orderDirectory = \Mockery::mock(OrderDirectory::class);
$customer = new Customer();
$customer->id = (string) Uuid::uuid7();
$order = new Order();
$order->id = (string) Uuid::uuid7();
$orderDirectory->shouldReceive('findOf')
->with($customer, $order->id)
->once()
->andReturn($order);
$service = new OrderService($orderDirectory);
// WHEN
$result = $service->isOrderOwnedBy($order, $customer);
// THEN
expect($result)->toBeTrue();
});
it('returns false if order is not owned by customer', function () {
// GIVEN
$orderDirectory = \Mockery::mock(OrderDirectory::class);
$customer = new Customer();
$customer->id = (string) Uuid::uuid7();
$order = new Order();
$order->id = (string) Uuid::uuid7();
$orderDirectory->shouldReceive('findOf')
->with($customer, $order->id)
->once()
->andReturn(null);
$service = new OrderService($orderDirectory);
// WHEN
$result = $service->isOrderOwnedBy($order, $customer);
// THEN
expect($result)->toBeFalse();
});
});