Completed
Push — master ( 5c8995...29ed75 )
by Jason
28s
created

LocatorTest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 8
c 3
b 0
f 1
lcom 0
cbo 5
dl 0
loc 68
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetCMSFields() 0 6 1
A testGetLocations() 0 6 1
A testGetAreLocations() 0 5 1
A testGetAllCategories() 0 6 1
A testGetPageCategories() 0 12 1
A testInit() 0 3 1
A testXml() 0 3 1
A testLocationSearch() 0 17 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 testGetLocations()
13
    {
14
        $locator = singleton('Locator');
15
        $count = Location::get()->filter('ShowInLocator', 1)->exclude('Lat', 0)->Count();
16
        $this->assertEquals($locator->getLocations()->Count(), $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...
17
    }
18
19
    public function testGetAreLocations()
20
    {
21
        $locator = singleton('Locator');
22
        $this->assertEquals($locator->getLocations(), $locator->getAreLocations());
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...
23
    }
24
25
    public function testGetAllCategories()
26
    {
27
        $locator = singleton('Locator');
28
        $count = LocationCategory::get();
29
        $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...
30
    }
31
32
    public function testGetPageCategories()
33
    {
34
        $locator = Locator::create();
35
        $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...
36
37
        $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...
38
39
        $locator->write();
40
        $category = $this->objFromFixture('LocationCategory', 'service');
41
        $locator->Categories()->add($category);
42
        $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...
43
    }
44
45
    public function testInit()
46
    {
47
    }
48
49
    public function testXml()
50
    {
51
    }
52
53
    public function testLocationSearch()
54
    {
55
        $locator = $this->objFromFixture('Locator', 'locator1');
56
        $object = Locator_Controller::create($locator);
57
        $form = $object->LocationSearch();
58
        $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...
59
        
60
        $category = $this->objFromFixture('LocationCategory', 'service');
61
        $category2 = $this->objFromFixture('LocationCategory', 'manufacturing');
62
        $locator->Categories()->add($category);
63
        $locator->Categories()->add($category2);
64
65
        $form = $object->LocationSearch();
66
        $fields = $form->Fields();
67
        $this->assertNotNull($fields->fieldByName('category'));
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...
68
        
69
    }
70
}
71