26 lines
1.1 KiB
PHP
26 lines
1.1 KiB
PHP
<?php
|
|
|
|
use App\Modules\Machines\Domain\Enums\MachineType;
|
|
use App\Modules\Machines\Domain\Services\QueueOrder;
|
|
|
|
it('puts a task after quick sale orders, by priority and then due date', function () {
|
|
$rows = [
|
|
['isOrder' => true, 'rank' => 0, 'dueOn' => null],
|
|
['isOrder' => false, 'rank' => 3, 'dueOn' => '2026-12-01'],
|
|
['isOrder' => false, 'rank' => 1, 'dueOn' => '2026-11-30'],
|
|
['isOrder' => false, 'rank' => 1, 'dueOn' => null],
|
|
];
|
|
|
|
expect(QueueOrder::insertionIndex($rows, 4, null))->toBe(1)
|
|
->and(QueueOrder::insertionIndex($rows, 1, '2026-11-28'))->toBe(2)
|
|
->and(QueueOrder::insertionIndex($rows, 1, '2026-12-05'))->toBe(3)
|
|
->and(QueueOrder::insertionIndex($rows, 1, null))->toBe(4)
|
|
->and(QueueOrder::insertionIndex([], 1, null))->toBe(0);
|
|
});
|
|
|
|
it('suggests the usual counters by machine type', function () {
|
|
expect(array_column(MachineType::Printer->suggestedCounters(), 'name'))->toBe(['prints', 'printed_area'])
|
|
->and(array_column(MachineType::Cutter->suggestedCounters(), 'name'))->toBe(['cut_length'])
|
|
->and(MachineType::Other->suggestedCounters())->toBe([]);
|
|
});
|