| 1 | <?php |
||
| 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 |