mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Updated test for perms. changes and fixed static issues
This commit is contained in:
@ -19,7 +19,7 @@ class CopyShelfPermissionsCommandTest extends TestCase
|
||||
$shelf = $this->entities->shelf();
|
||||
$child = $shelf->books()->first();
|
||||
$editorRole = $this->getEditor()->roles()->first();
|
||||
$this->assertFalse(boolval($child->hasPermissions()), 'Child book should not be restricted by default');
|
||||
$this->assertFalse($child->hasPermissions(), 'Child book should not be restricted by default');
|
||||
$this->assertTrue($child->permissions()->count() === 0, 'Child book should have no permissions by default');
|
||||
|
||||
$this->entities->setPermissions($shelf, ['view', 'update'], [$editorRole]);
|
||||
@ -28,10 +28,14 @@ class CopyShelfPermissionsCommandTest extends TestCase
|
||||
]);
|
||||
$child = $shelf->books()->first();
|
||||
|
||||
$this->assertTrue(boolval($child->hasPermissions()), '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]);
|
||||
$this->assertTrue($child->hasPermissions(), 'Child book should now be restricted');
|
||||
$this->assertEquals(2, $child->permissions()->count(), 'Child book should have copied permissions');
|
||||
$this->assertDatabaseHas('entity_permissions', [
|
||||
'entity_type' => 'book',
|
||||
'entity_id' => $child->id,
|
||||
'role_id' => $editorRole->id,
|
||||
'view' => true, 'update' => true, 'create' => false, 'delete' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_copy_shelf_permissions_command_using_all()
|
||||
@ -40,7 +44,7 @@ class CopyShelfPermissionsCommandTest extends TestCase
|
||||
Bookshelf::query()->where('id', '!=', $shelf->id)->delete();
|
||||
$child = $shelf->books()->first();
|
||||
$editorRole = $this->getEditor()->roles()->first();
|
||||
$this->assertFalse(boolval($child->hasPermissions()), 'Child book should not be restricted by default');
|
||||
$this->assertFalse($child->hasPermissions(), 'Child book should not be restricted by default');
|
||||
$this->assertTrue($child->permissions()->count() === 0, 'Child book should have no permissions by default');
|
||||
|
||||
$this->entities->setPermissions($shelf, ['view', 'update'], [$editorRole]);
|
||||
@ -48,9 +52,13 @@ class CopyShelfPermissionsCommandTest extends TestCase
|
||||
->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->hasPermissions()), '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]);
|
||||
$this->assertTrue($child->hasPermissions(), 'Child book should now be restricted');
|
||||
$this->assertEquals(2, $child->permissions()->count(), 'Child book should have copied permissions');
|
||||
$this->assertDatabaseHas('entity_permissions', [
|
||||
'entity_type' => 'book',
|
||||
'entity_id' => $child->id,
|
||||
'role_id' => $editorRole->id,
|
||||
'view' => true, 'update' => true, 'create' => false, 'delete' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user