Skip to content

Commit

Permalink
patches for laravel 10x compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Feb 6, 2024
1 parent f55bea7 commit 72bb675
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fleetbase/laravel-mysql-spatial",
"description": "MySQL spatial data types extension for Laravel x Fleetbase.",
"version": "1.0.1",
"version": "1.0.2",
"scripts": {
"test": "phpunit -c phpunit.xml.dist",
"test:unit": "phpunit -c phpunit.xml.dist --testsuite unit",
Expand Down
3 changes: 2 additions & 1 deletion src/Eloquent/SpatialExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

class SpatialExpression extends Expression
{
public function getValue()
#[\ReturnTypeWillChange]
public function getValue($grammar)
{
return "ST_GeomFromText(?, ?, 'axis-order=long-lat')";
}
Expand Down
5 changes: 5 additions & 0 deletions src/SpatialServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public function register()
return new DatabaseManager($app, $app['db.factory']);
});

// Bind for database schema
$this->app->bind('db.schema', function ($app) {
return $app['db']->connection()->getSchemaBuilder();
});

if (class_exists(DoctrineType::class)) {
// Prevent geometry type fields from throwing a 'type not found' error when changing them
$geometries = [
Expand Down
7 changes: 4 additions & 3 deletions tests/Integration/IntegrationBaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function createApplication()
*
* @return void
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand All @@ -59,7 +59,7 @@ public function setUp()
//});
}

public function tearDown()
public function tearDown(): void
{
$this->onMigrations(function ($migrationClass) {
(new $migrationClass())->down();
Expand All @@ -71,7 +71,8 @@ public function tearDown()
// MySQL 8.0.4 fixed bug #26941370 and bug #88031
private function isMySQL8AfterFix()
{
$results = DB::select(DB::raw('select version()'));
$expression = DB::raw('select version()');
$results = DB::select($expression->getValue(DB::connection()->getQueryGrammar()));
$mysql_version = $results[0]->{'version()'};

return version_compare($mysql_version, '8.0.4', '>=');
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

abstract class BaseTestCase extends TestCase
{
public function tearDown()
public function tearDown(): void
{
Mockery::close();
}
Expand Down
6 changes: 4 additions & 2 deletions tests/Unit/Eloquent/SpatialTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class SpatialTraitTest extends BaseTestCase
*/
protected $queries;

public function setUp()
public function setUp(): void
{
$this->model = new TestModel();
$this->queries = &$this->model->getConnection()->getPdo()->queries;
}

public function tearDown()
public function tearDown(): void
{
$this->model->getConnection()->getPdo()->resetQueries();
}
Expand Down Expand Up @@ -580,6 +580,7 @@ class TestPDO extends PDO

public $counter = 1;

#[\ReturnTypeWillChange]
public function prepare($statement, $driver_options = [])
{
$this->queries[] = $statement;
Expand All @@ -593,6 +594,7 @@ public function prepare($statement, $driver_options = [])
return $stmt;
}

#[\ReturnTypeWillChange]
public function lastInsertId($name = null)
{
return $this->counter++;
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/MysqlConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MysqlConnectionTest extends TestCase
{
private $mysqlConnection;

protected function setUp()
protected function setUp(): void
{
$mysqlConfig = ['driver' => 'mysql', 'prefix' => 'prefix', 'database' => 'database', 'name' => 'foo'];
$this->mysqlConnection = new MysqlConnection(new PDOStub(), 'database', 'prefix', $mysqlConfig);
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Schema/BlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BlueprintTest extends BaseTestCase
*/
protected $blueprint;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Types/LineStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class LineStringTest extends BaseTestCase
{
private $points;

protected function setUp()
protected function setUp(): void
{
$this->points = [new Point(0, 0), new Point(1, 1), new Point(2, 2)];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Types/PolygonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PolygonTest extends BaseTestCase
{
private $polygon;

protected function setUp()
protected function setUp(): void
{
$collection = new LineString(
[
Expand Down

0 comments on commit 72bb675

Please sign in to comment.