Skip to content

Commit 546f869

Browse files
authored
Use github action, remove travis, drop phpunit 4 support and support PHP 8.0 (#125)
* Move CI from Travis to Github action * Drop PHP 5.5.6 support and add PHP 8.0 support * Update ci.yml
1 parent 034720e commit 546f869

File tree

9 files changed

+71
-37
lines changed

9 files changed

+71
-37
lines changed

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: "CI"
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
pull_request:
8+
branches:
9+
- '**'
10+
11+
jobs:
12+
build:
13+
name: PHP ${{ matrix.php }}
14+
runs-on: 'ubuntu-latest'
15+
strategy:
16+
matrix:
17+
php: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- name: Setup PHP ${{ matrix.php }} and composer
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
coverage: none # disable xdebug, pcov
26+
tools: composer:v2
27+
28+
- name: "Set composer cache directory"
29+
id: composer-cache
30+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
31+
32+
- name: "Cache composer"
33+
uses: actions/cache@v2.1.2
34+
with:
35+
path: ${{ steps.composer-cache.outputs.dir }}
36+
key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}
37+
restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer-
38+
39+
- name: Install dependencies
40+
run: composer update
41+
42+
- name: Run CI
43+
run: vendor/bin/phpunit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
vendor/
22
composer.lock
33
phpunit.xml
4+
.phpunit.result.cache

.travis.yml

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

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
],
1818

1919
"require": {
20-
"php": "^5.5.9|^7.0.8|^7.1.3|^7.2.5",
20+
"php": "^5.5.9 || ^7.0.8 || ^7.1.3 || ^7.2.5 || ^8.0.0",
2121
"symfony/http-foundation": "~3.0|~4.0|~5.0"
2222
},
2323
"require-dev": {
24-
"phpunit/phpunit": "^4.8 || ^5.0"
24+
"phpunit/phpunit": "^5.0 || ^6.0 || ^8.0 || ^9.0.0"
2525
},
2626

