toBase58(); $reference = new OrderReference($orderReferenceValue); $employeeMatricule = new Matricule('1234567'); $pickupDay = CarbonImmutable::create(2025, 1, 1); $line1 = new OrderPlacedLine( productName: 'Product 1', productIncoId: new IncoId(45), productWeightIsVariable: false, productPriceKgTtc: null, productOrderUnit: UnitsOrderUnit::PCE, quantity: 2, totalTtc: Money::EUR(1000) ); $line2 = new OrderPlacedLine( productName: 'Product 2', productIncoId: new IncoId(46), productWeightIsVariable: false, productPriceKgTtc: null, productOrderUnit: UnitsOrderUnit::COLIS, quantity: 1, totalTtc: Money::EUR(2000) ); $line3 = new OrderPlacedLine( productName: 'Product 3', productIncoId: new IncoId(47), productWeightIsVariable: true, productPriceKgTtc: Money::EUR(1000), productOrderUnit: UnitsOrderUnit::KGM, quantity: 3, totalTtc: Money::EUR(3000) ); $csvGenerator->shouldReceive('generate')->once()->with( Mockery::type('array'), Mockery::on(function (array $rows) use ($orderReferenceValue): bool { return count($rows) === 3 && $rows[0][5] === 'UB' && $rows[1][5] === 'UEA' && $rows[2][5] === 'KGM' && $rows[0][0] === '45' && $rows[0][7] === '01/01/2025' && $rows[0][9] === $orderReferenceValue; }) )->andReturn('csv_content'); $dispatcher->shouldReceive('dispatch')->once()->with(Mockery::on(function (object $event) use ($orderReferenceValue): bool { return $event instanceof RegateOrderCsvGenerated && $event->csvContent === 'csv_content' && str_contains($event->fileName, sprintf('BTQ-%s-', $orderReferenceValue)); })); // WHEN $service->processOrder($reference, $employeeMatricule, $pickupDay, [$line1, $line2, $line3]); // THEN expect(true)->toBeTrue(); }); });