Skip to content

Commit 070cfbb

Browse files
authored
Allow PHP8 & Fix PHPUnit deprecations (#146)
* Fix PHPUnit deprecations * Allow PHP8
1 parent 3823933 commit 070cfbb

30 files changed

+239
-383
lines changed

.travis.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ matrix:
1515
# Minimum supported dependencies with the latest and oldest PHP version
1616
- php: 7.3
1717
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
18-
- php: 7.4
18+
- php: 8.0
1919
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
2020

2121
# Test the latest stable release
2222
- php: 7.3
2323
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text"
2424
- php: 7.4
2525
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text"
26+
- php: 8.0
27+
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text"
2628

2729
- php: 7.3
2830
env: SYMFONY_REQUIRE="~3.4"
@@ -38,11 +40,16 @@ matrix:
3840
- php: 7.4
3941
env: SYMFONY_REQUIRE="~5.0"
4042

43+
- php: 8.0
44+
env: SYMFONY_REQUIRE="~5.0"
45+
4146
# Latest commit to master
4247
- php: 7.3
4348
env: STABILITY="dev"
4449
- php: 7.4
4550
env: STABILITY="dev"
51+
- php: 8.0
52+
env: STABILITY="dev"
4653

4754
allow_failures:
4855
# Dev-master is allowed to fail.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323

2424
"require" : {
25-
"php" : "^7.3 || ^7.4",
25+
"php" : "^7.3 || ^7.4 || ^8.0",
2626
"psr/cache" : "^1.0",
2727
"willdurand/geocoder" : "^4.2",
2828
"react/promise" : "^2.2",

tests/Batch/BatchTest.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ protected function setup(): void
6767
$this->geocoder = $this->getMockGeocoderReturns($this->providers);
6868
}
6969

70+
/**
71+
* @doesNotPerformAssertions
72+
*/
7073
public function testConstructorShouldAcceptGeocoderInterface()
7174
{
7275
new TestableBatch($this->getStubGeocoder());
@@ -113,12 +116,12 @@ public function testGeocodeShouldMadeCorrectTasksArrayToComputeWithManyValues()
113116
}
114117

115118
/**
116-
* @expectedException League\Geotools\Exception\InvalidArgumentException
117-
* @expectedExceptionMessage The argument should be a string or an array of strings to geocode.
118119
* @dataProvider invalidValuesProvider
119120
*/
120121
public function testGeocodeShouldThrowInvalidArgumentException($values)
121122
{
123+
$this->expectException(\League\Geotools\Exception\InvalidArgumentException::class);
124+
$this->expectExceptionMessage('The argument should be a string or an array of strings to geocode.');
122125
$batch = new TestableBatch($this->geocoder);
123126
$batch->geocode($values);
124127
}
@@ -168,12 +171,12 @@ public function testReverseShouldMadeCorrectTasksArrayToComputeWithManyCoordinat
168171
}
169172

170173
/**
171-
* @expectedException League\Geotools\Exception\InvalidArgumentException
172-
* @expectedExceptionMessage The argument should be a Coordinate instance or an array of Coordinate instances to reverse.
173174
* @dataProvider coordinatesProvider
174175
*/
175176
public function testReverseShouldThrowInvalidArgumentException($coordinates)
176177
{
178+
$this->expectException(\League\Geotools\Exception\InvalidArgumentException::class);
179+
$this->expectExceptionMessage('The argument should be a Coordinate instance or an array of Coordinate instances to reverse.');
177180
$batch = new TestableBatch($this->geocoder);
178181
$batch->reverse($coordinates);
179182
}
@@ -735,12 +738,10 @@ public function testBatchReverseGeocodingInParallelReturnNewGeocodedInstanceWith
735738
}
736739
}
737740

