Skip to content

Commit 67b7e03

Browse files
authored
Merge pull request mstaack#127 from mstaack/update-deps-and-code
Update Deps & Tests
2 parents 4109ad4 + 228e277 commit 67b7e03

14 files changed

+108
-107
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ Laravel postgis extension
22
=========================
33

44
![Build Status](https://github.com/mstaack/laravel-postgis/workflows/.github/workflows/run-tests.yml/badge.svg)
5-
[![Code Climate](https://codeclimate.com/github/mstaack/laravel-postgis/badges/gpa.svg)](https://codeclimate.com/github/mstaack/laravel-postgis)
6-
[![Coverage Status](https://coveralls.io/repos/github/mstaack/laravel-postgis/badge.svg?branch=master)](https://coveralls.io/github/mstaack/laravel-postgis?branch=master)
75

86
## Features
97

composer.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
"name": "mstaack/laravel-postgis",
33
"description": "Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models",
44
"require": {
5-
"php": ">=7.0",
5+
"php": ">=7.1",
66
"illuminate/database": "^6.0|^7.0",
77
"geo-io/wkb-parser": "^1.0",
88
"jmikola/geojson": "^1.0",
99
"bosnadev/database": "0.19.*"
1010
},
1111
"require-dev": {
12-
"phpunit/phpunit": "~4.5",
13-
"mockery/mockery": "0.9.*",
14-
"codeclimate/php-test-reporter": "~0.3",
15-
"illuminate/pagination": "^6.0|^7.0"
12+
"illuminate/pagination": "^6.0|^7.0",
13+
"phpunit/phpunit": "^8.5",
14+
"mockery/mockery": "^1.3"
1615
},
1716
"autoload": {
1817
"psr-4": {
@@ -46,5 +45,8 @@
4645
"MStaack\\LaravelPostgis\\DatabaseServiceProvider"
4746
]
4847
}
48+
},
49+
"scripts": {
50+
"test": "./vendor/bin/phpunit"
4951
}
5052
}

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
convertNoticesToExceptions="true"
88
convertWarningsToExceptions="true"
99
processIsolation="false"
10-
stopOnFailure="false"
10+
stopOnFailure="true"
1111
syntaxCheck="true"
1212
verbose="true">
1313
<testsuites>

tests/BaseTestCase.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
22

3-
abstract class BaseTestCase extends PHPUnit_Framework_TestCase
3+
use PHPUnit\Framework\TestCase;
4+
5+
abstract class BaseTestCase extends TestCase
46
{
5-
public function tearDown()
7+
protected function tearDown(): void
68
{
79
Mockery::close();
810
}

tests/Eloquent/BuilderTest.php

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ class BuilderTest extends BaseTestCase
2020
*/
2121
protected $queryBuilder;
2222

23-
protected function setUp()
23+
protected function setUp(): void
2424
{
2525
$this->queryBuilder = m::mock(QueryBuilder::class);
2626
$this->queryBuilder->makePartial();
2727

2828
$this->queryBuilder
29-
->shouldReceive('from')
30-
->andReturn($this->queryBuilder);
29+
->shouldReceive('from')
30+
->andReturn($this->queryBuilder);
3131

3232
$this->queryBuilder
33-
->shouldReceive('take')
34-
->with(1)
35-
->andReturn($this->queryBuilder);
33+
->shouldReceive('take')
34+
->with(1)
35+
->andReturn($this->queryBuilder);
3636

3737
$this->queryBuilder
38-
->shouldReceive('get')
39-
->andReturn([]);
38+
->shouldReceive('get')
39+
->andReturn([]);
4040

4141
$this->builder = new Builder($this->queryBuilder);
4242
$this->builder->setModel(new TestBuilderModel());
@@ -45,89 +45,89 @@ protected function setUp()
4545
public function testUpdate()
4646
{
4747
$this->queryBuilder
48-
->shouldReceive('raw')
49-
->with("public.ST_GeogFromText('POINT(2 1)')")
50-
->andReturn(new Expression("public.ST_GeogFromText('POINT(2 1)')"));
48+
->shouldReceive('raw')
49+
->with("public.ST_GeogFromText('POINT(2 1)')")
50+
->andReturn(new Expression("public.ST_GeogFromText('POINT(2 1)')"));
5151

5252
$this->queryBuilder
53-
->shouldReceive('update')
54-
->andReturn(1);
53+
->shouldReceive('update')
54+
->andReturn(1);
5555

5656
$builder = m::mock(Builder::class, [$this->queryBuilder])->makePartial();
5757
$builder->shouldAllowMockingProtectedMethods();
5858
$builder
59-
->shouldReceive('addUpdatedAtColumn')
60-
->andReturn(['point' => new Point(1, 2)]);
59+
->shouldReceive('addUpdatedAtColumn')
60+
->andReturn(['point' => new Point(1, 2)]);
6161

6262
$builder->update(['point' => new Point(1, 2)]);
6363
}
6464

6565
public function testUpdateLinestring()
6666
{
6767
$this->queryBuilder
68-
->shouldReceive('raw')
69-
->with("public.ST_GeogFromText('LINESTRING(0 0, 1 1, 2 2)')")
70-
->andReturn(new Expression("public.ST_GeogFromText('LINESTRING(0 0, 1 1, 2 2)')"));
68+
->shouldReceive('raw')
69+
->with("public.ST_GeogFromText('LINESTRING(0 0, 1 1, 2 2)')")
70+
->andReturn(new Expression("public.ST_GeogFromText('LINESTRING(0 0, 1 1, 2 2)')"));
7171

7272
$this->queryBuilder
73-
->shouldReceive('update')
74-
->andReturn(1);
73+
->shouldReceive('update')
74+
->andReturn(1);
7575

7676
$linestring = new LineString([new Point(0, 0), new Point(1, 1), new Point(2, 2)]);
7777

7878
$builder = m::mock(Builder::class, [$this->queryBuilder])->makePartial();
7979
$builder->shouldAllowMockingProtectedMethods();
8080
$builder
81-
->shouldReceive('addUpdatedAtColumn')
82-
->andReturn(['linestring' => $linestring]);
81+
->shouldReceive('addUpdatedAtColumn')
82+
->andReturn(['linestring' => $linestring]);
8383

8484
$builder
85-
->shouldReceive('asWKT')->with($linestring)->once();
85+
->shouldReceive('asWKT')->with($linestring)->once();
8686

8787
$builder->update(['linestring' => $linestring]);
8888
}
8989

9090
public function testUpdate3d()
9191
{
9292
$this->queryBuilder
93-
->shouldReceive('raw')
94-
->with("public.ST_GeogFromText('POINT Z(2 1 0)')")
95-
->andReturn(new Expression("public.ST_GeogFromText('POINT Z(2 1 0)')"));
93+
->shouldReceive('raw')
94+
->with("public.ST_GeogFromText('POINT Z(2 1 0)')")
95+
->andReturn(new Expression("public.ST_GeogFromText('POINT Z(2 1 0)')"));
9696

9797
$this->queryBuilder
98-
->shouldReceive('update')
99-
->andReturn(1);
98+
->shouldReceive('update')
99+
->andReturn(1);
100100

101101
$builder = m::mock(Builder::class, [$this->queryBuilder])->makePartial();
102102
$builder->shouldAllowMockingProtectedMethods();
103103
$builder
104-
->shouldReceive('addUpdatedAtColumn')
105-
->andReturn(['point' => new Point(1, 2, 0)]);
104+
->shouldReceive('addUpdatedAtColumn')
105+
->andReturn(['point' => new Point(1, 2, 0)]);
106106

107107
$builder->update(['point' => new Point(1, 2, 0)]);
108108
}
109109

110110
public function testUpdateLinestring3d()
111111
{
112112
$this->queryBuilder
113-
->shouldReceive('raw')
114-
->with("public.ST_GeogFromText('LINESTRING Z(0 0 0, 1 1 1, 2 2 2)')")
115-
->andReturn(new Expression("public.ST_GeogFromText('LINESTRING Z(0 0 0, 1 1 1, 2 2 2)')"));
113+
->shouldReceive('raw')
114+
->with("public.ST_GeogFromText('LINESTRING Z(0 0 0, 1 1 1, 2 2 2)')")
115+
->andReturn(new Expression("public.ST_GeogFromText('LINESTRING Z(0 0 0, 1 1 1, 2 2 2)')"));
116116

117117
$this->queryBuilder
118-
->shouldReceive('update')
119-
->andReturn(1);
118+
->shouldReceive('update')
119+
->andReturn(1);
120120

121121
$linestring = new LineString([new Point(0, 0, 0), new Point(1, 1, 1), new Point(2, 2, 2)]);
122122

123123
$builder = m::mock(Builder::class, [$this->queryBuilder])->makePartial();
124124
$builder->shouldAllowMockingProtectedMethods();
125125
$builder
126-
->shouldReceive('addUpdatedAtColumn')
127-
->andReturn(['linestring' => $linestring]);
126+
->shouldReceive('addUpdatedAtColumn')
127+
->andReturn(['linestring' => $linestring]);
128128

129129
$builder
130-
->shouldReceive('asWKT')->with($linestring)->once();
130+
->shouldReceive('asWKT')->with($linestring)->once();
131131

132132
$builder->update(['linestring' => $linestring]);
133133
}
@@ -138,8 +138,8 @@ class TestBuilderModel extends Model
138138
use PostgisTrait;
139139

140140
protected $postgisFields = [
141-
'point' => Point::class,
142-
'linestring' => LineString::class,
143-
'polygon' => Polygon::class
141+
'point' => Point::class,
142+
'linestring' => LineString::class,
143+
'polygon' => Polygon::class
144144
];
145145
}

tests/Eloquent/PostgisTraitTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ class PostgisTraitTest extends BaseTestCase
1818
*/
1919
protected $queries;
2020

21-
public function setUp()
21+
public function setUp(): void
2222
{
2323
$this->model = new TestModel();
2424
$this->queries = &$this->model->getConnection()->getPdo()->queries;
2525
}
2626

27-
public function tearDown()
27+
public function tearDown(): void
2828
{
2929
$this->model->getConnection()->getPdo()->resetQueries();
3030
}
@@ -34,15 +34,15 @@ public function testInsertPointHasCorrectSql()
3434
$this->model->point = new Point(1, 2);
3535
$this->model->save();
3636

37-
$this->assertContains("public.ST_GeogFromText('POINT(2 1)')", $this->queries[0]);
37+
$this->assertStringContainsString("public.ST_GeogFromText('POINT(2 1)')", $this->queries[0]);
3838
}
3939

4040
public function testInsertPointGeometryHasCorrectSql()
4141
{
4242
$this->model->point2 = new Point(1, 2);
4343
$this->model->save();
4444

45-
$this->assertContains("public.ST_GeomFromText('POINT(2 1)', '27700')", $this->queries[0]);
45+
$this->assertStringContainsString("public.ST_GeomFromText('POINT(2 1)', '27700')", $this->queries[0]);
4646
}
4747

4848
public function testUpdatePointHasCorrectSql()
@@ -51,23 +51,23 @@ public function testUpdatePointHasCorrectSql()
5151
$this->model->point = new Point(2, 4);
5252
$this->model->save();
5353

54-
$this->assertContains("public.ST_GeogFromText('POINT(4 2)')", $this->queries[0]);
54+
$this->assertStringContainsString("public.ST_GeogFromText('POINT(4 2)')", $this->queries[0]);
5555
}
5656

5757
public function testInsertPoint3dHasCorrectSql()
5858
{
5959
$this->model->point = new Point(1, 2, 3);
6060
$this->model->save();
6161

62-
$this->assertContains("public.ST_GeogFromText('POINT Z(2 1 3)')", $this->queries[0]);
62+
$this->assertStringContainsString("public.ST_GeogFromText('POINT Z(2 1 3)')", $this->queries[0]);
6363
}
6464

6565
public function testInsertPoint3dGeometryHasCorrectSql()
6666
{
6767
$this->model->point2 = new Point(1, 2, 3);
6868
$this->model->save();
6969

70-
$this->assertContains("public.ST_GeomFromText('POINT Z(2 1 3)', '27700')", $this->queries[0]);
70+
$this->assertStringContainsString("public.ST_GeomFromText('POINT Z(2 1 3)', '27700')", $this->queries[0]);
7171
}
7272

7373
public function testUpdatePoint3dHasCorrectSql()
@@ -76,7 +76,7 @@ public function testUpdatePoint3dHasCorrectSql()
7676
$this->model->point = new Point(2, 4, 6);
7777
$this->model->save();
7878

79-
$this->assertContains("public.ST_GeogFromText('POINT Z(4 2 6)')", $this->queries[0]);
79+
$this->assertStringContainsString("public.ST_GeogFromText('POINT Z(4 2 6)')", $this->queries[0]);
8080
}
8181
}
8282

