Completed
Push — master ( 83571a...9e9b74 )
by Nic
30s
created

LocatorTest::testLocatorCategoriesByLocator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
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
        $locator = singleton('Locator');
15
        $this->assertInstanceOf('FieldList', $locator->getCMSFields());
1 ignored issue
show
Bug introduced by
The method assertInstanceOf() 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...
16
    }
17
18
    /**
19
     *
20
     */
21
    public function testLocations()
22
    {
23
        $filter = Config::inst()->get('Locator_Controller', 'base_filter');
24
        $filterAny = Config::inst()->get('Locator_Controller', 'base_filter_any');
25
        $exclude = Config::inst()->get('Locator_Controller', 'base_exclude');
26
        $locations = Locator::get_locations($filter, $filterAny, $exclude);
27
        $locations2 = Location::get()->filter($filter)->filterAny($filterAny)->exclude($exclude);
28
        $this->assertEquals($locations->count(), $locations2->count());
0 ignored issues
show
Bug introduced by
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...
29
    }
30
31
    /**
32
     *
33
     */
34
    public function testGetAllCategories()
35
    {
36
37
        $this->assertEquals(Locator::get_all_categories()->count(), 4);
0 ignored issues
show
Bug introduced by
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...
38
    }
39
40
    /**
41
     *
42
     */
43
    public function testGetPageCategories()
44
    {
45
        $locator = $this->objFromFixture('Locator', 'locator1');
46
        $this->assertEquals($locator->getPageCategories()->count(), 2);
0 ignored issues
show
Bug introduced by
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...
47
    }
48
49
    /**
50
     *
51
     */
52
    public function testLocatorCategoriesByLocator()
53
    {
54
55
        $locator = $this->objFromFixture('Locator', 'locator1');
56
        $this->assertEquals(Locator::locator_categories_by_locator($locator->ID)->count(), 2);
0 ignored issues
show
Bug introduced by
The method count cannot be called on \Locator::locator_catego...y_locator($locator->ID) (of type boolean).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
Bug introduced by
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...
57
58
        $newLocator = Locator::create();
59
        $newLocator->Title = 'Locator 2';
60
        $newLocator->write();
61
62
        $this->assertEquals(Locator::locator_categories_by_locator($newLocator->ID)->count(), 0);
0 ignored issues
show
Bug introduced by
The method count cannot be called on \Locator::locator_catego...ocator($newLocator->ID) (of type boolean).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
Bug introduced by
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...
63
64
    }
65
66
    /**
67
     *
68
     */
69
    public function testInit()
70
    {
71
    }
72
73
    /**
74
     *
75
     */
76
    public function testIndex()
77
    {
78
        $locator = $this->objFromFixture('Locator', 'locator1');
79
        $controller = Locator_Controller::create($locator);
80
        $this->assertInstanceOf('ViewableData', $controller->index($controller->request));
1 ignored issue
show
Bug introduced by
The method assertInstanceOf() 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...
81
    }
82
83
    /**
84
     *
85
     */
86
    public function testXml()
87
    {
88
        $locator = $this->objFromFixture('Locator', 'locator1');
89
        $controller = Locator_Controller::create($locator);
90
        $this->assertInstanceOf('HTMLText', $controller->xml($controller->request));
1 ignored issue
show
Bug introduced by
The method assertInstanceOf() 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...
91
    }
92
93
    /**
94
     *
95
     */
96
    public function testLocationSearch()
97
    {
98
        $locator = $this->objFromFixture('Locator', 'locator1');
99
        $object = Locator_Controller::create($locator);
100
        $form = $object->LocationSearch();
101
        $this->assertTrue(is_a($form, 'Form'));
0 ignored issues
show
Bug introduced by
The method assertTrue() 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...
102
103
        $category = $this->objFromFixture('LocationCategory', 'service');
104
        $category2 = $this->objFromFixture('LocationCategory', 'manufacturing');
105
        $locator->Categories()->add($category);
106
        $locator->Categories()->add($category2);
107
108
        $form = $object->LocationSearch();
109
        $fields = $form->Fields();
110
        $this->assertNotNull($fields->fieldByName('CategoryID'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() 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...
111
    }
112
113
}
114