Passed
Pull Request — master (#223)
by Nic
02:34
created
tests/Page/LocatorControllerTest.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -17,78 +17,78 @@
 block discarded – undo
17 17
 class LocatorControllerTest extends FunctionalTest
18 18
 {
19 19
 
20
-    /**
21
-     * @var string
22
-     */
23
-    protected static $fixture_file = 'locatorcontrollerfixture.yml';
20
+	/**
21
+	 * @var string
22
+	 */
23
+	protected static $fixture_file = 'locatorcontrollerfixture.yml';
24 24
 
25
-    /**
26
-     * @var bool
27
-     */
28
-    protected static $use_draft_site = true;
25
+	/**
26
+	 * @var bool
27
+	 */
28
+	protected static $use_draft_site = true;
29 29
 
30
-    /**
31
-     *
32
-     */
33
-    public function testIndex()
34
-    {
35
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
36
-        $controller = LocatorController::create($locator);
37
-        $this->assertInstanceOf(ViewableData::class, $controller->index($controller->getRequest()));
38
-    }
30
+	/**
31
+	 *
32
+	 */
33
+	public function testIndex()
34
+	{
35
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
36
+		$controller = LocatorController::create($locator);
37
+		$this->assertInstanceOf(ViewableData::class, $controller->index($controller->getRequest()));
38
+	}
39 39
 
40
-    /**
41
-     *
42
-     */
43
-    public function testXml()
44
-    {
45
-        /** @var Locator $locator */
46
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
47
-        $page = $this->get($locator->Link('xml'));
40
+	/**
41
+	 *
42
+	 */
43
+	public function testXml()
44
+	{
45
+		/** @var Locator $locator */
46
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
47
+		$page = $this->get($locator->Link('xml'));
48 48
 
49
-        $this->assertEquals(200, $page->getStatusCode());
50
-        $this->assertEquals('application/xml', $page->getHeader('content-type'));
49
+		$this->assertEquals(200, $page->getStatusCode());
50
+		$this->assertEquals('application/xml', $page->getHeader('content-type'));
51 51
 
52
-        $dom = new \DOMDocument();
53
-        // true if it loads, false if it doesn't
54
-        $valid = $dom->loadXML($page->getBody());
55
-        $this->assertTrue($valid);
56
-    }
52
+		$dom = new \DOMDocument();
53
+		// true if it loads, false if it doesn't
54
+		$valid = $dom->loadXML($page->getBody());
55
+		$this->assertTrue($valid);
56
+	}
57 57
 
58
-    /**
59
-     *
60
-     */
61
-    public function testJson()
62
-    {
63
-        /** @var Locator $locator */
64
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
65
-        $page = $this->get($locator->Link('json'));
58
+	/**
59
+	 *
60
+	 */
61
+	public function testJson()
62
+	{
63
+		/** @var Locator $locator */
64
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
65
+		$page = $this->get($locator->Link('json'));
66 66
 
67
-        $this->assertEquals(200, $page->getStatusCode());
68
-        $this->assertEquals('application/json', $page->getHeader('content-type'));
67
+		$this->assertEquals(200, $page->getStatusCode());
68
+		$this->assertEquals('application/json', $page->getHeader('content-type'));
69 69
 
70
-        $json = json_decode($page->getBody());
71
-        // if it is null its not valid
72
-        $this->assertNotNull($json);
73
-    }
70
+		$json = json_decode($page->getBody());
71
+		// if it is null its not valid
72
+		$this->assertNotNull($json);
73
+	}
74 74
 
75
-    /**
76
-     *
77
-     */
78
-    public function testLocationSearch()
79
-    {
80
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
81
-        $object = LocatorController::create($locator);
82
-        $form = $object->LocationSearch();
83
-        $this->assertInstanceOf(Form::class, $form);
75
+	/**
76
+	 *
77
+	 */
78
+	public function testLocationSearch()
79
+	{
80
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
81
+		$object = LocatorController::create($locator);
82
+		$form = $object->LocationSearch();
83
+		$this->assertInstanceOf(Form::class, $form);
84 84
 
85
-        $category = $this->objFromFixture(LocationCategory::class, 'service');
86
-        $category2 = $this->objFromFixture(LocationCategory::class, 'manufacturing');
87
-        $locator->Categories()->add($category);
88
-        $locator->Categories()->add($category2);
85
+		$category = $this->objFromFixture(LocationCategory::class, 'service');
86
+		$category2 = $this->objFromFixture(LocationCategory::class, 'manufacturing');
87
+		$locator->Categories()->add($category);
88
+		$locator->Categories()->add($category2);
89 89
 
90
-        $form = $object->LocationSearch();
91
-        $fields = $form->Fields();
92
-        $this->assertInstanceOf(FieldList::class, $fields);
93
-    }
90
+		$form = $object->LocationSearch();
91
+		$fields = $form->Fields();
92
+		$this->assertInstanceOf(FieldList::class, $fields);
93
+	}
94 94
 }
Please login to merge, or discard this patch.
tests/Page/LocatorTest.php 1 patch
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -17,158 +17,158 @@
 block discarded – undo
17 17
  */
18 18
 class LocatorTest extends FunctionalTest
19 19
 {
20
-    /**
21
-     * @var string
22
-     */
23
-    protected static $fixture_file = 'locatorfixture.yml';
24
-
25
-    /**
26
-     *
27
-     */
28
-    public function testGetCMSFields()
29
-    {
30
-        /** @var Locator $locator */
31
-        $locator = Injector::inst()->create(Locator::class);
32
-        $this->assertInstanceOf(FieldList::class, $locator->getCMSFields());
33
-    }
34
-
35
-    /**
36
-     *
37
-     */
38
-    public function testLocations()
39
-    {
40
-        $filter = Config::inst()->get(LocatorController::class, 'base_filter');
41
-        $filterAny = Config::inst()->get(LocatorController::class, 'base_filter_any');
42
-        $exclude = Config::inst()->get(LocatorController::class, 'base_exclude');
43
-        $locations = Locator::get_locations($filter, $filterAny, $exclude);
44
-        $locations2 = Location::get()->filter($filter)->filterAny($filterAny)->exclude($exclude);
45
-        $this->assertEquals($locations->count(), $locations2->count());
46
-    }
47
-
48
-    /**
49
-     *
50
-     */
51
-    public function testGetAllCategories()
52
-    {
53
-        $this->assertEquals(Locator::get_all_categories()->count(), 4);
54
-    }
55
-
56
-    /**
57
-     *
58
-     */
59
-    public function testGetPageCategories()
60
-    {
61
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
62
-        $this->assertEquals($locator->getPageCategories()->count(), 1);
63
-    }
64
-
65
-    /**
66
-     *
67
-     */
68
-    public function testLocator_categories_by_locator()
69
-    {
70
-        $categories = Locator::locator_categories_by_locator(0);
71
-        $this->assertFalse($categories);
72
-    }
73
-
74
-    /**
75
-     *
76
-     */
77
-    public function testLocatorCategoriesByLocator()
78
-    {
79
-
80
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
81
-        $this->assertEquals(Locator::locator_categories_by_locator($locator->ID)->count(), 1);
82
-
83
-        $newLocator = Locator::create();
84
-        $newLocator->Title = 'Locator 2';
85
-        $newLocator->write();
86
-
87
-        $this->assertEquals(Locator::locator_categories_by_locator($newLocator->ID)->count(), 0);
88
-    }
89
-
90
-    /**
91
-     *
92
-     */
93
-    public function testGetRadii()
94
-    {
95
-        /** @var Locator $locator */
96
-        $locator = Injector::inst()->create(Locator::class);
97
-        $radii = [
98
-            '0' => '5',
99
-            '1' => '10',
100
-            '2' => '15',
101
-            '3' => '100',
102
-        ];
103
-        Config::modify()->set(Locator::class, 'radii', $radii);
104
-        $this->assertEquals($radii, $locator->getRadii());
105
-    }
106
-
107
-    /**
108
-     *
109
-     */
110
-    public function testGetRadiiArrayList()
111
-    {
112
-        /** @var Locator $locator */
113
-        $locator = Injector::inst()->create(Locator::class);
114
-        $this->assertInstanceOf(ArrayList::class, $locator->getRadiiArrayList());
115
-    }
116
-
117
-    /**
118
-     *
119
-     */
120
-    public function testGetLimit()
121
-    {
122
-        /** @var Locator $locator */
123
-        $locator = Injector::inst()->create(Locator::class);
124
-        $this->assertEquals(50, $locator->getLimit());
125
-    }
126
-
127
-    /**
128
-     *
129
-     */
130
-    public function testGetShowRadius()
131
-    {
132
-        /** @var Locator $locator */
133
-        $locator = Injector::inst()->create(Locator::class);
134
-        $this->assertTrue($locator->getShowRadius());
135
-    }
136
-
137
-    /**
138
-     *
139
-     */
140
-    public function testGetUsedCategories()
141
-    {
142
-        /** @var Locator $locator */
143
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
144
-
145
-        $categories = $locator->getUsedCategories()->toArray();
146
-        $this->assertEquals(1, count($categories));
147
-    }
148
-
149
-    /**
150
-     *
151
-     */
152
-    public function testGetInfoWindowTemplate()
153
-    {
154
-        /** @var Locator $object */
155
-        $object = Injector::inst()->create(Locator::class);
156
-        $template = $object->getInfoWindowTemplate();
157
-        // get rid of cache ending
158
-        $template = preg_replace('/\?.*$/', '', $template);
159
-        $this->assertStringEndsWith('client/infowindow-description.html', $template);
160
-    }
161
-
162
-    /**
163
-     *
164
-     */
165
-    public function testGetListTemplate()
166
-    {
167
-        /** @var Locator $object */
168
-        $object = Injector::inst()->create(Locator::class);
169
-        $template = $object->getListTemplate();
170
-        // get rid of cache ending
171
-        $template = preg_replace('/\?.*$/', '', $template);
172
-        $this->assertStringEndsWith('client/location-list-description.html', $template);
173
-    }
20
+	/**
21
+	 * @var string
22
+	 */
23
+	protected static $fixture_file = 'locatorfixture.yml';
24
+
25
+	/**
26
+	 *
27
+	 */
28
+	public function testGetCMSFields()
29
+	{
30
+		/** @var Locator $locator */
31
+		$locator = Injector::inst()->create(Locator::class);
32
+		$this->assertInstanceOf(FieldList::class, $locator->getCMSFields());
33
+	}
34
+
35
+	/**
36
+	 *
37
+	 */
38
+	public function testLocations()
39
+	{
40
+		$filter = Config::inst()->get(LocatorController::class, 'base_filter');
41
+		$filterAny = Config::inst()->get(LocatorController::class, 'base_filter_any');
42
+		$exclude = Config::inst()->get(LocatorController::class, 'base_exclude');
43
+		$locations = Locator::get_locations($filter, $filterAny, $exclude);
44
+		$locations2 = Location::get()->filter($filter)->filterAny($filterAny)->exclude($exclude);
45
+		$this->assertEquals($locations->count(), $locations2->count());
46
+	}
47
+
48
+	/**
49
+	 *
50
+	 */
51
+	public function testGetAllCategories()
52
+	{
53
+		$this->assertEquals(Locator::get_all_categories()->count(), 4);
54
+	}
55
+
56
+	/**
57
+	 *
58
+	 */
59
+	public function testGetPageCategories()
60
+	{
61
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
62
+		$this->assertEquals($locator->getPageCategories()->count(), 1);
63
+	}
64
+
65
+	/**
66
+	 *
67
+	 */
68
+	public function testLocator_categories_by_locator()
69
+	{
70
+		$categories = Locator::locator_categories_by_locator(0);
71
+		$this->assertFalse($categories);
72
+	}
73
+
74
+	/**
75
+	 *
76
+	 */
77
+	public function testLocatorCategoriesByLocator()
78
+	{
79
+
80
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
81
+		$this->assertEquals(Locator::locator_categories_by_locator($locator->ID)->count(), 1);
82
+
83
+		$newLocator = Locator::create();
84
+		$newLocator->Title = 'Locator 2';
85
+		$newLocator->write();
86
+
87
+		$this->assertEquals(Locator::locator_categories_by_locator($newLocator->ID)->count(), 0);
88
+	}
89
+
90
+	/**
91
+	 *
92
+	 */
93
+	public function testGetRadii()
94
+	{
95
+		/** @var Locator $locator */
96
+		$locator = Injector::inst()->create(Locator::class);
97
+		$radii = [
98
+			'0' => '5',
99
+			'1' => '10',
100
+			'2' => '15',
101
+			'3' => '100',
102
+		];
103
+		Config::modify()->set(Locator::class, 'radii', $radii);
104
+		$this->assertEquals($radii, $locator->getRadii());
105
+	}
106
+
107
+	/**
108
+	 *
109
+	 */
110
+	public function testGetRadiiArrayList()
111
+	{
112
+		/** @var Locator $locator */
113
+		$locator = Injector::inst()->create(Locator::class);
114
+		$this->assertInstanceOf(ArrayList::class, $locator->getRadiiArrayList());
115
+	}
116
+
117
+	/**
118
+	 *
119
+	 */
120
+	public function testGetLimit()
121
+	{
122
+		/** @var Locator $locator */
123
+		$locator = Injector::inst()->create(Locator::class);
124
+		$this->assertEquals(50, $locator->getLimit());
125
+	}
126
+
127
+	/**
128
+	 *
129
+	 */
130
+	public function testGetShowRadius()
131
+	{
132
+		/** @var Locator $locator */
133
+		$locator = Injector::inst()->create(Locator::class);
134
+		$this->assertTrue($locator->getShowRadius());
135
+	}
136
+
137
+	/**
138
+	 *
139
+	 */
140
+	public function testGetUsedCategories()
141
+	{
142
+		/** @var Locator $locator */
143
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
144
+
145
+		$categories = $locator->getUsedCategories()->toArray();
146
+		$this->assertEquals(1, count($categories));
147
+	}
148
+
149
+	/**
150
+	 *
151
+	 */
152
+	public function testGetInfoWindowTemplate()
153
+	{
154
+		/** @var Locator $object */
155
+		$object = Injector::inst()->create(Locator::class);
156
+		$template = $object->getInfoWindowTemplate();
157
+		// get rid of cache ending
158
+		$template = preg_replace('/\?.*$/', '', $template);
159
+		$this->assertStringEndsWith('client/infowindow-description.html', $template);
160
+	}
161
+
162
+	/**
163
+	 *
164
+	 */
165
+	public function testGetListTemplate()
166
+	{
167
+		/** @var Locator $object */
168
+		$object = Injector::inst()->create(Locator::class);
169
+		$template = $object->getListTemplate();
170
+		// get rid of cache ending
171
+		$template = preg_replace('/\?.*$/', '', $template);
172
+		$this->assertStringEndsWith('client/location-list-description.html', $template);
173
+	}
174 174
 }
Please login to merge, or discard this patch.
tests/form/LocatorFormTest.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -15,46 +15,46 @@
 block discarded – undo
15 15
  */
16 16
 class LocatorFormTest extends FunctionalTest
17 17
 {
18
-    /**
19
-     *
20
-     */
21
-    public function testLocatorFormBase()
22
-    {
23
-        $form = LocatorForm::create(LocatorController::create(Locator::get()->first()), 'LocatorForm');
24
-
25
-        $this->assertInstanceOf(FieldList::class, $form->Fields());
26
-        $this->assertInstanceOf(RequiredFields::class, $form->getValidator());
27
-    }
28
-
29
-    /**
30
-     *
31
-     */
32
-    public function testUpdateRequiredFields()
33
-    {
34
-        $form = LocatorForm::create(LocatorController::create(Locator::get()->first()), 'LocatorForm');
35
-        $validator = $form->getValidator();
36
-
37
-        $validator->removeRequiredField('Address');
38
-        $validator->addRequiredField('Foo');
39
-
40
-        $this->assertEquals(['Foo'], $form->getValidator()->getRequired());
41
-    }
42
-
43
-    /**
44
-     *
45
-     */
46
-    public function testFields()
47
-    {
48
-        $form = LocatorForm::create(LocatorController::create(Locator::get()->first()), 'LocatorForm');
49
-        $this->assertInstanceOf(FieldList::class, $form->Fields());
50
-    }
51
-
52
-    /**
53
-     *
54
-     */
55
-    public function testActions()
56
-    {
57
-        $form = LocatorForm::create(LocatorController::create(Locator::get()->first()), 'LocatorForm');
58
-        $this->assertInstanceOf(FieldList::class, $form->Actions());
59
-    }
18
+	/**
19
+	 *
20
+	 */
21
+	public function testLocatorFormBase()
22
+	{
23
+		$form = LocatorForm::create(LocatorController::create(Locator::get()->first()), 'LocatorForm');
24
+
25
+		$this->assertInstanceOf(FieldList::class, $form->Fields());
26
+		$this->assertInstanceOf(RequiredFields::class, $form->getValidator());
27
+	}
28
+
29
+	/**
30
+	 *
31
+	 */
32
+	public function testUpdateRequiredFields()
33
+	{
34
+		$form = LocatorForm::create(LocatorController::create(Locator::get()->first()), 'LocatorForm');
35
+		$validator = $form->getValidator();
36
+
37
+		$validator->removeRequiredField('Address');
38
+		$validator->addRequiredField('Foo');
39
+
40
+		$this->assertEquals(['Foo'], $form->getValidator()->getRequired());
41
+	}
42
+
43
+	/**
44
+	 *
45
+	 */
46
+	public function testFields()
47
+	{
48
+		$form = LocatorForm::create(LocatorController::create(Locator::get()->first()), 'LocatorForm');
49
+		$this->assertInstanceOf(FieldList::class, $form->Fields());
50
+	}
51
+
52
+	/**
53
+	 *
54
+	 */
55
+	public function testActions()
56
+	{
57
+		$form = LocatorForm::create(LocatorController::create(Locator::get()->first()), 'LocatorForm');
58
+		$this->assertInstanceOf(FieldList::class, $form->Actions());
59
+	}
60 60
 }
Please login to merge, or discard this patch.
tests/Model/LocationCategoryTest.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -13,69 +13,69 @@
 block discarded – undo
13 13
  */
14 14
 class LocationCategoryTest extends SapphireTest
15 15
 {
16
-    /**
17
-     * @var string
18
-     */
19
-    protected static $fixture_file = 'categoryfixture.yml';
16
+	/**
17
+	 * @var string
18
+	 */
19
+	protected static $fixture_file = 'categoryfixture.yml';
20 20
 
21
-    /**
22
-     *
23
-     */
24
-    public function testGetCMSFields()
25
-    {
26
-        $object = $this->objFromFixture(LocationCategory::class, 'service');
27
-        $fieldset = $object->getCMSFields();
28
-        $this->assertInstanceOf(FieldList::class, $fieldset);
29
-    }
21
+	/**
22
+	 *
23
+	 */
24
+	public function testGetCMSFields()
25
+	{
26
+		$object = $this->objFromFixture(LocationCategory::class, 'service');
27
+		$fieldset = $object->getCMSFields();
28
+		$this->assertInstanceOf(FieldList::class, $fieldset);
29
+	}
30 30
 
31
-    /**
32
-     *
33
-     */
34
-    public function testCanView()
35
-    {
36
-        $object = $this->objFromFixture(LocationCategory::class, 'service');
37
-        $this->assertTrue($object->canView());
38
-    }
31
+	/**
32
+	 *
33
+	 */
34
+	public function testCanView()
35
+	{
36
+		$object = $this->objFromFixture(LocationCategory::class, 'service');
37
+		$this->assertTrue($object->canView());
38
+	}
39 39
 
40
-    /**
41
-     *
42
-     */
43
-    public function testCanEdit()
44
-    {
45
-        $object = $this->objFromFixture(LocationCategory::class, 'service');
40
+	/**
41
+	 *
42
+	 */
43
+	public function testCanEdit()
44
+	{
45
+		$object = $this->objFromFixture(LocationCategory::class, 'service');
46 46
 
47
-        $admin = $this->objFromFixture(Member::class, 'locationedit');
48
-        $this->assertTrue($object->canEdit($admin));
47
+		$admin = $this->objFromFixture(Member::class, 'locationedit');
48
+		$this->assertTrue($object->canEdit($admin));
49 49
 
50
-        $member = $this->objFromFixture(Member::class, 'default');
51
-        $this->assertFalse($object->canEdit($member));
52
-    }
50
+		$member = $this->objFromFixture(Member::class, 'default');
51
+		$this->assertFalse($object->canEdit($member));
52
+	}
53 53
 
54
-    /**
55
-     *
56
-     */
57
-    public function testCanDelete()
58
-    {
59
-        $object = $this->objFromFixture(LocationCategory::class, 'service');
54
+	/**
55
+	 *
56
+	 */
57
+	public function testCanDelete()
58
+	{
59
+		$object = $this->objFromFixture(LocationCategory::class, 'service');
60 60
 
61
-        $admin = $this->objFromFixture(Member::class, 'locationdelete');
62
-        $this->assertTrue($object->canDelete($admin));
61
+		$admin = $this->objFromFixture(Member::class, 'locationdelete');
62
+		$this->assertTrue($object->canDelete($admin));
63 63
 
64
-        $member = $this->objFromFixture(Member::class, 'default');
65
-        $this->assertFalse($object->canDelete($member));
66
-    }
64
+		$member = $this->objFromFixture(Member::class, 'default');
65
+		$this->assertFalse($object->canDelete($member));
66
+	}
67 67
 
68
-    /**
69
-     *
70
-     */
71
-    public function testCanCreate()
72
-    {
73
-        $object = $this->objFromFixture(LocationCategory::class, 'service');
68
+	/**
69
+	 *
70
+	 */
71
+	public function testCanCreate()
72
+	{
73
+		$object = $this->objFromFixture(LocationCategory::class, 'service');
74 74
 
75
-        $admin = $this->objFromFixture(Member::class, 'locationcreate');
76
-        $this->assertTrue($object->canCreate($admin));
75
+		$admin = $this->objFromFixture(Member::class, 'locationcreate');
76
+		$this->assertTrue($object->canCreate($admin));
77 77
 
78
-        $member = $this->objFromFixture(Member::class, 'default');
79
-        $this->assertFalse($object->canCreate($member));
80
-    }
78
+		$member = $this->objFromFixture(Member::class, 'default');
79
+		$this->assertFalse($object->canCreate($member));
80
+	}
81 81
 }
Please login to merge, or discard this patch.
tests/Model/LocationTest.php 1 patch
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -16,206 +16,206 @@
 block discarded – undo
16 16
  */
17 17
 class LocationTest extends SapphireTest
18 18
 {
19
-    /**
20
-     * @var string
21
-     */
22
-    protected static $fixture_file = 'locationfixture.yml';
23
-
24
-    /**
25
-     * @var array
26
-     */
27
-    protected static $extra_dataobjects = [
28
-        ExtendedLocation::class,
29
-    ];
30
-
31
-    /**
32
-     * @var array
33
-     */
34
-    protected static $required_extensions = [
35
-        ExtendedLocation::class => [
36
-            LocationExtension::class,
37
-        ],
38
-    ];
39
-
40
-    /**
41
-     *
42
-     */
43
-    public function testGetCoords()
44
-    {
45
-        $location = $this->objFromFixture(Location::class, 'dynamic');
46
-        $coords = ((int)$location->Lat != 0 && (int)$location->Lng != 0) ? 'true' : 'false';
47
-        $this->assertEquals($coords, $location->getCoords());
48
-    }
49
-
50
-    /**
51
-     *
52
-     */
53
-    public function testFieldLabels()
54
-    {
55
-        $this->markTestSkipped();
56
-        // Link and File tracking display as "Tracking" in SS 4.2 & 4.3, "Tracking" in 4.4
57
-        $location = $this->objFromFixture(Location::class, 'dynamic');
58
-        $labels = $location->FieldLabels();
59
-        $expected = [
60
-            'Title' => 'Name',
61
-            'Featured' => 'Featured',
62
-            'Website' => 'Website',
63
-            'Phone' => 'Phone',
64
-            'Email' => 'Email',
65
-            'Fax' => 'Fax',
66
-            'Address' => 'Address',
67
-            'City' => 'City',
68
-            'State' => 'State',
69
-            'PostalCode' => 'Postal Code',
70
-            'Country' => 'Country',
71
-            'Lat' => 'Lat',
72
-            'Lng' => 'Lng',
73
-            'Categories' => 'Categories',
74
-            'Category.Name' => 'Category',
75
-            'Category.ID' => 'Category',
76
-            'Featured.NiceAsBoolean' => 'Featured',
77
-            'Import_ID' => 'Import_ID',
78
-            'Version' => 'Version',
79
-            'Versions' => 'Versions',
80
-            'Address2' => 'Address2',
81
-            'LinkTracking' => 'Link tracking',
82
-            'FileTracking' => 'File tracking',
83
-        ];
84
-        $this->assertEquals($expected, $labels);
85
-    }
86
-
87
-    /**
88
-     *
89
-     */
90
-    public function testGetCMSFields()
91
-    {
92
-        $object = new Location();
93
-        $fieldset = $object->getCMSFields();
94
-        $this->assertinstanceOf(FieldList::class, $fieldset);
95
-    }
96
-
97
-    /**
98
-     *
99
-     */
100
-    public function testCanView()
101
-    {
102
-        $object = $this->objFromFixture(Location::class, 'dynamic');
103
-        $object->write();
104
-
105
-        $this->assertTrue($object->canView());
106
-
107
-        $nullMember = Member::create();
108
-        $nullMember->write();
109
-
110
-        $this->assertTrue($object->canView($nullMember));
111
-
112
-        $nullMember->delete();
113
-    }
114
-
115
-    /**
116
-     *
117
-     */
118
-    public function testCanEdit()
119
-    {
120
-        $object = $this->objFromFixture(Location::class, 'dynamic');
121
-        $object->write();
122
-
123
-        $objectID = $object->ID;
124
-
125
-        //test permissions per permission setting
126
-        $create = $this->objFromFixture(Member::class, 'locationcreate');
127
-        $edit = $this->objFromFixture(Member::class, 'locationedit');
128
-        $delete = $this->objFromFixture(Member::class, 'locationdelete');
129
-
130
-        $originalTitle = $object->Title;
131
-        $this->assertEquals($originalTitle, 'Dynamic, Inc.');
132
-
133
-        $this->assertTrue($object->canEdit($edit));
134
-        $this->assertFalse($object->canEdit($create));
135
-        $this->assertFalse($object->canEdit($delete));
136
-
137
-        $object->Title = 'Changed Title';
138
-        $object->write();
139
-
140
-        $testEdit = Location::get()->byID($objectID);
141
-        $this->assertEquals($testEdit->Title, 'Changed Title');
142
-    }
143
-
144
-    /**
145
-     *
146
-     */
147
-    public function testCanDelete()
148
-    {
149
-        $object = $this->objFromFixture(Location::class, 'dynamic');
150
-        $object->write();
151
-
152
-        //test permissions per permission setting
153
-        $create = $this->objFromFixture(Member::class, 'locationcreate');
154
-        $edit = $this->objFromFixture(Member::class, 'locationedit');
155
-        $delete = $this->objFromFixture(Member::class, 'locationdelete');
156
-
157
-        $this->assertTrue($object->canDelete($delete));
158
-        $this->assertFalse($object->canDelete($create));
159
-        $this->assertFalse($object->canDelete($edit));
160
-
161
-        $checkObject = $object;
162
-        $object->delete();
163
-
164
-        $this->assertEquals($checkObject->ID, 0);
165
-    }
166
-
167
-    /**
168
-     *
169
-     */
170
-    public function testCanCreate()
171
-    {
172
-        $object = singleton(Location::class);
173
-
174
-        //test permissions per permission setting
175
-        $create = $this->objFromFixture(Member::class, 'locationcreate');
176
-        $edit = $this->objFromFixture(Member::class, 'locationedit');
177
-        $delete = $this->objFromFixture(Member::class, 'locationdelete');
178
-
179
-        $this->assertTrue($object->canCreate($create));
180
-        $this->assertFalse($object->canCreate($edit));
181
-        $this->assertFalse($object->canCreate($delete));
182
-
183
-        $nullMember = Member::create();
184
-        $nullMember->write();
185
-        $this->assertFalse($object->canCreate($nullMember));
186
-
187
-        $nullMember->delete();
188
-    }
189
-
190
-    /**
191
-     *
192
-     */
193
-    public function testProvidePermissions()
194
-    {
195
-        $object = Location::create();
196
-        $expected = [
197
-            'Location_EDIT' => 'Edit a Location',
198
-            'Location_DELETE' => 'Delete a Location',
199
-            'Location_CREATE' => 'Create a Location',
200
-        ];
201
-        $this->assertEquals($expected, $object->providePermissions());
202
-    }
203
-
204
-    /**
205
-     *
206
-     */
207
-    public function testUpdateWebsiteURL()
208
-    {
209
-        $location = $this->objFromFixture(Location::class, 'dynamic');
210
-
211
-        // Create unsaved raw duplicate
212
-        $map = $location->toMap();
213
-        unset($map['Created']);
214
-        /** @var static $clone */
215
-        $clone = Injector::inst()->create(ExtendedLocation::class, $map);
216
-        $clone->ID = 0;
217
-
218
-        $this->assertEquals('http://www.dynamicagency.com', $location->getWebsiteURL());
219
-        $this->assertEquals('foo', $clone->getWebsiteURL());
220
-    }
19
+	/**
20
+	 * @var string
21
+	 */
22
+	protected static $fixture_file = 'locationfixture.yml';
23
+
24
+	/**
25
+	 * @var array
26
+	 */
27
+	protected static $extra_dataobjects = [
28
+		ExtendedLocation::class,
29
+	];
30
+
31
+	/**
32
+	 * @var array
33
+	 */
34
+	protected static $required_extensions = [
35
+		ExtendedLocation::class => [
36
+			LocationExtension::class,
37
+		],
38
+	];
39
+
40
+	/**
41
+	 *
42
+	 */
43
+	public function testGetCoords()
44
+	{
45
+		$location = $this->objFromFixture(Location::class, 'dynamic');
46
+		$coords = ((int)$location->Lat != 0 && (int)$location->Lng != 0) ? 'true' : 'false';
47
+		$this->assertEquals($coords, $location->getCoords());
48
+	}
49
+
50
+	/**
51
+	 *
52
+	 */
53
+	public function testFieldLabels()
54
+	{
55
+		$this->markTestSkipped();
56
+		// Link and File tracking display as "Tracking" in SS 4.2 & 4.3, "Tracking" in 4.4
57
+		$location = $this->objFromFixture(Location::class, 'dynamic');
58
+		$labels = $location->FieldLabels();
59
+		$expected = [
60
+			'Title' => 'Name',
61
+			'Featured' => 'Featured',
62
+			'Website' => 'Website',
63
+			'Phone' => 'Phone',
64
+			'Email' => 'Email',
65
+			'Fax' => 'Fax',
66
+			'Address' => 'Address',
67
+			'City' => 'City',
68
+			'State' => 'State',
69
+			'PostalCode' => 'Postal Code',
70
+			'Country' => 'Country',
71
+			'Lat' => 'Lat',
72
+			'Lng' => 'Lng',
73
+			'Categories' => 'Categories',
74
+			'Category.Name' => 'Category',
75
+			'Category.ID' => 'Category',
76
+			'Featured.NiceAsBoolean' => 'Featured',
77
+			'Import_ID' => 'Import_ID',
78
+			'Version' => 'Version',
79
+			'Versions' => 'Versions',
80
+			'Address2' => 'Address2',
81
+			'LinkTracking' => 'Link tracking',
82
+			'FileTracking' => 'File tracking',
83
+		];
84
+		$this->assertEquals($expected, $labels);
85
+	}
86
+
87
+	/**
88
+	 *
89
+	 */
90
+	public function testGetCMSFields()
91
+	{
92
+		$object = new Location();
93
+		$fieldset = $object->getCMSFields();
94
+		$this->assertinstanceOf(FieldList::class, $fieldset);
95
+	}
96
+
97
+	/**
98
+	 *
99
+	 */
100
+	public function testCanView()
101
+	{
102
+		$object = $this->objFromFixture(Location::class, 'dynamic');
103
+		$object->write();
104
+
105
+		$this->assertTrue($object->canView());
106
+
107
+		$nullMember = Member::create();
108
+		$nullMember->write();
109
+
110
+		$this->assertTrue($object->canView($nullMember));
111
+
112
+		$nullMember->delete();
113
+	}
114
+
115
+	/**
116
+	 *
117
+	 */
118
+	public function testCanEdit()
119
+	{
120
+		$object = $this->objFromFixture(Location::class, 'dynamic');
121
+		$object->write();
122
+
123
+		$objectID = $object->ID;
124
+
125
+		//test permissions per permission setting
126
+		$create = $this->objFromFixture(Member::class, 'locationcreate');
127
+		$edit = $this->objFromFixture(Member::class, 'locationedit');
128
+		$delete = $this->objFromFixture(Member::class, 'locationdelete');
129
+
130
+		$originalTitle = $object->Title;
131
+		$this->assertEquals($originalTitle, 'Dynamic, Inc.');
132
+
133
+		$this->assertTrue($object->canEdit($edit));
134
+		$this->assertFalse($object->canEdit($create));
135
+		$this->assertFalse($object->canEdit($delete));
136
+
137
+		$object->Title = 'Changed Title';
138
+		$object->write();
139
+
140
+		$testEdit = Location::get()->byID($objectID);
141
+		$this->assertEquals($testEdit->Title, 'Changed Title');
142
+	}
143
+
144
+	/**
145
+	 *
146
+	 */
147
+	public function testCanDelete()
148
+	{
149
+		$object = $this->objFromFixture(Location::class, 'dynamic');
150
+		$object->write();
151
+
152
+		//test permissions per permission setting
153
+		$create = $this->objFromFixture(Member::class, 'locationcreate');
154
+		$edit = $this->objFromFixture(Member::class, 'locationedit');
155
+		$delete = $this->objFromFixture(Member::class, 'locationdelete');
156
+
157
+		$this->assertTrue($object->canDelete($delete));
158
+		$this->assertFalse($object->canDelete($create));
159
+		$this->assertFalse($object->canDelete($edit));
160
+
161
+		$checkObject = $object;
162
+		$object->delete();
163
+
164
+		$this->assertEquals($checkObject->ID, 0);
165
+	}
166
+
167
+	/**
168
+	 *
169
+	 */
170
+	public function testCanCreate()
171
+	{
172
+		$object = singleton(Location::class);
173
+
174
+		//test permissions per permission setting
175
+		$create = $this->objFromFixture(Member::class, 'locationcreate');
176
+		$edit = $this->objFromFixture(Member::class, 'locationedit');
177
+		$delete = $this->objFromFixture(Member::class, 'locationdelete');
178
+
179
+		$this->assertTrue($object->canCreate($create));
180
+		$this->assertFalse($object->canCreate($edit));
181
+		$this->assertFalse($object->canCreate($delete));
182
+
183
+		$nullMember = Member::create();
184
+		$nullMember->write();
185
+		$this->assertFalse($object->canCreate($nullMember));
186
+
187
+		$nullMember->delete();
188
+	}
189
+
190
+	/**
191
+	 *
192
+	 */
193
+	public function testProvidePermissions()
194
+	{
195
+		$object = Location::create();
196
+		$expected = [
197
+			'Location_EDIT' => 'Edit a Location',
198
+			'Location_DELETE' => 'Delete a Location',
199
+			'Location_CREATE' => 'Create a Location',
200
+		];
201
+		$this->assertEquals($expected, $object->providePermissions());
202
+	}
203
+
204
+	/**
205
+	 *
206
+	 */
207
+	public function testUpdateWebsiteURL()
208
+	{
209
+		$location = $this->objFromFixture(Location::class, 'dynamic');
210
+
211
+		// Create unsaved raw duplicate
212
+		$map = $location->toMap();
213
+		unset($map['Created']);
214
+		/** @var static $clone */
215
+		$clone = Injector::inst()->create(ExtendedLocation::class, $map);
216
+		$clone->ID = 0;
217
+
218
+		$this->assertEquals('http://www.dynamicagency.com', $location->getWebsiteURL());
219
+		$this->assertEquals('foo', $clone->getWebsiteURL());
220
+	}
221 221
 }
Please login to merge, or discard this patch.