Completed
Branch master (0403bd)
by Doug
01:59
created

ItemListTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 20
wmc 2
lcom 0
cbo 3
rs 10
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
  class ItemListTest extends \PHPUnit_Framework_TestCase {
11
12
    function testCompare() {
13
14
      $box1 = new TestItem('Small', 20, 20, 2, 100);
15
      $box2 = new TestItem('Large', 200, 200, 20, 1000);
16
      $box3 = new TestItem('Medium', 100, 100, 10, 500);
17
18
      $list = new ItemList;
19
      $list->insert($box1);
20
      $list->insert($box2);
21
      $list->insert($box3);
22
23
      $sorted = [];
24
      while (!$list->isEmpty()) {
25
        $sorted[] = $list->extract();
26
      }
27
      self::assertEquals(array($box2,$box3,$box1), $sorted);
28
    }
29
  }
30