738-
/**
739-
* @expectedException RuntimeException
740-
* @expectedExceptionMessage booooooooooo!
741-
*/
742741
public function testSeriesShouldThrowException()
743742
{
743+
$this->expectException(\RuntimeException::class);
744+
$this->expectExceptionMessage('booooooooooo!');
744745
$batch = new TestableBatch($this->geocoder);
745746
$batch->setTasks($tasks = array(
746747
function () {
@@ -755,12 +756,10 @@ function () {
755756
))->geocode('foo')->serie();
756757
}
757758

758-
/**
759-
* @expectedException RuntimeException
760-
* @expectedExceptionMessage booooooooooo!
761-
*/
762759
public function testParallelShouldThrowException()
763760
{
761+
$this->expectException(\RuntimeException::class);
762+
$this->expectExceptionMessage('booooooooooo!');
764763
$called = 0;
765764

766765
$batch = new TestableBatch($this->geocoder);

tests/BoundingBox/BoundingBoxTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,34 @@ public function polygonAndExpectedNorthWestAndSouthEastCoordinates()
5050
);
5151
}
5252

53+
/**
54+
* @doesNotPerformAssertions
55+
*/
5356
public function testConstructWithPolygon()
5457
{
5558
new BoundingBox(new Polygon);
5659
}
5760

5861

62+
/**
63+
* @doesNotPerformAssertions
64+
*/
5965
public function testConstructWithCoordinate()
6066
{
6167
new BoundingBox(new Coordinate(array(0, 0)));
6268
}
6369

70+
/**
71+
* @doesNotPerformAssertions
72+
*/
6473
public function testConstructWithNull()
6574
{
6675
new BoundingBox;
6776
}
6877

69-
/**
70-
* @expectedException \InvalidArgumentException
71-
*/
7278
public function testConstructWithInvalidArgument()
7379
{
80+
$this->expectException(\InvalidArgumentException::class);
7481
new BoundingBox('string');
7582
}
7683

tests/CLI/Command/Convert/DMSTest.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,19 @@ protected function setup(): void
3434
$this->commandTester = new CommandTester($this->command);
3535
}
3636

37-
/**
38-
* @expectedException \RuntimeException
39-
* @expectedExceptionMessage Not enough arguments
40-
*/
4137
public function testExecuteWithoutArguments()
4238
{
39+
$this->expectException(\RuntimeException::class);
40+
$this->expectExceptionMessage('Not enough arguments');
4341
$this->commandTester->execute(array(
4442
'command' => $this->command->getName(),
4543
));
4644
}
4745

