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

ItemListTest::testDifferentItemsSameDimensions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 17
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
/**
3
 * Box packing (3D bin packing, knapsack problem)
4
 * @package BoxPacker
5
 * @author Doug Wright
6
 */
7
namespace DVDoug\BoxPacker;
8
9
use DVDoug\BoxPacker\Test\TestItem;
10
use PHPUnit\Framework\TestCase;
11
12
class ItemListTest extends TestCase
13
{
14
15
    function testCompare()
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...
16
    {
17
        $item1 = new TestItem('Small', 20, 20, 2, 100);
18
        $item2 = new TestItem('Large', 200, 200, 20, 1000);
19
        $item3 = new TestItem('Medium', 100, 100, 10, 500);
20
21
        $list = new ItemList;
22
        $list->insert($item1);
23
        $list->insert($item2);
24
        $list->insert($item3);
25
26
        $sorted = iterator_to_array($list,false);
27
        self::assertEquals(array($item2, $item3, $item1), $sorted);
28
    }
29
30
    function testDifferentItemsSameDimensions()
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...
31
    {
32
33
        $item1 = new TestItem('Item A', 20, 20, 2, 100);
34
        $item2 = new TestItem('Item B', 20, 20, 2, 100);
35
        $item3 = new TestItem('Item A', 20, 20, 2, 100);
36
        $item4 = new TestItem('Item B', 20, 20, 2, 100);
37
38
        $list = new ItemList;
39
        $list->insert($item1);
40
        $list->insert($item2);
41
        $list->insert($item3);
42
        $list->insert($item4);
43
44
        $sorted = iterator_to_array($list,false);
45
        self::assertEquals(array($item1, $item3, $item2, $item4), $sorted);
46
    }
47
}
48