Passed
Pull Request — master (#231)
by Nic
05:51 queued 02:58
created
tests/form/LocatorFormTest.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -17,62 +17,62 @@
 block discarded – undo
17 17
  */
18 18
 class LocatorFormTest extends FunctionalTest
19 19
 {
20
-    protected static $fixture_file = 'locatorformfixture.yml';
20
+	protected static $fixture_file = 'locatorformfixture.yml';
21 21
 
22
-    /**
23
-     *
24
-     */
25
-    protected function setUp(): void
26
-    {
27
-        parent::setUp();
22
+	/**
23
+	 *
24
+	 */
25
+	protected function setUp(): void
26
+	{
27
+		parent::setUp();
28 28
 
29
-        Config::modify()->set(Locator::class, 'location_class', Location::class);
30
-    }
29
+		Config::modify()->set(Locator::class, 'location_class', Location::class);
30
+	}
31 31
 
32
-    /**
33
-     *
34
-     */
35
-    public function testLocatorFormBase()
36
-    {
37
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
38
-        $form = LocatorForm::create(LocatorController::create($locator), 'LocatorForm');
32
+	/**
33
+	 *
34
+	 */
35
+	public function testLocatorFormBase()
36
+	{
37
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
38
+		$form = LocatorForm::create(LocatorController::create($locator), 'LocatorForm');
39 39
 
40
-        $this->assertInstanceOf(FieldList::class, $form->Fields());
41
-        $this->assertInstanceOf(RequiredFields::class, $form->getValidator());
42
-    }
40
+		$this->assertInstanceOf(FieldList::class, $form->Fields());
41
+		$this->assertInstanceOf(RequiredFields::class, $form->getValidator());
42
+	}
43 43
 
44
-    /**
45
-     *
46
-     */
47
-    public function testUpdateRequiredFields()
48
-    {
49
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
50
-        $form = LocatorForm::create(LocatorController::create($locator), 'LocatorForm');
51
-        $validator = $form->getValidator();
44
+	/**
45
+	 *
46
+	 */
47
+	public function testUpdateRequiredFields()
48
+	{
49
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
50
+		$form = LocatorForm::create(LocatorController::create($locator), 'LocatorForm');
51
+		$validator = $form->getValidator();
52 52
 
53
-        $validator->removeRequiredField('Address');
54
-        $validator->addRequiredField('Foo');
53
+		$validator->removeRequiredField('Address');
54
+		$validator->addRequiredField('Foo');
55 55
 
56
-        $this->assertEquals(['Foo'], $form->getValidator()->getRequired());
57
-    }
56
+		$this->assertEquals(['Foo'], $form->getValidator()->getRequired());
57
+	}
58 58
 
59
-    /**
60
-     *
61
-     */
62
-    public function testFields()
63
-    {
64
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
65
-        $form = LocatorForm::create(LocatorController::create($locator), 'LocatorForm');
66
-        $this->assertInstanceOf(FieldList::class, $form->Fields());
67
-    }
59
+	/**
60
+	 *
61
+	 */
62
+	public function testFields()
63
+	{
64
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
65
+		$form = LocatorForm::create(LocatorController::create($locator), 'LocatorForm');
66
+		$this->assertInstanceOf(FieldList::class, $form->Fields());
67
+	}
68 68
 
69
-    /**
70
-     *
71
-     */
72
-    public function testActions()
73
-    {
74
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
75
-        $form = LocatorForm::create(LocatorController::create($locator), 'LocatorForm');
76
-        $this->assertInstanceOf(FieldList::class, $form->Actions());
77
-    }
69
+	/**
70
+	 *
71
+	 */
72
+	public function testActions()
73
+	{
74
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
75
+		$form = LocatorForm::create(LocatorController::create($locator), 'LocatorForm');
76
+		$this->assertInstanceOf(FieldList::class, $form->Actions());
77
+	}
78 78
 }
Please login to merge, or discard this patch.
tests/Page/LocatorControllerTest.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -19,88 +19,88 @@
 block discarded – undo
19 19
 class LocatorControllerTest extends FunctionalTest
20 20
 {
21 21
 
22
-    /**
23
-     * @var string
24
-     */
25
-    protected static $fixture_file = 'locatorcontrollerfixture.yml';
26
-
27
-    /**
28
-     * @var bool
29
-     */
30
-    protected static $use_draft_site = true;
31
-
32
-    /**
33
-     *
34
-     */
35
-    protected function setUp(): void
36
-    {
37
-        parent::setUp();
38
-
39
-        Config::modify()->set(Locator::class, 'location_class', Location::class);
40
-    }
41
-
42
-    /**
43
-     *
44
-     */
45
-    public function testIndex()
46
-    {
47
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
48
-        $controller = LocatorController::create($locator);
49
-        $this->assertInstanceOf(ViewableData::class, $controller->index($controller->getRequest()));
50
-    }
51
-
52
-    /**
53
-     *
54
-     */
55
-    public function testXml()
56
-    {
57
-        /** @var Locator $locator */
58
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
59
-        $page = $this->get($locator->Link('xml'));
60
-
61
-        $this->assertEquals(200, $page->getStatusCode());
62
-        $this->assertEquals('application/xml', $page->getHeader('content-type'));
63
-
64
-        $dom = new \DOMDocument();
65
-        // true if it loads, false if it doesn't
66
-        $valid = $dom->loadXML($page->getBody());
67
-        $this->assertTrue($valid);
68
-    }
69
-
70
-    /**
71
-     *
72
-     */
73
-    public function testJson()
74
-    {
75
-        /** @var Locator $locator */
76
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
77
-        $page = $this->get($locator->Link('json'));
78
-
79
-        $this->assertEquals(200, $page->getStatusCode());
80
-        $this->assertEquals('application/json', $page->getHeader('content-type'));
81
-
82
-        $json = json_decode($page->getBody());
83
-        // if it is null its not valid
84
-        $this->assertNotNull($json);
85
-    }
86
-
87
-    /**
88
-     *
89
-     */
90
-    public function testLocationSearch()
91
-    {
92
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
93
-        $object = LocatorController::create($locator);
94
-        $form = $object->LocationSearch();
95
-        $this->assertInstanceOf(Form::class, $form);
96
-
97
-        $category = $this->objFromFixture(LocationCategory::class, 'service');
98
-        $category2 = $this->objFromFixture(LocationCategory::class, 'manufacturing');
99
-        $locator->Categories()->add($category);
100
-        $locator->Categories()->add($category2);
101
-
102
-        $form = $object->LocationSearch();
103
-        $fields = $form->Fields();
104
-        $this->assertInstanceOf(FieldList::class, $fields);
105
-    }
22
+	/**
23
+	 * @var string
24
+	 */
25
+	protected static $fixture_file = 'locatorcontrollerfixture.yml';
26
+
27
+	/**
28
+	 * @var bool
29
+	 */
30
+	protected static $use_draft_site = true;
31
+
32
+	/**
33
+	 *
34
+	 */
35
+	protected function setUp(): void
36
+	{
37
+		parent::setUp();
38
+
39
+		Config::modify()->set(Locator::class, 'location_class', Location::class);
40
+	}
41
+
42
+	/**
43
+	 *
44
+	 */
45
+	public function testIndex()
46
+	{
47
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
48
+		$controller = LocatorController::create($locator);
49
+		$this->assertInstanceOf(ViewableData::class, $controller->index($controller->getRequest()));
50
+	}
51
+
52
+	/**
53
+	 *
54
+	 */
55
+	public function testXml()
56
+	{
57
+		/** @var Locator $locator */
58
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
59
+		$page = $this->get($locator->Link('xml'));
60
+
61
+		$this->assertEquals(200, $page->getStatusCode());
62
+		$this->assertEquals('application/xml', $page->getHeader('content-type'));
63
+
64
+		$dom = new \DOMDocument();
65
+		// true if it loads, false if it doesn't
66
+		$valid = $dom->loadXML($page->getBody());
67
+		$this->assertTrue($valid);
68
+	}
69
+
70
+	/**
71
+	 *
72
+	 */
73
+	public function testJson()
74
+	{
75
+		/** @var Locator $locator */
76
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
77
+		$page = $this->get($locator->Link('json'));
78
+
79
+		$this->assertEquals(200, $page->getStatusCode());
80
+		$this->assertEquals('application/json', $page->getHeader('content-type'));
81
+
82
+		$json = json_decode($page->getBody());
83
+		// if it is null its not valid
84
+		$this->assertNotNull($json);
85
+	}
86
+
87
+	/**
88
+	 *
89
+	 */
90
+	public function testLocationSearch()
91
+	{
92
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
93
+		$object = LocatorController::create($locator);
94
+		$form = $object->LocationSearch();
95
+		$this->assertInstanceOf(Form::class, $form);
96
+
97
+		$category = $this->objFromFixture(LocationCategory::class, 'service');
98
+		$category2 = $this->objFromFixture(LocationCategory::class, 'manufacturing');
99
+		$locator->Categories()->add($category);
100
+		$locator->Categories()->add($category2);
101
+
102
+		$form = $object->LocationSearch();
103
+		$fields = $form->Fields();
104
+		$this->assertInstanceOf(FieldList::class, $fields);
105
+	}
106 106
 }
Please login to merge, or discard this patch.
tests/Page/LocatorTest.php 1 patch
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -17,168 +17,168 @@
 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
-    protected function setUp(): void
29
-    {
30
-        parent::setUp();
31
-
32
-        Config::modify()->set(Locator::class, 'location_class', Location::class);
33
-    }
34
-
35
-    /**
36
-     *
37
-     */
38
-    public function testGetCMSFields()
39
-    {
40
-        /** @var Locator $locator */
41
-        $locator = Injector::inst()->create(Locator::class);
42
-        $this->assertInstanceOf(FieldList::class, $locator->getCMSFields());
43
-    }
44
-
45
-    /**
46
-     *
47
-     */
48
-    public function testLocations()
49
-    {
50
-        $filter = Config::inst()->get(LocatorController::class, 'base_filter');
51
-        $filterAny = Config::inst()->get(LocatorController::class, 'base_filter_any');
52
-        $exclude = Config::inst()->get(LocatorController::class, 'base_exclude');
53
-        $locations = Locator::get_locations($filter, $filterAny, $exclude);
54
-        $locations2 = Location::get()->filter($filter)->filterAny($filterAny)->exclude($exclude);
55
-        $this->assertEquals($locations->count(), $locations2->count());
56
-    }
57
-
58
-    /**
59
-     *
60
-     */
61
-    public function testGetAllCategories()
62
-    {
63
-        $this->assertEquals(Locator::get_all_categories()->count(), 4);
64
-    }
65
-
66
-    /**
67
-     *
68
-     */
69
-    public function testGetPageCategories()
70
-    {
71
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
72
-        $this->assertEquals($locator->getPageCategories()->count(), 1);
73
-    }
74
-
75
-    /**
76
-     *
77
-     */
78
-    public function testLocator_categories_by_locator()
79
-    {
80
-        $categories = Locator::locator_categories_by_locator(0);
81
-        $this->assertFalse($categories);
82
-    }
83
-
84
-    /**
85
-     *
86
-     */
87
-    public function testLocatorCategoriesByLocator()
88
-    {
89
-
90
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
91
-        $this->assertEquals(Locator::locator_categories_by_locator($locator->ID)->count(), 1);
92
-
93
-        $newLocator = Locator::create();
94
-        $newLocator->Title = 'Locator 2';
95
-        $newLocator->write();
96
-
97
-        $this->assertEquals(Locator::locator_categories_by_locator($newLocator->ID)->count(), 0);
98
-    }
99
-
100
-    /**
101
-     *
102
-     */
103
-    public function testGetRadii()
104
-    {
105
-        /** @var Locator $locator */
106
-        $locator = Injector::inst()->create(Locator::class);
107
-        $radii = [
108
-            '0' => '5',
109
-            '1' => '10',
110
-            '2' => '15',
111
-            '3' => '100',
112
-        ];
113
-        Config::modify()->set(Locator::class, 'radii', $radii);
114
-        $this->assertEquals($radii, $locator->getRadii());
115
-    }
116
-
117
-    /**
118
-     *
119
-     */
120
-    public function testGetRadiiArrayList()
121
-    {
122
-        /** @var Locator $locator */
123
-        $locator = Injector::inst()->create(Locator::class);
124
-        $this->assertInstanceOf(ArrayList::class, $locator->getRadiiArrayList());
125
-    }
126
-
127
-    /**
128
-     *
129
-     */
130
-    public function testGetLimit()
131
-    {
132
-        /** @var Locator $locator */
133
-        $locator = Injector::inst()->create(Locator::class);
134
-        $this->assertEquals(50, $locator->getLimit());
135
-    }
136
-
137
-    /**
138
-     *
139
-     */
140
-    public function testGetShowRadius()
141
-    {
142
-        /** @var Locator $locator */
143
-        $locator = Injector::inst()->create(Locator::class);
144
-        $this->assertTrue($locator->getShowRadius());
145
-    }
146
-
147
-    /**
148
-     *
149
-     */
150
-    public function testGetUsedCategories()
151
-    {
152
-        /** @var Locator $locator */
153
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
154
-
155
-        $categories = $locator->getUsedCategories()->toArray();
156
-        $this->assertEquals(1, count($categories));
157
-    }
158
-
159
-    /**
160
-     *
161
-     */
162
-    public function testGetInfoWindowTemplate()
163
-    {
164
-        /** @var Locator $object */
165
-        $object = Injector::inst()->create(Locator::class);
166
-        $template = $object->getInfoWindowTemplate();
167
-        // get rid of cache ending
168
-        $template = preg_replace('/\?.*$/', '', $template);
169
-        $this->assertStringEndsWith('client/infowindow-description.html', $template);
170
-    }
171
-
172
-    /**
173
-     *
174
-     */
175
-    public function testGetListTemplate()
176
-    {
177
-        /** @var Locator $object */
178
-        $object = Injector::inst()->create(Locator::class);
179
-        $template = $object->getListTemplate();
180
-        // get rid of cache ending
181
-        $template = preg_replace('/\?.*$/', '', $template);
182
-        $this->assertStringEndsWith('client/location-list-description.html', $template);
183
-    }
20
+	/**
21
+	 * @var string
22
+	 */
23
+	protected static $fixture_file = 'locatorfixture.yml';
24
+
25
+	/**
26
+	 *
27
+	 */
28
+	protected function setUp(): void
29
+	{
30
+		parent::setUp();
31
+
32
+		Config::modify()->set(Locator::class, 'location_class', Location::class);
33
+	}
34
+
35
+	/**
36
+	 *
37
+	 */
38
+	public function testGetCMSFields()
39
+	{
40
+		/** @var Locator $locator */
41
+		$locator = Injector::inst()->create(Locator::class);
42
+		$this->assertInstanceOf(FieldList::class, $locator->getCMSFields());
43
+	}
44
+
45
+	/**
46
+	 *
47
+	 */
48
+	public function testLocations()
49
+	{
50
+		$filter = Config::inst()->get(LocatorController::class, 'base_filter');
51
+		$filterAny = Config::inst()->get(LocatorController::class, 'base_filter_any');
52
+		$exclude = Config::inst()->get(LocatorController::class, 'base_exclude');
53
+		$locations = Locator::get_locations($filter, $filterAny, $exclude);
54
+		$locations2 = Location::get()->filter($filter)->filterAny($filterAny)->exclude($exclude);
55
+		$this->assertEquals($locations->count(), $locations2->count());
56
+	}
57
+
58
+	/**
59
+	 *
60
+	 */
61
+	public function testGetAllCategories()
62
+	{
63
+		$this->assertEquals(Locator::get_all_categories()->count(), 4);
64
+	}
65
+
66
+	/**
67
+	 *
68
+	 */
69
+	public function testGetPageCategories()
70
+	{
71
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
72
+		$this->assertEquals($locator->getPageCategories()->count(), 1);
73
+	}
74
+
75
+	/**
76
+	 *
77
+	 */
78
+	public function testLocator_categories_by_locator()
79
+	{
80
+		$categories = Locator::locator_categories_by_locator(0);
81
+		$this->assertFalse($categories);
82
+	}
83
+
84
+	/**
85
+	 *
86
+	 */
87
+	public function testLocatorCategoriesByLocator()
88
+	{
89
+
90
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
91
+		$this->assertEquals(Locator::locator_categories_by_locator($locator->ID)->count(), 1);
92
+
93
+		$newLocator = Locator::create();
94
+		$newLocator->Title = 'Locator 2';
95
+		$newLocator->write();
96
+
97
+		$this->assertEquals(Locator::locator_categories_by_locator($newLocator->ID)->count(), 0);
98
+	}
99
+
100
+	/**
101
+	 *
102
+	 */
103
+	public function testGetRadii()
104
+	{
105
+		/** @var Locator $locator */
106
+		$locator = Injector::inst()->create(Locator::class);
107
+		$radii = [
108
+			'0' => '5',
109
+			'1' => '10',
110
+			'2' => '15',
111
+			'3' => '100',
112
+		];
113
+		Config::modify()->set(Locator::class, 'radii', $radii);
114
+		$this->assertEquals($radii, $locator->getRadii());
115
+	}
116
+
117
+	/**
118
+	 *
119
+	 */
120
+	public function testGetRadiiArrayList()
121
+	{
122
+		/** @var Locator $locator */
123
+		$locator = Injector::inst()->create(Locator::class);
124
+		$this->assertInstanceOf(ArrayList::class, $locator->getRadiiArrayList());
125
+	}
126
+
127
+	/**
128
+	 *
129
+	 */
130
+	public function testGetLimit()
131
+	{
132
+		/** @var Locator $locator */
133
+		$locator = Injector::inst()->create(Locator::class);
134
+		$this->assertEquals(50, $locator->getLimit());
135
+	}
136
+
137
+	/**
138
+	 *
139
+	 */
140
+	public function testGetShowRadius()
141
+	{
142
+		/** @var Locator $locator */
143
+		$locator = Injector::inst()->create(Locator::class);
144
+		$this->assertTrue($locator->getShowRadius());
145
+	}
146
+
147
+	/**
148
+	 *
149
+	 */
150
+	public function testGetUsedCategories()
151
+	{
152
+		/** @var Locator $locator */
153
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
154
+
155
+		$categories = $locator->getUsedCategories()->toArray();
156
+		$this->assertEquals(1, count($categories));
157
+	}
158
+
159
+	/**
160
+	 *
161
+	 */
162
+	public function testGetInfoWindowTemplate()
163
+	{
164
+		/** @var Locator $object */
165
+		$object = Injector::inst()->create(Locator::class);
166
+		$template = $object->getInfoWindowTemplate();
167
+		// get rid of cache ending
168
+		$template = preg_replace('/\?.*$/', '', $template);
169
+		$this->assertStringEndsWith('client/infowindow-description.html', $template);
170
+	}
171
+
172
+	/**
173
+	 *
174
+	 */
175
+	public function testGetListTemplate()
176
+	{
177
+		/** @var Locator $object */
178
+		$object = Injector::inst()->create(Locator::class);
179
+		$template = $object->getListTemplate();
180
+		// get rid of cache ending
181
+		$template = preg_replace('/\?.*$/', '', $template);
182
+		$this->assertStringEndsWith('client/location-list-description.html', $template);
183
+	}
184 184
 }
Please login to merge, or discard this patch.