mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-12-06 00:03:53 +08:00
e2a72d16aa
Ported non-compatible elements, Now all tests passing apart from some specific permission scenario tests which are probably correctly failing. Updates some tests to better avoid messing environment state.
41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Commands;
|
|
|
|
use BookStack\Auth\Permissions\CollapsedPermission;
|
|
use BookStack\Auth\Permissions\EntityPermission;
|
|
use BookStack\Auth\Permissions\JointPermission;
|
|
use Illuminate\Support\Facades\Artisan;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\TestCase;
|
|
|
|
class RegeneratePermissionsCommandTest extends TestCase
|
|
{
|
|
public function test_regen_permissions_command()
|
|
{
|
|
DB::rollBack();
|
|
$page = $this->entities->page();
|
|
$editor = $this->users->editor();
|
|
$role = $editor->roles()->first();
|
|
$this->permissions->addEntityPermission($page, ['view'], $role);
|
|
JointPermission::query()->truncate();
|
|
|
|
$this->assertDatabaseMissing('joint_permissions', ['entity_id' => $page->id]);
|
|
|
|
$exitCode = Artisan::call('bookstack:regenerate-permissions');
|
|
$this->assertTrue($exitCode === 0, 'Command executed successfully');
|
|
|
|
$this->assertDatabaseHas('joint_permissions', [
|
|
'entity_id' => $page->id,
|
|
'entity_type' => 'page',
|
|
'role_id' => $role->id,
|
|
'has_permission' => 1,
|
|
]);
|
|
|
|
$page->permissions()->delete();
|
|
$page->rebuildPermissions();
|
|
|
|
DB::beginTransaction();
|
|
}
|
|
}
|