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(); }); });