mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
Apply fixes from StyleCI
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
<?php namespace Tests\Commands;
|
||||
<?php
|
||||
|
||||
namespace Tests\Commands;
|
||||
|
||||
use BookStack\Entities\Models\Bookshelf;
|
||||
use Tests\TestCase;
|
||||
@ -17,8 +19,8 @@ class CopyShelfPermissionsCommandTest extends TestCase
|
||||
$shelf = Bookshelf::first();
|
||||
$child = $shelf->books()->first();
|
||||
$editorRole = $this->getEditor()->roles()->first();
|
||||
$this->assertFalse(boolval($child->restricted), "Child book should not be restricted by default");
|
||||
$this->assertTrue($child->permissions()->count() === 0, "Child book should have no permissions by default");
|
||||
$this->assertFalse(boolval($child->restricted), 'Child book should not be restricted by default');
|
||||
$this->assertTrue($child->permissions()->count() === 0, 'Child book should have no permissions by default');
|
||||
|
||||
$this->setEntityRestrictions($shelf, ['view', 'update'], [$editorRole]);
|
||||
$this->artisan('bookstack:copy-shelf-permissions', [
|
||||
@ -26,8 +28,8 @@ class CopyShelfPermissionsCommandTest extends TestCase
|
||||
]);
|
||||
$child = $shelf->books()->first();
|
||||
|
||||
$this->assertTrue(boolval($child->restricted), "Child book should now be restricted");
|
||||
$this->assertTrue($child->permissions()->count() === 2, "Child book should have copied permissions");
|
||||
$this->assertTrue(boolval($child->restricted), 'Child book should now be restricted');
|
||||
$this->assertTrue($child->permissions()->count() === 2, 'Child book should have copied permissions');
|
||||
$this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'view', 'role_id' => $editorRole->id]);
|
||||
$this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'update', 'role_id' => $editorRole->id]);
|
||||
}
|
||||
@ -38,17 +40,17 @@ class CopyShelfPermissionsCommandTest extends TestCase
|
||||
Bookshelf::query()->where('id', '!=', $shelf->id)->delete();
|
||||
$child = $shelf->books()->first();
|
||||
$editorRole = $this->getEditor()->roles()->first();
|
||||
$this->assertFalse(boolval($child->restricted), "Child book should not be restricted by default");
|
||||
$this->assertTrue($child->permissions()->count() === 0, "Child book should have no permissions by default");
|
||||
$this->assertFalse(boolval($child->restricted), 'Child book should not be restricted by default');
|
||||
$this->assertTrue($child->permissions()->count() === 0, 'Child book should have no permissions by default');
|
||||
|
||||
$this->setEntityRestrictions($shelf, ['view', 'update'], [$editorRole]);
|
||||
$this->artisan('bookstack:copy-shelf-permissions --all')
|
||||
->expectsQuestion('Permission settings for all shelves will be cascaded. Books assigned to multiple shelves will receive only the permissions of it\'s last processed shelf. Are you sure you want to proceed?', 'y');
|
||||
$child = $shelf->books()->first();
|
||||
|
||||
$this->assertTrue(boolval($child->restricted), "Child book should now be restricted");
|
||||
$this->assertTrue($child->permissions()->count() === 2, "Child book should have copied permissions");
|
||||
$this->assertTrue(boolval($child->restricted), 'Child book should now be restricted');
|
||||
$this->assertTrue($child->permissions()->count() === 2, 'Child book should have copied permissions');
|
||||
$this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'view', 'role_id' => $editorRole->id]);
|
||||
$this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'update', 'role_id' => $editorRole->id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user