From 6c8b06557be78104722122f3b9b0dfcf6f54030f Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Fri, 27 Nov 2020 13:55:42 +0000 Subject: [PATCH 01/19] chore(ci): Move to GH actions --- .github/workflows/run-tests.yml | 55 +++++++++++++++++++++++++++++++++ composer.json | 2 +- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/run-tests.yml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 000000000..5b46cc07b --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,55 @@ +name: Run tests + +on: + pull_request: + push: + +jobs: + php-tests: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + php: [7.2, 7.3, 7.4, 8.0] + laravel: [6.*, 7.*, 8.*] + os: [ubuntu-latest] + coverage: ['none', 'xdebug'] + + name: '[P${{ matrix.php }}] [L${{ matrix.laravel }}] [${{ matrix.os }}] [${{ matrix.coverage }}]' + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, gmp, exif, iconv, imagick + coverage: ${{ matrix.coverage }} + tools: composer:v2 + + - name: "Cache dependencies" + uses: "actions/cache@v2" + with: + path: | + ~/.composer/cache + vendor + key: "composer-${{ matrix.php }}-${{ matrix.laravel }}" + restore-keys: "composer-${{ matrix.php }}-${{ matrix.laravel }}" + + - name: Install dependencies + run: | + composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-update + composer update --prefer-stable --prefer-dist --no-interaction --no-suggest --ignore-platform-req=php + + - name: Execute tests + run: composer test:ci + + - name: Upload coverage + uses: codecov/codecov-action@v1 + if: matrix.coverage == 'xdebug' + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage.xml + yml: ./codecov.yml diff --git a/composer.json b/composer.json index dd22367ca..6042ab193 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ } ], "require": { - "php": "^5.5.9|^7.0", + "php": "^7.2", "illuminate/auth": "^5.2|^6|^7|^8", "illuminate/contracts": "^5.2|^6|^7|^8", "illuminate/http": "^5.2|^6|^7|^8", From a2d41c8916419524bf7d38168f4211f369fc4967 Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Fri, 27 Nov 2020 14:04:10 +0000 Subject: [PATCH 02/19] tweaks --- .github/workflows/run-tests.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 5b46cc07b..771200235 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,8 +1,10 @@ name: Run tests on: - pull_request: push: + release: + types: + - published jobs: php-tests: @@ -10,7 +12,7 @@ jobs: strategy: matrix: - php: [7.2, 7.3, 7.4, 8.0] + php: [7.2, 7.3, 7.4] laravel: [6.*, 7.*, 8.*] os: [ubuntu-latest] coverage: ['none', 'xdebug'] @@ -27,6 +29,7 @@ jobs: php-version: ${{ matrix.php }} extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, gmp, exif, iconv, imagick coverage: ${{ matrix.coverage }} + ini-values: memory_limit=-1 tools: composer:v2 - name: "Cache dependencies" From b108b12a2eeabe7148bad9dbd4d5f13d9a44ea51 Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Fri, 27 Nov 2020 14:14:12 +0000 Subject: [PATCH 03/19] remove travis --- .github/workflows/run-tests.yml | 6 +- .travis.yml | 114 -------------------------------- 2 files changed, 3 insertions(+), 117 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 771200235..8963707d6 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -17,7 +17,7 @@ jobs: os: [ubuntu-latest] coverage: ['none', 'xdebug'] - name: '[P${{ matrix.php }}] [L${{ matrix.laravel }}] [${{ matrix.os }}] [${{ matrix.coverage }}]' + name: '[P${{ matrix.php }}] [L${{ matrix.laravel }}] [${{ matrix.coverage }}]' steps: - name: Checkout code @@ -38,8 +38,8 @@ jobs: path: | ~/.composer/cache vendor - key: "composer-${{ matrix.php }}-${{ matrix.laravel }}" - restore-keys: "composer-${{ matrix.php }}-${{ matrix.laravel }}" + key: "php-${{ matrix.php }}-laravel-${{ matrix.laravel }}" + restore-keys: "php-${{ matrix.php }}-laravel-${{ matrix.laravel }}" - name: Install dependencies run: | diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5eb5d68a9..000000000 --- a/.travis.yml +++ /dev/null @@ -1,114 +0,0 @@ -sudo: false - -git: - depth: 1 - -cache: - directories: - - $HOME/.composer/cache - -language: php - -env: - global: - - COVERAGE=0 XDEBUG=0 - -matrix: - include: - - php: 5.5.9 - dist: trusty - env: LARAVEL='5.2.*' - - php: 5.5 - dist: trusty - env: LARAVEL='5.2.*' - - php: 5.6 - dist: trusty - env: LARAVEL='5.2.*' - - php: 5.6 - dist: trusty - env: LARAVEL='5.3.*' - - php: 5.6 - dist: trusty - env: LARAVEL='5.4.*' - - php: 7.0 - env: LARAVEL='5.2.*' - - php: 7.0 - env: LARAVEL='5.3.*' - - php: 7.0 - env: LARAVEL='5.4.*' - - php: 7.0 - env: LARAVEL='5.5.*' - - php: 7.1 - env: LARAVEL='5.2.*' - - php: 7.1 - env: LARAVEL='5.3.*' - - php: 7.1 - env: LARAVEL='5.4.*' - - php: 7.1 - env: LARAVEL='5.5.*' - - php: 7.1 - env: LARAVEL='5.6.*' - - php: 7.1 - env: LARAVEL='5.7.*' - - php: 7.1 - env: LARAVEL='5.8.*' - - php: 7.2 - env: LARAVEL='5.2.*' - - php: 7.2 - env: LARAVEL='5.3.*' - - php: 7.2 - env: LARAVEL='5.4.*' - - php: 7.2 - env: LARAVEL='5.5.*' - - php: 7.2 - env: LARAVEL='5.6.*' - - php: 7.2 - env: LARAVEL='5.7.*' - - php: 7.2 - env: LARAVEL='5.8.*' - - php: 7.2 - env: LARAVEL='6.*' - - php: 7.2 - env: LARAVEL='7.*' - - php: 7.3 - env: LARAVEL='5.2.*' XDEBUG=1 - - php: 7.3 - env: LARAVEL='5.3.*' XDEBUG=1 - - php: 7.3 - env: LARAVEL='5.4.*' XDEBUG=1 - - php: 7.3 - env: LARAVEL='5.5.*' XDEBUG=1 - - php: 7.3 - env: LARAVEL='5.6.*' XDEBUG=1 - - php: 7.3 - env: LARAVEL='5.7.*' XDEBUG=1 - - php: 7.3 - env: LARAVEL='5.8.*' XDEBUG=1 - - php: 7.3 - env: COVERAGE=1 LARAVEL='6.*' XDEBUG=1 - - php: 7.3 - env: COVERAGE=1 LARAVEL='7.*' XDEBUG=1 - - php: 7.3 - env: COVERAGE=1 LARAVEL='8.*' XDEBUG=1 - - php: 7.4 - env: COVERAGE=1 LARAVEL='6.*' XDEBUG=1 - - php: 7.4 - env: COVERAGE=1 LARAVEL='7.*' XDEBUG=1 - - php: 7.4 - env: COVERAGE=1 LARAVEL='8.*' XDEBUG=1 - fast_finish: true - - -before_install: - - if [[ $XDEBUG = 0 ]]; then phpenv config-rm xdebug.ini; fi - - travis_retry composer self-update - - travis_retry composer require "illuminate/contracts:${LARAVEL}" --no-interaction --no-update - -install: - - COMPOSER_MEMORY_LIMIT=-1 travis_retry composer install --prefer-dist --no-interaction --no-suggest - -script: - - composer test:ci - -after_success: - - if [[ $COVERAGE = 1 ]]; then bash <(curl -s https://codecov.io/bash); fi From 298ebf6d6bf78d06757f504d0d3bb7ab2abc9ab2 Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Fri, 27 Nov 2020 15:37:23 +0000 Subject: [PATCH 04/19] upgrade phpunit --- .gitattributes | 1 + .github/workflows/run-tests.yml | 27 ++-- .gitignore | 1 + composer.json | 2 +- phpunit.xml.dist | 82 ++++++------ src/Http/Middleware/Authenticate.php | 1 + src/Http/Middleware/AuthenticateAndRenew.php | 1 + src/Http/Middleware/BaseMiddleware.php | 1 + src/Http/Middleware/Check.php | 1 + src/Http/Middleware/RefreshToken.php | 1 + src/JWTAuth.php | 1 + src/Payload.php | 11 +- tests/AbstractTestCase.php | 4 +- tests/BlacklistTest.php | 2 +- tests/Claims/ClaimTest.php | 14 +- tests/Claims/DatetimeClaimTest.php | 2 +- tests/Claims/FactoryTest.php | 2 +- tests/Claims/IssuedAtTest.php | 10 +- tests/Claims/NotBeforeTest.php | 10 +- tests/FactoryTest.php | 2 +- tests/JWTAuthTest.php | 20 ++- tests/JWTGuardTest.php | 123 ++++++------------ tests/ManagerTest.php | 40 +++--- tests/Middleware/AbstractMiddlewareTest.php | 2 +- tests/Middleware/AuthenticateAndRenewTest.php | 23 ++-- tests/Middleware/AuthenticateTest.php | 28 ++-- tests/Middleware/CheckTest.php | 2 +- tests/Middleware/RefreshTokenTest.php | 23 ++-- tests/PayloadTest.php | 49 ++++--- tests/Providers/Auth/IlluminateTest.php | 2 +- tests/Providers/JWT/LcobucciTest.php | 56 ++++---- tests/Providers/JWT/NamshiTest.php | 52 ++++---- tests/Providers/JWT/ProviderTest.php | 2 +- tests/Providers/Storage/IlluminateTest.php | 2 +- tests/TokenTest.php | 4 +- tests/Validators/PayloadValidatorTest.php | 69 +++++----- tests/Validators/TokenValidatorTest.php | 63 +++++---- 37 files changed, 345 insertions(+), 391 deletions(-) diff --git a/.gitattributes b/.gitattributes index 25e09b89b..8fdd9ee89 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,6 +9,7 @@ /.styleci.yml export-ignore /.travis.yml export-ignore /.github export-ignore +/mkdocs.yml export-ignore /phpunit.xml.dist export-ignore /README.md export-ignore /mkdocs.yml export-ignore diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 8963707d6..fb3e95d63 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,10 +12,19 @@ jobs: strategy: matrix: - php: [7.2, 7.3, 7.4] - laravel: [6.*, 7.*, 8.*] - os: [ubuntu-latest] - coverage: ['none', 'xdebug'] + php: + - 7.2 + - 7.3 + - 7.4 + laravel: + - 6.* + - 7.* + - 8.* + os: + - ubuntu-latest + coverage: + - none + - xdebug name: '[P${{ matrix.php }}] [L${{ matrix.laravel }}] [${{ matrix.coverage }}]' @@ -32,19 +41,19 @@ jobs: ini-values: memory_limit=-1 tools: composer:v2 - - name: "Cache dependencies" - uses: "actions/cache@v2" + - name: Cache dependencies + uses: actions/cache@v2 with: path: | ~/.composer/cache vendor - key: "php-${{ matrix.php }}-laravel-${{ matrix.laravel }}" - restore-keys: "php-${{ matrix.php }}-laravel-${{ matrix.laravel }}" + key: 'php-${{ matrix.php }}-laravel-${{ matrix.laravel }}' + restore-keys: 'php-${{ matrix.php }}-laravel-${{ matrix.laravel }}' - name: Install dependencies run: | composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-update - composer update --prefer-stable --prefer-dist --no-interaction --no-suggest --ignore-platform-req=php + composer update --prefer-stable --prefer-dist --no-interaction --ignore-platform-req=php - name: Execute tests run: composer test:ci diff --git a/.gitignore b/.gitignore index 8830b4835..187e79cda 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ composer.lock build coverage.xml +.phpunit.result.cache diff --git a/composer.json b/composer.json index 6042ab193..3392f23ee 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "illuminate/database": "^5.2|^6|^7|^8", "illuminate/routing": "^5.2|^6|^7|^8", "mockery/mockery": ">=0.9.9", - "phpunit/phpunit": "~4.8|~6.0" + "phpunit/phpunit": "^9.4" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ee9ce0773..08e96d06e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,41 +1,45 @@ - - - - tests - - - - - src/ - - src/Providers/AbstractServiceProvider.php - src/Providers/LaravelServiceProvider.php - src/Providers/LumenServiceProvider.php - src/Facades/ - src/Console/ - - - - - - - - - - + + + + src/ + + + src/Providers/AbstractServiceProvider.php + src/Providers/LaravelServiceProvider.php + src/Providers/LumenServiceProvider.php + src/Facades/ + src/Console/ + + + + + + + + + + tests + + + + + diff --git a/src/Http/Middleware/Authenticate.php b/src/Http/Middleware/Authenticate.php index cd3b99ae1..257839b08 100644 --- a/src/Http/Middleware/Authenticate.php +++ b/src/Http/Middleware/Authenticate.php @@ -13,6 +13,7 @@ use Closure; +/** @deprecated */ class Authenticate extends BaseMiddleware { /** diff --git a/src/Http/Middleware/AuthenticateAndRenew.php b/src/Http/Middleware/AuthenticateAndRenew.php index a40bba5ce..7f6ba58c8 100644 --- a/src/Http/Middleware/AuthenticateAndRenew.php +++ b/src/Http/Middleware/AuthenticateAndRenew.php @@ -13,6 +13,7 @@ use Closure; +/** @deprecated */ class AuthenticateAndRenew extends BaseMiddleware { /** diff --git a/src/Http/Middleware/BaseMiddleware.php b/src/Http/Middleware/BaseMiddleware.php index 647dc12ab..c977d4e10 100644 --- a/src/Http/Middleware/BaseMiddleware.php +++ b/src/Http/Middleware/BaseMiddleware.php @@ -16,6 +16,7 @@ use Tymon\JWTAuth\Exceptions\JWTException; use Tymon\JWTAuth\JWTAuth; +/** @deprecated */ abstract class BaseMiddleware { /** diff --git a/src/Http/Middleware/Check.php b/src/Http/Middleware/Check.php index 38d2bfb5a..ae249c3a6 100644 --- a/src/Http/Middleware/Check.php +++ b/src/Http/Middleware/Check.php @@ -14,6 +14,7 @@ use Closure; use Exception; +/** @deprecated */ class Check extends BaseMiddleware { /** diff --git a/src/Http/Middleware/RefreshToken.php b/src/Http/Middleware/RefreshToken.php index fa7a8fc29..f3eefa7a8 100644 --- a/src/Http/Middleware/RefreshToken.php +++ b/src/Http/Middleware/RefreshToken.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; use Tymon\JWTAuth\Exceptions\JWTException; +/** @deprecated */ class RefreshToken extends BaseMiddleware { /** diff --git a/src/JWTAuth.php b/src/JWTAuth.php index c0d703090..38612bea4 100644 --- a/src/JWTAuth.php +++ b/src/JWTAuth.php @@ -14,6 +14,7 @@ use Tymon\JWTAuth\Contracts\Providers\Auth; use Tymon\JWTAuth\Http\Parser\Parser; +/** @deprecated */ class JWTAuth extends JWT { /** diff --git a/src/Payload.php b/src/Payload.php index b4b72d597..a071965af 100644 --- a/src/Payload.php +++ b/src/Payload.php @@ -11,15 +11,16 @@ namespace Tymon\JWTAuth; +use Countable; use ArrayAccess; +use JsonSerializable; use BadMethodCallException; -use Countable; -use Illuminate\Contracts\Support\Arrayable; -use Illuminate\Contracts\Support\Jsonable; use Illuminate\Support\Arr; -use JsonSerializable; +use Illuminate\Support\Str; use Tymon\JWTAuth\Claims\Claim; use Tymon\JWTAuth\Claims\Collection; +use Illuminate\Contracts\Support\Jsonable; +use Illuminate\Contracts\Support\Arrayable; use Tymon\JWTAuth\Exceptions\PayloadException; use Tymon\JWTAuth\Validators\PayloadValidator; @@ -286,6 +287,6 @@ public function __call($method, $parameters) } } - throw new BadMethodCallException(sprintf('The claim [%s] does not exist on the payload.', $method)); + throw new BadMethodCallException(sprintf('The claim [%s] does not exist on the payload.', Str::after($method, 'get'))); } } diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index 85aaddd41..84d5261b0 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -22,7 +22,7 @@ abstract class AbstractTestCase extends TestCase */ protected $testNowTimestamp; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -30,7 +30,7 @@ public function setUp() $this->testNowTimestamp = $now->getTimestamp(); } - public function tearDown() + public function tearDown(): void { Carbon::setTestNow(); Mockery::close(); diff --git a/tests/BlacklistTest.php b/tests/BlacklistTest.php index e5d95f0cf..7412e82d3 100644 --- a/tests/BlacklistTest.php +++ b/tests/BlacklistTest.php @@ -41,7 +41,7 @@ class BlacklistTest extends AbstractTestCase */ protected $validator; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Claims/ClaimTest.php b/tests/Claims/ClaimTest.php index e65ffc44c..7b092c5af 100644 --- a/tests/Claims/ClaimTest.php +++ b/tests/Claims/ClaimTest.php @@ -11,9 +11,10 @@ namespace Tymon\JWTAuth\Test\Claims; -use Illuminate\Contracts\Support\Arrayable; use Tymon\JWTAuth\Claims\Expiration; use Tymon\JWTAuth\Test\AbstractTestCase; +use Illuminate\Contracts\Support\Arrayable; +use Tymon\JWTAuth\Exceptions\InvalidClaimException; class ClaimTest extends AbstractTestCase { @@ -22,20 +23,19 @@ class ClaimTest extends AbstractTestCase */ protected $claim; - public function setUp() + public function setUp(): void { parent::setUp(); $this->claim = new Expiration($this->testNowTimestamp); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\InvalidClaimException - * @expectedExceptionMessage Invalid value provided for claim [exp] - */ + /** @test */ public function it_should_throw_an_exception_when_passing_an_invalid_value() { + $this->expectException(InvalidClaimException::class); + $this->expectExceptionMessage('Invalid value provided for claim [exp]'); + $this->claim->setValue('foo'); } diff --git a/tests/Claims/DatetimeClaimTest.php b/tests/Claims/DatetimeClaimTest.php index 5214500c0..f8c1d0b97 100644 --- a/tests/Claims/DatetimeClaimTest.php +++ b/tests/Claims/DatetimeClaimTest.php @@ -40,7 +40,7 @@ class DatetimeClaimTest extends AbstractTestCase */ protected $claimsTimestamp; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Claims/FactoryTest.php b/tests/Claims/FactoryTest.php index 70584dfe0..057e1f61b 100644 --- a/tests/Claims/FactoryTest.php +++ b/tests/Claims/FactoryTest.php @@ -30,7 +30,7 @@ class FactoryTest extends AbstractTestCase */ protected $factory; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Claims/IssuedAtTest.php b/tests/Claims/IssuedAtTest.php index 700731130..36b1856ba 100644 --- a/tests/Claims/IssuedAtTest.php +++ b/tests/Claims/IssuedAtTest.php @@ -13,16 +13,16 @@ use Tymon\JWTAuth\Claims\IssuedAt; use Tymon\JWTAuth\Test\AbstractTestCase; +use Tymon\JWTAuth\Exceptions\InvalidClaimException; class IssuedAtTest extends AbstractTestCase { - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\InvalidClaimException - * @expectedExceptionMessage Invalid value provided for claim [iat] - */ + /** @test */ public function it_should_throw_an_exception_when_passing_a_future_timestamp() { + $this->expectException(InvalidClaimException::class); + $this->expectExceptionMessage('Invalid value provided for claim [iat]'); + new IssuedAt($this->testNowTimestamp + 3600); } } diff --git a/tests/Claims/NotBeforeTest.php b/tests/Claims/NotBeforeTest.php index 40745cb1f..6157b53a4 100644 --- a/tests/Claims/NotBeforeTest.php +++ b/tests/Claims/NotBeforeTest.php @@ -13,16 +13,16 @@ use Tymon\JWTAuth\Claims\NotBefore; use Tymon\JWTAuth\Test\AbstractTestCase; +use Tymon\JWTAuth\Exceptions\InvalidClaimException; class NotBeforeTest extends AbstractTestCase { - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\InvalidClaimException - * @expectedExceptionMessage Invalid value provided for claim [nbf] - */ + /** @test */ public function it_should_throw_an_exception_when_passing_an_invalid_value() { + $this->expectException(InvalidClaimException::class); + $this->expectExceptionMessage('Invalid value provided for claim [nbf]'); + new NotBefore('foo'); } } diff --git a/tests/FactoryTest.php b/tests/FactoryTest.php index 7a8cc27ae..773cbbe31 100644 --- a/tests/FactoryTest.php +++ b/tests/FactoryTest.php @@ -42,7 +42,7 @@ class FactoryTest extends AbstractTestCase */ protected $factory; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/JWTAuthTest.php b/tests/JWTAuthTest.php index 734b8c7b2..f3499fb14 100644 --- a/tests/JWTAuthTest.php +++ b/tests/JWTAuthTest.php @@ -47,7 +47,7 @@ class JWTAuthTest extends AbstractTestCase */ protected $jwtAuth; - public function setUp() + public function setUp(): void { $this->manager = Mockery::mock(Manager::class); $this->auth = Mockery::mock(Auth::class); @@ -150,13 +150,12 @@ public function it_should_return_false_when_passing_invalid_credentials_to_attem $this->assertFalse($token); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\JWTException - * @expectedExceptionMessage A token is required - */ + /** @test */ public function it_should_throw_an_exception_when_not_providing_a_token() { + $this->expectException(JWTException::class); + $this->expectExceptionMessage('A token is required'); + $this->jwtAuth->toUser(); } @@ -261,13 +260,12 @@ public function it_should_return_true_if_the_token_is_valid() $this->assertTrue($this->jwtAuth->parseToken()->check()); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\JWTException - * @expectedExceptionMessage The token could not be parsed from the request - */ + /** @test */ public function it_should_throw_an_exception_when_token_not_present_in_request() { + $this->expectException(JWTException::class); + $this->expectExceptionMessage('The token could not be parsed from the request'); + $this->parser->shouldReceive('parseToken')->andReturn(false); $this->jwtAuth->parseToken(); diff --git a/tests/JWTGuardTest.php b/tests/JWTGuardTest.php index 25078ec68..8af43713e 100644 --- a/tests/JWTGuardTest.php +++ b/tests/JWTGuardTest.php @@ -11,14 +11,16 @@ namespace Tymon\JWTAuth\Test; -use Illuminate\Auth\EloquentUserProvider; -use Illuminate\Http\Request; use Mockery; -use Tymon\JWTAuth\Factory; use Tymon\JWTAuth\JWT; -use Tymon\JWTAuth\JWTGuard; +use Tymon\JWTAuth\Factory; use Tymon\JWTAuth\Payload; +use Tymon\JWTAuth\JWTGuard; +use Illuminate\Http\Request; +use Illuminate\Auth\EloquentUserProvider; +use Tymon\JWTAuth\Exceptions\JWTException; use Tymon\JWTAuth\Test\Stubs\LaravelUserStub; +use Tymon\JWTAuth\Exceptions\UserNotDefinedException; class JWTGuardTest extends AbstractTestCase { @@ -37,7 +39,7 @@ class JWTGuardTest extends AbstractTestCase */ protected $guard; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -46,17 +48,13 @@ public function setUp() $this->guard = new JWTGuard($this->jwt, $this->provider, Request::create('/foo', 'GET')); } - /** - * @test - */ + /** @test */ public function it_should_get_the_request() { $this->assertInstanceOf(Request::class, $this->guard->getRequest()); } - /** - * @test - */ + /** @test */ public function it_should_get_the_authenticated_user_if_a_valid_token_is_provided() { $payload = Mockery::mock(Payload::class); @@ -88,9 +86,7 @@ public function it_should_get_the_authenticated_user_if_a_valid_token_is_provide $this->assertSame(1, $this->guard->userOrFail()->id); } - /** - * @test - */ + /** @test */ public function it_should_get_the_authenticated_user_if_a_valid_token_is_provided_and_not_throw_an_exception() { $payload = Mockery::mock(Payload::class); @@ -119,9 +115,7 @@ public function it_should_get_the_authenticated_user_if_a_valid_token_is_provide $this->assertTrue($this->guard->check()); } - /** - * @test - */ + /** @test */ public function it_should_return_null_if_an_invalid_token_is_provided() { $this->jwt->shouldReceive('setRequest')->andReturn($this->jwt); @@ -134,9 +128,7 @@ public function it_should_return_null_if_an_invalid_token_is_provided() $this->assertFalse($this->guard->check()); // twice } - /** - * @test - */ + /** @test */ public function it_should_return_null_if_no_token_is_provided() { $this->jwt->shouldReceive('setRequest')->andReturn($this->jwt); @@ -149,13 +141,12 @@ public function it_should_return_null_if_no_token_is_provided() $this->assertFalse($this->guard->check()); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\UserNotDefinedException - * @expectedExceptionMessage An error occurred - */ + /** @test */ public function it_should_throw_an_exception_if_an_invalid_token_is_provided() { + $this->expectException(UserNotDefinedException::class); + $this->expectExceptionMessage('An error occurred'); + $this->jwt->shouldReceive('setRequest')->andReturn($this->jwt); $this->jwt->shouldReceive('getToken')->twice()->andReturn('invalid.token.here'); $this->jwt->shouldReceive('check')->twice()->andReturn(false); @@ -166,13 +157,12 @@ public function it_should_throw_an_exception_if_an_invalid_token_is_provided() $this->guard->userOrFail(); // twice, throws the exception } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\UserNotDefinedException - * @expectedExceptionMessage An error occurred - */ + /** @test */ public function it_should_throw_an_exception_if_no_token_is_provided() { + $this->expectException(UserNotDefinedException::class); + $this->expectExceptionMessage('An error occurred'); + $this->jwt->shouldReceive('setRequest')->andReturn($this->jwt); $this->jwt->shouldReceive('getToken')->andReturn(false); $this->jwt->shouldReceive('check')->never(); @@ -183,9 +173,7 @@ public function it_should_throw_an_exception_if_no_token_is_provided() $this->guard->userOrFail(); // throws the exception } - /** - * @test - */ + /** @test */ public function it_should_return_a_token_if_credentials_are_ok_and_user_is_found() { $credentials = ['foo' => 'bar', 'baz' => 'bob']; @@ -222,9 +210,7 @@ public function it_should_return_a_token_if_credentials_are_ok_and_user_is_found $this->assertSame($token, 'foo.bar.baz'); } - /** - * @test - */ + /** @test */ public function it_should_return_true_if_credentials_are_ok_and_user_is_found_when_choosing_not_to_login() { $credentials = ['foo' => 'bar', 'baz' => 'bob']; @@ -244,9 +230,7 @@ public function it_should_return_true_if_credentials_are_ok_and_user_is_found_wh $this->assertTrue($this->guard->validate($credentials)); // twice } - /** - * @test - */ + /** @test */ public function it_should_return_false_if_credentials_are_invalid() { $credentials = ['foo' => 'bar', 'baz' => 'bob']; @@ -265,18 +249,14 @@ public function it_should_return_false_if_credentials_are_invalid() $this->assertFalse($this->guard->attempt($credentials)); } - /** - * @test - */ + /** @test */ public function it_should_magically_call_the_jwt_instance() { $this->jwt->shouldReceive('factory')->andReturn(Mockery::mock(Factory::class)); $this->assertInstanceOf(Factory::class, $this->guard->factory()); } - /** - * @test - */ + /** @test */ public function it_should_logout_the_user_by_invalidating_the_token() { $this->jwt->shouldReceive('setRequest')->andReturn($this->jwt); @@ -288,9 +268,7 @@ public function it_should_logout_the_user_by_invalidating_the_token() $this->assertNull($this->guard->getUser()); } - /** - * @test - */ + /** @test */ public function it_should_refresh_the_token() { $this->jwt->shouldReceive('setRequest')->andReturn($this->jwt); @@ -300,9 +278,7 @@ public function it_should_refresh_the_token() $this->assertSame($this->guard->refresh(), 'foo.bar.baz'); } - /** - * @test - */ + /** @test */ public function it_should_invalidate_the_token() { $this->jwt->shouldReceive('setRequest')->andReturn($this->jwt); @@ -312,13 +288,12 @@ public function it_should_invalidate_the_token() $this->assertTrue($this->guard->invalidate()); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\JWTException - * @expectedExceptionMessage Token could not be parsed from the request. - */ + /** @test */ public function it_should_throw_an_exception_if_there_is_no_token_present_when_required() { + $this->expectException(JWTException::class); + $this->expectExceptionMessage('Token could not be parsed from the request.'); + $this->jwt->shouldReceive('setRequest')->andReturn($this->jwt); $this->jwt->shouldReceive('getToken')->once()->andReturn(false); $this->jwt->shouldReceive('refresh')->never(); @@ -326,9 +301,7 @@ public function it_should_throw_an_exception_if_there_is_no_token_present_when_r $this->guard->refresh(); } - /** - * @test - */ + /** @test */ public function it_should_generate_a_token_by_id() { $user = new LaravelUserStub; @@ -346,9 +319,7 @@ public function it_should_generate_a_token_by_id() $this->assertSame('foo.bar.baz', $this->guard->tokenById(1)); } - /** - * @test - */ + /** @test */ public function it_should_not_generate_a_token_by_id() { $this->provider->shouldReceive('retrieveById') @@ -359,9 +330,7 @@ public function it_should_not_generate_a_token_by_id() $this->assertNull($this->guard->tokenById(1)); } - /** - * @test - */ + /** @test */ public function it_should_authenticate_the_user_by_credentials_and_return_true_if_valid() { $credentials = ['foo' => 'bar', 'baz' => 'bob']; @@ -380,9 +349,7 @@ public function it_should_authenticate_the_user_by_credentials_and_return_true_i $this->assertTrue($this->guard->once($credentials)); } - /** - * @test - */ + /** @test */ public function it_should_attempt_to_authenticate_the_user_by_credentials_and_return_false_if_invalid() { $credentials = ['foo' => 'bar', 'baz' => 'bob']; @@ -401,9 +368,7 @@ public function it_should_attempt_to_authenticate_the_user_by_credentials_and_re $this->assertFalse($this->guard->once($credentials)); } - /** - * @test - */ + /** @test */ public function it_should_authenticate_the_user_by_id_and_return_boolean() { $user = new LaravelUserStub; @@ -417,9 +382,7 @@ public function it_should_authenticate_the_user_by_id_and_return_boolean() $this->assertTrue($this->guard->byId(1)); // twice } - /** - * @test - */ + /** @test */ public function it_should_not_authenticate_the_user_by_id_and_return_false() { $this->provider->shouldReceive('retrieveById') @@ -431,9 +394,7 @@ public function it_should_not_authenticate_the_user_by_id_and_return_false() $this->assertFalse($this->guard->byId(1)); // twice } - /** - * @test - */ + /** @test */ public function it_should_create_a_token_from_a_user_object() { $user = new LaravelUserStub; @@ -453,9 +414,7 @@ public function it_should_create_a_token_from_a_user_object() $this->assertSame('foo.bar.baz', $token); } - /** - * @test - */ + /** @test */ public function it_should_get_the_payload() { $this->jwt->shouldReceive('setRequest')->andReturn($this->jwt); @@ -464,9 +423,7 @@ public function it_should_get_the_payload() $this->assertInstanceOf(Payload::class, $this->guard->payload()); } - /** - * @test - */ + /** @test */ public function it_should_be_macroable() { $this->guard->macro('foo', function () { diff --git a/tests/ManagerTest.php b/tests/ManagerTest.php index 43586a27f..ad8d793f2 100644 --- a/tests/ManagerTest.php +++ b/tests/ManagerTest.php @@ -12,20 +12,22 @@ namespace Tymon\JWTAuth\Test; use Mockery; +use Tymon\JWTAuth\Token; +use Tymon\JWTAuth\Factory; +use Tymon\JWTAuth\Manager; +use Tymon\JWTAuth\Payload; use Tymon\JWTAuth\Blacklist; -use Tymon\JWTAuth\Claims\Collection; -use Tymon\JWTAuth\Claims\Expiration; -use Tymon\JWTAuth\Claims\IssuedAt; -use Tymon\JWTAuth\Claims\Issuer; use Tymon\JWTAuth\Claims\JwtId; -use Tymon\JWTAuth\Claims\NotBefore; +use Tymon\JWTAuth\Claims\Issuer; use Tymon\JWTAuth\Claims\Subject; +use Tymon\JWTAuth\Claims\IssuedAt; +use Tymon\JWTAuth\Claims\NotBefore; +use Tymon\JWTAuth\Claims\Collection; +use Tymon\JWTAuth\Claims\Expiration; use Tymon\JWTAuth\Contracts\Providers\JWT; -use Tymon\JWTAuth\Factory; -use Tymon\JWTAuth\Manager; -use Tymon\JWTAuth\Payload; -use Tymon\JWTAuth\Token; +use Tymon\JWTAuth\Exceptions\JWTException; use Tymon\JWTAuth\Validators\PayloadValidator; +use Tymon\JWTAuth\Exceptions\TokenBlacklistedException; class ManagerTest extends AbstractTestCase { @@ -54,7 +56,7 @@ class ManagerTest extends AbstractTestCase */ protected $validator; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -121,13 +123,12 @@ public function it_should_decode_a_token() $this->assertSame($payload->count(), 6); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\TokenBlacklistedException - * @expectedExceptionMessage The token has been blacklisted - */ + /** @test */ public function it_should_throw_exception_when_token_is_blacklisted() { + $this->expectException(TokenBlacklistedException::class); + $this->expectExceptionMessage('The token has been blacklisted'); + $claims = [ new Subject(1), new Issuer('http://example.com'), @@ -247,13 +248,12 @@ public function it_should_force_invalidate_a_token_forever() $this->manager->invalidate($token, true); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\JWTException - * @expectedExceptionMessage You must have the blacklist enabled to invalidate a token. - */ + /** @test */ public function it_should_throw_an_exception_when_enable_blacklist_is_set_to_false() { + $this->expectException(JWTException::class); + $this->expectExceptionMessage('You must have the blacklist enabled to invalidate a token.'); + $token = new Token('foo.bar.baz'); $this->manager->setBlacklistEnabled(false)->invalidate($token); diff --git a/tests/Middleware/AbstractMiddlewareTest.php b/tests/Middleware/AbstractMiddlewareTest.php index b1a0e452e..6f8fa4133 100644 --- a/tests/Middleware/AbstractMiddlewareTest.php +++ b/tests/Middleware/AbstractMiddlewareTest.php @@ -28,7 +28,7 @@ abstract class AbstractMiddlewareTest extends AbstractTestCase */ protected $request; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Middleware/AuthenticateAndRenewTest.php b/tests/Middleware/AuthenticateAndRenewTest.php index bb2eab84d..6d36f423b 100644 --- a/tests/Middleware/AuthenticateAndRenewTest.php +++ b/tests/Middleware/AuthenticateAndRenewTest.php @@ -11,12 +11,13 @@ namespace Tymon\JWTAuth\Test\Middleware; -use Illuminate\Http\Response; use Mockery; -use Tymon\JWTAuth\Exceptions\TokenInvalidException; -use Tymon\JWTAuth\Http\Middleware\AuthenticateAndRenew; +use Illuminate\Http\Response; use Tymon\JWTAuth\Http\Parser\Parser; use Tymon\JWTAuth\Test\Stubs\UserStub; +use Tymon\JWTAuth\Exceptions\TokenInvalidException; +use Tymon\JWTAuth\Http\Middleware\AuthenticateAndRenew; +use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; class AuthenticateAndRenewTest extends AbstractMiddlewareTest { @@ -25,7 +26,7 @@ class AuthenticateAndRenewTest extends AbstractMiddlewareTest */ protected $middleware; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -51,12 +52,11 @@ public function it_should_authenticate_a_user_and_return_a_new_token() $this->assertSame($response->headers->get('authorization'), 'Bearer foo.bar.baz'); } - /** - * @test - * @expectedException \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException - */ + /** @test */ public function it_should_throw_an_unauthorized_exception_if_token_not_provided() { + $this->expectException(UnauthorizedHttpException::class); + $parser = Mockery::mock(Parser::class); $parser->shouldReceive('hasToken')->once()->andReturn(false); @@ -68,12 +68,11 @@ public function it_should_throw_an_unauthorized_exception_if_token_not_provided( }); } - /** - * @test - * @expectedException \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException - */ + /** @test */ public function it_should_throw_an_unauthorized_exception_if_token_invalid() { + $this->expectException(UnauthorizedHttpException::class); + $parser = Mockery::mock(Parser::class); $parser->shouldReceive('hasToken')->once()->andReturn(true); diff --git a/tests/Middleware/AuthenticateTest.php b/tests/Middleware/AuthenticateTest.php index 05f5fb208..d48e5d01a 100644 --- a/tests/Middleware/AuthenticateTest.php +++ b/tests/Middleware/AuthenticateTest.php @@ -12,10 +12,11 @@ namespace Tymon\JWTAuth\Test\Middleware; use Mockery; -use Tymon\JWTAuth\Exceptions\TokenInvalidException; -use Tymon\JWTAuth\Http\Middleware\Authenticate; use Tymon\JWTAuth\Http\Parser\Parser; use Tymon\JWTAuth\Test\Stubs\UserStub; +use Tymon\JWTAuth\Http\Middleware\Authenticate; +use Tymon\JWTAuth\Exceptions\TokenInvalidException; +use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; class AuthenticateTest extends AbstractMiddlewareTest { @@ -24,7 +25,7 @@ class AuthenticateTest extends AbstractMiddlewareTest */ protected $middleware; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -47,12 +48,11 @@ public function it_should_authenticate_a_user() }); } - /** - * @test - * @expectedException \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException - */ + /** @test */ public function it_should_throw_an_unauthorized_exception_if_token_not_provided() { + $this->expectException(UnauthorizedHttpException::class); + $parser = Mockery::mock(Parser::class); $parser->shouldReceive('hasToken')->once()->andReturn(false); @@ -64,12 +64,11 @@ public function it_should_throw_an_unauthorized_exception_if_token_not_provided( }); } - /** - * @test - * @expectedException \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException - */ + /** @test */ public function it_should_throw_an_unauthorized_exception_if_token_invalid() { + $this->expectException(UnauthorizedHttpException::class); + $parser = Mockery::mock(Parser::class); $parser->shouldReceive('hasToken')->once()->andReturn(true); @@ -83,12 +82,11 @@ public function it_should_throw_an_unauthorized_exception_if_token_invalid() }); } - /** - * @test - * @expectedException \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException - */ + /** @test */ public function it_should_throw_an_unauthorized_exception_if_user_not_found() { + $this->expectException(UnauthorizedHttpException::class); + $parser = Mockery::mock(Parser::class); $parser->shouldReceive('hasToken')->once()->andReturn(true); diff --git a/tests/Middleware/CheckTest.php b/tests/Middleware/CheckTest.php index 5f716bc8f..4a48ffa96 100644 --- a/tests/Middleware/CheckTest.php +++ b/tests/Middleware/CheckTest.php @@ -24,7 +24,7 @@ class CheckTest extends AbstractMiddlewareTest */ protected $middleware; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Middleware/RefreshTokenTest.php b/tests/Middleware/RefreshTokenTest.php index 3e1da974c..4be3b59fc 100644 --- a/tests/Middleware/RefreshTokenTest.php +++ b/tests/Middleware/RefreshTokenTest.php @@ -11,11 +11,12 @@ namespace Tymon\JWTAuth\Test\Middleware; -use Illuminate\Http\Response; use Mockery; -use Tymon\JWTAuth\Exceptions\TokenInvalidException; -use Tymon\JWTAuth\Http\Middleware\RefreshToken; +use Illuminate\Http\Response; use Tymon\JWTAuth\Http\Parser\Parser; +use Tymon\JWTAuth\Http\Middleware\RefreshToken; +use Tymon\JWTAuth\Exceptions\TokenInvalidException; +use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; class RefreshTokenTest extends AbstractMiddlewareTest { @@ -24,7 +25,7 @@ class RefreshTokenTest extends AbstractMiddlewareTest */ protected $middleware; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -49,12 +50,11 @@ public function it_should_refresh_a_token() $this->assertSame($response->headers->get('authorization'), 'Bearer foo.bar.baz'); } - /** - * @test - * @expectedException \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException - */ + /** @test */ public function it_should_throw_an_unauthorized_exception_if_token_not_provided() { + $this->expectException(UnauthorizedHttpException::class); + $parser = Mockery::mock(Parser::class); $parser->shouldReceive('hasToken')->once()->andReturn(false); @@ -66,12 +66,11 @@ public function it_should_throw_an_unauthorized_exception_if_token_not_provided( }); } - /** - * @test - * @expectedException \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException - */ + /** @test */ public function it_should_throw_an_unauthorized_exception_if_token_invalid() { + $this->expectException(UnauthorizedHttpException::class); + $parser = Mockery::mock(Parser::class); $parser->shouldReceive('hasToken')->once()->andReturn(true); diff --git a/tests/PayloadTest.php b/tests/PayloadTest.php index e1da9f8d2..5734bcf70 100644 --- a/tests/PayloadTest.php +++ b/tests/PayloadTest.php @@ -12,16 +12,18 @@ namespace Tymon\JWTAuth\Test; use Mockery; -use Tymon\JWTAuth\Claims\Audience; +use Tymon\JWTAuth\Payload; +use BadMethodCallException; use Tymon\JWTAuth\Claims\Claim; -use Tymon\JWTAuth\Claims\Collection; -use Tymon\JWTAuth\Claims\Expiration; -use Tymon\JWTAuth\Claims\IssuedAt; -use Tymon\JWTAuth\Claims\Issuer; use Tymon\JWTAuth\Claims\JwtId; -use Tymon\JWTAuth\Claims\NotBefore; +use Tymon\JWTAuth\Claims\Issuer; use Tymon\JWTAuth\Claims\Subject; -use Tymon\JWTAuth\Payload; +use Tymon\JWTAuth\Claims\Audience; +use Tymon\JWTAuth\Claims\IssuedAt; +use Tymon\JWTAuth\Claims\NotBefore; +use Tymon\JWTAuth\Claims\Collection; +use Tymon\JWTAuth\Claims\Expiration; +use Tymon\JWTAuth\Exceptions\PayloadException; use Tymon\JWTAuth\Validators\PayloadValidator; class PayloadTest extends AbstractTestCase @@ -36,7 +38,7 @@ class PayloadTest extends AbstractTestCase */ protected $payload; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -71,23 +73,21 @@ private function getTestPayload(array $extraClaims = []) return new Payload($collection, $this->validator); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\PayloadException - * @expectedExceptionMessage The payload is immutable - */ + /** @test */ public function it_should_throw_an_exception_when_trying_to_add_to_the_payload() { + $this->expectException(PayloadException::class); + $this->expectExceptionMessage('The payload is immutable'); + $this->payload['foo'] = 'bar'; } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\PayloadException - * @expectedExceptionMessage The payload is immutable - */ + /** @test */ public function it_should_throw_an_exception_when_trying_to_remove_a_key_from_the_payload() { + $this->expectException(PayloadException::class); + $this->expectExceptionMessage('The payload is immutable'); + unset($this->payload['foo']); } @@ -109,7 +109,7 @@ public function it_should_allow_array_access_on_the_payload() /** @test */ public function it_should_get_properties_of_payload_via_get_method() { - $this->assertInternalType('array', $this->payload->get()); + $this->assertIsArray($this->payload->get()); $this->assertSame($this->payload->get('sub'), 1); $this->assertSame( @@ -128,7 +128,7 @@ public function it_should_get_multiple_properties_when_passing_an_array_to_the_g $sub = $values[0]; $jti = $values[1]; - $this->assertInternalType('array', $values); + $this->assertIsArray($values); $this->assertSame($sub, 1); $this->assertSame($jti, 'foo'); } @@ -168,13 +168,12 @@ public function it_should_invoke_the_instance_as_a_callable() $this->assertSame($payload(), $this->payload->toArray()); } - /** - * @test - * @expectedException \BadMethodCallException - * @expectedExceptionMessage The claim [getFoo] does not exist on the payload. - */ + /** @test */ public function it_should_throw_an_exception_when_magically_getting_a_property_that_does_not_exist() { + $this->expectException(BadMethodCallException::class); + $this->expectExceptionMessage('The claim [Foo] does not exist on the payload'); + $this->payload->getFoo(); } diff --git a/tests/Providers/Auth/IlluminateTest.php b/tests/Providers/Auth/IlluminateTest.php index 7f0a381e6..b850c1f06 100644 --- a/tests/Providers/Auth/IlluminateTest.php +++ b/tests/Providers/Auth/IlluminateTest.php @@ -28,7 +28,7 @@ class IlluminateTest extends AbstractTestCase */ protected $auth; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Providers/JWT/LcobucciTest.php b/tests/Providers/JWT/LcobucciTest.php index 7f1d8bd7e..35f0d9fca 100644 --- a/tests/Providers/JWT/LcobucciTest.php +++ b/tests/Providers/JWT/LcobucciTest.php @@ -11,14 +11,16 @@ namespace Tymon\JWTAuth\Test\Providers\JWT; +use Mockery; use Exception; -use InvalidArgumentException; -use Lcobucci\JWT\Builder; use Lcobucci\JWT\Parser; +use Lcobucci\JWT\Builder; use Lcobucci\JWT\Signer\Key; -use Mockery; -use Tymon\JWTAuth\Providers\JWT\Lcobucci; +use InvalidArgumentException; use Tymon\JWTAuth\Test\AbstractTestCase; +use Tymon\JWTAuth\Providers\JWT\Lcobucci; +use Tymon\JWTAuth\Exceptions\JWTException; +use Tymon\JWTAuth\Exceptions\TokenInvalidException; class LcobucciTest extends AbstractTestCase { @@ -37,7 +39,7 @@ class LcobucciTest extends AbstractTestCase */ protected $provider; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -60,13 +62,12 @@ public function it_should_return_the_token_when_passing_a_valid_payload_to_encod $this->assertSame('foo.bar.baz', $token); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\JWTException - * @expectedExceptionMessage Could not create token: - */ + /** @test */ public function it_should_throw_an_invalid_exception_when_the_payload_could_not_be_encoded() { + $this->expectException(JWTException::class); + $this->expectExceptionMessage('Could not create token:'); + $payload = ['sub' => 1, 'exp' => $this->testNowTimestamp, 'iat' => $this->testNowTimestamp, 'iss' => '/foo']; $this->builder->shouldReceive('unsign')->once()->andReturnSelf(); @@ -88,13 +89,12 @@ public function it_should_return_the_payload_when_passing_a_valid_token_to_decod $this->assertSame($payload, $this->getProvider('secret', 'HS256')->decode('foo.bar.baz')); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\TokenInvalidException - * @expectedExceptionMessage Token Signature could not be verified. - */ + /** @test */ public function it_should_throw_a_token_invalid_exception_when_the_token_could_not_be_decoded_due_to_a_bad_signature() { + $this->expectException(TokenInvalidException::class); + $this->expectExceptionMessage('Token Signature could not be verified.'); + $this->parser->shouldReceive('parse')->once()->with('foo.bar.baz')->andReturn(Mockery::self()); $this->parser->shouldReceive('verify')->once()->with(Mockery::any(), 'secret')->andReturn(false); $this->parser->shouldReceive('getClaims')->never(); @@ -102,13 +102,12 @@ public function it_should_throw_a_token_invalid_exception_when_the_token_could_n $this->getProvider('secret', 'HS256')->decode('foo.bar.baz'); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\TokenInvalidException - * @expectedExceptionMessage Could not decode token: - */ + /** @test */ public function it_should_throw_a_token_invalid_exception_when_the_token_could_not_be_decoded() { + $this->expectException(TokenInvalidException::class); + $this->expectExceptionMessage('Could not decode token:'); + $this->parser->shouldReceive('parse')->once()->with('foo.bar.baz')->andThrow(new InvalidArgumentException); $this->parser->shouldReceive('verify')->never(); $this->parser->shouldReceive('getClaims')->never(); @@ -137,22 +136,19 @@ public function it_should_generate_a_token_when_using_an_rsa_algorithm() $this->assertSame('foo.bar.baz', $token); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\JWTException - * @expectedExceptionMessage The given algorithm could not be found - */ + /** @test */ public function it_should_throw_a_exception_when_the_algorithm_passed_is_invalid() { + $this->expectException(JWTException::class); + $this->expectExceptionMessage('The given algorithm could not be found'); + $this->parser->shouldReceive('parse')->never(); $this->parser->shouldReceive('verify')->never(); $this->getProvider('secret', 'AlgorithmWrong')->decode('foo.bar.baz'); } - /** - * @test - */ + /** @test */ public function it_should_return_the_public_key() { $provider = $this->getProvider( @@ -164,9 +160,7 @@ public function it_should_return_the_public_key() $this->assertSame($keys['public'], $provider->getPublicKey()); } - /** - * @test - */ + /** @test */ public function it_should_return_the_keys() { $provider = $this->getProvider( diff --git a/tests/Providers/JWT/NamshiTest.php b/tests/Providers/JWT/NamshiTest.php index 883192e72..375ce1898 100644 --- a/tests/Providers/JWT/NamshiTest.php +++ b/tests/Providers/JWT/NamshiTest.php @@ -11,12 +11,14 @@ namespace Tymon\JWTAuth\Test\Providers\JWT; -use Exception; -use InvalidArgumentException; use Mockery; +use Exception; use Namshi\JOSE\JWS; +use InvalidArgumentException; use Tymon\JWTAuth\Providers\JWT\Namshi; use Tymon\JWTAuth\Test\AbstractTestCase; +use Tymon\JWTAuth\Exceptions\JWTException; +use Tymon\JWTAuth\Exceptions\TokenInvalidException; class NamshiTest extends AbstractTestCase { @@ -30,7 +32,7 @@ class NamshiTest extends AbstractTestCase */ protected $provider; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -51,13 +53,12 @@ public function it_should_return_the_token_when_passing_a_valid_payload_to_encod $this->assertSame('foo.bar.baz', $token); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\JWTException - * @expectedExceptionMessage Could not create token: - */ + /** @test */ public function it_should_throw_an_invalid_exception_when_the_payload_could_not_be_encoded() { + $this->expectException(JWTException::class); + $this->expectExceptionMessage('Could not create token:'); + $payload = ['sub' => 1, 'exp' => $this->testNowTimestamp, 'iat' => $this->testNowTimestamp, 'iss' => '/foo']; $this->jws->shouldReceive('setPayload')->once()->with($payload)->andReturn(Mockery::self()); @@ -78,13 +79,12 @@ public function it_should_return_the_payload_when_passing_a_valid_token_to_decod $this->assertSame($payload, $this->getProvider('secret', 'HS256')->decode('foo.bar.baz')); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\TokenInvalidException - * @expectedExceptionMessage Token Signature could not be verified. - */ + /** @test */ public function it_should_throw_a_token_invalid_exception_when_the_token_could_not_be_decoded_due_to_a_bad_signature() { + $this->expectException(TokenInvalidException::class); + $this->expectExceptionMessage('Token Signature could not be verified.'); + $this->jws->shouldReceive('load')->once()->with('foo.bar.baz', false)->andReturn(Mockery::self()); $this->jws->shouldReceive('verify')->once()->with('secret', 'HS256')->andReturn(false); $this->jws->shouldReceive('getPayload')->never(); @@ -92,13 +92,12 @@ public function it_should_throw_a_token_invalid_exception_when_the_token_could_n $this->getProvider('secret', 'HS256')->decode('foo.bar.baz'); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\TokenInvalidException - * @expectedExceptionMessage Could not decode token: - */ + /** @test */ public function it_should_throw_a_token_invalid_exception_when_the_token_could_not_be_decoded() { + $this->expectException(TokenInvalidException::class); + $this->expectExceptionMessage('Could not decode token:'); + $this->jws->shouldReceive('load')->once()->with('foo.bar.baz', false)->andThrow(new InvalidArgumentException); $this->jws->shouldReceive('verify')->never(); $this->jws->shouldReceive('getPayload')->never(); @@ -166,22 +165,19 @@ public function it_should_decode_a_token_when_using_an_rsa_algorithm() $this->assertSame('foo.bar.baz', $token); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\JWTException - * @expectedExceptionMessage The given algorithm could not be found - */ + /** @test */ public function it_should_throw_a_exception_when_the_algorithm_passed_is_invalid() { + $this->expectException(JWTException::class); + $this->expectExceptionMessage('The given algorithm could not be found'); + $this->jws->shouldReceive('load')->once()->with('foo.bar.baz', false)->andReturn(Mockery::self()); $this->jws->shouldReceive('verify')->with('secret', 'AlgorithmWrong')->andReturn(true); $this->getProvider('secret', 'AlgorithmWrong')->decode('foo.bar.baz'); } - /** - * @test - */ + /** @test */ public function it_should_return_the_public_key() { $provider = $this->getProvider( @@ -193,9 +189,7 @@ public function it_should_return_the_public_key() $this->assertSame($keys['public'], $provider->getPublicKey()); } - /** - * @test - */ + /** @test */ public function it_should_return_the_keys() { $provider = $this->getProvider( diff --git a/tests/Providers/JWT/ProviderTest.php b/tests/Providers/JWT/ProviderTest.php index 89a1018e9..be4942d05 100644 --- a/tests/Providers/JWT/ProviderTest.php +++ b/tests/Providers/JWT/ProviderTest.php @@ -21,7 +21,7 @@ class ProviderTest extends AbstractTestCase */ protected $provider; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Providers/Storage/IlluminateTest.php b/tests/Providers/Storage/IlluminateTest.php index 0ec560862..3817c8651 100644 --- a/tests/Providers/Storage/IlluminateTest.php +++ b/tests/Providers/Storage/IlluminateTest.php @@ -29,7 +29,7 @@ class IlluminateTest extends AbstractTestCase */ protected $storage; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/TokenTest.php b/tests/TokenTest.php index ca44ce7fb..034f7b870 100644 --- a/tests/TokenTest.php +++ b/tests/TokenTest.php @@ -20,7 +20,7 @@ class TokenTest extends AbstractTestCase */ protected $token; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -36,6 +36,6 @@ public function it_should_return_the_token_when_casting_to_a_string() /** @test */ public function it_should_return_the_token_when_calling_get_method() { - $this->assertInternalType('string', $this->token->get()); + $this->assertIsString($this->token->get()); } } diff --git a/tests/Validators/PayloadValidatorTest.php b/tests/Validators/PayloadValidatorTest.php index 90125c218..64e246e6f 100644 --- a/tests/Validators/PayloadValidatorTest.php +++ b/tests/Validators/PayloadValidatorTest.php @@ -11,15 +11,18 @@ namespace Tymon\JWTAuth\Test\Validators; -use Tymon\JWTAuth\Claims\Collection; -use Tymon\JWTAuth\Claims\Expiration; -use Tymon\JWTAuth\Claims\IssuedAt; -use Tymon\JWTAuth\Claims\Issuer; use Tymon\JWTAuth\Claims\JwtId; -use Tymon\JWTAuth\Claims\NotBefore; +use Tymon\JWTAuth\Claims\Issuer; use Tymon\JWTAuth\Claims\Subject; +use Tymon\JWTAuth\Claims\IssuedAt; +use Tymon\JWTAuth\Claims\NotBefore; +use Tymon\JWTAuth\Claims\Collection; +use Tymon\JWTAuth\Claims\Expiration; use Tymon\JWTAuth\Test\AbstractTestCase; use Tymon\JWTAuth\Validators\PayloadValidator; +use Tymon\JWTAuth\Exceptions\InvalidClaimException; +use Tymon\JWTAuth\Exceptions\TokenExpiredException; +use Tymon\JWTAuth\Exceptions\TokenInvalidException; class PayloadValidatorTest extends AbstractTestCase { @@ -28,7 +31,7 @@ class PayloadValidatorTest extends AbstractTestCase */ protected $validator; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -52,13 +55,12 @@ public function it_should_return_true_when_providing_a_valid_payload() $this->assertTrue($this->validator->isValid($collection)); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\TokenExpiredException - * @expectedExceptionMessage Token has expired - */ + /** @test */ public function it_should_throw_an_exception_when_providing_an_expired_payload() { + $this->expectException(TokenExpiredException::class); + $this->expectExceptionMessage('Token has expired'); + $claims = [ new Subject(1), new Issuer('http://example.com'), @@ -73,13 +75,12 @@ public function it_should_throw_an_exception_when_providing_an_expired_payload() $this->validator->check($collection); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\TokenInvalidException - * @expectedExceptionMessage Not Before (nbf) timestamp cannot be in the future - */ + /** @test */ public function it_should_throw_an_exception_when_providing_an_invalid_nbf_claim() { + $this->expectException(TokenInvalidException::class); + $this->expectExceptionMessage('Not Before (nbf) timestamp cannot be in the future'); + $claims = [ new Subject(1), new Issuer('http://example.com'), @@ -94,13 +95,12 @@ public function it_should_throw_an_exception_when_providing_an_invalid_nbf_claim $this->validator->check($collection); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\InvalidClaimException - * @expectedExceptionMessage Invalid value provided for claim [iat] - */ + /** @test */ public function it_should_throw_an_exception_when_providing_an_invalid_iat_claim() { + $this->expectException(InvalidClaimException::class); + $this->expectExceptionMessage('Invalid value provided for claim [iat]'); + $claims = [ new Subject(1), new Issuer('http://example.com'), @@ -115,13 +115,12 @@ public function it_should_throw_an_exception_when_providing_an_invalid_iat_claim $this->validator->check($collection); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\TokenInvalidException - * @expectedExceptionMessage JWT payload does not contain the required claims - */ + /** @test */ public function it_should_throw_an_exception_when_providing_an_invalid_payload() { + $this->expectException(TokenInvalidException::class); + $this->expectExceptionMessage('JWT payload does not contain the required claims'); + $claims = [ new Subject(1), new Issuer('http://example.com'), @@ -132,13 +131,12 @@ public function it_should_throw_an_exception_when_providing_an_invalid_payload() $this->validator->check($collection); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\InvalidClaimException - * @expectedExceptionMessage Invalid value provided for claim [exp] - */ + /** @test */ public function it_should_throw_an_exception_when_providing_an_invalid_expiry() { + $this->expectException(InvalidClaimException::class); + $this->expectExceptionMessage('Invalid value provided for claim [exp]'); + $claims = [ new Subject(1), new Issuer('http://example.com'), @@ -204,13 +202,12 @@ public function it_should_return_true_if_the_refresh_ttl_is_null() ); } - /** - * @test - * @expectedException \Tymon\JWTAuth\Exceptions\TokenExpiredException - * @expectedExceptionMessage Token has expired and can no longer be refreshed - */ + /** @test */ public function it_should_throw_an_exception_if_the_token_cannot_be_refreshed() { + $this->expectException(TokenExpiredException::class); + $this->expectExceptionMessage('Token has expired and can no longer be refreshed'); + $claims = [ new Subject(1), new Issuer('http://example.com'), diff --git a/tests/Validators/TokenValidatorTest.php b/tests/Validators/TokenValidatorTest.php index 657fd6198..33fb3633b 100644 --- a/tests/Validators/TokenValidatorTest.php +++ b/tests/Validators/TokenValidatorTest.php @@ -13,6 +13,7 @@ use Tymon\JWTAuth\Test\AbstractTestCase; use Tymon\JWTAuth\Validators\TokenValidator; +use Tymon\JWTAuth\Exceptions\TokenInvalidException; class TokenValidatorTest extends AbstractTestCase { @@ -21,7 +22,7 @@ class TokenValidatorTest extends AbstractTestCase */ protected $validator; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -34,19 +35,6 @@ public function it_should_return_true_when_providing_a_well_formed_token() $this->assertTrue($this->validator->isValid('one.two.three')); } - public function dataProviderMalformedTokens() - { - return [ - ['one.two.'], - ['.two.'], - ['.two.three'], - ['one..three'], - ['..'], - [' . . '], - [' one . two . three '], - ]; - } - /** * @test * @dataProvider \Tymon\JWTAuth\Test\Validators\TokenValidatorTest::dataProviderMalformedTokens @@ -61,30 +49,18 @@ public function it_should_return_false_when_providing_a_malformed_token($token) /** * @test * @dataProvider \Tymon\JWTAuth\Test\Validators\TokenValidatorTest::dataProviderMalformedTokens - * - * @param string $token - * @expectedException \Tymon\JWTAuth\Exceptions\TokenInvalidException - * @expectedExceptionMessage Malformed token */ public function it_should_throw_an_exception_when_providing_a_malformed_token($token) { - $this->validator->check($token); - } + $this->expectException(TokenInvalidException::class); + $this->expectExceptionMessage('Malformed token'); - public function dataProviderTokensWithWrongSegmentsNumber() - { - return [ - ['one.two'], - ['one.two.three.four'], - ['one.two.three.four.five'], - ]; + $this->validator->check($token); } /** * @test * @dataProvider \Tymon\JWTAuth\Test\Validators\TokenValidatorTest::dataProviderTokensWithWrongSegmentsNumber - * - * @param string $token */ public function it_should_return_false_when_providing_a_token_with_wrong_segments_number($token) { @@ -94,13 +70,34 @@ public function it_should_return_false_when_providing_a_token_with_wrong_segment /** * @test * @dataProvider \Tymon\JWTAuth\Test\Validators\TokenValidatorTest::dataProviderTokensWithWrongSegmentsNumber - * - * @param string $token - * @expectedException \Tymon\JWTAuth\Exceptions\TokenInvalidException - * @expectedExceptionMessage Wrong number of segments */ public function it_should_throw_an_exception_when_providing_a_malformed_token_with_wrong_segments_number($token) { + $this->expectException(TokenInvalidException::class); + $this->expectExceptionMessage('Wrong number of segments'); + $this->validator->check($token); } + + public function dataProviderMalformedTokens() + { + return [ + ['one.two.'], + ['.two.'], + ['.two.three'], + ['one..three'], + ['..'], + [' . . '], + [' one . two . three '], + ]; + } + + public function dataProviderTokensWithWrongSegmentsNumber() + { + return [ + ['one.two'], + ['one.two.three.four'], + ['one.two.three.four.five'], + ]; + } } From e94ec8d0c918adedfd84b955c59da7f89a448cb8 Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Fri, 27 Nov 2020 15:37:46 +0000 Subject: [PATCH 05/19] Apply fixes from StyleCI (#2066) [ci skip] [skip ci] --- src/Payload.php | 8 ++++---- tests/Claims/ClaimTest.php | 4 ++-- tests/Claims/IssuedAtTest.php | 2 +- tests/Claims/NotBeforeTest.php | 2 +- tests/JWTGuardTest.php | 12 +++++------ tests/ManagerTest.php | 20 +++++++++---------- tests/Middleware/AuthenticateAndRenewTest.php | 8 ++++---- tests/Middleware/AuthenticateTest.php | 6 +++--- tests/Middleware/RefreshTokenTest.php | 8 ++++---- tests/PayloadTest.php | 16 +++++++-------- tests/Providers/JWT/LcobucciTest.php | 10 +++++----- tests/Providers/JWT/NamshiTest.php | 8 ++++---- tests/Validators/PayloadValidatorTest.php | 14 ++++++------- tests/Validators/TokenValidatorTest.php | 2 +- 14 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/Payload.php b/src/Payload.php index a071965af..b7b49974d 100644 --- a/src/Payload.php +++ b/src/Payload.php @@ -11,16 +11,16 @@ namespace Tymon\JWTAuth; -use Countable; use ArrayAccess; -use JsonSerializable; use BadMethodCallException; +use Countable; +use Illuminate\Contracts\Support\Arrayable; +use Illuminate\Contracts\Support\Jsonable; use Illuminate\Support\Arr; use Illuminate\Support\Str; +use JsonSerializable; use Tymon\JWTAuth\Claims\Claim; use Tymon\JWTAuth\Claims\Collection; -use Illuminate\Contracts\Support\Jsonable; -use Illuminate\Contracts\Support\Arrayable; use Tymon\JWTAuth\Exceptions\PayloadException; use Tymon\JWTAuth\Validators\PayloadValidator; diff --git a/tests/Claims/ClaimTest.php b/tests/Claims/ClaimTest.php index 7b092c5af..eed44cca4 100644 --- a/tests/Claims/ClaimTest.php +++ b/tests/Claims/ClaimTest.php @@ -11,10 +11,10 @@ namespace Tymon\JWTAuth\Test\Claims; -use Tymon\JWTAuth\Claims\Expiration; -use Tymon\JWTAuth\Test\AbstractTestCase; use Illuminate\Contracts\Support\Arrayable; +use Tymon\JWTAuth\Claims\Expiration; use Tymon\JWTAuth\Exceptions\InvalidClaimException; +use Tymon\JWTAuth\Test\AbstractTestCase; class ClaimTest extends AbstractTestCase { diff --git a/tests/Claims/IssuedAtTest.php b/tests/Claims/IssuedAtTest.php index 36b1856ba..f57874aea 100644 --- a/tests/Claims/IssuedAtTest.php +++ b/tests/Claims/IssuedAtTest.php @@ -12,8 +12,8 @@ namespace Tymon\JWTAuth\Test\Claims; use Tymon\JWTAuth\Claims\IssuedAt; -use Tymon\JWTAuth\Test\AbstractTestCase; use Tymon\JWTAuth\Exceptions\InvalidClaimException; +use Tymon\JWTAuth\Test\AbstractTestCase; class IssuedAtTest extends AbstractTestCase { diff --git a/tests/Claims/NotBeforeTest.php b/tests/Claims/NotBeforeTest.php index 6157b53a4..185c108aa 100644 --- a/tests/Claims/NotBeforeTest.php +++ b/tests/Claims/NotBeforeTest.php @@ -12,8 +12,8 @@ namespace Tymon\JWTAuth\Test\Claims; use Tymon\JWTAuth\Claims\NotBefore; -use Tymon\JWTAuth\Test\AbstractTestCase; use Tymon\JWTAuth\Exceptions\InvalidClaimException; +use Tymon\JWTAuth\Test\AbstractTestCase; class NotBeforeTest extends AbstractTestCase { diff --git a/tests/JWTGuardTest.php b/tests/JWTGuardTest.php index 8af43713e..d15ca5a50 100644 --- a/tests/JWTGuardTest.php +++ b/tests/JWTGuardTest.php @@ -11,16 +11,16 @@ namespace Tymon\JWTAuth\Test; +use Illuminate\Auth\EloquentUserProvider; +use Illuminate\Http\Request; use Mockery; -use Tymon\JWTAuth\JWT; +use Tymon\JWTAuth\Exceptions\JWTException; +use Tymon\JWTAuth\Exceptions\UserNotDefinedException; use Tymon\JWTAuth\Factory; -use Tymon\JWTAuth\Payload; +use Tymon\JWTAuth\JWT; use Tymon\JWTAuth\JWTGuard; -use Illuminate\Http\Request; -use Illuminate\Auth\EloquentUserProvider; -use Tymon\JWTAuth\Exceptions\JWTException; +use Tymon\JWTAuth\Payload; use Tymon\JWTAuth\Test\Stubs\LaravelUserStub; -use Tymon\JWTAuth\Exceptions\UserNotDefinedException; class JWTGuardTest extends AbstractTestCase { diff --git a/tests/ManagerTest.php b/tests/ManagerTest.php index ad8d793f2..aee83ffa3 100644 --- a/tests/ManagerTest.php +++ b/tests/ManagerTest.php @@ -12,22 +12,22 @@ namespace Tymon\JWTAuth\Test; use Mockery; -use Tymon\JWTAuth\Token; -use Tymon\JWTAuth\Factory; -use Tymon\JWTAuth\Manager; -use Tymon\JWTAuth\Payload; use Tymon\JWTAuth\Blacklist; -use Tymon\JWTAuth\Claims\JwtId; -use Tymon\JWTAuth\Claims\Issuer; -use Tymon\JWTAuth\Claims\Subject; -use Tymon\JWTAuth\Claims\IssuedAt; -use Tymon\JWTAuth\Claims\NotBefore; use Tymon\JWTAuth\Claims\Collection; use Tymon\JWTAuth\Claims\Expiration; +use Tymon\JWTAuth\Claims\IssuedAt; +use Tymon\JWTAuth\Claims\Issuer; +use Tymon\JWTAuth\Claims\JwtId; +use Tymon\JWTAuth\Claims\NotBefore; +use Tymon\JWTAuth\Claims\Subject; use Tymon\JWTAuth\Contracts\Providers\JWT; use Tymon\JWTAuth\Exceptions\JWTException; -use Tymon\JWTAuth\Validators\PayloadValidator; use Tymon\JWTAuth\Exceptions\TokenBlacklistedException; +use Tymon\JWTAuth\Factory; +use Tymon\JWTAuth\Manager; +use Tymon\JWTAuth\Payload; +use Tymon\JWTAuth\Token; +use Tymon\JWTAuth\Validators\PayloadValidator; class ManagerTest extends AbstractTestCase { diff --git a/tests/Middleware/AuthenticateAndRenewTest.php b/tests/Middleware/AuthenticateAndRenewTest.php index 6d36f423b..31321e350 100644 --- a/tests/Middleware/AuthenticateAndRenewTest.php +++ b/tests/Middleware/AuthenticateAndRenewTest.php @@ -11,13 +11,13 @@ namespace Tymon\JWTAuth\Test\Middleware; -use Mockery; use Illuminate\Http\Response; -use Tymon\JWTAuth\Http\Parser\Parser; -use Tymon\JWTAuth\Test\Stubs\UserStub; +use Mockery; +use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; use Tymon\JWTAuth\Exceptions\TokenInvalidException; use Tymon\JWTAuth\Http\Middleware\AuthenticateAndRenew; -use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; +use Tymon\JWTAuth\Http\Parser\Parser; +use Tymon\JWTAuth\Test\Stubs\UserStub; class AuthenticateAndRenewTest extends AbstractMiddlewareTest { diff --git a/tests/Middleware/AuthenticateTest.php b/tests/Middleware/AuthenticateTest.php index d48e5d01a..0872323b1 100644 --- a/tests/Middleware/AuthenticateTest.php +++ b/tests/Middleware/AuthenticateTest.php @@ -12,11 +12,11 @@ namespace Tymon\JWTAuth\Test\Middleware; use Mockery; +use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; +use Tymon\JWTAuth\Exceptions\TokenInvalidException; +use Tymon\JWTAuth\Http\Middleware\Authenticate; use Tymon\JWTAuth\Http\Parser\Parser; use Tymon\JWTAuth\Test\Stubs\UserStub; -use Tymon\JWTAuth\Http\Middleware\Authenticate; -use Tymon\JWTAuth\Exceptions\TokenInvalidException; -use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; class AuthenticateTest extends AbstractMiddlewareTest { diff --git a/tests/Middleware/RefreshTokenTest.php b/tests/Middleware/RefreshTokenTest.php index 4be3b59fc..4cb2aca8d 100644 --- a/tests/Middleware/RefreshTokenTest.php +++ b/tests/Middleware/RefreshTokenTest.php @@ -11,12 +11,12 @@ namespace Tymon\JWTAuth\Test\Middleware; -use Mockery; use Illuminate\Http\Response; -use Tymon\JWTAuth\Http\Parser\Parser; -use Tymon\JWTAuth\Http\Middleware\RefreshToken; -use Tymon\JWTAuth\Exceptions\TokenInvalidException; +use Mockery; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; +use Tymon\JWTAuth\Exceptions\TokenInvalidException; +use Tymon\JWTAuth\Http\Middleware\RefreshToken; +use Tymon\JWTAuth\Http\Parser\Parser; class RefreshTokenTest extends AbstractMiddlewareTest { diff --git a/tests/PayloadTest.php b/tests/PayloadTest.php index 5734bcf70..5d6263de6 100644 --- a/tests/PayloadTest.php +++ b/tests/PayloadTest.php @@ -11,19 +11,19 @@ namespace Tymon\JWTAuth\Test; -use Mockery; -use Tymon\JWTAuth\Payload; use BadMethodCallException; -use Tymon\JWTAuth\Claims\Claim; -use Tymon\JWTAuth\Claims\JwtId; -use Tymon\JWTAuth\Claims\Issuer; -use Tymon\JWTAuth\Claims\Subject; +use Mockery; use Tymon\JWTAuth\Claims\Audience; -use Tymon\JWTAuth\Claims\IssuedAt; -use Tymon\JWTAuth\Claims\NotBefore; +use Tymon\JWTAuth\Claims\Claim; use Tymon\JWTAuth\Claims\Collection; use Tymon\JWTAuth\Claims\Expiration; +use Tymon\JWTAuth\Claims\IssuedAt; +use Tymon\JWTAuth\Claims\Issuer; +use Tymon\JWTAuth\Claims\JwtId; +use Tymon\JWTAuth\Claims\NotBefore; +use Tymon\JWTAuth\Claims\Subject; use Tymon\JWTAuth\Exceptions\PayloadException; +use Tymon\JWTAuth\Payload; use Tymon\JWTAuth\Validators\PayloadValidator; class PayloadTest extends AbstractTestCase diff --git a/tests/Providers/JWT/LcobucciTest.php b/tests/Providers/JWT/LcobucciTest.php index 35f0d9fca..e3983023c 100644 --- a/tests/Providers/JWT/LcobucciTest.php +++ b/tests/Providers/JWT/LcobucciTest.php @@ -11,16 +11,16 @@ namespace Tymon\JWTAuth\Test\Providers\JWT; -use Mockery; use Exception; -use Lcobucci\JWT\Parser; +use InvalidArgumentException; use Lcobucci\JWT\Builder; +use Lcobucci\JWT\Parser; use Lcobucci\JWT\Signer\Key; -use InvalidArgumentException; -use Tymon\JWTAuth\Test\AbstractTestCase; -use Tymon\JWTAuth\Providers\JWT\Lcobucci; +use Mockery; use Tymon\JWTAuth\Exceptions\JWTException; use Tymon\JWTAuth\Exceptions\TokenInvalidException; +use Tymon\JWTAuth\Providers\JWT\Lcobucci; +use Tymon\JWTAuth\Test\AbstractTestCase; class LcobucciTest extends AbstractTestCase { diff --git a/tests/Providers/JWT/NamshiTest.php b/tests/Providers/JWT/NamshiTest.php index 375ce1898..a8d80138e 100644 --- a/tests/Providers/JWT/NamshiTest.php +++ b/tests/Providers/JWT/NamshiTest.php @@ -11,14 +11,14 @@ namespace Tymon\JWTAuth\Test\Providers\JWT; -use Mockery; use Exception; -use Namshi\JOSE\JWS; use InvalidArgumentException; -use Tymon\JWTAuth\Providers\JWT\Namshi; -use Tymon\JWTAuth\Test\AbstractTestCase; +use Mockery; +use Namshi\JOSE\JWS; use Tymon\JWTAuth\Exceptions\JWTException; use Tymon\JWTAuth\Exceptions\TokenInvalidException; +use Tymon\JWTAuth\Providers\JWT\Namshi; +use Tymon\JWTAuth\Test\AbstractTestCase; class NamshiTest extends AbstractTestCase { diff --git a/tests/Validators/PayloadValidatorTest.php b/tests/Validators/PayloadValidatorTest.php index 64e246e6f..91d31ef11 100644 --- a/tests/Validators/PayloadValidatorTest.php +++ b/tests/Validators/PayloadValidatorTest.php @@ -11,18 +11,18 @@ namespace Tymon\JWTAuth\Test\Validators; -use Tymon\JWTAuth\Claims\JwtId; -use Tymon\JWTAuth\Claims\Issuer; -use Tymon\JWTAuth\Claims\Subject; -use Tymon\JWTAuth\Claims\IssuedAt; -use Tymon\JWTAuth\Claims\NotBefore; use Tymon\JWTAuth\Claims\Collection; use Tymon\JWTAuth\Claims\Expiration; -use Tymon\JWTAuth\Test\AbstractTestCase; -use Tymon\JWTAuth\Validators\PayloadValidator; +use Tymon\JWTAuth\Claims\IssuedAt; +use Tymon\JWTAuth\Claims\Issuer; +use Tymon\JWTAuth\Claims\JwtId; +use Tymon\JWTAuth\Claims\NotBefore; +use Tymon\JWTAuth\Claims\Subject; use Tymon\JWTAuth\Exceptions\InvalidClaimException; use Tymon\JWTAuth\Exceptions\TokenExpiredException; use Tymon\JWTAuth\Exceptions\TokenInvalidException; +use Tymon\JWTAuth\Test\AbstractTestCase; +use Tymon\JWTAuth\Validators\PayloadValidator; class PayloadValidatorTest extends AbstractTestCase { diff --git a/tests/Validators/TokenValidatorTest.php b/tests/Validators/TokenValidatorTest.php index 33fb3633b..68b3cec00 100644 --- a/tests/Validators/TokenValidatorTest.php +++ b/tests/Validators/TokenValidatorTest.php @@ -11,9 +11,9 @@ namespace Tymon\JWTAuth\Test\Validators; +use Tymon\JWTAuth\Exceptions\TokenInvalidException; use Tymon\JWTAuth\Test\AbstractTestCase; use Tymon\JWTAuth\Validators\TokenValidator; -use Tymon\JWTAuth\Exceptions\TokenInvalidException; class TokenValidatorTest extends AbstractTestCase { From cd787a7aab4ed579a600dde83f5fb2fbe68a13ad Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Fri, 27 Nov 2020 18:47:07 +0000 Subject: [PATCH 06/19] tweaks --- .github/workflows/run-tests.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index fb3e95d63..bdb7b93e9 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -13,9 +13,9 @@ jobs: strategy: matrix: php: - - 7.2 - 7.3 - 7.4 + - 8.0 laravel: - 6.* - 7.* @@ -36,19 +36,20 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, gmp, exif, iconv, imagick + extensions: mbstring json openssl coverage: ${{ matrix.coverage }} ini-values: memory_limit=-1 - tools: composer:v2 + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache dependencies uses: actions/cache@v2 with: - path: | - ~/.composer/cache - vendor - key: 'php-${{ matrix.php }}-laravel-${{ matrix.laravel }}' - restore-keys: 'php-${{ matrix.php }}-laravel-${{ matrix.laravel }}' + path: ${{ steps.composer-cache.outputs.dir }} + key: "php-${{ matrix.php }}-laravel-${{ matrix.laravel }}-${{ hashFiles('**/composer.json') }}" + restore-keys: "php-${{ matrix.php }}-laravel-${{ matrix.laravel }}-" - name: Install dependencies run: | From 58e2b9ec9c581befbdf96cfe85d976bdb49737fe Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Fri, 27 Nov 2020 18:51:57 +0000 Subject: [PATCH 07/19] tweaks --- .github/workflows/run-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index bdb7b93e9..d778ca7b8 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -49,12 +49,12 @@ jobs: with: path: ${{ steps.composer-cache.outputs.dir }} key: "php-${{ matrix.php }}-laravel-${{ matrix.laravel }}-${{ hashFiles('**/composer.json') }}" - restore-keys: "php-${{ matrix.php }}-laravel-${{ matrix.laravel }}-" + restore-keys: "php-${{ matrix.php }}-laravel-${{ matrix.laravel }}-${{ hashFiles('**/composer.json') }}" - name: Install dependencies run: | - composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-update - composer update --prefer-stable --prefer-dist --no-interaction --ignore-platform-req=php + composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-progress --no-update + composer update --prefer-stable --no-progress --prefer-dist --no-interaction --ignore-platform-req=php - name: Execute tests run: composer test:ci From 66bf6c1443e22887c26a6ba55e1a53c1d523ffaf Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Sat, 28 Nov 2020 00:19:55 +0000 Subject: [PATCH 08/19] :eyeglasses: --- .gitattributes | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 8fdd9ee89..25e09b89b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,7 +9,6 @@ /.styleci.yml export-ignore /.travis.yml export-ignore /.github export-ignore -/mkdocs.yml export-ignore /phpunit.xml.dist export-ignore /README.md export-ignore /mkdocs.yml export-ignore From 05e41e1aca04d503513d92006eef31da2c75d2d0 Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Mon, 30 Nov 2020 11:24:53 +0000 Subject: [PATCH 09/19] test phpunit polyfills --- .github/workflows/run-tests.yml | 1 + composer.json | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index d778ca7b8..b8fd632f2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -13,6 +13,7 @@ jobs: strategy: matrix: php: + - 7.2 - 7.3 - 7.4 - 8.0 diff --git a/composer.json b/composer.json index 3392f23ee..b524f85b0 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,8 @@ "illuminate/database": "^5.2|^6|^7|^8", "illuminate/routing": "^5.2|^6|^7|^8", "mockery/mockery": ">=0.9.9", - "phpunit/phpunit": "^9.4" + "phpunit/phpunit": "^8.5|^9.4", + "yoast/phpunit-polyfills": "^0.2.0" }, "autoload": { "psr-4": { From c297c3a2ed54b5bab70d2e3508817bd8e841739b Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Mon, 30 Nov 2020 11:33:47 +0000 Subject: [PATCH 10/19] test phpunit polyfills --- tests/AbstractTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index 84d5261b0..45011233b 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -13,7 +13,7 @@ use Carbon\Carbon; use Mockery; -use PHPUnit\Framework\TestCase; +use Yoast\PHPUnitPolyfills\TestCases\TestCase; abstract class AbstractTestCase extends TestCase { From ae3705d62f453a3330bf5af28747f57f2358f76a Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Tue, 1 Dec 2020 10:32:27 +0000 Subject: [PATCH 11/19] fix --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index b8fd632f2..a57f5999e 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -55,7 +55,7 @@ jobs: - name: Install dependencies run: | composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-progress --no-update - composer update --prefer-stable --no-progress --prefer-dist --no-interaction --ignore-platform-req=php + composer update --prefer-stable --no-progress --prefer-dist --no-interaction - name: Execute tests run: composer test:ci From 192aca03d4b22008ab102d4bcdd629675bff6795 Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Tue, 1 Dec 2020 10:38:34 +0000 Subject: [PATCH 12/19] remove php7.2 from laravel 8 --- .github/workflows/run-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a57f5999e..507e5d2a5 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -26,6 +26,9 @@ jobs: coverage: - none - xdebug + exclude: + - php: 7.2 + laravel: 8.* name: '[P${{ matrix.php }}] [L${{ matrix.laravel }}] [${{ matrix.coverage }}]' From 6cb40528859d93a6825f080fe68e72d15fb6655b Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Tue, 1 Dec 2020 10:40:39 +0000 Subject: [PATCH 13/19] remove php8.0 from laravel 6 --- .github/workflows/run-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 507e5d2a5..11b7b039e 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -29,6 +29,8 @@ jobs: exclude: - php: 7.2 laravel: 8.* + - php: 8.0 + laravel: 6.* name: '[P${{ matrix.php }}] [L${{ matrix.laravel }}] [${{ matrix.coverage }}]' From ab6c11965936c186a6d93f3f4f2156d7ee39b4c0 Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Tue, 1 Dec 2020 10:52:12 +0000 Subject: [PATCH 14/19] allow php 8 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b524f85b0..a15b39bf3 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2|^8.0", "illuminate/auth": "^5.2|^6|^7|^8", "illuminate/contracts": "^5.2|^6|^7|^8", "illuminate/http": "^5.2|^6|^7|^8", From 477966d73866bda1f79f6a30d9008c2f64a14f53 Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Wed, 2 Dec 2020 09:37:54 +0000 Subject: [PATCH 15/19] xdebug only once --- .github/workflows/run-tests.yml | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 11b7b039e..c8f8f1e59 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,20 +12,14 @@ jobs: strategy: matrix: - php: - - 7.2 - - 7.3 - - 7.4 - - 8.0 - laravel: - - 6.* - - 7.* - - 8.* - os: - - ubuntu-latest - coverage: - - none - - xdebug + php: [7.2, 7.3, 7.4, 8.0] + laravel: [6.*, 7.*, 8.*] + os: [ubuntu-latest] + coverage: [none] + include: + - php: 8.0 + laravel: 8.* + coverage: xdebug exclude: - php: 7.2 laravel: 8.* From e79fe010d2aa6f0efa313c7c7abb77b1b373541f Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Wed, 2 Dec 2020 09:39:02 +0000 Subject: [PATCH 16/19] xdebug only once --- .github/workflows/run-tests.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index c8f8f1e59..a29d5ee92 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,10 +12,19 @@ jobs: strategy: matrix: - php: [7.2, 7.3, 7.4, 8.0] - laravel: [6.*, 7.*, 8.*] - os: [ubuntu-latest] - coverage: [none] + php: + - 7.2 + - 7.3 + - 7.4 + - 8.0 + laravel: + - 6.* + - 7.* + - 8.* + os: + - ubuntu-latest + coverage: + - none include: - php: 8.0 laravel: 8.* From 27171088188d754dfab37851c46f2dd34ff6740d Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Wed, 2 Dec 2020 09:45:53 +0000 Subject: [PATCH 17/19] fixes --- .github/workflows/run-tests.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a29d5ee92..feaedd36b 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,26 +9,25 @@ on: jobs: php-tests: runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.experimental }} strategy: matrix: - php: - - 7.2 - - 7.3 - - 7.4 - - 8.0 - laravel: - - 6.* - - 7.* - - 8.* - os: - - ubuntu-latest - coverage: - - none + php: [7.2, 7.3, 7.4, 8.0] + laravel: [6.*, 7.*, 8.*] + os: [ubuntu-latest] + coverage: [none] + experimental: [false] include: - php: 8.0 laravel: 8.* + os: ubuntu-latest coverage: xdebug + - php: 8.1 + laravel: 8.* + os: ubuntu-latest + coverage: none + experimental: true exclude: - php: 7.2 laravel: 8.* From d481fd896e23728faa39cc282cd79ec4e3f64f45 Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Wed, 2 Dec 2020 09:46:23 +0000 Subject: [PATCH 18/19] fixes --- .github/workflows/run-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index feaedd36b..81386edf4 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -23,6 +23,7 @@ jobs: laravel: 8.* os: ubuntu-latest coverage: xdebug + experimental: false - php: 8.1 laravel: 8.* os: ubuntu-latest From 95e9e629b251c1b194ad631b47daceba80bf992b Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Wed, 2 Dec 2020 10:02:54 +0000 Subject: [PATCH 19/19] remove experimental for now --- .github/workflows/run-tests.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 81386edf4..2bd9e9f25 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,26 +9,19 @@ on: jobs: php-tests: runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.experimental }} strategy: + fail-fast: false matrix: php: [7.2, 7.3, 7.4, 8.0] laravel: [6.*, 7.*, 8.*] os: [ubuntu-latest] coverage: [none] - experimental: [false] include: - php: 8.0 laravel: 8.* os: ubuntu-latest coverage: xdebug - experimental: false - - php: 8.1 - laravel: 8.* - os: ubuntu-latest - coverage: none - experimental: true exclude: - php: 7.2 laravel: 8.* @@ -63,7 +56,7 @@ jobs: - name: Install dependencies run: | composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-progress --no-update - composer update --prefer-stable --no-progress --prefer-dist --no-interaction + composer update --no-progress --prefer-dist --no-interaction --no-suggest - name: Execute tests run: composer test:ci