Source of file GeoJsonImporterTest.php
Size: 1,182 Bytes - Last Modified: 2021-12-23T10:37:40+00:00
/var/www/docs.ssmods.com/process/src/tests/php/GeoJsonImporterTest.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | <?php namespace Smindel\GIS\Tests; use SilverStripe\Dev\SapphireTest; use SilverStripe\Core\Config\Config; use Smindel\GIS\GIS; use Smindel\GIS\Service\GeoJsonImporter; class GeoJsonImporterTest extends SapphireTest { public static function getExtraDataObjects() { return [TestLocation::class]; } public function setUp() { // reset GIS environment Config::modify()->set(GIS::class, 'default_srid', 4326); parent::setUp(); } public function testImport() { $json = json_encode([ 'type' => 'FeatureCollection', 'features' => [ [ 'type' => 'Feature', 'geometry' => [ 'type' => 'Point', 'coordinates' => [91,54] ], 'properties' => [ 'Name' => 'Abakan' ] ] ] ]); GeoJsonImporter::import(TestLocation::class, $json); $this->assertEquals(['Abakan' => 'SRID=4326;POINT(91 54)'], TestLocation::get()->map('Name', 'GeoLocation')->toArray()); } } |