MappableDataObjectSetTest::getInstance()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 8
Ratio 80 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 8
loc 10
ccs 7
cts 7
cp 1
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
class MappableDataObjectSetTest extends SapphireTest
4
{
5
    public function setUpOnce()
6
    {
7
        $this->requiredExtensions = array(
8
            'Member' => array('MapExtension'),
9
        );
10
11
        parent::setupOnce();
12
    }
13
14 1
    public function setUp()
15
    {
16 1
        MapUtil::reset();
17 1
        parent::setUp();
18 1
    }
19
20 1
    public function testSetMarkerTemplateValues()
21
    {
22 1
        $instance1 = $this->getInstance();
23 1
        $instance1->MapPinEdited = true;
24 1
        $instance1->write();
25
26 1
        $instance2 = $this->getInstance();
27 1
        $instance2->Lat = 7.12;
28 1
        $instance2->Lon = 23.4;
29 1
        $instance2->MapPinEdited = true;
30 1
        $instance2->write();
31
32
        // Mappable list has MappableDataObjectSet enabled by default
33
        // Items in the list are Mappable via the MapExtension
34 1
        $mappableList = new ArrayList();
35 1
        $mappableList->push($instance1);
36 1
        $mappableList->push($instance2);
37
38 1
        $vals = array('TestKey' => ' TestKeyValMDOS');
39 1
        $mappableList->setMarkerTemplateValues($vals);
40
41 1
        $html = $mappableList->getRenderableMap(300, 800, 2)->setDivId('testmap')->forTemplate()->getValue();
42
        $expected = <<<HTML
43
44
45
<div id="testmap" data-google-map-lang="en"  style="width:300; height: 800;"
46
 class=" mappable"
47
data-map
48
data-centre='{"lat":48.856614,"lng":2.3522219}'
49
data-zoom=9
50
data-maptype='road'
51
data-allowfullscreen='1'
52
data-clusterergridsize=50,
53
data-clusterermaxzoom=17,
54
data-enableautocentrezoom=1
55
data-enablewindowzoom=false
56
data-infowindowzoom=13
57
data-mapmarkers='[{"latitude":13.8188931,"longitude":100.5005558,"html":"MEMBER: Test User TestKeyValMDOS","category":"default","icon":false},{"latitude":7.12,"longitude":23.4,"html":"MEMBER: Test User TestKeyValMDOS","category":"default","icon":false}]'
58
data-defaulthidemarker=false
59
data-lines='[]'
60
data-kmlfiles='[]'
61
data-mapstyles='[]'
62
data-useclusterer=false
63
>
64
</div>
65
66 1
HTML;
67 1
        $this->assertEquals($expected, $html);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MappableDataObjectSetTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
68 1
    }
69
70 1 View Code Duplication
    private function getInstance()
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...
71
    {
72 1
        $instance = new Member();
73 1
        $instance->Lat = 13.8188931;
74 1
        $instance->Lon = 100.5005558;
75 1
        $instance->FirstName = 'Test';
76 1
        $instance->Surname = 'User';
77
78 1
        return $instance;
79
    }
80
}
81