Skip to content

Commit f70a82e

Browse files
authored
Merge pull request #148 from grimzy/v4
v4.0.0 (Laravel 8 / MySQL 8)
2 parents 49b0daf + 2c4c671 commit f70a82e

14 files changed

+254
-70
lines changed

.travis.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
language: php
22

33
php:
4-
- '5.5'
5-
- '5.6'
6-
- '7.0'
7-
- '7.1'
8-
- '7.2'
94
- '7.3'
5+
- '7.4'
106

117
env:
128
- MYSQL_VERSION=8.0
@@ -33,7 +29,5 @@ before_script:
3329

3430
script: vendor/bin/phpunit --coverage-clover build/logs/clover.xml
3531

36-
after_script:
37-
- php vendor/bin/coveralls -v
38-
- ./cc-test-reporter after-build --coverage-input-type clover --exit-code $TRAVIS_TEST_RESULT
32+
after_script: ./cc-test-reporter after-build --coverage-input-type clover --exit-code $TRAVIS_TEST_RESULT
3933

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Please check the documentation for your MySQL version. MySQL's Extension for Spa
1414

1515
- `1.x.x`: MySQL 5.6 (also supports MySQL 5.5 but not all spatial analysis functions)
1616
- `2.x.x`: MySQL 5.7
17-
- **`3.x.x`: MySQL 8.0 with SRID support (Current branch)**
17+
- `3.x.x`: MySQL 8.0 with SRID support (Laravel version < 8.0)
18+
- **`4.x.x`: MySQL 8.0 with SRID support (Laravel 8+) [Current branch]**
1819

