Source of file MapFieldTest.php
Size: 1,517 Bytes - Last Modified: 2021-12-23T10:37:40+00:00
/var/www/docs.ssmods.com/process/src/tests/php/MapFieldTest.php
123456789101112131415161718192021222324252627282930313233343536373839 | <?php namespace Smindel\GIS\Tests; use SilverStripe\Dev\SapphireTest; use SilverStripe\Core\Config\Config; use Smindel\GIS\GIS; use Smindel\GIS\Forms\MapField; class MapFieldTest extends SapphireTest { public function setUp() { // reset GIS environment Config::modify()->set(GIS::class, 'default_srid', 3857); Config::modify()->set(MapField::class, 'default_location', ['lon' => 174, 'lat' => -41]); parent::setUp(); } public function testMapField() { $field = MapField::create('Location', null, GIS::create(['srid' => '2193', 'type' => 'Point', 'coordinates' => [5436343, 1760120]])) ->setControl('polyline', false) ->setControl('polygon', false) ->enableMulti(); $html = (string)$field->Field(); $this->assertRegExp('/\Wclass="map-field-widget"\W/', $html); $this->assertRegExp('/\Wdata-field="Location"\W/', $html); $this->assertRegExp('/\Wdata-default-srid="3857"\W/', $html); $this->assertRegExp('/\Wdata-multi-enabled="1"\W/', $html); $this->assertRegExp('/\Wvalue="SRID=2193;POINT\(5436343 1760120\)"\W/', $html); $this->assertRegExp('/\Wdata-controls="{"polyline":false,"polygon":false,"marker":true,"circle":false,"rectangle":false,"circlemarker":false}"\W/', $html); $this->assertRegExp('/\Wdata-default-location="\{"lon":174,"lat":-41\}"\W/', $html); } } |