shouldReceive('check')->twice()->andReturn(true, false); $request = new ConfirmOrderRequest($authService); $request->initialize(); // WHEN $authorized = $request->authorize(); $denied = $request->authorize(); // THEN expect($authorized)->toBeTrue() ->and($denied)->toBeFalse(); }); it('requires cgv acceptance in validation rules', function (): void { // GIVEN $authService = \Mockery::mock(AppCustomerAuthService::class); $rules = new ConfirmOrderRequest($authService)->rules(); // WHEN $missing = Validator::make([], $rules); $rejected = Validator::make(['ok_cgv' => false], $rules); $accepted = Validator::make(['ok_cgv' => true], $rules); // THEN expect($missing->errors()->has('ok_cgv'))->toBeTrue() ->and($rejected->errors()->has('ok_cgv'))->toBeTrue() ->and($accepted->passes())->toBeTrue(); }); it('maps to PlacePendingOrderInput', function (): void { // GIVEN $shopperId = new ShopperId(UuidHelper::v7()); $customer = new Customer(); $customer->id = $shopperId->value->toString(); $authService = \Mockery::mock(AppCustomerAuthService::class); $authService->shouldReceive('getCustomerAsMandatory')->once()->andReturn($customer); $request = new ConfirmOrderRequest($authService); $request->initialize(); // WHEN $input = $request->toPlacePendingOrderInput(); // THEN expect($input->shopperId?->value->toString())->toBe($shopperId->value->toString()); }); });