Skip to content

Commit 60254fc

Browse files
authored
chore: migrate tests, drop support for PHP 7.0 and below (#1018)
1 parent 5a0c800 commit 60254fc

File tree

15 files changed

+191
-234
lines changed

15 files changed

+191
-234
lines changed

.github/workflows/tests.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Test Suite
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
services:
11+
redis:
12+
image: redis
13+
ports:
14+
- 6379:6379
15+
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
16+
mongodb:
17+
image: mongo
18+
ports:
19+
- 27017:27017
20+
myriadb:
21+
image: mariadb
22+
env:
23+
MYSQL_ROOT_PASSWORD: root
24+
ports:
25+
- 3808:3808
26+
- 3306:3306
27+
postgres:
28+
image: postgres
29+
env:
30+
POSTGRES_DB: oauth2_server_php
31+
POSTGRES_USER: postgres
32+
POSTGRES_PASSWORD: postgres
33+
ports:
34+
- 5432:5432
35+
options: --health-cmd="pg_isready -h localhost" --health-interval=10s --health-timeout=5s --health-retries=5
36+
strategy:
37+
matrix:
38+
php: [ 7.1, 7.2, 7.3, 7.4, "8.0", 8.1 ]
39+
name: "PHP ${{ matrix.php }} Unit Test"
40+
steps:
41+
- uses: actions/checkout@v2
42+
- uses: codecov/codecov-action@v1
43+
- name: Setup PHP
44+
uses: shivammathur/setup-php@v2
45+
with:
46+
php-version: ${{ matrix.php }}
47+
extensions: mongodb, mbstring, intl, redis, pdo_mysql
48+
- name: Install composer dependencies
49+
uses: nick-invision/retry@v1
50+
with:
51+
timeout_minutes: 10
52+
max_attempts: 3
53+
command: composer install
54+
- name: Run PHPUnit
55+
run: vendor/bin/phpunit -v

.travis.yml

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

composer.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@
1616
"psr-0": { "OAuth2": "src/" }
1717
},
1818
"require":{
19-
"php":">=5.3.9"
19+
"php":">=7.1"
2020
},
2121
"require-dev": {
22-
"phpunit/phpunit": "^4.0",
23-
"aws/aws-sdk-php": "~2.8",
24-
"firebase/php-jwt": "~2.2",
25-
"predis/predis": "dev-master",
22+
"phpunit/phpunit": "^7.5||^8.0",
23+
"aws/aws-sdk-php": "^2.8",
24+
"firebase/php-jwt": "^2.2",
25+
"predis/predis": "^1.1",
2626
"thobbs/phpcassa": "dev-master",
27-
"mongodb/mongodb": "^1.1"
27+
"mongodb/mongodb": "^1.1",
28+
"yoast/phpunit-polyfills": "^1.0"
2829
},
2930
"suggest": {
3031
"predis/predis": "Required to use Redis storage",

test/OAuth2/Controller/AuthorizeControllerTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function testDoNotEnforceState()
133133
$server->handleAuthorizeRequest($request, $response = new Response(), true);
134134

135135
$this->assertEquals($response->getStatusCode(), 302);
136-
$this->assertNotContains('error', $response->getHttpHeader('Location'));
136+
$this->assertStringNotContainsString('error', $response->getHttpHeader('Location'));
137137
}
138138

139139
public function testEnforceScope()
@@ -161,7 +161,7 @@ public function testEnforceScope()
161161
$server->handleAuthorizeRequest($request, $response = new Response(), true);
162162

163163
$this->assertEquals($response->getStatusCode(), 302);
164-
$this->assertNotContains('error', $response->getHttpHeader('Location'));
164+
$this->assertStringNotContainsString('error', $response->getHttpHeader('Location'));
165165
}
166166

167167
public function testInvalidRedirectUri()
@@ -227,7 +227,7 @@ public function testRedirectUriWithValidRedirectUri()
227227
$server->handleAuthorizeRequest($request, $response = new Response(), true);
228228

229229
$this->assertEquals($response->getStatusCode(), 302);
230-
$this->assertContains('code', $response->getHttpHeader('Location'));
230+
$this->assertStringContainsString('code', $response->getHttpHeader('Location'));
231231
}
232232

233233
public function testRedirectUriWithDifferentQueryAndExactMatchRequired()
@@ -263,7 +263,7 @@ public function testRedirectUriWithDifferentQueryAndExactMatchNotRequired()
263263
$server->handleAuthorizeRequest($request, $response = new Response(), true);
264264

265265
$this->assertEquals($response->getStatusCode(), 302);
266-
$this->assertContains('code', $response->getHttpHeader('Location'));
266+
$this->assertStringContainsString('code', $response->getHttpHeader('Location'));
267267
}
268268

269269
public function testMultipleRedirectUris()
@@ -278,14 +278,14 @@ public function testMultipleRedirectUris()
278278

279279
$server->handleAuthorizeRequest($request, $response = new Response(), true);
280280
$this->assertEquals($response->getStatusCode(), 302);
281-
$this->assertContains('code', $response->getHttpHeader('Location'));
281+
$this->assertStringContainsString('code', $response->getHttpHeader('Location'));
282282

