Skip to content

Commit

Permalink
add laravel 11 to workflow run tests (#2605)
Browse files Browse the repository at this point in the history
* add laravel 11 to workflow run tests
* Passport 12
* override passport:install

---------

Co-authored-by: Chris Brown <code@drbyte.dev>
Co-authored-by: drbyte <drbyte@users.noreply.github.com>
  • Loading branch information
3 people committed Feb 28, 2024
1 parent eea8090 commit 05cce01
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/run-tests.yml
Expand Up @@ -10,16 +10,22 @@ jobs:
fail-fast: false
matrix:
php: [8.3, 8.2, 8.1, 8.0]
laravel: ["^10.0", "^9.0", "^8.12"]
laravel: ["^11.0", "^10.0", "^9.0", "^8.12"]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: "^11.0"
testbench: 9.*
- laravel: "^10.0"
testbench: 8.*
- laravel: "^9.0"
testbench: 7.*
- laravel: "^8.12"
testbench: "^6.23"
exclude:
- laravel: "^11.0"
php: 8.1
- laravel: "^11.0"
php: 8.0
- laravel: "^10.0"
php: 8.0
- laravel: "^8.12"
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -29,7 +29,7 @@
"illuminate/database": "^8.12|^9.0|^10.0|^11.0"
},
"require-dev": {
"laravel/passport": "^11.0",
"laravel/passport": "^11.0|^12.0",
"orchestra/testbench": "^6.23|^7.0|^8.0|^9.0",
"phpunit/phpunit": "^9.4|^10.1"
},
Expand Down
4 changes: 2 additions & 2 deletions src/Guard.php
Expand Up @@ -13,7 +13,7 @@ class Guard
* Return a collection of guard names suitable for the $model,
* as indicated by the presence of a $guard_name property or a guardName() method on the model.
*
* @param string|Model $model model class object or name
* @param string|Model $model model class object or name
*/
public static function getNames($model): Collection
{
Expand Down Expand Up @@ -58,7 +58,7 @@ protected static function getConfigAuthGuards(string $class): Collection
/**
* Lookup a guard name relevant for the $class model and the current user.
*
* @param string|Model $class model class object or name
* @param string|Model $class model class object or name
* @return string guard name
*/
public static function getDefaultName($class): string
Expand Down
8 changes: 6 additions & 2 deletions tests/TestCase.php
Expand Up @@ -203,8 +203,12 @@ protected function setUpPassport($app): void
$app['config']->set('permission.use_passport_client_credentials', true);
$app['config']->set('auth.guards.api', ['driver' => 'passport', 'provider' => 'users']);

$this->artisan('migrate');
$this->artisan('passport:install');
// mimic passport:install (must load migrations using our own call to loadMigrationsFrom() else rollbacks won't occur, and migrations will be left in skeleton directory
$this->artisan('passport:keys');
$this->loadMigrationsFrom(__DIR__.'/../vendor/laravel/passport/database/migrations/');
$provider = in_array('users', array_keys(config('auth.providers'))) ? 'users' : null;
$this->artisan('passport:client', ['--personal' => true, '--name' => config('app.name').' Personal Access Client']);
$this->artisan('passport:client', ['--password' => true, '--name' => config('app.name').' Password Grant Client', '--provider' => $provider]);

$this->testClient = Client::create(['name' => 'Test', 'redirect' => 'https://example.com', 'personal_access_client' => 0, 'password_client' => 0, 'revoked' => 0]);
$this->testClientRole = $app[Role::class]->create(['name' => 'clientRole', 'guard_name' => 'api']);
Expand Down

0 comments on commit 05cce01

Please sign in to comment.