-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[13.x] Cleanup and add feature tests (#1767)
* cleanup * add test * fix tests * formatting
- Loading branch information
1 parent
5ab8904
commit 4ffc542
Showing
9 changed files
with
61 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Laravel\Passport\Tests\Feature; | ||
|
||
use Illuminate\Contracts\Hashing\Hasher; | ||
use Laravel\Passport\Client; | ||
use Laravel\Passport\Database\Factories\ClientFactory; | ||
use Laravel\Passport\Passport; | ||
use Laravel\Passport\PersonalAccessTokenResult; | ||
use Orchestra\Testbench\Concerns\WithLaravelMigrations; | ||
use Workbench\Database\Factories\UserFactory; | ||
|
||
class PersonalAccessTokenFactoryTest extends PassportTestCase | ||
{ | ||
use WithLaravelMigrations; | ||
|
||
public function testIssueToken() | ||
{ | ||
$user = UserFactory::new()->create([ | ||
'email' => '[email protected]', | ||
'password' => $this->app->make(Hasher::class)->make('foobar123'), | ||
]); | ||
|
||
/** @var Client $client */ | ||
$client = ClientFactory::new()->asPersonalAccessTokenClient()->create(); | ||
|
||
config([ | ||
'passport.personal_access_client.id' => $client->getKey(), | ||
'passport.personal_access_client.secret' => $client->plainSecret, | ||
]); | ||
|
||
Passport::tokensCan([ | ||
'foo' => 'Do foo', | ||
'bar' => 'Do bar', | ||
]); | ||
|
||
$result = $user->createToken('test', ['bar']); | ||
|
||
$this->assertInstanceOf(PersonalAccessTokenResult::class, $result); | ||
$this->assertSame($client->getKey(), $result->token->client_id); | ||
$this->assertSame($user->getAuthIdentifier(), $result->token->user_id); | ||
$this->assertSame(['bar'], $result->token->scopes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.