1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class LocationTest extends Locator_Test |
4
|
|
|
{ |
5
|
|
|
public function testGetCoords() |
6
|
|
|
{ |
7
|
|
|
$location = $this->objFromFixture('Location', 'dynamic'); |
8
|
|
|
$location->write(); |
9
|
|
|
|
10
|
|
|
$coords = ($location->Lat && $location->Lng) ? 'true' : 'false'; |
11
|
|
|
$geoCodable = Location::get()->byID($location->ID); |
12
|
|
|
|
13
|
|
|
$this->assertEquals($coords, $geoCodable->getCoords()); |
|
|
|
|
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
public function testFieldLabels() |
17
|
|
|
{ |
18
|
|
|
$location = $this->objFromFixture('Location', 'dynamic'); |
19
|
|
|
$labels = $location->FieldLabels(); |
20
|
|
|
$expected = array( |
21
|
|
|
'Title' => 'Name', |
22
|
|
|
'Featured' => 'Featured', |
23
|
|
|
'Website' => 'Website', |
24
|
|
|
'Phone' => 'Phone', |
25
|
|
|
'Email' => 'Email', |
26
|
|
|
'EmailAddress' => 'Email Address', |
27
|
|
|
'ShowInLocator' => 'Show', |
28
|
|
|
'Address' => 'Address', |
29
|
|
|
'Suburb' => 'City', |
30
|
|
|
'State' => 'State', |
31
|
|
|
'Postcode' => 'Postal Code', |
32
|
|
|
'Country' => 'Country', |
33
|
|
|
'Lat' => 'Lat', |
34
|
|
|
'Lng' => 'Lng', |
35
|
|
|
'Category' => 'Category', |
36
|
|
|
'ShowInLocator.NiceAsBoolean' => 'Show', |
37
|
|
|
'Category.Name' => 'Category', |
38
|
|
|
'Category.ID' => 'Category', |
39
|
|
|
'Featured.NiceAsBoolean' => 'Featured', |
40
|
|
|
'Coords' => 'Coords', |
41
|
|
|
); |
42
|
|
|
$this->assertEquals($expected, $labels); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testGetCMSFields() |
46
|
|
|
{ |
47
|
|
|
$object = new Location(); |
48
|
|
|
$fieldset = $object->getCMSFields(); |
49
|
|
|
$this->assertTrue(is_a($fieldset, 'FieldList')); |
|
|
|
|
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testValidate() |
53
|
|
|
{ |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function testEmailAddress() |
57
|
|
|
{ |
58
|
|
|
} |
59
|
|
|
|
60
|
|
View Code Duplication |
public function testCanView() |
|
|
|
|
61
|
|
|
{ |
62
|
|
|
$object = $this->objFromFixture('Location', 'dynamic'); |
63
|
|
|
$object->write(); |
64
|
|
|
$this->logInWithPermission('ADMIN'); |
65
|
|
|
$this->assertTrue($object->canView()); |
|
|
|
|
66
|
|
|
$this->logOut(); |
67
|
|
|
$nullMember = Member::create(); |
68
|
|
|
$nullMember->write(); |
69
|
|
|
$this->assertTrue($object->canView($nullMember)); |
|
|
|
|
70
|
|
|
$nullMember->delete(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function testCanEdit() |
74
|
|
|
{ |
75
|
|
|
$object = $this->objFromFixture('Location', 'dynamic'); |
76
|
|
|
$object->write(); |
77
|
|
|
$objectID = $object->ID; |
78
|
|
|
$this->logInWithPermission('Location_EDIT'); |
79
|
|
|
$originalTitle = $object->Title; |
80
|
|
|
$this->assertEquals($originalTitle, 'Dynamic, Inc.'); |
|
|
|
|
81
|
|
|
$this->assertTrue($object->canEdit()); |
|
|
|
|
82
|
|
|
$object->Title = 'Changed Title'; |
83
|
|
|
$object->write(); |
84
|
|
|
$testEdit = Location::get()->byID($objectID); |
85
|
|
|
$this->assertEquals($testEdit->Title, 'Changed Title'); |
|
|
|
|
86
|
|
|
$this->logOut(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function testCanDelete() |
90
|
|
|
{ |
91
|
|
|
$object = $this->objFromFixture('Location', 'dynamic'); |
92
|
|
|
$object->write(); |
93
|
|
|
$this->logInWithPermission('Location_DELETE'); |
94
|
|
|
$this->assertTrue($object->canDelete()); |
|
|
|
|
95
|
|
|
$checkObject = $object; |
96
|
|
|
$object->delete(); |
97
|
|
|
$this->assertEquals($checkObject->ID, 0); |
|
|
|
|
98
|
|
|
} |
99
|
|
|
|
100
|
|
View Code Duplication |
public function testCanCreate() |
|
|
|
|
101
|
|
|
{ |
102
|
|
|
$object = singleton('Location'); |
103
|
|
|
$this->logInWithPermission('Location_CREATE'); |
104
|
|
|
$this->assertTrue($object->canCreate()); |
|
|
|
|
105
|
|
|
$this->logOut(); |
106
|
|
|
$nullMember = Member::create(); |
107
|
|
|
$nullMember->write(); |
108
|
|
|
$this->assertFalse($object->canCreate($nullMember)); |
|
|
|
|
109
|
|
|
$nullMember->delete(); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function testProvidePermissions() |
113
|
|
|
{ |
114
|
|
|
$object = Location::create(); |
115
|
|
|
$expected = array( |
116
|
|
|
'Location_EDIT' => 'Edit a Location', |
117
|
|
|
'Location_DELETE' => 'Delete a Location', |
118
|
|
|
'Location_CREATE' => 'Create a Location', |
119
|
|
|
); |
120
|
|
|
$this->assertEquals($expected, $object->providePermissions()); |
|
|
|
|
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|
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.