Completed
Push — 2.x-dev ( 55a3c1...c10cce )
by Doug
33:44
created

BoxListTest::testCompare()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 12

Duplication

Lines 18
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
dl 18
loc 18
rs 9.4285
c 2
b 0
f 1
cc 2
eloc 12
nc 2
nop 0
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 PHPUnit\Framework\TestCase;
12
13
class BoxListTest extends TestCase
14
{
15
16 View Code Duplication
    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...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
    {
18
19
        $box1 = new TestBox('Small', 21, 21, 3, 1, 20, 20, 2, 100);
20
        $box2 = new TestBox('Large', 201, 201, 21, 1, 200, 200, 20, 1000);
21
        $box3 = new TestBox('Medium', 101, 101, 11, 5, 100, 100, 10, 500);
22
23
        $list = new BoxList;
24
        $list->insert($box1);
25
        $list->insert($box2);
26
        $list->insert($box3);
27
28
        $sorted = [];
29
        while (!$list->isEmpty()) {
30
            $sorted[] = $list->extract();
31
        }
32
        self::assertEquals(array($box1, $box3, $box2), $sorted);
33
    }
34
35 View Code Duplication
    function testIssue14A()
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...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        $box1 = new TestBox('Small', 21, 21, 3, 1, 20, 20, 2, 100);
38
        $box2 = new TestBox('Large', 1301, 1301, 1301, 1, 1300, 1300, 1300, 1000);
39
        $box3 = new TestBox('Medium', 101, 101, 11, 5, 100, 100, 10, 500);
40
        $list = new BoxList;
41
        $list->insert($box1);
42
        $list->insert($box2);
43
        $list->insert($box3);
44
        $sorted = [];
45
        while (!$list->isEmpty()) {
46
            $sorted[] = $list->extract();
47
        }
48
        self::assertEquals(array($box1, $box3, $box2), $sorted);
49
    }
50
51
    function testIssue14B()
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...
52
    {
53
        $box1 = new TestBox('Small', 21, 21, 3, 1, 20, 20, 2, 100);
54
        $box2 = new TestBox('Large', 1301, 1301, 1301, 1, 1300, 1300, 1300, 1000);
55
        $box3 = new TestBox('Medium', 101, 101, 11, 5, 100, 100, 10, 500);
56
        $list = new BoxList;
57
        $list->insert($box3);
58
        $list->insert($box2);
59
        $list->insert($box1);
60
        $sorted = [];
61
        while (!$list->isEmpty()) {
62
            $sorted[] = $list->extract();
63
        }
64
        self::assertEquals(array($box1, $box3, $box2), $sorted);
65
        $list = new BoxList;
66
        $list->insert($box2);
67
        $list->insert($box1);
68
        $list->insert($box3);
69
        $sorted = [];
70
        while (!$list->isEmpty()) {
71
            $sorted[] = $list->extract();
72
        }
73
        self::assertEquals(array($box1, $box3, $box2), $sorted);
74
    }
75
}
76