Completed
Push — 1.x-dev ( 423a53...2f7d84 )
by Doug
48:23 queued 46:55
created

PackedBoxTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 31
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetters() 0 15 1
A testVolumeUtilisation() 0 12 1
1
<?php
2
/**
3
 * Box packing (3D bin packing, knapsack problem)
4
 * @package BoxPacker
5
 * @author Doug Wright
6
 */
7
8
namespace DVDoug\BoxPacker;
9
10
use DVDoug\BoxPacker\Test\TestBox;
11
use DVDoug\BoxPacker\Test\TestItem;
12
use PHPUnit\Framework\TestCase;
13
14
class PackedBoxTest extends TestCase
15
{
16
    function testGetters()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
17
    {
18
        $box = new TestBox('Box', 370, 375, 60, 140, 364, 374, 40, 3000);
19
        $item = new TestItem('Item', 230, 330, 6, 320);
20
21
        $boxItems = new ItemList();
22
        $boxItems->insert($item);
23
24
        $packedBox = new PackedBox($box, $boxItems, 1, 2, 3, 4, 0, 0, 0);
25
26
        self::assertEquals(1, $packedBox->getRemainingWidth());
27
        self::assertEquals(2, $packedBox->getRemainingLength());
28
        self::assertEquals(3, $packedBox->getRemainingDepth());
29
        self::assertEquals(4, $packedBox->getRemainingWeight());
30
    }
31
32
    function testVolumeUtilisation()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
33
    {
34
        $box = new TestBox('Box', 10, 10, 10, 10, 10, 10, 10, 10);
35
        $item = new TestItem('Item', 5, 10, 10, 10);
36
37
        $boxItems = new ItemList();
38
        $boxItems->insert($item);
39
40
        $packedBox = new PackedBox($box, $boxItems, 1, 2, 3, 4, 0, 0, 0);
41
42
        self::assertEquals(50, $packedBox->getVolumeUtilisation());
43
    }
44
}
45