Skip to content

Commit 99c02b2

Browse files
authored
Merge pull request #53 from grimzy/build-fix
2 parents 78c96b5 + 4dd729d commit 99c02b2

File tree

7 files changed

+133
-62
lines changed

7 files changed

+133
-62
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ php:
55
- '5.6'
66
- '7.0'
77
- '7.1'
8+
- '7.2'
89

910
env:
1011
- MYSQL_VERSION=5.7

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"require-dev": {
1919
"phpunit/phpunit": "~4.8||~5.7",
20-
"mockery/mockery": "^1.1.0",
20+
"mockery/mockery": "^0.9.9",
2121
"laravel/laravel": "^5.2",
2222
"doctrine/dbal": "^2.5",
2323
"laravel/browser-kit-testing": "^2.0",

src/Eloquent/BaseBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Grimzy\LaravelMysqlSpatial\Eloquent;
44

5-
use Illuminate\Database\Query\Builder;
5+
use Illuminate\Database\Query\Builder as QueryBuilder;
66

7-
class BaseBuilder extends Builder
7+
class BaseBuilder extends QueryBuilder
88
{
99
protected function cleanBindings(array $bindings)
1010
{

src/MysqlConnection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function __construct($pdo, $database = '', $tablePrefix = '', array $conf
2424
'multilinestring',
2525
'multipolygon',
2626
'geometrycollection',
27+
'geomcollection',
2728
];
2829
$dbPlatform = $this->getDoctrineSchemaManager()->getDatabasePlatform();
2930
foreach ($geometries as $type) {

tests/Integration/SpatialTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ public function createApplication()
3232
$app['config']->set('database.connections.mysql.database', 'spatial_test');
3333
$app['config']->set('database.connections.mysql.username', 'root');
3434
$app['config']->set('database.connections.mysql.password', '');
35+
$app['config']->set('database.connections.mysql.modes', [
36+
'ONLY_FULL_GROUP_BY',
37+
'STRICT_TRANS_TABLES',
38+
'NO_ZERO_IN_DATE',
39+
'NO_ZERO_DATE',
40+
'ERROR_FOR_DIVISION_BY_ZERO',
41+
'NO_ENGINE_SUBSTITUTION',
42+
]);
3543

3644
return $app;
3745
}
@@ -71,7 +79,7 @@ private function isMySQL8AfterFix()
7179
$results = DB::select(DB::raw('select version()'));
7280
$mysql_version = $results[0]->{'version()'};
7381

74-
return strpos($mysql_version, '8.0.4') !== false;
82+
return version_compare($mysql_version, '8.0.4', '>=');
7583
}
7684

7785
protected function assertDatabaseHas($table, array $data, $connection = null)

tests/Unit/Eloquent/BuilderTest.php

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use BaseTestCase;
66
use Grimzy\LaravelMysqlSpatial\Eloquent\Builder;
7+
use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialExpression;
78
use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait;
89
use Grimzy\LaravelMysqlSpatial\MysqlConnection;
910
use Grimzy\LaravelMysqlSpatial\Types\LineString;
@@ -36,50 +37,39 @@ protected function setUp()
3637

3738
public function testUpdatePoint()
3839
{
39-
$this->queryBuilder
40-
->shouldReceive('raw')
41-
->with("ST_GeomFromText('POINT(2 1)')")
42-
->once();
43-
40+
$point = new Point(1, 2);
4441
$this->queryBuilder
4542
->shouldReceive('update')
43+
->with(['point' => new SpatialExpression($point)])
4644
->once();
4745

48-
$this->builder->update(['point' => new Point(1, 2)]);
46+
$this->builder->update(['point' => $point]);
4947
}
5048

5149
public function testUpdateLinestring()
5250
{
53-
$this->queryBuilder
54-
->shouldReceive('raw')
55-
->with("ST_GeomFromText('LINESTRING(0 0,1 1,2 2)')")
56-
->once();
51+
$linestring = new LineString([new Point(0, 0), new Point(1, 1), new Point(2, 2)]);
5752

5853
$this->queryBuilder
5954
->shouldReceive('update')
55+
->with(['linestring' => new SpatialExpression($linestring)])
6056
->once();
6157

62-
$linestring = new LineString([new Point(0, 0), new Point(1, 1), new Point(2, 2)]);
63-
6458
$this->builder->update(['linestring' => $linestring]);
6559
}
6660

6761
public function testUpdatePolygon()
6862
{
69-
$this->queryBuilder
70-
->shouldReceive('raw')
71-
->with("ST_GeomFromText('POLYGON((0 0,1 0),(1 0,1 1),(1 1,0 0))')")
72-
->once();
73-
74-
$this->queryBuilder
75-
->shouldReceive('update')
76-
->once();
77-
7863
$linestrings[] = new LineString([new Point(0, 0), new Point(0, 1)]);
7964
$linestrings[] = new LineString([new Point(0, 1), new Point(1, 1)]);
8065
$linestrings[] = new LineString([new Point(1, 1), new Point(0, 0)]);
8166
$polygon = new Polygon($linestrings);
8267

68+
$this->queryBuilder
69+
->shouldReceive('update')
70+
->with(['polygon' => new SpatialExpression($polygon)])
71+
->once();
72+
8373
$this->builder->update(['polygon' => $polygon]);
8474
}
8575
}

0 commit comments

Comments
 (0)