jwt-auth
jwt-auth copied to clipboard
Add support for Laravel 11
Description
Good news: it works!
Due to the wide range of PHP, Laravel and phpunit versions we support here, some misc changes around the test procedure had to be done, as outlined below.
~Ah yes, and of course php-cs-fixer also wants to say something, see also https://github.com/PHP-Open-Source-Saver/jwt-auth/pull/232 already~
Summary of changes:
-
bump all L11 related dependencies incl. orchestra/testbench Note: testbench requires
9.x-dev
but I also already added^9
once it's related (and then9.x-dev
can be removed)- had to refine the handling to force a phpunit version for a specific PHP/Laravel combination; this is probably done to combat some
prefer-lowest
setting but I haven't looked closer as the current version "worked"
- had to refine the handling to force a phpunit version for a specific PHP/Laravel combination; this is probably done to combat some
-
adapted / fixed changelog
-
removed rector/rector testbench has a dependency on some package which has a dependency on rector which wants a different version; in those cases packages wouldn't even install. But since for unit tests it isn't necessary -> I removed it Should probably be updated to ^1 or removed, if not used regularly
-
the phpunit
--verbose
flag had to be removed, does not exist in phpunit 10 and it would refuse to run -
Add new getAuthPasswordName for stub
Necessary because that method was added to L11Authenticable
contract; does not impact older versions -
had to run phpunit
--migrate-configuration
, the warning it emitted would break the workflow Also removed setting which have their default anyway, I consulted https://docs.phpunit.de/en/10.5/configuration.html for this.Note: removed
colors=true
nevertheless, don't think it's really necessary -
rename abstract class for tests phpunit does not want non-executable test classes, fixes:
Class PHPOpenSourceSaver\JWTAuth\Test\Middleware\AbstractMiddlewareTest declared in /home/runner/work/jwt-auth/jwt-auth/tests/Middleware/AbstractMiddlewareTest.php is abstract
-
make data providers static
Fixes:
1) PHPOpenSourceSaver\JWTAuth\Test\BlacklistTest::itShouldCheckWhetherATokenHasNotBeenBlacklisted Data Provider method PHPOpenSourceSaver\JWTAuth\Test\BlacklistTest::blacklist_provider() is not static /home/runner/work/jwt-auth/jwt-auth/tests/BlacklistTest.php:198 2) PHPOpenSourceSaver\JWTAuth\Test\Http\ParserTest::itShouldHandleExcessWhitespaceFromTheAuthorizationHeader Data Provider method PHPOpenSourceSaver\JWTAuth\Test\Http\ParserTest::whitespaceProvider() is not static /home/runner/work/jwt-auth/jwt-auth/tests/Http/ParserTest.php:137 3) PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::itShouldReturnFalseWhenProvidingAMalformedToken Data Provider method \PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::dataProviderMalformedTokens() is not static /home/runner/work/jwt-auth/jwt-auth/tests/Validators/TokenValidatorTest.php:46 4) PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::itShouldThrowAnExceptionWhenProvidingAMalformedToken Data Provider method \PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::dataProviderMalformedTokens() is not static /home/runner/work/jwt-auth/jwt-auth/tests/Validators/TokenValidatorTest.php:56 5) PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::itShouldReturnFalseWhenProvidingATokenWithWrongSegmentsNumber Data Provider method \PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::dataProviderTokensWithWrongSegmentsNumber() is not static /home/runner/work/jwt-auth/jwt-auth/tests/Validators/TokenValidatorTest.php:69 6) PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::itShouldThrowAnExceptionWhenProvidingAMalformedTokenWithWrongSegmentsNumber Data Provider method \PHPOpenSourceSaver\JWTAuth\Test\Validators\TokenValidatorTest::dataProviderTokensWithWrongSegmentsNumber() is not static
-
always make xdebug available
Fixes the following phpunit warning for now (which fails the workflow):
No code coverage driver available
We still only upload the coverage when explicitly enabled.
Notes
- There are lot of old and therefore also unsupported versions still used in here. I really suggest to cut down the matrix and bump minimum required PHP versions to what is the currently supported ones etc. This will make the whole setup much slimmer and easier to maintain going forward.
- Coverage reports are not working: https://github.com/PHP-Open-Source-Saver/jwt-auth/actions/runs/7987659716/job/21810573995?pr=233#step:13:50 I haven't look yet but I suggest not to make this a blocker and maybe decide to slim down the whole support matrix, would make fixing coverage easier too
All done, ready for review, please read the description and also the notes about coverage! I suggest we do this iteratively.
I'll take a look at this today at evening or later this weekend. Thanks @mfn