RectangularFromTwoPointsTest::count_provider()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Cgi\Calc\Tests\Field;
4
5
use Cgi\Calc\Field\RectangularFromTwoPoints;
6
use Cgi\Calc\Point;
7
8
class RectangularFromTwoPointsTest extends \PHPUnit_Framework_TestCase
9
{
10
    public function count_provider()
11
    {
12
        return [
13
            [new Point(1,1), new Point(1, 1), 1],
14
            [new Point(1,1), new Point(2, 2), 4],
15
            [new Point(1,1), new Point(3, 3), 9],
16
17
            [new Point(1,1), new Point(4, 3), 12],
18
        ];
19
    }
20
21
    /**
22
     * @dataProvider count_provider
23
     */
24 View Code Duplication
    public function test_count(Point $lowerLeft, Point $upperRight, $expectedCount)
0 ignored issues
show
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...
25
    {
26
        $producer = new RectangularFromTwoPoints($lowerLeft, $upperRight);
27
        $field = $producer->produce();
28
29
        $actualCount = $field->count();
30
        static::assertEquals($expectedCount, $actualCount);
31
    }
32
33
    public function point_belongs_to_rectangular_provider()
34
    {
35
        return [
36
            [new Point(1,1), new Point(4, 3), new Point(1,1), true],
37
            [new Point(1,1), new Point(4, 3), new Point(2,2), true],
38
            [new Point(1,1), new Point(4, 3), new Point(3,3), true],
39
            [new Point(1,1), new Point(4, 3), new Point(4,3), true],
40
41
            [new Point(1,1), new Point(4, 3), new Point(0,0), false],
42
            [new Point(1,1), new Point(4, 3), new Point(0,4), false],
43
            [new Point(1,1), new Point(4, 3), new Point(4,4), false],
44
            [new Point(1,1), new Point(4, 3), new Point(4,0), false],
45
        ];
46
    }
47
48
    /**
49
     * @dataProvider point_belongs_to_rectangular_provider
50
     */
51 View Code Duplication
    public function test_point_belongs_to_rectangular(Point $lowerLeft, Point $upperRight, Point $testPoint, $expectedIn)
0 ignored issues
show
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...
52
    {
53
        $producer = new RectangularFromTwoPoints($lowerLeft, $upperRight);
54
        $field = $producer->produce();
55
56
        $actualIn = $field->contains($testPoint);
57
        static::assertEquals($expectedIn, $actualIn);
58
    }
59
}
60