Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Laravel 11 #233

Merged
merged 8 commits into from
Mar 12, 2024
Merged

Conversation

mfn
Copy link
Contributor

@mfn mfn commented Feb 21, 2024

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 #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 then 9.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"
  • 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 L11 Authenticable 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

mfn added 6 commits February 21, 2024 11:34
Was added to the L11 Authenticable contract
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
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`
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
```
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.
@mfn
Copy link
Contributor Author

mfn commented Feb 21, 2024

All done, ready for review, please read the description and also the notes about coverage! I suggest we do this iteratively.

@Messhias
Copy link
Collaborator

I'll take a look at this today at evening or later this weekend. Thanks @mfn

@mfn mfn mentioned this pull request Feb 21, 2024
# Conflicts:
#	CHANGELOG.md
@Messhias Messhias merged commit f9151ef into PHP-Open-Source-Saver:main Mar 12, 2024
29 checks passed
@mfn mfn mentioned this pull request Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants