Completed
Push — master ( 7a07c8...997185 )
by Nic
29s
created

tests/LocatorTest.php (1 issue)

calls to non-existent methods.

Bug Major

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * Class LocatorTest
5
 */
6
class LocatorTest extends Locator_Test
7
{
8
9
    /**
10
     *
11
     */
12
    public function testGetCMSFields()
13
    {
14
        $object = new Locator();
15
        $fieldset = $object->getCMSFields();
16
        $this->assertTrue(is_a($fieldset, 'FieldList'));
17
    }
18
19
    /**
20
     *
21
     */
22 View Code Duplication
    public function testLocations()
23
    {
24
        $filter = array('ShowInLocator' => 1);
25
        $filterAny = array('Suburb' => 'Sheboygan');
26
        $exclude = array('Suburb' => 'Milwaukee');
27
        $locations = Locator::locations($filter, $filterAny, $exclude);
28
        $locations2 = Location::get()->filter($filter)->filterAny($filterAny)->exclude($exclude);
29
        $this->assertEquals($locations->Count(), $locations2->Count());
0 ignored issues
show
The method assertEquals() does not seem to exist on object<LocatorTest>.

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
    }
31
32
    /**
33
     *
34
     */
35
    public function testGetAllCategories()
36
    {
37
        $locator = singleton('Locator');
38
        $count = LocationCategory::get();
39
        $this->assertEquals($locator->getAllCategories(), $count);
40
    }
41
42
    /**
43
     *
44
     */
45
    public function testGetPageCategories()
46
    {
47
        $locator = Locator::create();
48
        $this->assertFalse($locator->getPageCategories());
49
50
        $this->assertFalse($locator->getPageCategories(500));
51
52
        $locator->write();
53
        $category = $this->objFromFixture('LocationCategory', 'service');
54
        $locator->Categories()->add($category);
55
        $this->assertEquals($locator->getPageCategories($locator->ID), $locator->Categories());
56
    }
57
58
    /**
59
     *
60
     */
61
    public function testInit()
62
    {
63
    }
64
65
    /**
66
     *
67
     */
68
    public function testIndex()
69
    {
70
        $locator = $this->objFromFixture('Locator', 'locator1');
71
        $controller = Locator_Controller::create($locator);
72
        $this->assertInstanceOf('ViewableData', $controller->index($controller->request));
73
    }
74
75
    /**
76
     *
77
     */
78
    public function testXml()
79
    {
80
        $locator = $this->objFromFixture('Locator', 'locator1');
81
        $controller = Locator_Controller::create($locator);
82
        $this->assertInstanceOf('HTMLText', $controller->xml($controller->request));
83
    }
84
85
    /**
86
     *
87
     */
88 View Code Duplication
    public function testItems()
89
    {
90
        $locator = $this->objFromFixture('Locator', 'locator1');
91
        $controller = Locator_Controller::create($locator);
92
93
        $filter = array('ShowInLocator' => 1);
94
        $exclude = ['Lat' => 0.00000, 'Lng' => 0.00000];
95
96
        $locations = $controller->Items($controller->request);
97
        $locations2 = Location::get()->filter($filter)->exclude($exclude);
98
        $this->assertEquals($locations->count(), $locations2->count());
99
    }
100
101
    /**
102
     *
103
     */
104
    public function testLocationSearch()
105
    {
106
        $locator = $this->objFromFixture('Locator', 'locator1');
107
        $object = Locator_Controller::create($locator);
108
        $form = $object->LocationSearch();
109
        $this->assertTrue(is_a($form, 'Form'));
110
111
        $category = $this->objFromFixture('LocationCategory', 'service');
112
        $category2 = $this->objFromFixture('LocationCategory', 'manufacturing');
113
        $locator->Categories()->add($category);
114
        $locator->Categories()->add($category2);
115
116
        $form = $object->LocationSearch();
117
        $fields = $form->Fields();
118
        $this->assertNotNull($fields->fieldByName('CategoryID'));
119
    }
120
121
}
122