Completed
Branch AUTOMATED_TESTING (4870f5)
by Gordon
03:01
created

PointOfInterestTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5
Metric Value
wmc 4
lcom 0
cbo 5
dl 0
loc 58
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testUpdateCMSFields() 0 12 2
B testShowGuideMarkers() 0 38 2
1
<?php
2
3
class PointOfInterestTest 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
	
5
	protected static $fixture_file = 'mappable-poi/tests/pointsofinterest.yml';
6
7
	public function testUpdateCMSFields() {
8
		$poi = new PointOfInterest();
9
		$fields = $poi->getCMSFields();
10
		$tab = $fields->findOrMakeTab('Root.Main');
11
		$fields = $tab->FieldList();
12
		$names = array();
13
		foreach ($fields as $field) {
14
			$names[] = $field->getName();
15
		}
16
		 
17
		$this->assertEquals(array('Name'), $names);
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<PointOfInterestTest>.

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...
18
	}
19
20
	
21
	public function testShowGuideMarkers() {
22
		$layer = $this->objFromFixture('PointsOfInterestLayer', 'BTS');
23
		error_log('LAYER: '.$layer->Name);
24
		$pois = $layer->PointsOfInterest();
25
		$poi = $pois->first(); 
26
		
27
		// guidemarkers off, expect null returned
28
		$layer->ShowGuideMarkers = 0;
29
		$layer->write();
30
		$fields = $poi->getCMSFields();
0 ignored issues
show
Unused Code introduced by
$fields is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
31
		$guidepoints = $poi->getMapField()->getGuidePoints();
32
		$this->assertNull($guidepoints);
1 ignored issue
show
Bug introduced by
The method assertNull() does not seem to exist on object<PointOfInterestTest>.

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...
33
		
34
		// guidemarkers on, convert datalist to an array of coordinates
35
		$layer->ShowGuideMarkers = 1;
36
		$layer->write();
37
		$fields = $poi->getCMSFields();
0 ignored issues
show
Unused Code introduced by
$fields is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
38
		$guidepoints = $poi->getMapField()->getGuidePoints();
39
		$expected = array();
1 ignored issue
show
Unused Code introduced by
$expected is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
40
		$coors = array();
41
		foreach ($guidepoints as $gp) {
42
			$coors[] = array($gp->Lat, $gp->Lon);
43
		}
44
45
		$expected = array(
46
			array(13.77965803301,100.54461523531),
47
			array(13.744081610619, 100.54311513861),
48
			array(13.802594511242, 100.55379467004),
49
			array(13.74054138487, 100.55545772112),
50
			array(13.756924089277, 100.53381164654),
51
			array(13.751846080459, 100.53157277536),
52
			array(13.772614550915, 100.54209276599),
53
			array(13.793846082833, 100.54974883766),
54
			array(13.762764662241, 100.53706848861)
55
		);
56
		$this->assertEquals($expected, $coors);
1 ignored issue
show
Bug introduced by
The method assertEquals() does not seem to exist on object<PointOfInterestTest>.

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
60
}
61