public function testSerialization() { $geometry = $this->getMockGeometry(); $geometry->expects($this->any())->method('jsonSerialize')->will($this->returnValue('geometry')); $properties = array('key' => 'value'); $id = 'identifier'; $feature = new Feature($geometry, $properties, $id); $expected = array('type' => 'Feature', 'geometry' => 'geometry', 'properties' => $properties, 'id' => 'identifier'); $this->assertSame('Feature', $feature->getType()); $this->assertSame($geometry, $feature->getGeometry()); $this->assertSame($id, $feature->getId()); $this->assertSame($properties, $feature->getProperties()); $this->assertSame($expected, $feature->jsonSerialize()); }
/** * Save a new model and return the instance. * * @param array $attributes * @return static */ public static function createFromFeature(Feature $feature, array $attributes = []) { $instance = new static(); $properties = [$instance->getPropertiesField() => array_filter($feature->getAllProperties()), $instance->getGeometryField() => $feature->getGeometry()]; $attributes = array_merge($attributes, $properties); return parent::create($attributes); }