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