Completed
Branch AUTOMATED_TESTING (6eabf7)
by Gordon
14:03
created

MapExtensionTest   A

Complexity

Total Complexity 25

Size/Duplication

Total Lines 203
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 25
lcom 1
cbo 2
dl 0
loc 203
rs 10

25 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A setUpOnce() 0 5 1
A testupdateCMSFields() 0 3 1
A testGetMappableLatitude() 0 9 1
A testGetMappableLongitude() 0 8 1
A testgetMappableMapContent() 0 3 1
A testonBeforeWriteMapPinNotEdited() 0 7 1
B testonBeforeWriteMapPinEdited() 0 28 1
A testgetMappableMapPin() 0 3 1
A testHasGeoWest() 0 5 1
A testHasGeoEast() 0 5 1
A testHasGeoNorth() 0 5 1
A testHasGeoNorthWest() 0 6 1
A testHasGeoNortEast() 0 6 1
A testHasGeoSouth() 0 5 1
A testHasGeoSouthWest() 0 6 1
A testHasGeoSouthEast() 0 6 1
A testHasGeoOrigin() 0 6 1
A testHasGeoOriginMapLayerExtension() 0 9 1
A testHasGeoOriginPointsOfInterestLayers() 0 7 1
A testBasicMap() 0 3 1
A testgetMapField() 0 8 1
A testUseCompressedAssets() 0 3 1
A getInstance() 0 4 1
A showMapPinEdited() 0 6 1
1
<?php
2
3
class MapExtensionTest extends SapphireTest {
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
	protected static $fixture_file = 'mappable/tests/mapextensions.yml';
5
6
	public function setUp() {
7
		//Member::add_extension('MapExtension');
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
8
9
		parent::setUp();
10
	}
11
12
13
	public function setUpOnce() {
14
		Member::add_extension('MapExtension');
15
16
		parent::setupOnce();
17
	}
18
19
20
	public function testupdateCMSFields() {
21
22
	}
23
24
25
	public function testGetMappableLatitude() {
26
		$instance = $this->getInstance();
27
		$instance->Lat = 42.1;
28
		$instance->write();
29
		$this->assertEquals(
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MapExtensionTest>.

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...
30
			42.1,
31
			$instance->getMappableLatitude()
32
		);
33
	}
34
35
36
	public function testGetMappableLongitude() {
37
		$instance = $this->getInstance();
38
		$instance->Lon = 42.1;
39
		$this->assertEquals(
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<MapExtensionTest>.

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...
40
			42.1,
41
			$instance->getMappableLongitude()
42
		);
43
	}
44
45
46
	public function testgetMappableMapContent() {
47
48
	}
49
50
51
	public function testonBeforeWriteMapPinNotEdited() {
52
		$instance = $this->getInstance();
53
		$this->Lat = 0;
1 ignored issue
show
Bug introduced by
The property Lat does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
54
		$this->Lon = 0;
1 ignored issue
show
Bug introduced by
The property Lon does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
55
		$instance->write();
56
		$this->assertFalse($instance->MapPinEdited);
1 ignored issue
show
Bug introduced by
The method assertFalse() does not seem to exist on object<MapExtensionTest>.

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...
57
	}
58
59
	public function testonBeforeWriteMapPinEdited() {
60
		$instance = $this->getInstance();
61
62
		// north
63
		$this->showMapPinEdited($instance, 10, 0);
64
65
		// north west
66
		$this->showMapPinEdited($instance, 10, -10);
67
68
		// west
69
		$this->showMapPinEdited($instance, 0, -10);
70
71
		// south west
72
		$this->showMapPinEdited($instance, -10, -10);
73
74
		// south
75
		$this->showMapPinEdited($instance, -10, 0);
76
77
		// south east
78
		$this->showMapPinEdited($instance, -10, 10);
79
80
		// east
81
		$this->showMapPinEdited($instance, 0, 10);
82
83
		// north east
84
		$this->showMapPinEdited($instance, 10, 10);
85
86
	}
87
88
89
	public function testgetMappableMapPin() {
90
91
	}
92
93
94
	public function testHasGeoWest() {
95
		$instance = $this->getInstance();
96
		$instance->Lon = -20;
97
		$this->assertTrue($instance->HasGeo());
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<MapExtensionTest>.

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...
98
	}
99
100
	public function testHasGeoEast() {
101
		$instance = $this->getInstance();
102
		$instance->Lon = 20;
103
		$this->assertTrue($instance->HasGeo());
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<MapExtensionTest>.

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...
104
	}
105
106
	public function testHasGeoNorth() {
107
		$instance = $this->getInstance();
108
		$instance->Lat = 20;
109
		$this->assertTrue($instance->HasGeo());
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<MapExtensionTest>.

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...
110
	}
111
112
	public function testHasGeoNorthWest() {
113
		$instance = $this->getInstance();
114
		$instance->Lat = 20;
115
		$instance->Lon = -20;
116
		$this->assertTrue($instance->HasGeo());
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<MapExtensionTest>.

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...
117
	}
118
119
	public function testHasGeoNortEast() {
120
		$instance = $this->getInstance();
121
		$instance->Lat = 20;
122
		$instance->Lon = 20;
123
		$this->assertTrue($instance->HasGeo());
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<MapExtensionTest>.

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...
124
	}
125
126
	public function testHasGeoSouth() {
127
		$instance = $this->getInstance();
128
		$instance->Lat = -20;
129
		$this->assertTrue($instance->HasGeo());
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<MapExtensionTest>.

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...
130
	}
131
132
	public function testHasGeoSouthWest() {
133
		$instance = $this->getInstance();
134
		$instance->Lat = -20;
135
		$instance->Lon = -20;
136
		$this->assertTrue($instance->HasGeo());
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<MapExtensionTest>.

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...
137
	}
138
139
	public function testHasGeoSouthEast() {
140
		$instance = $this->getInstance();
141
		$instance->Lat = -20;
142
		$instance->Lon = 20;
143
		$this->assertTrue($instance->HasGeo());
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<MapExtensionTest>.

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...
144
	}
145
146
	public function testHasGeoOrigin() {
147
		$instance = $this->getInstance();
148
		$instance->Lat = 0;
149
		$instance->Lon = 0;
150
		$this->assertFalse($instance->HasGeo());
1 ignored issue
show
Bug introduced by
The method assertFalse() does not seem to exist on object<MapExtensionTest>.

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...
151
	}
152
153
	public function testHasGeoOriginMapLayerExtension() {
154
		$instance = $this->getInstance();
155
		$instance->Lat = 0;
156
		$instance->Lon = 0;
157
		$this->assertFalse($instance->HasGeo());
1 ignored issue
show
Bug introduced by
The method assertFalse() does not seem to exist on object<MapExtensionTest>.

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...
158
		Page::add_extension('MapLayerExtension');
159
		Page::remove_extension('MapLayerExtension');
160
		$this->markTestSkipped('TODO');
0 ignored issues
show
Bug introduced by
The method markTestSkipped() does not seem to exist on object<MapExtensionTest>.

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...
161
	}
162
163
	public function testHasGeoOriginPointsOfInterestLayers() {
164
		$instance = $this->getInstance();
165
		$instance->Lat = 0;
166
		$instance->Lon = 0;
167
		$this->assertFalse($instance->HasGeo());
1 ignored issue
show
Bug introduced by
The method assertFalse() does not seem to exist on object<MapExtensionTest>.

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...
168
		$this->markTestSkipped('TODO');
0 ignored issues
show
Bug introduced by
The method markTestSkipped() does not seem to exist on object<MapExtensionTest>.

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...
169
	}
170
171
	public function testBasicMap() {
172
173
	}
174
175
176
	public function testgetMapField() {
177
		$instance = $this->getInstance();
178
		$this->Lat = 37.1;
179
		$this->Lon = 28;
180
		$this->Zoom = 12;
1 ignored issue
show
Bug introduced by
The property Zoom does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
181
		$mapField  = $instance->getMapField();
182
		$this->assertInstanceOf('LatLongField', $mapField);
1 ignored issue
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<MapExtensionTest>.

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...
183
	}
184
185
186
	public function testUseCompressedAssets() {
187
188
	}
189
190
191
	private function getInstance() {
192
		$instance = new Member();
193
		return $instance;
194
	}
195
196
	private function showMapPinEdited(&$instance, $lat, $lon) {
197
		$instance->Lat = $lat;
198
		$instance->Long = $lon;
199
		$instance->write();
200
		$this->assertTrue($instance->MapPinEdited);
1 ignored issue
show
Bug introduced by
The method assertTrue() does not seem to exist on object<MapExtensionTest>.

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...
201
	}
202
203
204
205
}
206