Skip to content

Commit df4ca79

Browse files
Support PHP 8.1, minimum to 7.3 (#20)
1 parent 839e3ba commit df4ca79

File tree

19 files changed

+61
-65
lines changed

19 files changed

+61
-65
lines changed

.dunitconfig

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
operating-system: [ubuntu-latest]
19-
# TODO: Upgrade PHPUnit to support testing on PHP 8, will require bumping minimum
20-
# php-versions: ['7.3', '7.4', '8.0']
21-
php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4']
19+
php-versions: ['7.3', '7.4', '8.0', '8.1']
2220

2321
steps:
2422
- name: Checkout

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ composer.phar
55
coverage/
66
site/
77
vendor/
8+
.phpunit.result.cache

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,16 @@
2929
"source": "https://github.com/Vectorface/snappy-router"
3030
},
3131
"require": {
32-
"php": ">=7.0.0",
32+
"php": ">=7.3.0",
3333
"vectorface/whip": "^0.4",
3434
"twig/twig": "^2.0",
3535
"nikic/fast-route":"^1.0.0",
3636
"psr/log": "^1.0",
3737
"ext-json": "*"
3838
},
3939
"require-dev": {
40-
"phpunit/phpunit": "^4.8",
41-
"squizlabs/php_codesniffer": "1.*",
42-
"vectorface/dunit": "~2.0"
40+
"phpunit/phpunit": "^9.5.10",
41+
"squizlabs/php_codesniffer": "1.*"
4342
},
4443
"scripts": {
4544
"test": [

phpunit.xml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
4-
backupGlobals="false"
5-
colors="true"
6-
bootstrap="tests/bootstrap.php">
7-
<testsuites>
8-
<testsuite name="Main suite">
9-
<directory>tests/</directory>
10-
</testsuite>
11-
</testsuites>
12-
<filter>
13-
<whitelist processUncoveredFilesFromWhitelist="true">
14-
<directory addUncoveredFilesFromWhitelist="true">./src/Vectorface/SnappyRouter</directory>
15-
</whitelist>
16-
</filter>
17-
<php>
18-
<ini name="register_argc_argv" value="On" />
19-
</php>
20-
</phpunit>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
5+
backupGlobals="false"
6+
colors="true"
7+
bootstrap="tests/bootstrap.php">
8+
<coverage/>
9+
<testsuites>
10+
<testsuite name="Main suite">
11+
<directory>tests/</directory>
12+
</testsuite>
13+
</testsuites>
14+
<php>
15+
<ini name="register_argc_argv" value="On"/>
16+
</php>
17+
</phpunit>

src/Vectorface/SnappyRouter/Config/Config.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function __construct($config)
5555
* @param string $offset The key to be checked.
5656
* @return bool Returns true if the key exists and false otherwise.
5757
*/
58+
#[\ReturnTypeWillChange]
5859
public function offsetExists($offset)
5960
{
6061
return isset($this->config[$offset]);
@@ -65,6 +66,7 @@ public function offsetExists($offset)
6566
* @param string $offset The key to be fetched.
6667
* @return bool Returns the value associated with the key or null if no value exists.
6768
*/
69+
#[\ReturnTypeWillChange]
6870
public function offsetGet($offset)
6971
{
7072
return $this->offsetExists($offset) ? $this->config[$offset] : null;
@@ -77,6 +79,7 @@ public function offsetGet($offset)
7779
* @param mixed $value The value to be set.
7880
* @throws Exception
7981
*/
82+
#[\ReturnTypeWillChange]
8083
public function offsetSet($offset, $value)
8184
{
8285
if (null === $offset) {
@@ -90,6 +93,7 @@ public function offsetSet($offset, $value)
9093
* @param string $offset The key to unset.
9194
* @return void
9295
*/
96+
#[\ReturnTypeWillChange]
9397
public function offsetUnset($offset)
9498
{
9599
unset($this->config[$offset]);

src/Vectorface/SnappyRouter/Plugin/HttpHeader/RouterHeaderPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class RouterHeaderPlugin extends AbstractPlugin
1818
*/
1919
public function afterHandlerSelected(AbstractHandler $handler)
2020
{
21-
parent::afterhandlerSelected($handler);
21+
parent::afterHandlerSelected($handler);
2222
@header('X-Router: SnappyRouter');
2323
}
2424
}

tests/Vectorface/SnappyRouterTests/Config/ConfigTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public function testSynopsis()
5555
*/
5656
public function testExceptionThrownWhenConfigIsAppended()
5757
{
58-
$this->setExpectedException(Exception::class, "Config values must contain a key.");
58+
$this->expectException(Exception::class);
59+
$this->expectExceptionMessage("Config values must contain a key.");
5960

6061
$config = new Config([]);
6162
$config[] = 'new value';

tests/Vectorface/SnappyRouterTests/Di/DiTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ public function testGetDefaultAndSetDefault()
8484
*/
8585
public function testMissingServiceThrowsException()
8686
{
87-
$this->setExpectedException(Exception::class, "No element registered for key: TestElement");
87+
$this->expectException(Exception::class);
88+
$this->expectExceptionMessage("No element registered for key: TestElement");
8889

8990
$di = new Di();
9091
$di->get('TestElement');

tests/Vectorface/SnappyRouterTests/Di/ServiceProviderTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ public function testNamespaceProvisioning()
115115
*/
116116
public function testNamespaceProvisioningMissingService()
117117
{
118-
$this->setExpectedException(Exception::class, "Controller class TestDummyController was not found in any listed namespace.");
118+
$this->expectException(Exception::class);
119+
$this->expectExceptionMessage("Controller class TestDummyController was not found in any listed namespace.");
119120

120121
$serviceProvider = new ServiceProvider([]);
121122
$serviceProvider->setNamespaces([]);
@@ -151,7 +152,8 @@ public function testFolderProvisioning()
151152
*/
152153
public function testFolderProvisioningMissingService()
153154
{
154-
$this->setExpectedException(Exception::class, "Controller class NonExistentController not found in any listed folder.");
155+
$this->expectException(Exception::class);
156+
$this->expectExceptionMessage("Controller class NonExistentController not found in any listed folder.");
155157

156158
$serviceProvider = new ServiceProvider([]);
157159
$folders = [realpath(__DIR__.'/../')];

tests/Vectorface/SnappyRouterTests/Encoder/JsonEncoderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ public function encodeProvider()
6363
*/
6464
public function testNonSerializableEncode()
6565
{
66-
$this->setExpectedException(EncoderException::class, "Unable to encode response as JSON.");
66+
$this->expectException(EncoderException::class);
67+
$this->expectExceptionMessage("Unable to encode response as JSON.");
6768

6869
$encoder = new JsonEncoder();
6970
$resource = fopen(__FILE__, 'r'); // resources can't be serialized

tests/Vectorface/SnappyRouterTests/Encoder/JsonpEncoderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public function encodeProvider()
4646
*/
4747
public function testMissingClientMethodThrowsException()
4848
{
49-
$this->setExpectedException(Exception::class, "Client method missing from plugin options.");
49+
$this->expectException(Exception::class);
50+
$this->expectExceptionMessage("Client method missing from plugin options.");
5051

5152
new JsonpEncoder([]);
5253
}

tests/Vectorface/SnappyRouterTests/Handler/ControllerHandlerTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public function testSynopsis()
7878
*/
7979
public function testRouteToNonExistentController()
8080
{
81-
$this->setExpectedException(ResourceNotFoundException::class, 'No such controller found "TestController".');
81+
$this->expectException(ResourceNotFoundException::class);
82+
$this->expectExceptionMessage('No such controller found "TestController".');
8283

8384
$options = [];
8485
$handler = new ControllerHandler($options);
@@ -96,7 +97,8 @@ public function testRouteToNonExistentController()
9697
*/
9798
public function testRouteToNonExistentControllerAction()
9899
{
99-
$this->setExpectedException(ResourceNotFoundException::class, 'TestController does not have method notexistsAction');
100+
$this->expectException(ResourceNotFoundException::class);
101+
$this->expectExceptionMessage('TestController does not have method notexistsAction');
100102

101103
$options = [
102104
Config::KEY_CONTROLLERS => [
@@ -119,7 +121,8 @@ public function testRouteToNonExistentControllerAction()
119121
*/
120122
public function testMissingClassOnPlugin()
121123
{
122-
$this->setExpectedException(PluginException::class, 'Invalid or missing class for plugin TestPlugin');
124+
$this->expectException(PluginException::class);
125+
$this->expectExceptionMessage('Invalid or missing class for plugin TestPlugin');
123126

124127
$options = [
125128
Config::KEY_PLUGINS => [
@@ -137,7 +140,8 @@ public function testMissingClassOnPlugin()
137140
*/
138141
public function testInvalidClassOnPlugin()
139142
{
140-
$this->setExpectedException(PluginException::class, 'Invalid or missing class for plugin TestPlugin');
143+
$this->expectException(PluginException::class);
144+
$this->expectExceptionMessage('Invalid or missing class for plugin TestPlugin');
141145

142146
$options = [
143147
Config::KEY_PLUGINS => [
@@ -156,7 +160,8 @@ public function testInvalidClassOnPlugin()
156160
*/
157161
public function testInvalidViewConfiguration()
158162
{
159-
$this->setExpectedException(InternalErrorException::class, 'View environment missing views path.');
163+
$this->expectException(InternalErrorException::class);
164+
$this->expectExceptionMessage('View environment missing views path.');
160165

161166
$options = [
162167
ControllerHandler::KEY_BASE_PATH => '/',
@@ -270,7 +275,8 @@ public function testActionRendersNonDefaultView()
270275
*/
271276
public function testExceptionForNullEncoderRenderView()
272277
{
273-
$this->setExpectedException(Exception::class, 'The current encoder does not support the render view method.');
278+
$this->expectException(Exception::class);
279+
$this->expectExceptionMessage('The current encoder does not support the render view method.');
274280

275281
$options = [
276282
Config::KEY_CONTROLLERS => [

tests/Vectorface/SnappyRouterTests/Handler/JsonRpcHandlerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ public function testHandleException()
176176
*/
177177
public function testServiceNotFound()
178178
{
179-
$this->setExpectedException(ResourceNotFoundException::class, "No such service: nonexistent");
179+
$this->expectException(ResourceNotFoundException::class);
180+
$this->expectExceptionMessage("No such service: nonexistent");
180181

181182
$handler = new JsonRpcHandler([]);
182183
$this->setRequestPayload($handler, ['method' => 'someMethod', 'id' => '1']);

tests/Vectorface/SnappyRouterTests/Plugin/Authentication/HttpBasicAuthenticationPluginTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace casino\Tests\engine\ServiceRouter\Plugin\Authentication;
3+
namespace Vectorface\SnappyRouterTests\Plugin\Authentication;
44

55
use PHPUnit\Framework\TestCase;
66
use Vectorface\SnappyRouter\Authentication\CallbackAuthenticator;

tests/Vectorface/SnappyRouterTests/Plugin/HttpHeader/RouterHeaderPluginTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function testSynopsis()
2323
{
2424
$handler = new ControllerHandler([]);
2525
$plugin = new RouterHeaderPlugin([]);
26-
$plugin->afterhandlerSelected($handler);
26+
$plugin->afterHandlerSelected($handler);
27+
$this->assertEquals(1000, $plugin->getExecutionOrder());
2728
}
2829
}

tests/Vectorface/SnappyRouterTests/Request/HttpRequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testInputStream()
7373
*/
7474
public function testInputStreamIncorrectTypeFailure()
7575
{
76-
$this->setExpectedException(InternalErrorException::class);
76+
$this->expectException(InternalErrorException::class);
7777

7878
$request = new HttpRequest('TestService', 'TestMethod', 'GET', 1);
7979
$request->getBody();
@@ -86,7 +86,7 @@ public function testInputStreamIncorrectTypeFailure()
8686
*/
8787
public function testInputStreamIncorrectFileFailure()
8888
{
89-
$this->setExpectedException(InternalErrorException::class);
89+
$this->expectException(InternalErrorException::class);
9090

9191
$request = new HttpRequest('TestService', 'TestMethod', 'GET', 'file');
9292
$request->getBody();

tests/Vectorface/SnappyRouterTests/SnappyRouterTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ public function testNoHandlerFoundException()
130130
*/
131131
public function testInvalidHandlerClass()
132132
{
133-
$this->setExpectedException(Exception::class, "Cannot instantiate instance of Vectorface\SnappyRouter\Handler\NonexistentHandler");
133+
$this->expectException(Exception::class);
134+
$this->expectExceptionMessage("Cannot instantiate instance of Vectorface\SnappyRouter\Handler\NonexistentHandler");
134135

135136
$config = $this->getStandardConfig();
136137
$config[Config::KEY_HANDLERS]['InvalidHandler'] = [

tests/Vectorface/SnappyRouterTests/Task/CliTaskHandlerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public function testSynopsis()
5656
*/
5757
public function testMissingActionOnTask()
5858
{
59-
$this->setExpectedException(ResourceNotFoundException::class, "TestTask task does not have action missingAction.");
59+
$this->expectException(ResourceNotFoundException::class);
60+
$this->expectExceptionMessage("TestTask task does not have action missingAction.");
6061

6162
$options = [
6263
Config::KEY_TASKS => [

0 commit comments

Comments
 (0)