Skip to content

Commit 0c98fca

Browse files
committed
Support Laravel 8
1 parent 29f137a commit 0c98fca

File tree

5 files changed

+68
-46
lines changed

5 files changed

+68
-46
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
strategy:
1414
fail-fast: true
1515
matrix:
16-
php: [7.2, 7.3, 7.4]
17-
laravel: [^6.0, ^7.0]
16+
php: [7.3, 7.4]
17+
laravel: [^8.0]
1818

1919
name: P${{ matrix.php }} - L${{ matrix.laravel }}
2020

composer.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,32 @@
1414
}
1515
],
1616
"require": {
17-
"php": "^7.2",
17+
"php": "^7.3",
1818
"ext-json": "*",
1919
"firebase/php-jwt": "^5.0",
20-
"guzzlehttp/guzzle": "^6.0|^7.0",
21-
"illuminate/auth": "^6.18.31|^7.22.4",
22-
"illuminate/console": "^6.18.31|^7.22.4",
23-
"illuminate/container": "^6.18.31|^7.22.4",
24-
"illuminate/contracts": "^6.18.31|^7.22.4",
25-
"illuminate/cookie": "^6.18.31|^7.22.4",
26-
"illuminate/database": "^6.18.31|^7.22.4",
27-
"illuminate/encryption": "^6.18.31|^7.22.4",
28-
"illuminate/http": "^6.18.31|^7.22.4",
29-
"illuminate/support": "^6.18.31|^7.22.4",
20+
"illuminate/auth": "^8.0",
21+
"illuminate/console": "^8.0",
22+
"illuminate/container": "^8.0",
23+
"illuminate/contracts": "^8.0",
24+
"illuminate/cookie": "^8.0",
25+
"illuminate/database": "^8.0",
26+
"illuminate/encryption": "^8.0",
27+
"illuminate/http": "^8.0",
28+
"illuminate/support": "^8.0",
3029
"league/oauth2-server": "^8.1",
3130
"nyholm/psr7": "^1.3",
3231
"phpseclib/phpseclib": "^2.0",
3332
"symfony/psr-http-message-bridge": "^2.0"
3433
},
3534
"require-dev": {
3635
"mockery/mockery": "^1.0",
37-
"orchestra/testbench": "^4.4|^5.0",
38-
"phpunit/phpunit": "^8.0"
36+
"orchestra/testbench": "^6.0",
37+
"phpunit/phpunit": "^9.3"
3938
},
4039
"autoload": {
4140
"psr-4": {
42-
"Laravel\\Passport\\": "src/"
41+
"Laravel\\Passport\\": "src/",
42+
"Laravel\\Passport\\Database\\Factories\\": "database/factories/"
4343
}
4444
},
4545
"autoload-dev": {

database/factories/ClientFactory.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace Laravel\Passport\Database\Factories;
4+
5+
use Faker\Generator as Faker;
6+
use Illuminate\Database\Eloquent\Factories\Factory;
7+
use Illuminate\Support\Str;
8+
use Laravel\Passport\Client;
9+
10+
class ClientFactory extends Factory
11+
{
12+
/**
13+
* The name of the factory's corresponding model.
14+
*
15+
* @var string
16+
*/
17+
protected $model = Client::class;
18+
19+
/**
20+
* Define the model's default state.
21+
*
22+
* @return array
23+
*/
24+
public function definition()
25+
{
26+
return [
27+
'user_id' => null,
28+
'name' => $this->faker->company,
29+
'secret' => Str::random(40),
30+
'redirect' => $this->faker->url,
31+
'personal_access_client' => false,
32+
'password_client' => false,
33+
'revoked' => false,
34+
];
35+
}
36+
37+
/**
38+
* Use as Password Client.
39+
*
40+
* @return $this
41+
*/
42+
public function asPasswordClient()
43+
{
44+
return $this->state([
45+
'personal_access_client' => false,
46+
'password_client' => true,
47+
]);
48+
}
49+
}

database/factories/PassportClientFactory.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/Feature/AccessTokenControllerTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Carbon\CarbonImmutable;
66
use Illuminate\Contracts\Hashing\Hasher;
7-
use Illuminate\Database\Eloquent\Factory;
87
use Illuminate\Database\Schema\Blueprint;
98
use Illuminate\Support\Facades\Schema;
109
use Laravel\Passport\Client;
@@ -52,7 +51,7 @@ public function testGettingAccessTokenWithPasswordGrant()
5251
$user->save();
5352

5453
/** @var Client $client */
55-
$client = $this->app->make(Factory::class)->of(Client::class)->state('password_client')->create(['user_id' => $user->id]);
54+
$client = Client::factory()->asPasswordClient()->create(['user_id' => $user->id]);
5655

5756
$response = $this->post(
5857
'/oauth/token',
@@ -103,7 +102,7 @@ public function testGettingAccessTokenWithPasswordGrantWithInvalidPassword()
103102
$user->save();
104103

105104
/** @var Client $client */
106-
$client = $this->app->make(Factory::class)->of(Client::class)->state('password_client')->create(['user_id' => $user->id]);
105+
$client = Client::factory()->asPasswordClient()->create(['user_id' => $user->id]);
107106

108107
$response = $this->post(
109108
'/oauth/token',
@@ -146,7 +145,7 @@ public function testGettingAccessTokenWithPasswordGrantWithInvalidClientSecret()
146145
$user->save();
147146

148147
/** @var Client $client */
149-
$client = $this->app->make(Factory::class)->of(Client::class)->state('password_client')->create(['user_id' => $user->id]);
148+
$client = Client::factory()->asPasswordClient()->create(['user_id' => $user->id]);
150149

151150
$response = $this->post(
152151
'/oauth/token',

0 commit comments

Comments
 (0)