Skip to content

Commit

Permalink
Merge pull request #148 from grimzy/v4
Browse files Browse the repository at this point in the history
v4.0.0 (Laravel 8 / MySQL 8)
  • Loading branch information
grimzy authored Sep 21, 2020
2 parents 49b0daf + 2c4c671 commit f70a82e
Show file tree
Hide file tree
Showing 14 changed files with 254 additions and 70 deletions.
10 changes: 2 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
language: php

php:
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'

env:
- MYSQL_VERSION=8.0
Expand All @@ -33,7 +29,5 @@ before_script:

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

after_script:
- php vendor/bin/coveralls -v
- ./cc-test-reporter after-build --coverage-input-type clover --exit-code $TRAVIS_TEST_RESULT
after_script: ./cc-test-reporter after-build --coverage-input-type clover --exit-code $TRAVIS_TEST_RESULT

8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Please check the documentation for your MySQL version. MySQL's Extension for Spa

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

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.

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

```sh
$ composer require grimzy/laravel-mysql-spatial
$ composer require grimzy/laravel-mysql-spatial:^4.0

# or for Laravel version < 8.0
$ composer require grimzy/laravel-mysql-spatial:^3.0
```

For MySQL 5.7:
Expand Down
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@
}
],
"require": {
"php": ">=5.5.9",
"php": ">=7.3",
"ext-pdo": "*",
"ext-json": "*",
"illuminate/database": "^5.2|^6.0|^7.0",
"illuminate/database": "^8.0",
"geo-io/wkb-parser": "^1.0",
"jmikola/geojson": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.8|~5.7",
"mockery/mockery": "^0.9.9",
"laravel/laravel": "^5.2|^6.0|^7.0",
"phpunit/phpunit": "~6.5",
"laravel/laravel": "^8.0",
"doctrine/dbal": "^2.5",
"laravel/browser-kit-testing": "^2.0",
"php-coveralls/php-coveralls": "^2.0"
"mockery/mockery": "^1.3"
},
"autoload": {
"psr-4": {
Expand All @@ -43,7 +42,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
"dev-master": "4.0.x-dev"
},
"laravel": {
"providers": [
Expand Down
2 changes: 1 addition & 1 deletion src/Eloquent/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class BaseBuilder extends QueryBuilder
{
protected function cleanBindings(array $bindings)
public function cleanBindings(array $bindings)
{
$spatialBindings = [];
foreach ($bindings as &$binding) {
Expand Down
4 changes: 3 additions & 1 deletion tests/Unit/BaseTestCase.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

abstract class BaseTestCase extends PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

abstract class BaseTestCase extends TestCase
{
public function tearDown()
{
Expand Down
42 changes: 30 additions & 12 deletions tests/Unit/Eloquent/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ public function testUpdatePoint()
$this->queryBuilder
->shouldReceive('update')
->with(['point' => new SpatialExpression($point)])
->once();
->once()
->andReturn(1);

$result = $this->builder->update(['point' => $point]);

$this->builder->update(['point' => $point]);
$this->assertSame(1, $result);
}

public function testUpdateLinestring()
Expand All @@ -53,9 +56,12 @@ public function testUpdateLinestring()
$this->queryBuilder
->shouldReceive('update')
->with(['linestring' => new SpatialExpression($linestring)])
->once();
->once()
->andReturn(1);

$this->builder->update(['linestring' => $linestring]);
$result = $this->builder->update(['linestring' => $linestring]);

$this->assertSame(1, $result);
}

public function testUpdatePolygon()
Expand All @@ -68,9 +74,12 @@ public function testUpdatePolygon()
$this->queryBuilder
->shouldReceive('update')
->with(['polygon' => new SpatialExpression($polygon)])
->once();
->once()
->andReturn(1);

$result = $this->builder->update(['polygon' => $polygon]);

$this->builder->update(['polygon' => $polygon]);
$this->assertSame(1, $result);
}

public function testUpdatePointWithSrid()
Expand All @@ -79,9 +88,12 @@ public function testUpdatePointWithSrid()
$this->queryBuilder
->shouldReceive('update')
->with(['point' => new SpatialExpression($point)])
->once();
->once()
->andReturn(1);

$result = $this->builder->update(['point' => $point]);

$this->builder->update(['point' => $point]);
$this->assertSame(1, $result);
}

public function testUpdateLinestringWithSrid()
Expand All @@ -91,9 +103,12 @@ public function testUpdateLinestringWithSrid()
$this->queryBuilder
->shouldReceive('update')
->with(['linestring' => new SpatialExpression($linestring)])
->once();
->once()
->andReturn(1);

$this->builder->update(['linestring' => $linestring]);
$result = $this->builder->update(['linestring' => $linestring]);

$this->assertSame(1, $result);
}

public function testUpdatePolygonWithSrid()
Expand All @@ -106,9 +121,12 @@ public function testUpdatePolygonWithSrid()
$this->queryBuilder
->shouldReceive('update')
->with(['polygon' => new SpatialExpression($polygon)])
->once();
->once()
->andReturn(1);

$result = $this->builder->update(['polygon' => $polygon]);

$this->builder->update(['polygon' => $polygon]);
$this->assertSame(1, $result);
}
}

Expand Down
8 changes: 7 additions & 1 deletion tests/Unit/Eloquent/SpatialTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
use Grimzy\LaravelMysqlSpatial\MysqlConnection;
use Grimzy\LaravelMysqlSpatial\Types\Point;
use Illuminate\Database\Eloquent\Model;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use Mockery as m;

class SpatialTraitTest extends BaseTestCase
{
use MockeryPHPUnitIntegration;

/**
* @var TestModel
*/
Expand Down Expand Up @@ -217,7 +220,10 @@ public function testSettingRawAttributes()
public function testSpatialFieldsNotDefinedException()
{
$model = new TestNoSpatialModel();
$this->setExpectedException(SpatialFieldsNotDefinedException::class);
$this->assertException(
SpatialFieldsNotDefinedException::class,
'TestNoSpatialModel has to define $spatialFields'
);
$model->getSpatialFields();
}

Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/MysqlConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

use Grimzy\LaravelMysqlSpatial\MysqlConnection;
use Grimzy\LaravelMysqlSpatial\Schema\Builder;
use PHPUnit\Framework\TestCase;
use Stubs\PDOStub;

class MysqlConnectionTest extends PHPUnit_Framework_TestCase
class MysqlConnectionTest extends TestCase
{
private $mysqlConnection;

Expand Down
Loading

0 comments on commit f70a82e

Please sign in to comment.