1920
This package also works with MariaDB. Please refer to the [MySQL/MariaDB Spatial Support Matrix](https://mariadb.com/kb/en/library/mysqlmariadb-spatial-support-matrix/) for compatibility.
2021

@@ -23,7 +24,10 @@ This package also works with MariaDB. Please refer to the [MySQL/MariaDB Spatial
2324
Add the package using composer:
2425

2526
```sh
26-
$ composer require grimzy/laravel-mysql-spatial
27+
$ composer require grimzy/laravel-mysql-spatial:^4.0
28+
29+
# or for Laravel version < 8.0
30+
$ composer require grimzy/laravel-mysql-spatial:^3.0
2731
```
2832

2933
For MySQL 5.7:

composer.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,19 @@
1515
}
1616
],
1717
"require": {
18-
"php": ">=5.5.9",
18+
"php": ">=7.3",
1919
"ext-pdo": "*",
2020
"ext-json": "*",
21-
"illuminate/database": "^5.2|^6.0|^7.0",
21+
"illuminate/database": "^8.0",
2222
"geo-io/wkb-parser": "^1.0",
2323
"jmikola/geojson": "^1.0"
2424
},
2525
"require-dev": {
26-
"phpunit/phpunit": "~4.8|~5.7",
27-
"mockery/mockery": "^0.9.9",
28-
"laravel/laravel": "^5.2|^6.0|^7.0",
26+
"phpunit/phpunit": "~6.5",
27+
"laravel/laravel": "^8.0",
2928
"doctrine/dbal": "^2.5",
3029
"laravel/browser-kit-testing": "^2.0",
31-
"php-coveralls/php-coveralls": "^2.0"
30+
"mockery/mockery": "^1.3"
3231
},
3332
"autoload": {
3433
"psr-4": {
@@ -43,7 +42,7 @@
4342
},
4443
"extra": {
4544
"branch-alias": {
46-
"dev-master": "3.0.x-dev"
45+
"dev-master": "4.0.x-dev"
4746
},
4847
"laravel": {
4948
"providers": [

src/Eloquent/BaseBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class BaseBuilder extends QueryBuilder
88
{
9-
protected function cleanBindings(array $bindings)
9+
public function cleanBindings(array $bindings)
1010
{
1111
$spatialBindings = [];
1212
foreach ($bindings as &$binding) {

tests/Unit/BaseTestCase.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
abstract class BaseTestCase extends PHPUnit_Framework_TestCase
3+
use PHPUnit\Framework\TestCase;
4+
5+
abstract class BaseTestCase extends TestCase
46
{
57
public function tearDown()
68
{

tests/Unit/Eloquent/BuilderTest.php

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ public function testUpdatePoint()
4141
$this->queryBuilder
4242
->shouldReceive('update')
4343
->with(['point' => new SpatialExpression($point)])
44-
->once();
44+
->once()
45+
->andReturn(1);
46+
47+
$result = $this->builder->update(['point' => $point]);
4548

46-
$this->builder->update(['point' => $point]);
49+
$this->assertSame(1, $result);
4750
}
4851

4952
public function testUpdateLinestring()
@@ -53,9 +56,12 @@ public function testUpdateLinestring()
5356
$this->queryBuilder
5457
->shouldReceive('update')
5558
->with(['linestring' => new SpatialExpression($linestring)])
56-
->once();
59+
->once()
60+
->andReturn(1);
5761

58-
$this->builder->update(['linestring' => $linestring]);
62+
$result = $this->builder->update(['linestring' => $linestring]);
63+
64+
$this->assertSame(1, $result);
5965
}
6066

6167
public function testUpdatePolygon()
@@ -68,9 +74,12 @@ public function testUpdatePolygon()
6874
$this->queryBuilder
6975
->shouldReceive('update')
7076
->with(['polygon' => new SpatialExpression($polygon)])
71-
->once();
77+
->once()
78+
->andReturn(1);
79+
80+
$result = $this->builder->update(['polygon' => $polygon]);
7281

73-
$this->builder->update(['polygon' => $polygon]);
82+
$this->assertSame(1, $result);
7483
}
7584

7685
public function testUpdatePointWithSrid()
@@ -79,9 +88,12 @@ public function testUpdatePointWithSrid()
7988
$this->queryBuilder
8089
->shouldReceive('update')
8190
->with(['point' => new SpatialExpression($point)])
82-
->once();
91+
->once()
92+
->andReturn(1);
93+
94+
$result = $this->builder->update(['point' => $point]);
8395

84-
$this->builder->update(['point' => $point]);
96+
$this->assertSame(1, $result);
8597
}
8698

8799
public function testUpdateLinestringWithSrid()
@@ -91,9 +103,12 @@ public function testUpdateLinestringWithSrid()
91103
$this->queryBuilder
92104
->shouldReceive('update')
93105
->with(['linestring' => new SpatialExpression($linestring)])
94-
->once();
106+
->once()
107+
->andReturn(1);
95108

96-
$this->builder->update(['linestring' => $linestring]);
109+
$result = $this->builder->update(['linestring' => $linestring]);
110+
111+
$this->assertSame(1, $result);
97112
}
98113

99114
public function testUpdatePolygonWithSrid()
@@ -106,9 +121,12 @@ public function testUpdatePolygonWithSrid()
106121
$this->queryBuilder
107122
->shouldReceive('update')
108123
->with(['polygon' => new SpatialExpression($polygon)])
109-
->once();
124+
->once()
125+
->andReturn(1);
126+
127+
$result = $this->builder->update(['polygon' => $polygon]);
110128

111-
$this->builder->update(['polygon' => $polygon]);
129+
$this->assertSame(1, $result);
112130
}
113131
}
114132

tests/Unit/Eloquent/SpatialTraitTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
use Grimzy\LaravelMysqlSpatial\MysqlConnection;
55
use Grimzy\LaravelMysqlSpatial\Types\Point;
66
use Illuminate\Database\Eloquent\Model;
7+
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
78
use Mockery as m;
89

910
class SpatialTraitTest extends BaseTestCase
1011
{
12+
use MockeryPHPUnitIntegration;
13+
1114
/**
1215
* @var TestModel
1316
*/
@@ -217,7 +220,10 @@ public function testSettingRawAttributes()
217220
public function testSpatialFieldsNotDefinedException()
218221
{
219222
$model = new TestNoSpatialModel();
220-
$this->setExpectedException(SpatialFieldsNotDefinedException::class);
223+
$this->assertException(
224+
SpatialFieldsNotDefinedException::class,
225+
'TestNoSpatialModel has to define $spatialFields'
226+
);
221227
$model->getSpatialFields();
222228
}
223229

tests/Unit/MysqlConnectionTest.php

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

33
use Grimzy\LaravelMysqlSpatial\MysqlConnection;
44
use Grimzy\LaravelMysqlSpatial\Schema\Builder;
5+
use PHPUnit\Framework\TestCase;
56
use Stubs\PDOStub;
67

7-
class MysqlConnectionTest extends PHPUnit_Framework_TestCase
8+
class MysqlConnectionTest extends TestCase
89
{
910
private $mysqlConnection;
1011

0 commit comments

Comments
 (0)