- Issue created by @ekes
- 🇳🇱Netherlands ekes
Pushed an update to the test in the branch which will fail because all the computed values are loaded from the db as NULL.
It uses a reflection class to get the field values from the entity as they came from the EntityLoad without doing any field loading.
// Before accessing the entity field and incidentally trigger a calculation. $relection = new \ReflectionClass($entity); $property = $relection->getProperty('values'); $property->setAccessible(TRUE); // Retrieve the values as they came from storage. $values = $property->getValue($entity);
The first test added passes as the
$entity->geofield_field->value
does set a wkt value to thevalue
property and this is stored.// Check stored set value. $this->assertEquals($value, $values['geofield_field']['x-default'][0]['value']);
But the following tests all fail because while the property values have been loaded from the database, they are all NULL.
// Check stored computed values. $geom = \Drupal::service('geofield.geophp')->load($value); $centroid = $geom->getCentroid(); $bounding = $geom->getBBox(); $computed = []; $computed['geo_type'] = $geom->geometryType(); $computed['lon'] = $centroid->getX(); $computed['lat'] = $centroid->getY(); $computed['left'] = $bounding['minx']; $computed['top'] = $bounding['maxy']; $computed['right'] = $bounding['maxx']; $computed['bottom'] = $bounding['miny']; $computed['geohash'] = $geom->out('geohash'); foreach ($computed as $index => $computed_value) { $this->assertEquals($computed_value, $values['geofield_field']['x-default'][0][$index]); }