Skip to content

Commit

Permalink
Add testcase for #620
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Nov 17, 2024
1 parent ee5deab commit bd4d600
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/PackerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1416,4 +1416,44 @@ public function testAllPermutationsUnpackableItemsHandledWhenNotThrowing(): void
self::assertCount(0, $permutations);
self::assertCount(3, $packer->getUnpackedItems());
}

/**
* From issue #620.
*/
#[Group('efficiency')]
public function testIssue620(): void
{
$packer = new Packer();
$packer->setMaxBoxesToBalanceWeight(0);

for ($i = 0; $i < 100; ++$i) {
$box = new TestBox(
reference: 'box ' . $i,
outerWidth: $i * 10,
outerLength: $i * 10,
outerDepth: $i * 10,
emptyWeight: 1,
innerWidth: $i * 10,
innerLength: $i * 10,
innerDepth: $i * 10,
maxWeight: 10000
);
$packer->addBox($box);
}

$item = new TestItem(
description: 'item 1',
width: 100,
length: 100,
depth: 100,
weight: 100,
allowedRotation: Rotation::BestFit
);
$packer->addItem($item, 500);

/** @var PackedBox[] $packedBoxes */
$packedBoxes = iterator_to_array($packer->pack(), false);

self::assertCount(6, $packedBoxes);
}
}

0 comments on commit bd4d600

Please sign in to comment.