From 05cce017fe3ac78f60a3fce78c07fe6e8e6e6e52 Mon Sep 17 00:00:00 2001 From: Raheel Khan Date: Wed, 28 Feb 2024 13:11:20 +0500 Subject: [PATCH] add laravel 11 to workflow run tests (#2605) * add laravel 11 to workflow run tests * Passport 12 * override passport:install --------- Co-authored-by: Chris Brown Co-authored-by: drbyte --- .github/workflows/run-tests.yml | 8 +++++++- composer.json | 2 +- src/Guard.php | 4 ++-- tests/TestCase.php | 8 ++++++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 84e1a0f9..cd56424e 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -10,9 +10,11 @@ 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" @@ -20,6 +22,10 @@ jobs: - 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" diff --git a/composer.json b/composer.json index ab0515b8..bd29fa40 100644 --- a/composer.json +++ b/composer.json @@ -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" }, diff --git a/src/Guard.php b/src/Guard.php index dd502314..4f697ce2 100644 --- a/src/Guard.php +++ b/src/Guard.php @@ -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 { @@ -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 diff --git a/tests/TestCase.php b/tests/TestCase.php index 48de05ed..24af65bf 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -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']);