tests/Geometries/GeometryCollectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class GeometryCollectionTest extends BaseTestCase
1212
private $collection;
1313
private $collection3d;
1414

15-
protected function setUp()
15+
protected function setUp(): void
1616
{
1717
$collection = new LineString(
1818
[

tests/Geometries/LineStringTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class LineStringTest extends BaseTestCase
88
private $points;
99
private $points3d;
1010

11-
protected function setUp()
11+
protected function setUp(): void
1212
{
1313
$this->points = [new Point(1, 1), new Point(2, 2), new Point(3, 3)];
1414
$this->points3d = [new Point(1, 1, 1), new Point(2, 2, 2), new Point(3, 3, 3)];

tests/Geometries/MultiPolygonTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class MultiPolygonTest extends BaseTestCase
1313
private $multiPolygon;
1414
private $multiPolygon3d;
1515

16-
protected function setUp()
16+
protected function setUp(): void
1717
{
1818
$collection1 = new LineString(
1919
[

tests/Geometries/PolygonTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class PolygonTest extends BaseTestCase
99
private $polygon;
1010
private $polygon3d;
1111

12-
protected function setUp()
12+
protected function setUp(): void
1313
{
1414
$collection = new LineString(
1515
[

tests/Geometries/UnderLocaleTest.php

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

3-
use MStaack\LaravelPostgis\Geometries\Point;
4-
use MStaack\LaravelPostgis\Geometries\MultiPoint;
3+
use MStaack\LaravelPostgis\Geometries\GeometryCollection;
54
use MStaack\LaravelPostgis\Geometries\LineString;
65
use MStaack\LaravelPostgis\Geometries\MultiLineString;
7-
use MStaack\LaravelPostgis\Geometries\Polygon;
6+
use MStaack\LaravelPostgis\Geometries\MultiPoint;
87
use MStaack\LaravelPostgis\Geometries\MultiPolygon;
9-
use MStaack\LaravelPostgis\Geometries\GeometryCollection;
8+
use MStaack\LaravelPostgis\Geometries\Point;
9+
use MStaack\LaravelPostgis\Geometries\Polygon;
1010

1111
class UnderLocaleTest extends BaseTestCase
1212
{
1313

14-
public static function setUpBeforeClass()
14+
public static function setUpBeforeClass(): void
1515
{
1616
setlocale(LC_NUMERIC, 'fr_FR.utf-8');
1717
}
1818

19-
public static function tearDownAfterClass()
19+
public static function tearDownAfterClass(): void
2020
{
2121
setlocale(LC_NUMERIC, null);
2222
}
2323

24-
public function setUp()
24+
public function setUp(): void
2525
{
26-
if(localeconv()['decimal_point'] == '.') {
26+
if (localeconv()['decimal_point'] == '.') {
2727
$this->markTestSkipped('The locale is not available for testing float output formatting');
2828
}
2929
}

tests/PostgisConnectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
use MStaack\LaravelPostgis\Schema\Builder;
55
use Stubs\PDOStub;
66

7-
class PostgisConnectionTest extends PHPUnit_Framework_TestCase
7+
class PostgisConnectionTest extends BaseTestCase
88
{
99
private $postgisConnection;
1010

11-
protected function setUp()
11+
protected function setUp(): void
1212
{
1313
$pgConfig = ['driver' => 'pgsql', 'prefix' => 'prefix', 'database' => 'database', 'name' => 'foo'];
1414
$this->postgisConnection = new PostgisConnection(new PDOStub(), 'database', 'prefix', $pgConfig);

tests/Schema/BlueprintTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class BlueprintTest extends BaseTestCase
88
{
99
protected $blueprint;
1010

11-
public function setUp()
11+
public function setUp(): void
1212
{
1313
parent::setUp();
1414

0 commit comments

Comments
 (0)