Skip to content

Commit

Permalink
Merge pull request #233 from mfn/mfn-l11
Browse files Browse the repository at this point in the history
Add support for Laravel 11
  • Loading branch information
Messhias authored Mar 12, 2024
2 parents 826aa52 + 81c1f08 commit f9151ef
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 43 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
php: [7.4, 8.0, 8.1, 8.2]
laravel: [6.*, 7.*, 8.*, 9.*, 10.*]
laravel: [6.*, 7.*, 8.*, 9.*, 10.*, 11.*]
stability: [prefer-lowest, prefer-stable]
os: [ubuntu-latest]
coverage: [none]
Expand All @@ -41,6 +41,12 @@ jobs:
php: 7.4
- laravel: 10.*
php: 8.0
- laravel: 11.*
php: 7.4
- laravel: 11.*
php: 8.0
- laravel: 11.*
php: 8.1
include:
- laravel: 6.*
dotenv: ^3.3
Expand All @@ -57,6 +63,9 @@ jobs:
- laravel: 10.*
dotenv: ^5.4.1

- laravel: 11.*
dotenv: ^5.4.1

- php: 8.0
laravel: 9.*
stability: prefer-stable
Expand All @@ -82,7 +91,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
extensions: mbstring json openssl
coverage: ${{ matrix.coverage }}
coverage: xdebug
ini-values: memory_limit=-1

- name: Setup Problem Matchers
Expand All @@ -94,9 +103,18 @@ jobs:
id: composer-cache
run: echo "dir=$(composer config cache-dir)" >> $GITHUB_OUTPUT

- name: Set Minimum PHP 8.0 Versions
- name: Set phpunit for PHP >= 8 but Laravel < 11
run: composer require phpunit/phpunit:^9.4 --no-interaction --no-progress --no-update
if: matrix.php >= 8
if: matrix.php >= 8 || matrix.laravel != '11.*'

- name: Set phpunit for Laravel >= 11
run: composer require phpunit/phpunit:^10 --no-interaction --no-progress --no-update
if: matrix.laravel == '11.*'

# Packages which are not striclty required for testing but could cause
# conflicts with other packages
- name: Remove packages not necessary
run: composer remove --dev rector/rector --no-interaction --no-progress --no-update

- name: Set Minimum Laravel ${{ matrix.laravel }} Versions
run: |
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ You can find and compare releases at the GitHub release page.
### Added
- Different TTL configurations for each guard
- lcobucci/jwt: add array support for `aud` claim
- Laravel 11 support

## [2.1.0] 2023-02-17

### Added
- Laravel 10 support

## [2.0.0] 2022-09-08
- No changes to 2.0.0-RC1
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@
"require": {
"php": "^7.4|^8.0",
"ext-json": "*",
"illuminate/auth": "^6|^7|^8.67|^9|^10",
"illuminate/contracts": "^6|^7|^8.67|^9|^10",
"illuminate/http": "^6|^7|^8.67|^9|^10",
"illuminate/support": "^6|^7|^8.67|^9|^10",
"illuminate/auth": "^6|^7|^8.67|^9|^10|^11",
"illuminate/contracts": "^6|^7|^8.67|^9|^10|^11",
"illuminate/http": "^6|^7|^8.67|^9|^10|^11",
"illuminate/support": "^6|^7|^8.67|^9|^10|^11",
"lcobucci/jwt": "^4.0",
"namshi/jose": "^7.0",
"nesbot/carbon": "^1.0|^2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3",
"illuminate/console": "^6|^7|^8.67|^9|^10",
"illuminate/routing": "^6|^7|^8.67|^9|^10",
"orchestra/testbench": "^4.18|^5.8|^6.3|^7|^8",
"illuminate/console": "^6|^7|^8.67|^9|^10|^11",
"illuminate/routing": "^6|^7|^8.67|^9|^10|^11",
"orchestra/testbench": "^4.18|^5.8|^6.3|^7|^8|^9|9.x-dev",
"mockery/mockery": "^1.4.4",
"phpstan/phpstan": "^1",
"phpunit/phpunit": "^8.5|^9.4|^10",
Expand Down Expand Up @@ -88,7 +88,7 @@
"scripts": {
"php-cs-fixer": "php-cs-fixer fix --diff",
"test": "phpunit --colors=always",
"test:ci": "composer test -- --verbose --coverage-text --coverage-clover=coverage.xml",
"test:ci": "composer test -- --coverage-text --coverage-clover=coverage.xml",
"phpstan": "phpstan analyse --memory-limit=256M",
"phpstan-baseline": "phpstan analyse --generate-baseline --memory-limit=256M"
}
Expand Down
37 changes: 15 additions & 22 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,31 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="false"
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
beStrictAboutOutputDuringTests="true"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
beStrictAboutTestsThatDoNotTestAnything="false"
cacheDirectory=".phpunit.result.cache"
failOnRisky="true"
failOnWarning="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<exclude>
<file>src/Providers/LumenServiceProvider.php</file>
<directory suffix=".php">src/Facades/</directory>
<directory suffix=".php">src/Console/</directory>
</exclude>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
Expand All @@ -40,4 +23,14 @@
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
<exclude>
<file>src/Providers/LumenServiceProvider.php</file>
<directory suffix=".php">src/Facades/</directory>
<directory suffix=".php">src/Console/</directory>
</exclude>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion tests/BlacklistTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function itShouldCheckWhetherATokenHasBeenBlacklisted()
$this->assertTrue($this->blacklist->has($payload));
}

