Skip to content

Commit e62eafe

Browse files
authored
Support Laravel 10 (animalife#1)
Co-authored-by: Tsuguya Toma <[email protected]>
1 parent e4f1065 commit e62eafe

File tree

9 files changed

+40
-24
lines changed

9 files changed

+40
-24
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
ini-file: development
2828
tools: composer:v2
2929
extensions: mbstring, dom, fileinfo, pdo, pcntl
30-
coverage: none
30+
coverage: xdebug
3131
- run: composer install
3232
- name: run test
3333
run: vendor/bin/phpunit

composer.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
}
1616
],
1717
"require": {
18-
"php": "^8.0",
18+
"php": "^8.1",
1919
"ext-pdo": "*",
2020
"ext-json": "*",
21-
"illuminate/database": "^9.0",
21+
"illuminate/database": "^10.0",
2222
"geo-io/wkb-parser": "^1.0",
2323
"jmikola/geojson": "^1.0"
2424
},
2525
"require-dev": {
26-
"phpunit/phpunit": "^9.5.10",
27-
"laravel/laravel": "^9.0",
26+
"phpunit/phpunit": "^10.0",
27+
"laravel/laravel": "^10.0",
2828
"doctrine/dbal": "^3.3",
29-
"laravel/browser-kit-testing": "^6.3",
29+
"laravel/browser-kit-testing": "^7.0",
3030
"mockery/mockery": "^1.4.4"
3131
},
3232
"autoload": {

phpunit.xml.dist

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="./vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<coverage processUncoveredFiles="true">
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
backupGlobals="false"
5+
bootstrap="./vendor/autoload.php"
6+
colors="true"
7+
processIsolation="false"
8+
stopOnFailure="false"
9+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
10+
cacheDirectory=".phpunit.cache"
11+
backupStaticProperties="false"
12+
displayDetailsOnTestsThatTriggerDeprecations="true"
13+
>
14+
<coverage>
415
<include>
516
<directory suffix=".php">./src</directory>
617
</include>
@@ -16,10 +27,6 @@
1627
<directory suffix="Test.php">./tests/Integration</directory>
1728
</testsuite>
1829
</testsuites>
19-
<listeners>
20-
<listener class="\Mockery\Adapter\Phpunit\TestListener" file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php">
21-
</listener>
22-
</listeners>
2330
<logging/>
2431
<php>
2532
<env name="APP_ENV" value="testing"/>

src/Eloquent/SpatialExpression.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
namespace Grimzy\LaravelMysqlSpatial\Eloquent;
44

5+
use Illuminate\Database\Grammar;
56
use Illuminate\Database\Query\Expression;
67

78
class SpatialExpression extends Expression
89
{
9-
public function getValue()
10+
public function getValue(Grammar $grammar)
1011
{
1112
return "ST_GeomFromText(?, ?, 'axis-order=long-lat')";
1213
}

tests/Integration/IntegrationBaseTestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function tearDown(): void
7171
// MySQL 8.0.4 fixed bug #26941370 and bug #88031
7272
private function isMySQL8AfterFix()
7373
{
74-
$results = DB::select(DB::raw('select version()'));
74+
$results = DB::select('select version()');
7575
$mysql_version = $results[0]->{'version()'};
7676

7777
return version_compare($mysql_version, '8.0.4', '>=');

tests/Integration/SridSpatialTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ public function testInsertPointWithWrongSrid()
113113
'does not match the SRID of the column \'location\'. The SRID '.
114114
'of the geometry is 0, but the SRID of the column is 3857. '.
115115
'Consider changing the SRID of the geometry or the SRID property '.
116-
'of the column. (SQL: insert into `with_srid` (`location`) values '.
117-
'(ST_GeomFromText(POINT(2 1), 0, \'axis-order=long-lat\')))'
116+
'of the column. (Connection: mysql, SQL: insert into `with_srid` '.
117+
'(`location`) values (ST_GeomFromText(POINT(2 1), 0, '.
118+
'\'axis-order=long-lat\')))'
118119
);
119120
$geo->save();
120121
}

tests/Unit/Connectors/ConnectionFactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Illuminate\Container\Container;
66
use Stubs\PDOStub;
77

8-
class ConnectionFactoryBaseTest extends BaseTestCase
8+
class ConnectionFactoryTest extends BaseTestCase
99
{
1010
public function testMakeCallsCreateConnection()
1111
{

tests/Unit/Eloquent/SpatialTraitTest.php

+13-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use Grimzy\LaravelMysqlSpatial\MysqlConnection;
55
use Grimzy\LaravelMysqlSpatial\Types\Point;
66
use Illuminate\Database\Eloquent\Model;
7+
use Illuminate\Database\Grammar;
78
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
89
use Mockery as m;
910

@@ -14,17 +15,23 @@ class SpatialTraitTest extends BaseTestCase
1415
/**
1516
* @var TestModel
1617
*/
17-
protected $model;
18+
protected TestModel $model;
1819

1920
/**
2021
* @var array
2122
*/
22-
protected $queries;
23+
protected array $queries;
24+
25+
/**
26+
* @var Grammar
27+
*/
28+
protected Grammar $grammar;
2329

2430
public function setUp(): void
2531
{
2632
$this->model = new TestModel();
2733
$this->queries = &$this->model->getConnection()->getPdo()->queries;
34+
$this->grammar = $this->model->getConnection()->getQueryGrammar();
2835
}
2936

3037
public function tearDown(): void
@@ -303,7 +310,7 @@ public function testScopeDistanceValue()
303310
$this->assertNotEmpty($bindings);
304311
$this->assertEquals('*', $q->columns[0]);
305312
$this->assertInstanceOf(\Illuminate\Database\Query\Expression::class, $q->columns[1]);
306-
$this->assertEquals('st_distance(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat\')) as distance', $q->columns[1]->getValue());
313+
$this->assertEquals('st_distance(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat\')) as distance', $q->columns[1]->getValue($this->grammar));
307314
$this->assertEquals('POINT(2 1)', $bindings[0]);
308315
}
309316

@@ -319,7 +326,7 @@ public function testScopeDistanceValueWithSelect()
319326
$this->assertNotEmpty($bindings);
320327
$this->assertEquals('some_column', $q->columns[0]);
321328
$this->assertInstanceOf(\Illuminate\Database\Query\Expression::class, $q->columns[1]);
322-
$this->assertEquals('st_distance(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat\')) as distance', $q->columns[1]->getValue());
329+
$this->assertEquals('st_distance(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat\')) as distance', $q->columns[1]->getValue($this->grammar));
323330
$this->assertEquals('POINT(2 1)', $bindings[0]);
324331
}
325332

@@ -335,7 +342,7 @@ public function testScopeDistanceSphereValue()
335342
$this->assertNotEmpty($bindings);
336343
$this->assertEquals('*', $q->columns[0]);
337344
$this->assertInstanceOf(\Illuminate\Database\Query\Expression::class, $q->columns[1]);
338-
$this->assertEquals('st_distance_sphere(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat\')) as distance', $q->columns[1]->getValue());
345+
$this->assertEquals('st_distance_sphere(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat\')) as distance', $q->columns[1]->getValue($this->grammar));
339346
$this->assertEquals('POINT(2 1)', $bindings[0]);
340347
}
341348

@@ -351,7 +358,7 @@ public function testScopeDistanceSphereValueWithSelect()
351358
$this->assertNotEmpty($bindings);
352359
$this->assertEquals('some_column', $q->columns[0]);
353360
$this->assertInstanceOf(\Illuminate\Database\Query\Expression::class, $q->columns[1]);
354-
$this->assertEquals('st_distance_sphere(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat\')) as distance', $q->columns[1]->getValue());
361+
$this->assertEquals('st_distance_sphere(`point`, ST_GeomFromText(?, ?, \'axis-order=long-lat\')) as distance', $q->columns[1]->getValue($this->grammar));
355362
$this->assertEquals('POINT(2 1)', $bindings[0]);
356363
}
357364

tests/Unit/Schema/Grammars/MySqlGrammarTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Grimzy\LaravelMysqlSpatial\Schema\Blueprint;
55
use Grimzy\LaravelMysqlSpatial\Schema\Grammars\MySqlGrammar;
66

7-
class MySqlGrammarBaseTest extends BaseTestCase
7+
class MySqlGrammarTest extends BaseTestCase
88
{
99
public function testAddingGeometry()
1010
{

0 commit comments

Comments
 (0)