MapTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testEmptyMapPoints() 0 6 1
A testGetDataWithOneEmptyPoint() 0 12 1
B testGetDataWithSomePoints() 0 44 1
1
<?php
2
3
namespace CarlosIO\Geckoboard\Tests\Widgets;
4
5
use CarlosIO\Geckoboard\Data\Point;
6
use CarlosIO\Geckoboard\Widgets\Map;
7
8
class MapTest extends \PHPUnit_Framework_TestCase
9
{
10
    public function testEmptyMapPoints()
11
    {
12
        $myMap = new Map();
13
14
        $this->assertSame(array(), $myMap->getPoints());
15
    }
16
17
    public function testGetDataWithOneEmptyPoint()
18
    {
19
        $myMap = new Map();
20
21
        $point1 = new Point();
22
23
        $myMap->addPoint($point1);
24
25
        $expectedResult = array('points' => array('point' => array(array())));
26
27
        $this->assertSame($expectedResult, $myMap->getData());
28
    }
29
30
    public function testGetDataWithSomePoints()
31
    {
32
        $myMap = new Map();
33
34
        $point1 = new Point();
35
        $point1->setCityName('city 1');
36
        $point1->setColor('color 1');
37
        $point1->setCountryCode('ES');
38
        $point1->setSize(1);
39
40
        $point2 = new Point();
41
        $point2->setCityName('city 2');
42
        $point2->setColor('color 2');
43
        $point2->setCountryCode('ES');
44
        $point2->setSize(2);
45
46
        $myMap->addPoint($point1);
47
        $myMap->addPoint($point2);
48
49
        $expectedResult = array(
50
            'points' => array(
51
                'point' => array(
52
                    array(
53
                        'city' => array(
54
                            'city_name' => $point1->getCityName(),
55
                            'country_code' => $point1->getCountryCode(),
56
                        ),
57
                        'size' => $point1->getSize(),
58
                        'color' => $point1->getColor(),
59
                    ),
60
                    array(
61
                        'city' => array(
62
                            'city_name' => $point2->getCityName(),
63
                            'country_code' => $point2->getCountryCode(),
64
                        ),
65
                        'size' => $point2->getSize(),
66
                        'color' => $point2->getColor(),
67
                    ),
68
                ),
69
            ),
70
        );
71
72
        $this->assertSame($expectedResult, $myMap->getData());
73
    }
74
}
75