Skip to content

Commit

Permalink
Use github action, remove travis, drop phpunit 4 support and support …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
vasilvestre committed Apr 6, 2021
1 parent 034720e commit 546f869
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 37 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "CI"

on:
push:
branches:
- 'master'
pull_request:
branches:
- '**'

jobs:
build:
name: PHP ${{ matrix.php }}
runs-on: 'ubuntu-latest'
strategy:
matrix:
php: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
steps:
- uses: actions/checkout@v2

- name: Setup PHP ${{ matrix.php }} and composer
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none # disable xdebug, pcov
tools: composer:v2

- name: "Set composer cache directory"
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: "Cache composer"
uses: actions/cache@v2.1.2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer-

- name: Install dependencies
run: composer update

- name: Run CI
run: vendor/bin/phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor/
composer.lock
phpunit.xml
.phpunit.result.cache
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
],

"require": {
"php": "^5.5.9|^7.0.8|^7.1.3|^7.2.5",
"php": "^5.5.9 || ^7.0.8 || ^7.1.3 || ^7.2.5 || ^8.0.0",
"symfony/http-foundation": "~3.0|~4.0|~5.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8 || ^5.0"
"phpunit/phpunit": "^5.0 || ^6.0 || ^8.0 || ^9.0.0"
},

"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion tests/ExtraHeadersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Extra Headers test case.
*/
class ExtraHeadersTest extends PHPUnit_Framework_TestCase
class ExtraHeadersTest extends \PHPUnit\Framework\TestCase
{
public function testErrorResponseContainsExtraHeaders()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Model/OAuth2TokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use OAuth2\Model\OAuth2Token;

class OAuth2TokenTest extends \PHPUnit_Framework_TestCase
class OAuth2TokenTest extends \PHPUnit\Framework\TestCase
{
public function testConstruct()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/OAuth2ImplicitGrantTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* OAuth2 test case.
*/
class OAuth2ImplicitGrantTypeTest extends PHPUnit_Framework_TestCase
class OAuth2ImplicitGrantTypeTest extends \PHPUnit\Framework\TestCase
{
/**
* Tests OAuth2->grantAccessToken() with implicit
Expand Down
4 changes: 2 additions & 2 deletions tests/OAuth2OutputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* OAuth2 test cases that involve capturing output.
*/
class OAuth2OutputTest extends PHPUnit_Framework_TestCase
class OAuth2OutputTest extends \PHPUnit\Framework\TestCase
{
/**
* @var OAuth2
Expand Down Expand Up @@ -71,7 +71,7 @@ protected function createBaseMock($interfaceName)
{
$client = new OAuth2Client('my_little_app');

$mockStorage = $this->getMockBuilder($interfaceName)->getMock();
$mockStorage = $this->createMock($interfaceName);
$mockStorage->expects($this->any())
->method('getClient')
->will($this->returnCallback(function ($id) use ($client) {
Expand Down
36 changes: 20 additions & 16 deletions tests/OAuth2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* OAuth2 test case.
*/
class OAuth2Test extends PHPUnit_Framework_TestCase
class OAuth2Test extends \PHPUnit\Framework\TestCase
{
/**
* @var OAuth2
Expand All @@ -32,11 +32,11 @@ class OAuth2Test extends PHPUnit_Framework_TestCase
*/
public function testVerifyAccessTokenWithNoParam()
{
$mockStorage = $this->getMockBuilder('OAuth2\IOAuth2Storage')->getMock();
$mockStorage = $this->createMock('OAuth2\IOAuth2Storage');
$this->fixture = new OAuth2($mockStorage);

$scope = null;
$this->setExpectedException('OAuth2\OAuth2AuthenticateException');
$this->expectException('OAuth2\OAuth2AuthenticateException');
$this->fixture->verifyAccessToken('', $scope);
}

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

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

$scope = null;
$this->setExpectedException('OAuth2\OAuth2AuthenticateException');
$this->expectException('OAuth2\OAuth2AuthenticateException');
$this->fixture->verifyAccessToken($this->tokenId, $scope);
}

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

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

$scope = null;
$this->setExpectedException('OAuth2\OAuth2AuthenticateException');
$this->expectException('OAuth2\OAuth2AuthenticateException');
$this->fixture->verifyAccessToken($this->tokenId, $scope);
}

Expand All @@ -86,7 +86,7 @@ public function testVerifyAccessTokenMalformedToken(IOAuth2AccessToken $token)
public function testVerifyAccessTokenCheckExpiry(IOAuth2AccessToken $token, $expectedToPass)
{
// Set up the mock storage to say this token does not exist
$mockStorage = $this->getMockBuilder('OAuth2\IOAuth2Storage')->getMock();
$mockStorage = $this->createMock('OAuth2\IOAuth2Storage');
$mockStorage->expects($this->once())
->method('getAccessToken')
->will($this->returnValue($token));
Expand All @@ -101,7 +101,7 @@ public function testVerifyAccessTokenCheckExpiry(IOAuth2AccessToken $token, $exp
$this->assertNotEmpty($actual, "verifyAccessToken() was expected to PASS, but it failed");
$this->assertInstanceOf('OAuth2\Model\IOAuth2AccessToken', $actual);
} else {
$this->setExpectedException('OAuth2\OAuth2AuthenticateException');
$this->expectException('OAuth2\OAuth2AuthenticateException');
$this->fixture->verifyAccessToken($this->tokenId, $scope);
}
}
Expand All @@ -114,7 +114,7 @@ public function testVerifyAccessTokenCheckExpiry(IOAuth2AccessToken $token, $exp
public function testVerifyAccessTokenCheckScope($scopeRequired, IOAuth2AccessToken $token, $expectedToPass)
{
// Set up the mock storage to say this token does not exist
$mockStorage = $this->getMockBuilder('OAuth2\IOAuth2Storage')->getMock();
$mockStorage = $this->createMock('OAuth2\IOAuth2Storage');
$mockStorage->expects($this->once())
->method('getAccessToken')
->will($this->returnValue($token));
Expand All @@ -127,7 +127,7 @@ public function testVerifyAccessTokenCheckScope($scopeRequired, IOAuth2AccessTok
$this->assertNotEmpty($actual, "verifyAccessToken() was expected to PASS, but it failed");
$this->assertInstanceOf('OAuth2\Model\IOAuth2AccessToken', $actual);
} else {
$this->setExpectedException('OAuth2\OAuth2AuthenticateException');
$this->expectException('OAuth2\OAuth2AuthenticateException');
$this->fixture->verifyAccessToken($this->tokenId, $scopeRequired);
}
}
Expand All @@ -139,10 +139,10 @@ public function testVerifyAccessTokenCheckScope($scopeRequired, IOAuth2AccessTok
*/
public function testGrantAccessTokenMissingData($request)
{
$mockStorage = $this->getMockBuilder('OAuth2\IOAuth2Storage')->getMock();
$mockStorage = $this->createMock('OAuth2\IOAuth2Storage');
$this->fixture = new OAuth2($mockStorage);

$this->setExpectedException('OAuth2\OAuth2ServerException');
$this->expectException('OAuth2\OAuth2ServerException');
$this->fixture->grantAccessToken($request);
}

Expand All @@ -153,7 +153,7 @@ public function testGrantAccessTokenMissingData($request)
*/
public function testGrantAccessTokenCheckClientCredentials()
{
$mockStorage = $this->getMockBuilder('OAuth2\IOAuth2Storage')->getMock();
$mockStorage = $this->createMock('OAuth2\IOAuth2Storage');
$mockStorage->expects($this->any())
->method('getClient')
->will($this->returnValue(new OAuth2Client('dev-abc')));
Expand Down Expand Up @@ -384,6 +384,7 @@ public function testGrantAccessTokenWithSameGrantAuthCode()
/**
* Tests OAuth2->grantAccessToken() with implicit
*
* @doesNotPerformAssertions
*/
public function testGrantAccessTokenWithGrantImplicit()
{
Expand Down Expand Up @@ -591,6 +592,7 @@ public function testGrantAccessTokenWithGrantUserWithNewScopeThrowsError()
/**
* Tests OAuth2->grantAccessToken() with client credentials
*
* @doesNotPerformAssertions
*/
public function testGrantAccessTokenWithGrantClient()
{
Expand All @@ -602,6 +604,7 @@ public function testGrantAccessTokenWithGrantClient()
/**
* Tests OAuth2->grantAccessToken() with refresh token
*
* @doesNotPerformAssertions
*/
public function testGrantAccessTokenWithGrantRefresh()
{
Expand Down Expand Up @@ -727,6 +730,7 @@ public function testGrantAccessTokenWithGrantExtensionJwtBearer()

/**
* Tests OAuth2->getAuthorizeParams()
* @doesNotPerformAssertions
*/
public function testGetAuthorizeParams()
{
Expand Down Expand Up @@ -1077,7 +1081,7 @@ public function testFinishClientAuthorizationThrowsErrorIfUnauthorized()
*/
public function testGetBearerToken(Request $request, $token, $remove = false, $exception = null, $exceptionMessage = null, $headers = null, $body = null)
{
$mock = $this->getMockBuilder('OAuth2\IOAuth2Storage')->getMock();
$mock = $this->createMock('OAuth2\IOAuth2Storage');
$oauth2 = new OAuth2($mock);

try {
Expand Down Expand Up @@ -1225,7 +1229,7 @@ public function getTestGetBearerTokenData()
*/
protected function createBaseMock($interfaceName)
{
$mockStorage = $this->getMockBuilder($interfaceName)->getMock();
$mockStorage = $this->createMock($interfaceName);
$mockStorage->expects($this->any())
->method('checkClientCredentials')
->will($this->returnValue(true)); // Always return true for any combination of user/pass
Expand Down

0 comments on commit 546f869

Please sign in to comment.