283283
// call again with different (but still valid) redirect URI
284284
$request->query['redirect_uri'] = 'http://morehazards.com';
285285

286286
$server->handleAuthorizeRequest($request, $response = new Response(), true);
287287
$this->assertEquals($response->getStatusCode(), 302);
288-
$this->assertContains('code', $response->getHttpHeader('Location'));
288+
$this->assertStringContainsString('code', $response->getHttpHeader('Location'));
289289
}
290290

291291
/**
@@ -303,7 +303,7 @@ public function testNoRedirectUriSuppliedDoesNotRequireTokenRedirectUri()
303303

304304
$server->handleAuthorizeRequest($request, $response = new Response(), true);
305305
$this->assertEquals($response->getStatusCode(), 302);
306-
$this->assertContains('state', $response->getHttpHeader('Location'));
306+
$this->assertStringContainsString('state', $response->getHttpHeader('Location'));
307307
$this->assertStringStartsWith('http://brentertainment.com?code=', $response->getHttpHeader('Location'));
308308

309309
$parts = parse_url($response->getHttpHeader('Location'));
@@ -421,7 +421,7 @@ public function testSuccessfulRequestStripsExtraParameters()
421421

422422
$this->assertEquals($response->getStatusCode(), 302);
423423
$location = $response->getHttpHeader('Location');
424-
$this->assertNotContains('error', $location);
424+
$this->assertStringNotContainsString('error', $location);
425425

426426
$parts = parse_url($location);
427427
$this->assertFalse(isset($parts['fake']));

test/OAuth2/Encryption/FirebaseJwtTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class FirebaseJwtTest extends TestCase
99
{
1010
private $privateKey;
1111

12-
public function setUp()
12+
public function setUp(): void
1313
{
1414
$this->privateKey = <<<EOD
1515
-----BEGIN RSA PRIVATE KEY-----

test/OAuth2/Encryption/JwtTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class JwtTest extends TestCase
99
{
1010
private $privateKey;
1111

12-
public function setUp()
12+
public function setUp(): void
1313
{
1414
$this->privateKey = <<<EOD
1515
-----BEGIN RSA PRIVATE KEY-----

test/OAuth2/GrantType/JwtBearerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class JwtBearerTest extends TestCase
1313
{
1414
private $privateKey;
1515

16-
public function setUp()
16+
public function setUp(): void
1717
{
1818
$this->privateKey = <<<EOD
1919
-----BEGIN RSA PRIVATE KEY-----

test/OAuth2/OpenID/ResponseType/CodeIdTokenTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testHandleAuthorizeRequest()
2929

3030
$this->assertEquals($response->getStatusCode(), 302);
3131
$location = $response->getHttpHeader('Location');
32-
$this->assertNotContains('error', $location);
32+
$this->assertStringNotContainsString('error', $location);
3333

3434
$parts = parse_url($location);
3535
$this->assertArrayHasKey('query', $parts);
@@ -87,7 +87,7 @@ public function testUserClaimsWithUserId()
8787

8888
$this->assertEquals($response->getStatusCode(), 302);
8989
$location = $response->getHttpHeader('Location');
90-
$this->assertNotContains('error', $location);
90+
$this->assertStringNotContainsString('error', $location);
9191

9292
$parts = parse_url($location);
9393
$this->assertArrayHasKey('query', $parts);
@@ -133,7 +133,7 @@ public function testUserClaimsWithoutUserId()
133133

134134
$this->assertEquals($response->getStatusCode(), 302);
135135
$location = $response->getHttpHeader('Location');
136-
$this->assertNotContains('error', $location);
136+
$this->assertStringNotContainsString('error', $location);
137137

138138
$parts = parse_url($location);
139139
$this->assertArrayHasKey('query', $parts);

test/OAuth2/OpenID/ResponseType/IdTokenTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testHandleAuthorizeRequest()
5252

5353
$this->assertEquals($response->getStatusCode(), 302);
5454
$location = $response->getHttpHeader('Location');
55-
$this->assertNotContains('error', $location);
55+
$this->assertStringNotContainsString('error', $location);
5656

5757
$parts = parse_url($location);
5858
$this->assertArrayHasKey('fragment', $parts);
@@ -110,7 +110,7 @@ private function extractTokenDataFromResponse(Response $response)
110110
{
111111
$this->assertEquals($response->getStatusCode(), 302);
112112
$location = $response->getHttpHeader('Location');
113-
$this->assertNotContains('error', $location);
113+
$this->assertStringNotContainsString('error', $location);
114114

115115
$parts = parse_url($location);
116116
$this->assertArrayHasKey('fragment', $parts);

test/OAuth2/OpenID/ResponseType/IdTokenTokenTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testHandleAuthorizeRequest()
3131

3232
$this->assertEquals($response->getStatusCode(), 302);
3333
$location = $response->getHttpHeader('Location');
34-
$this->assertNotContains('error', $location);
34+
$this->assertStringNotContainsString('error', $location);
3535

3636
$parts = parse_url($location);
3737
$this->assertArrayHasKey('fragment', $parts);

0 commit comments

Comments
 (0)