public function blacklist_provider()
public static function blacklist_provider()
{
return [
[null],
Expand Down
2 changes: 1 addition & 1 deletion tests/Http/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function itShouldHandleExcessWhitespaceFromTheAuthorizationHeader($whites
$this->assertTrue($parser->hasToken());
}

public function whitespaceProvider()
public static function whitespaceProvider()
{
return [
'space' => [' '],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use PHPOpenSourceSaver\JWTAuth\JWTAuth;
use PHPOpenSourceSaver\JWTAuth\Test\AbstractTestCase;

abstract class AbstractMiddlewareTest extends AbstractTestCase
abstract class AbstractMiddleware extends AbstractTestCase
{
/**
* @var MockInterface|JWTAuth
Expand Down
2 changes: 1 addition & 1 deletion tests/Middleware/AuthenticateAndRenewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use PHPOpenSourceSaver\JWTAuth\Test\Stubs\UserStub;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;

class AuthenticateAndRenewTest extends AbstractMiddlewareTest
class AuthenticateAndRenewTest extends AbstractMiddleware
{
/**
* @var Authenticate|AuthenticateAndRenew
Expand Down
2 changes: 1 addition & 1 deletion tests/Middleware/AuthenticateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use PHPOpenSourceSaver\JWTAuth\Test\Stubs\UserStub;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;

class AuthenticateTest extends AbstractMiddlewareTest
class AuthenticateTest extends AbstractMiddleware
{
/**
* @var Authenticate
Expand Down
2 changes: 1 addition & 1 deletion tests/Middleware/CheckTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use PHPOpenSourceSaver\JWTAuth\Http\Parser\Parser;
use PHPOpenSourceSaver\JWTAuth\Test\Stubs\UserStub;

class CheckTest extends AbstractMiddlewareTest
class CheckTest extends AbstractMiddleware
{
/**
* @var Check
Expand Down
2 changes: 1 addition & 1 deletion tests/Middleware/RefreshTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use PHPOpenSourceSaver\JWTAuth\Http\Parser\Parser;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;

class RefreshTokenTest extends AbstractMiddlewareTest
class RefreshTokenTest extends AbstractMiddleware
{
/**
* @var RefreshToken
Expand Down
4 changes: 4 additions & 0 deletions tests/Stubs/LaravelUserStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public function getAuthIdentifier()
{
}

public function getAuthPasswordName()
{
}

public function getAuthPassword()
{
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Validators/TokenValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function itShouldThrowAnExceptionWhenProvidingAMalformedTokenWithWrongSeg
$this->validator->check($token);
}

public function dataProviderMalformedTokens()
public static function dataProviderMalformedTokens()
{
return [
['one.two.'],
Expand All @@ -97,7 +97,7 @@ public function dataProviderMalformedTokens()
];
}

public function dataProviderTokensWithWrongSegmentsNumber()
public static function dataProviderTokensWithWrongSegmentsNumber()
{
return [
['one.two'],
Expand Down

0 comments on commit f9151ef

Please sign in to comment.