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

ItemListTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 36
rs 10
c 3
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCompare() 0 14 1
A testDifferentItemsSameDimensions() 0 17 1
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