@@ -17,168 +17,168 @@ |
||
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() |
|
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() |
|
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 | } |
@@ -11,11 +11,11 @@ |
||
11 | 11 | */ |
12 | 12 | class LocationExtension extends DataExtension implements TestOnly |
13 | 13 | { |
14 | - /** |
|
15 | - * @param $url |
|
16 | - */ |
|
17 | - public function updateWebsiteURL(&$url) |
|
18 | - { |
|
19 | - $url = 'foo'; |
|
20 | - } |
|
14 | + /** |
|
15 | + * @param $url |
|
16 | + */ |
|
17 | + public function updateWebsiteURL(&$url) |
|
18 | + { |
|
19 | + $url = 'foo'; |
|
20 | + } |
|
21 | 21 | } |