-
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6874 from getkirby/v5/feature/access-permissions-1
Access permissions 1: Refactor access to roles
- Loading branch information
Showing
7 changed files
with
124 additions
and
52 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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -110,7 +110,95 @@ public function testImpersonateErrorMissingUser() | |
$this->app->impersonate('[email protected]'); | ||
} | ||
|
||
public function testLoad() | ||
public function testRolesSet() | ||
{ | ||
$app = new App([ | ||
'roles' => [ | ||
[ | ||
'name' => 'editor', | ||
'title' => 'Editor' | ||
] | ||
] | ||
]); | ||
|
||
$this->assertCount(2, $app->roles()); | ||
$this->assertSame('editor', $app->roles()->last()->name()); | ||
} | ||
|
||
public function testRolesLoad() | ||
{ | ||
$app = new App([ | ||
'roots' => [ | ||
'site' => static::FIXTURES | ||
] | ||
]); | ||
|
||
$this->assertCount(2, $app->roles()); | ||
$this->assertSame('editor', $app->roles()->last()->name()); | ||
} | ||
|
||
public function testRoleManual() | ||
{ | ||
$app = new App([ | ||
'roles' => [ | ||
[ | ||
'name' => 'editor', | ||
'title' => 'Editor' | ||
] | ||
] | ||
]); | ||
|
||
$this->assertSame('editor', $app->role('editor')->name()); | ||
$this->assertNull($app->role('something')); | ||
} | ||
|
||
public function testRoleFromUser() | ||
{ | ||
$app = new App([ | ||
'roles' => [ | ||
[ | ||
'name' => 'editor', | ||
'title' => 'Editor' | ||
] | ||
], | ||
'users' => [ | ||
[ | ||
'email' => '[email protected]', | ||
'role' => 'editor' | ||
] | ||
] | ||
]); | ||
|
||
$app->auth()->setUser($app->user('[email protected]')); | ||
|
||
$this->assertSame('editor', $app->role()->name()); | ||
$this->assertSame('editor', $app->role(null, false)->name()); | ||
} | ||
|
||
public function testRoleFromImpersonatedUser() | ||
{ | ||
$app = new App([ | ||
'roles' => [ | ||
[ | ||
'name' => 'editor', | ||
'title' => 'Editor' | ||
] | ||
], | ||
'users' => [ | ||
[ | ||
'email' => '[email protected]', | ||
'role' => 'editor' | ||
] | ||
] | ||
]); | ||
|
||
$app->impersonate('[email protected]'); | ||
|
||
$this->assertSame('editor', $app->role()->name()); | ||
$this->assertNull($app->role(null, false)); | ||
} | ||
|
||
public function testUsersLoad() | ||
{ | ||
$app = $this->app->clone([ | ||
'roots' => [ | ||
|
@@ -122,7 +210,7 @@ public function testLoad() | |
$this->assertSame('[email protected]', $app->users()->first()->email()); | ||
} | ||
|
||
public function testSet() | ||
public function testUsersSet() | ||
{ | ||
$app = $this->app->clone([ | ||
'users' => [ | ||
|