-
Notifications
You must be signed in to change notification settings - Fork 783
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix getting/setting client scopes and grant types (#1717)
- Loading branch information
Showing
4 changed files
with
114 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
namespace Laravel\Passport\Tests\Feature; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Laravel\Passport\Client; | ||
use Orchestra\Testbench\TestCase; | ||
|
||
final class ClientTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
Model::preventAccessingMissingAttributes(); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
Model::preventAccessingMissingAttributes(false); | ||
|
||
parent::tearDown(); | ||
} | ||
|
||
public function testScopesWhenClientDoesNotHaveScope(): void | ||
{ | ||
$client = new Client(['scopes' => ['bar']]); | ||
$client->exists = true; | ||
|
||
$this->assertFalse($client->hasScope('foo')); | ||
} | ||
|
||
public function testScopesWhenClientHasScope(): void | ||
{ | ||
$client = new Client(['scopes' => ['foo', 'bar']]); | ||
$client->exists = true; | ||
|
||
$this->assertTrue($client->hasScope('foo')); | ||
} | ||
|
||
public function testScopesWhenColumnDoesNotExist(): void | ||
{ | ||
$client = new Client(); | ||
$client->exists = true; | ||
|
||
$this->assertTrue($client->hasScope('foo')); | ||
} | ||
|
||
public function testScopesWhenColumnIsNull(): void | ||
{ | ||
$client = new Client(['scopes' => null]); | ||
$client->exists = true; | ||
|
||
$this->assertTrue($client->hasScope('foo')); | ||
} | ||
|
||
public function testGrantTypesWhenClientDoesNotHaveGrantType(): void | ||
{ | ||
$client = new Client(['grant_types' => ['bar']]); | ||
$client->exists = true; | ||
|
||
$this->assertFalse($client->hasGrantType('foo')); | ||
} | ||
|
||
public function testGrantTypesWhenClientHasGrantType(): void | ||
{ | ||
$client = new Client(['grant_types' => ['foo', 'bar']]); | ||
$client->exists = true; | ||
|
||
$this->assertTrue($client->hasGrantType('foo')); | ||
} | ||
|
||
public function testGrantTypesWhenColumnDoesNotExist(): void | ||
{ | ||
$client = new Client(); | ||
$client->exists = true; | ||
|
||
$this->assertTrue($client->hasGrantType('foo')); | ||
} | ||
|
||
public function testGrantTypesWhenColumnIsNull(): void | ||
{ | ||
$client = new Client(['scopes' => null]); | ||
$client->exists = true; | ||
|
||
$this->assertTrue($client->hasGrantType('foo')); | ||
} | ||
} |
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