48-
/**
49-
* @expectedException League\Geotools\Exception\InvalidArgumentException
50-
* @expectedExceptionMessage It should be a valid and acceptable ways to write geographic coordinates !
51-
*/
5246
public function testExecuteInvalidArguments()
5347
{
48+
$this->expectException(\League\Geotools\Exception\InvalidArgumentException::class);
49+
$this->expectExceptionMessage('It should be a valid and acceptable ways to write geographic coordinates !');
5450
$this->commandTester->execute(array(
5551
'command' => $this->command->getName(),
5652
'coordinate' => 'foo, bar',
@@ -93,25 +89,21 @@ public function testExecuteWithEmptyFormatOption()
9389
$this->assertRegExp('/<value> <\/value>/', $this->commandTester->getDisplay());
9490
}
9591

96-
/**
97-
* @expectedException League\Geotools\Exception\InvalidArgumentException
98-
* @expectedExceptionMessage Please provide an ellipsoid name !
99-
*/
10092
public function testExecuteWithEmptyEllipsoidOption()
10193
{
94+
$this->expectException(\League\Geotools\Exception\InvalidArgumentException::class);
95+
$this->expectExceptionMessage('Please provide an ellipsoid name !');
10296
$this->commandTester->execute(array(
10397
'command' => $this->command->getName(),
10498
'coordinate' => '40° 26.7717, -79° 56.93172',
10599
'--ellipsoid' => ' ',
106100
));
107101
}
108102

109-
/**
110-
* @expectedException League\Geotools\Exception\InvalidArgumentException
111-
* @expectedExceptionMessage foo ellipsoid does not exist in selected reference ellipsoids !
112-
*/
113103
public function testExecuteWithoutAvailableEllipsoidOption()
114104
{
105+
$this->expectException(\League\Geotools\Exception\InvalidArgumentException::class);
106+
$this->expectExceptionMessage('foo ellipsoid does not exist in selected reference ellipsoids !');
115107
$this->commandTester->execute(array(
116108
'command' => $this->command->getName(),
117109
'coordinate' => '40° 26.7717, -79° 56.93172',

tests/CLI/Command/Convert/DMTest.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,19 @@ protected function setup(): void
3434
$this->commandTester = new CommandTester($this->command);
3535
}
3636

37-
/**
38-
* @expectedException \RuntimeException
39-
* @expectedExceptionMessage Not enough arguments
40-
*/
4137
public function testExecuteWithoutArguments()
4238
{
39+
$this->expectException(\RuntimeException::class);
40+
$this->expectExceptionMessage('Not enough arguments');
4341
$this->commandTester->execute(array(
4442
'command' => $this->command->getName(),
4543
));
4644
}
4745

48-
/**
49-
* @expectedException League\Geotools\Exception\InvalidArgumentException
50-
* @expectedExceptionMessage It should be a valid and acceptable ways to write geographic coordinates !
51-
*/
5246
public function testExecuteInvalidArguments()
5347
{
48+
$this->expectException(\League\Geotools\Exception\InvalidArgumentException::class);
49+
$this->expectExceptionMessage('It should be a valid and acceptable ways to write geographic coordinates !');
5450
$this->commandTester->execute(array(
5551
'command' => $this->command->getName(),
5652
'coordinate' => 'foo, bar',
@@ -93,25 +89,21 @@ public function testExecuteWithEmptyFormatOption()
9389
$this->assertRegExp('/<value> <\/value>/', $this->commandTester->getDisplay());
9490
}
9591

96-
/**
97-
* @expectedException League\Geotools\Exception\InvalidArgumentException
98-
* @expectedExceptionMessage Please provide an ellipsoid name !
99-
*/
10092
public function testExecuteWithEmptyEllipsoidOption()
10193
{
94+
$this->expectException(\League\Geotools\Exception\InvalidArgumentException::class);
95+
$this->expectExceptionMessage('Please provide an ellipsoid name !');
10296
$this->commandTester->execute(array(
10397
'command' => $this->command->getName(),
10498
'coordinate' => '40° 26.7717, -79° 56.93172',
10599
'--ellipsoid' => ' ',
106100
));
107101
}
108102

109-
/**
110-
* @expectedException League\Geotools\Exception\InvalidArgumentException
111-
* @expectedExceptionMessage foo ellipsoid does not exist in selected reference ellipsoids !
112-
*/
113103
public function testExecuteWithoutAvailableEllipsoidOption()
114104
{
105+
$this->expectException(\League\Geotools\Exception\InvalidArgumentException::class);
106+
$this->expectExceptionMessage('foo ellipsoid does not exist in selected reference ellipsoids !');
115107
$this->commandTester->execute(array(
116108
'command' => $this->command->getName(),
117109
'coordinate' => '40° 26.7717, -79° 56.93172',

tests/CLI/Command/Convert/UTMTest.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,19 @@ protected function setup(): void
3434
$this->commandTester = new CommandTester($this->command);
3535
}
3636

37-
/**
38-
* @expectedException \RuntimeException
39-
* @expectedExceptionMessage Not enough arguments
40-
*/
4137
public function testExecuteWithoutArguments()
4238
{
39+
$this->expectException(\RuntimeException::class);
40+
$this->expectExceptionMessage('Not enough arguments');
4341
$this->commandTester->execute(array(
4442
'command' => $this->command->getName(),
4543
));
4644
}
4745

48-
/**
49-
* @expectedException League\Geotools\Exception\InvalidArgumentException
50-
* @expectedExceptionMessage It should be a valid and acceptable ways to write geographic coordinates !
51-
*/
5246
public function testExecuteInvalidArguments()
5347
{
48+
$this->expectException(\League\Geotools\Exception\InvalidArgumentException::class);
49+
$this->expectExceptionMessage('It should be a valid and acceptable ways to write geographic coordinates !');
5450
$this->commandTester->execute(array(
5551
'command' => $this->command->getName(),
5652
'coordinate' => 'foo, bar',
@@ -68,25 +64,21 @@ public function testExecute()
6864
$this->assertRegExp('/31U 449152 5408055/', $this->commandTester->getDisplay());
6965
}
7066

71-
/**
72-
* @expectedException League\Geotools\Exception\InvalidArgumentException
73-
* @expectedExceptionMessage Please provide an ellipsoid name !
74-
*/
7567
public function testExecuteWithEmptyEllipsoidOption()
7668
{
69+
$this->expectException(\League\Geotools\Exception\InvalidArgumentException::class);
70+
$this->expectExceptionMessage('Please provide an ellipsoid name !');
7771
$this->commandTester->execute(array(
7872
'command' => $this->command->getName(),
7973
'coordinate' => '40° 26.7717, -79° 56.93172',
8074
'--ellipsoid' => ' ',
8175
));
8276
}
8377

84-
/**
85-
* @expectedException League\Geotools\Exception\InvalidArgumentException
86-
* @expectedExceptionMessage foo ellipsoid does not exist in selected reference ellipsoids !
87-
*/
8878
public function testExecuteWithoutAvailableEllipsoidOption()
8979
{
80+
$this->expectException(\League\Geotools\Exception\InvalidArgumentException::class);
81+
$this->expectExceptionMessage('foo ellipsoid does not exist in selected reference ellipsoids !');
9082
$this->commandTester->execute(array(
9183
'command' => $this->command->getName(),
9284
'coordinate' => '40° 26.7717, -79° 56.93172',

tests/CLI/Command/Distance/AllTest.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,19 @@ protected function setup(): void
3434
$this->commandTester = new CommandTester($this->command);
3535
}
3636

37-
/**
38-
* @expectedException \RuntimeException
39-
* @expectedExceptionMessage Not enough arguments
40-
*/
4137
public function testExecuteWithoutArguments()
4238
{
39+
$this->expectException(\RuntimeException::class);
40+
$this->expectExceptionMessage('Not enough arguments');
4341
$this->commandTester->execute(array(
4442
'command' => $this->command->getName(),
4543
));
4644
}
4745

48-
/**
49-
* @expectedException League\Geotools\Exception\InvalidArgumentException
50-
* @expectedExceptionMessage It should be a valid and acceptable ways to write geographic coordinates !
51-
*/
5246
public function testExecuteInvalidArguments()
5347
{
48+
$this->expectException(\League\Geotools\Exception\InvalidArgumentException::class);
49+
$this->expectExceptionMessage('It should be a valid and acceptable ways to write geographic coordinates !');
5450
$this->commandTester->execute(array(
5551
'command' => $this->command->getName(),
5652
'origin' => 'foo, bar',
@@ -136,12 +132,10 @@ public function testExecuteOutput()
136132
$this->assertSame($expected, $this->commandTester->getDisplay());
137133
}
138134

139-
/**
140-
* @expectedException League\Geotools\Exception\InvalidArgumentException
141-
* @expectedExceptionMessage Please provide an ellipsoid name !
142-
*/
143135
public function testExecuteWithEmptyEllipsoidOption()
144136
{
137+
$this->expectException(\League\Geotools\Exception\InvalidArgumentException::class);
138+
$this->expectExceptionMessage('Please provide an ellipsoid name !');
145139
$this->commandTester->execute(array(
146140
'command' => $this->command->getName(),
147141
'origin' => '40° 26.7717, -79° 56.93172',
@@ -150,12 +144,10 @@ public function testExecuteWithEmptyEllipsoidOption()
150144
));
151145
}
152146

153-
/**
154-
* @expectedException League\Geotools\Exception\InvalidArgumentException
155-
* @expectedExceptionMessage foo ellipsoid does not exist in selected reference ellipsoids !
156-
*/
157147
public function testExecuteWithoutAvailableEllipsoidOption()
158148
{
149+
$this->expectException(\League\Geotools\Exception\InvalidArgumentException::class);
150+
$this->expectExceptionMessage('foo ellipsoid does not exist in selected reference ellipsoids !');
159151
$this->commandTester->execute(array(
160152
'command' => $this->command->getName(),
161153
'origin' => '40° 26.7717, -79° 56.93172',

0 commit comments

Comments
 (0)