Completed
Pull Request — master (#88)
by Jason
02:28
created

LocatorTest   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 9
c 5
b 0
f 1
lcom 1
cbo 5
dl 0
loc 86
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetCMSFields() 0 6 1
A testGetAllCategories() 0 6 1
A testGetPageCategories() 0 12 1
A testInit() 0 3 1
A testXml() 0 6 1
A testLocations() 0 9 1
A testIndex() 0 6 1
A testItems() 0 11 1
A testLocationSearch() 0 16 1
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'));
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...
10
    }
11
12
    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());
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...
20
    }
21
22
    public function testGetAllCategories()
23
    {
24
        $locator = singleton('Locator');
25
        $count = LocationCategory::get();
26
        $this->assertEquals($locator->getAllCategories(), $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...
27
    }
28
29
    public function testGetPageCategories()
30
    {
31
        $locator = Locator::create();
32
        $this->assertFalse($locator->getPageCategories());
0 ignored issues
show
Bug introduced by
The method assertFalse() 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...
33
34
        $this->assertFalse($locator->getPageCategories(500));
0 ignored issues
show
Bug introduced by
The method assertFalse() 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...
35
36
        $locator->write();
37
        $category = $this->objFromFixture('LocationCategory', 'service');
38
        $locator->Categories()->add($category);
39
        $this->assertEquals($locator->getPageCategories($locator->ID), $locator->Categories());
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...
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));
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...
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));
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...
58
    }
59
60
    public function testItems()
61
    {
62
        $locator = $this->objFromFixture('Locator', 'locator1');
63
        $controller = Locator_Controller::create($locator);
64
65
        $filter = array('ShowInLocator' => 1);
66
67
        $locations = $controller->Items($controller->request);
68
        $locations2 = Location::get()->filter($filter);
69
        $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...
70
    }
71
72
    public function testLocationSearch()
73
    {
74
        $locator = $this->objFromFixture('Locator', 'locator1');
75
        $object = Locator_Controller::create($locator);
76
        $form = $object->LocationSearch();
77
        $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...
78
79
        $category = $this->objFromFixture('LocationCategory', 'service');
80
        $category2 = $this->objFromFixture('LocationCategory', 'manufacturing');
81
        $locator->Categories()->add($category);
82
        $locator->Categories()->add($category2);
83
84
        $form = $object->LocationSearch();
85
        $fields = $form->Fields();
86
        $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...
87
    }
88
}
89