mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
Copied over work from user_permissions branch
Only that relevant to the additional testing work.
This commit is contained in:
@ -2,8 +2,7 @@
|
||||
|
||||
namespace Tests\Commands;
|
||||
|
||||
use BookStack\Auth\Permissions\JointPermission;
|
||||
use BookStack\Entities\Models\Page;
|
||||
use BookStack\Auth\Permissions\CollapsedPermission;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
@ -13,15 +12,23 @@ class RegeneratePermissionsCommandTest extends TestCase
|
||||
public function test_regen_permissions_command()
|
||||
{
|
||||
DB::rollBack();
|
||||
JointPermission::query()->truncate();
|
||||
$page = Page::first();
|
||||
$page = $this->entities->page();
|
||||
$editor = $this->users->editor();
|
||||
$this->permissions->addEntityPermission($page, ['view'], null, $editor);
|
||||
CollapsedPermission::query()->truncate();
|
||||
|
||||
$this->assertDatabaseMissing('joint_permissions', ['entity_id' => $page->id]);
|
||||
$this->assertDatabaseMissing('entity_permissions_collapsed', ['entity_id' => $page->id]);
|
||||
|
||||
$exitCode = Artisan::call('bookstack:regenerate-permissions');
|
||||
$this->assertTrue($exitCode === 0, 'Command executed successfully');
|
||||
DB::beginTransaction();
|
||||
|
||||
$this->assertDatabaseHas('joint_permissions', ['entity_id' => $page->id]);
|
||||
$this->assertDatabaseHas('entity_permissions_collapsed', [
|
||||
'entity_id' => $page->id,
|
||||
'user_id' => $editor->id,
|
||||
'view' => 1,
|
||||
]);
|
||||
|
||||
CollapsedPermission::query()->truncate();
|
||||
DB::beginTransaction();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user