2727
"autoload": {

tests/ExtraHeadersTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Extra Headers test case.
1010
*/
11-
class ExtraHeadersTest extends PHPUnit_Framework_TestCase
11+
class ExtraHeadersTest extends \PHPUnit\Framework\TestCase
1212
{
1313
public function testErrorResponseContainsExtraHeaders()
1414
{

tests/Model/OAuth2TokenTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use OAuth2\Model\OAuth2Token;
66

7-
class OAuth2TokenTest extends \PHPUnit_Framework_TestCase
7+
class OAuth2TokenTest extends \PHPUnit\Framework\TestCase
88
{
99
public function testConstruct()
1010
{

tests/OAuth2ImplicitGrantTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* OAuth2 test case.
1111
*/
12-
class OAuth2ImplicitGrantTypeTest extends PHPUnit_Framework_TestCase
12+
class OAuth2ImplicitGrantTypeTest extends \PHPUnit\Framework\TestCase
1313
{
1414
/**
1515
* Tests OAuth2->grantAccessToken() with implicit

tests/OAuth2OutputTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* OAuth2 test cases that involve capturing output.
1010
*/
11-
class OAuth2OutputTest extends PHPUnit_Framework_TestCase
11+
class OAuth2OutputTest extends \PHPUnit\Framework\TestCase
1212
{
1313
/**
1414
* @var OAuth2
@@ -71,7 +71,7 @@ protected function createBaseMock($interfaceName)
7171
{
7272
$client = new OAuth2Client('my_little_app');
7373

74-
$mockStorage = $this->getMockBuilder($interfaceName)->getMock();
74+
$mockStorage = $this->createMock($interfaceName);
7575
$mockStorage->expects($this->any())
7676
->method('getClient')
7777
->will($this->returnCallback(function ($id) use ($client) {

tests/OAuth2Test.php

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* OAuth2 test case.
1616
*/
17-
class OAuth2Test extends PHPUnit_Framework_TestCase
17+
class OAuth2Test extends \PHPUnit\Framework\TestCase
1818
{
1919
/**
2020
* @var OAuth2
@@ -32,11 +32,11 @@ class OAuth2Test extends PHPUnit_Framework_TestCase
3232
*/
3333
public function testVerifyAccessTokenWithNoParam()
3434
{
35-
$mockStorage = $this->getMockBuilder('OAuth2\IOAuth2Storage')->getMock();
35+
$mockStorage = $this->createMock('OAuth2\IOAuth2Storage');
3636
$this->fixture = new OAuth2($mockStorage);
3737

3838
$scope = null;
39-
$this->setExpectedException('OAuth2\OAuth2AuthenticateException');
39+
$this->expectException('OAuth2\OAuth2AuthenticateException');
4040
$this->fixture->verifyAccessToken('', $scope);
4141
}
4242

@@ -46,15 +46,15 @@ public function testVerifyAccessTokenWithNoParam()
4646
public function testVerifyAccessTokenInvalidToken()
4747
{
4848
// Set up the mock storage to say this token does not exist
49-
$mockStorage = $this->getMockBuilder('OAuth2\IOAuth2Storage')->getMock();
49+
$mockStorage = $this->createMock('OAuth2\IOAuth2Storage');
5050
$mockStorage->expects($this->once())
5151
->method('getAccessToken')
5252
->will($this->returnValue(false));
5353

5454
$this->fixture = new OAuth2($mockStorage);
5555

5656
$scope = null;
57-
$this->setExpectedException('OAuth2\OAuth2AuthenticateException');
57+
$this->expectException('OAuth2\OAuth2AuthenticateException');
5858
$this->fixture->verifyAccessToken($this->tokenId, $scope);
5959
}
6060

@@ -66,15 +66,15 @@ public function testVerifyAccessTokenInvalidToken()
6666
public function testVerifyAccessTokenMalformedToken(IOAuth2AccessToken $token)
6767
{
6868
// Set up the mock storage to say this token does not exist
69-
$mockStorage = $this->getMockBuilder('OAuth2\IOAuth2Storage')->getMock();
69+
$mockStorage = $this->createMock('OAuth2\IOAuth2Storage');
7070
$mockStorage->expects($this->once())
7171
->method('getAccessToken')
7272
->will($this->returnValue($token));
7373

7474
$this->fixture = new OAuth2($mockStorage);
7575

7676
$scope = null;
77-
$this->setExpectedException('OAuth2\OAuth2AuthenticateException');
77+
$this->expectException('OAuth2\OAuth2AuthenticateException');
7878
$this->fixture->verifyAccessToken($this->tokenId, $scope);
7979
}
8080

@@ -86,7 +86,7 @@ public function testVerifyAccessTokenMalformedToken(IOAuth2AccessToken $token)
8686
public function testVerifyAccessTokenCheckExpiry(IOAuth2AccessToken $token, $expectedToPass)
8787
{
8888
// Set up the mock storage to say this token does not exist
89-
$mockStorage = $this->getMockBuilder('OAuth2\IOAuth2Storage')->getMock();
89+
$mockStorage = $this->createMock('OAuth2\IOAuth2Storage');
9090
$mockStorage->expects($this->once())
9191
->method('getAccessToken')
9292
->will($this->returnValue($token));
@@ -101,7 +101,7 @@ public function testVerifyAccessTokenCheckExpiry(IOAuth2AccessToken $token, $exp
101101
$this->assertNotEmpty($actual, "verifyAccessToken() was expected to PASS, but it failed");
102102
$this->assertInstanceOf('OAuth2\Model\IOAuth2AccessToken', $actual);
103103
} else {
104-
$this->setExpectedException('OAuth2\OAuth2AuthenticateException');
104+
$this->expectException('OAuth2\OAuth2AuthenticateException');
105105
$this->fixture->verifyAccessToken($this->tokenId, $scope);
106106
}
107107
}
@@ -114,7 +114,7 @@ public function testVerifyAccessTokenCheckExpiry(IOAuth2AccessToken $token, $exp
114114
public function testVerifyAccessTokenCheckScope($scopeRequired, IOAuth2AccessToken $token, $expectedToPass)
115115
{
116116
// Set up the mock storage to say this token does not exist
117-
$mockStorage = $this->getMockBuilder('OAuth2\IOAuth2Storage')->getMock();
117+
$mockStorage = $this->createMock('OAuth2\IOAuth2Storage');
118118
$mockStorage->expects($this->once())
119119
->method('getAccessToken')
120120
->will($this->returnValue($token));
@@ -127,7 +127,7 @@ public function testVerifyAccessTokenCheckScope($scopeRequired, IOAuth2AccessTok
127127
$this->assertNotEmpty($actual, "verifyAccessToken() was expected to PASS, but it failed");
128128
$this->assertInstanceOf('OAuth2\Model\IOAuth2AccessToken', $actual);
129129
} else {
130-
$this->setExpectedException('OAuth2\OAuth2AuthenticateException');
130+
$this->expectException('OAuth2\OAuth2AuthenticateException');
131131
$this->fixture->verifyAccessToken($this->tokenId, $scopeRequired);
132132
}
133133
}
@@ -139,10 +139,10 @@ public function testVerifyAccessTokenCheckScope($scopeRequired, IOAuth2AccessTok
139139
*/
140140
public function testGrantAccessTokenMissingData($request)
141141
{
142-
$mockStorage = $this->getMockBuilder('OAuth2\IOAuth2Storage')->getMock();
142+
$mockStorage = $this->createMock('OAuth2\IOAuth2Storage');
143143
$this->fixture = new OAuth2($mockStorage);
144144

145-
$this->setExpectedException('OAuth2\OAuth2ServerException');
145+
$this->expectException('OAuth2\OAuth2ServerException');
146146
$this->fixture->grantAccessToken($request);
147147
}
148148

@@ -153,7 +153,7 @@ public function testGrantAccessTokenMissingData($request)
153153
*/
154154
public function testGrantAccessTokenCheckClientCredentials()
155155
{
156-
$mockStorage = $this->getMockBuilder('OAuth2\IOAuth2Storage')->getMock();
156+
$mockStorage = $this->createMock('OAuth2\IOAuth2Storage');
157157
$mockStorage->expects($this->any())
158158
->method('getClient')
159159
->will($this->returnValue(new OAuth2Client('dev-abc')));
@@ -384,6 +384,7 @@ public function testGrantAccessTokenWithSameGrantAuthCode()
384384
/**
385385
* Tests OAuth2->grantAccessToken() with implicit
386386
*
387+
* @doesNotPerformAssertions
387388
*/
388389
public function testGrantAccessTokenWithGrantImplicit()
389390
{
@@ -591,6 +592,7 @@ public function testGrantAccessTokenWithGrantUserWithNewScopeThrowsError()
591592
/**
592593
* Tests OAuth2->grantAccessToken() with client credentials
593594
*
595+
* @doesNotPerformAssertions
594596
*/
595597
public function testGrantAccessTokenWithGrantClient()
596598
{
@@ -602,6 +604,7 @@ public function testGrantAccessTokenWithGrantClient()
602604
/**
603605
* Tests OAuth2->grantAccessToken() with refresh token
604606
*
607+
* @doesNotPerformAssertions
605608
*/
606609
public function testGrantAccessTokenWithGrantRefresh()
607610
{
@@ -727,6 +730,7 @@ public function testGrantAccessTokenWithGrantExtensionJwtBearer()
727730

728731
/**
729732
* Tests OAuth2->getAuthorizeParams()
733+
* @doesNotPerformAssertions
730734
*/
731735
public function testGetAuthorizeParams()
732736
{
@@ -1077,7 +1081,7 @@ public function testFinishClientAuthorizationThrowsErrorIfUnauthorized()
10771081
*/
10781082
public function testGetBearerToken(Request $request, $token, $remove = false, $exception = null, $exceptionMessage = null, $headers = null, $body = null)
10791083
{
1080-
$mock = $this->getMockBuilder('OAuth2\IOAuth2Storage')->getMock();
1084+
$mock = $this->createMock('OAuth2\IOAuth2Storage');
10811085
$oauth2 = new OAuth2($mock);
10821086

10831087
try {
@@ -1225,7 +1229,7 @@ public function getTestGetBearerTokenData()
12251229
*/
12261230
protected function createBaseMock($interfaceName)
12271231
{
1228-
$mockStorage = $this->getMockBuilder($interfaceName)->getMock();
1232+
$mockStorage = $this->createMock($interfaceName);
12291233
$mockStorage->expects($this->any())
12301234
->method('checkClientCredentials')
12311235
->will($this->returnValue(true)); // Always return true for any combination of user/pass

0 commit comments

Comments
 (0)