diff --git a/Packer.php b/Packer.php index 7a353874..b4a2a5fc 100644 --- a/Packer.php +++ b/Packer.php @@ -250,7 +250,7 @@ public function packIntoBox(Box $aBox, ItemList $aItems) { $itemToPack = $aItems->top(); - if ($itemToPack->getDepth() > ($layerDepth ?: $remainingDepth) || $itemToPack->getWeight() > $remainingWeight) { + if ($itemToPack->getDepth() > $remainingDepth || $itemToPack->getWeight() > $remainingWeight) { break; } diff --git a/tests/PackerTest.php b/tests/PackerTest.php index ac6b7a99..d4c97c22 100644 --- a/tests/PackerTest.php +++ b/tests/PackerTest.php @@ -350,6 +350,18 @@ public function testIssue9() { self::assertEquals(1, $packedBoxes->count()); } + public function testIssue13() { + $packer = new Packer(); + $packer->addBox(new TestBox('Le petite box', 12, 12, 12, 10, 10, 10, 10, 1000)); + + $packer->addItem(new TestItem('Item 1', 5, 3, 2, 2)); + $packer->addItem(new TestItem('Item 2', 5, 3, 2, 2)); + $packer->addItem(new TestItem('Item 3', 3, 3, 3, 3)); + $packedBoxes = $packer->pack(); + + self::assertEquals(1, $packedBoxes->count()); + } + /** * @dataProvider getSamples