diff --git a/.travis.yml b/.travis.yml index 5b5e88d9..14518a32 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,11 +27,12 @@ install: composer install before_script: - mkdir -p build/logs + - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + - chmod +x ./cc-test-reporter + - ./cc-test-reporter before-build script: vendor/bin/phpunit --coverage-clover build/logs/clover.xml after_script: - php vendor/bin/coveralls -v - - vendor/bin/test-reporter - - + - ./cc-test-reporter after-build --coverage-input-type clover --exit-code $TRAVIS_TEST_RESULT diff --git a/src/Eloquent/SpatialTrait.php b/src/Eloquent/SpatialTrait.php index 54119b59..499e677a 100755 --- a/src/Eloquent/SpatialTrait.php +++ b/src/Eloquent/SpatialTrait.php @@ -95,7 +95,7 @@ public function setRawAttributes(array $attributes, $sync = false) $spatial_fields = $this->getSpatialFields(); foreach ($attributes as $attribute => &$value) { - if (in_array($attribute, $spatial_fields) && is_string($value) && strlen($value) >= 15) { + if (in_array($attribute, $spatial_fields) && is_string($value) && strlen($value) >= 13) { $value = Geometry::fromWKB($value); } } diff --git a/tests/Integration/Models/GeometryModel.php b/tests/Integration/Models/GeometryModel.php index 0b08186a..0565fd35 100644 --- a/tests/Integration/Models/GeometryModel.php +++ b/tests/Integration/Models/GeometryModel.php @@ -9,5 +9,5 @@ class GeometryModel extends Model protected $table = 'geometry'; - protected $spatialFields = ['location', 'line']; + protected $spatialFields = ['location', 'line', 'multi_geometries']; } diff --git a/tests/Integration/SpatialTest.php b/tests/Integration/SpatialTest.php index f8ebe62b..cd99ec42 100644 --- a/tests/Integration/SpatialTest.php +++ b/tests/Integration/SpatialTest.php @@ -184,6 +184,9 @@ public function testInsertEmptyGeometryCollection() $geo->multi_geometries = new GeometryCollection([]); $geo->save(); $this->assertDatabaseHas('geometry', ['id' => $geo->id]); + + $geo2 = GeometryModel::find($geo->id); + $this->assertNull($geo2->multi_geometries); // MySQL 5.6 saves null instead of empty GeometryCollection } public function testUpdate()