1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class LocatorTest extends Locator_Test |
4
|
|
|
{ |
5
|
|
|
public function testGetCMSFields() |
6
|
|
|
{ |
7
|
|
|
$object = new Locator(); |
8
|
|
|
$fieldset = $object->getCMSFields(); |
9
|
|
|
$this->assertTrue(is_a($fieldset, 'FieldList')); |
|
|
|
|
10
|
|
|
} |
11
|
|
|
|
12
|
|
View Code Duplication |
public function testLocations() |
|
|
|
|
13
|
|
|
{ |
14
|
|
|
$filter = array('ShowInLocator' => 1); |
15
|
|
|
$filterAny = array('Suburb' => 'Sheboygan'); |
16
|
|
|
$exclude = array('Suburb' => 'Milwaukee'); |
17
|
|
|
$locations = Locator::locations($filter, $filterAny, $exclude); |
18
|
|
|
$locations2 = Location::get()->filter($filter)->filterAny($filterAny)->exclude($exclude); |
19
|
|
|
$this->assertEquals($locations->Count(), $locations2->Count()); |
|
|
|
|
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function testGetAllCategories() |
23
|
|
|
{ |
24
|
|
|
$locator = singleton('Locator'); |
25
|
|
|
$count = LocationCategory::get(); |
26
|
|
|
$this->assertEquals($locator->getAllCategories(), $count); |
|
|
|
|
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function testGetPageCategories() |
30
|
|
|
{ |
31
|
|
|
$locator = Locator::create(); |
32
|
|
|
$this->assertFalse($locator->getPageCategories()); |
|
|
|
|
33
|
|
|
|
34
|
|
|
$this->assertFalse($locator->getPageCategories(500)); |
|
|
|
|
35
|
|
|
|
36
|
|
|
$locator->write(); |
37
|
|
|
$category = $this->objFromFixture('LocationCategory', 'service'); |
38
|
|
|
$locator->Categories()->add($category); |
39
|
|
|
$this->assertEquals($locator->getPageCategories($locator->ID), $locator->Categories()); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testInit() |
43
|
|
|
{ |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function testIndex() |
47
|
|
|
{ |
48
|
|
|
$locator = $this->objFromFixture('Locator', 'locator1'); |
49
|
|
|
$controller = Locator_Controller::create($locator); |
50
|
|
|
$this->assertInstanceOf('ViewableData', $controller->index($controller->request)); |
|
|
|
|
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function testXml() |
54
|
|
|
{ |
55
|
|
|
$locator = $this->objFromFixture('Locator', 'locator1'); |
56
|
|
|
$controller = Locator_Controller::create($locator); |
57
|
|
|
$this->assertInstanceOf('HTMLText', $controller->xml($controller->request)); |
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
60
|
|
View Code Duplication |
public function testItems() |
|
|
|
|
61
|
|
|
{ |
62
|
|
|
$locator = $this->objFromFixture('Locator', 'locator1'); |
63
|
|
|
$controller = Locator_Controller::create($locator); |
64
|
|
|
|
65
|
|
|
$filter = array('ShowInLocator' => 1); |
66
|
|
|
$exclude = ['Lat' => 0.00000, 'Lng' => 0.00000]; |
67
|
|
|
|
68
|
|
|
$locations = $controller->Items($controller->request); |
69
|
|
|
$locations2 = Location::get()->filter($filter)->exclude($exclude); |
70
|
|
|
$this->assertEquals($locations->count(), $locations2->count()); |
|
|
|
|
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function testLocationSearch() |
74
|
|
|
{ |
75
|
|
|
$locator = $this->objFromFixture('Locator', 'locator1'); |
76
|
|
|
$object = Locator_Controller::create($locator); |
77
|
|
|
$form = $object->LocationSearch(); |
78
|
|
|
$this->assertTrue(is_a($form, 'Form')); |
|
|
|
|
79
|
|
|
|
80
|
|
|
$category = $this->objFromFixture('LocationCategory', 'service'); |
81
|
|
|
$category2 = $this->objFromFixture('LocationCategory', 'manufacturing'); |
82
|
|
|
$locator->Categories()->add($category); |
83
|
|
|
$locator->Categories()->add($category2); |
84
|
|
|
|
85
|
|
|
$form = $object->LocationSearch(); |
86
|
|
|
$fields = $form->Fields(); |
87
|
|
|
$this->assertNotNull($fields->fieldByName('CategoryID')); |
|
|
|
|
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
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.