{
protected $user;
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->user = $this->getViewer();
public function test_admin_can_see_settings()
{
- $this->asAdmin()->get('/settings')->assertSee('Settings');
+ $this->asAdmin()->get('/settings/features')->assertSee('Settings');
}
public function test_cannot_delete_admin_role()
$testRoleUpdateName = 'An Super Updated role';
// Creation
- $resp = $this->asAdmin()->get('/settings');
+ $resp = $this->asAdmin()->get('/settings/features');
$resp->assertElementContains('a[href="' . url('/settings/roles') . '"]', 'Roles');
$resp = $this->get('/settings/roles');
$this->assertEquals($this->user->id, $roleA->users()->first()->id);
}
+ public function test_copy_role_button_shown()
+ {
+ /** @var Role $role */
+ $role = Role::query()->first();
+ $resp = $this->asAdmin()->get("/settings/roles/{$role->id}");
+ $resp->assertElementContains('a[href$="/roles/new?copy_from=' . $role->id . '"]', 'Copy');
+ }
+
+ public function test_copy_from_param_on_create_prefills_with_other_role_data()
+ {
+ /** @var Role $role */
+ $role = Role::query()->first();
+ $resp = $this->asAdmin()->get("/settings/roles/new?copy_from={$role->id}");
+ $resp->assertOk();
+ $resp->assertElementExists('input[name="display_name"][value="' . ($role->display_name . ' (Copy)') . '"]');
+ }
+
public function test_manage_user_permission()
{
$this->actingAs($this->user)->get('/settings/users')->assertRedirect('/');
public function test_manage_users_permission_shows_link_in_header_if_does_not_have_settings_manage_permision()
{
$usersLink = 'href="' . url('/settings/users') . '"';
- $this->actingAs($this->user)->get('/')->assertDontSee($usersLink);
+ $this->actingAs($this->user)->get('/')->assertDontSee($usersLink, false);
$this->giveUserPermissions($this->user, ['users-manage']);
- $this->actingAs($this->user)->get('/')->assertSee($usersLink);
+ $this->actingAs($this->user)->get('/')->assertSee($usersLink, false);
$this->giveUserPermissions($this->user, ['settings-manage', 'users-manage']);
- $this->actingAs($this->user)->get('/')->assertDontSee($usersLink);
+ $this->actingAs($this->user)->get('/')->assertDontSee($usersLink, false);
}
public function test_user_cannot_change_email_unless_they_have_manage_users_permission()
public function test_settings_manage_permission()
{
- $this->actingAs($this->user)->get('/settings')->assertRedirect('/');
+ $this->actingAs($this->user)->get('/settings/features')->assertRedirect('/');
$this->giveUserPermissions($this->user, ['settings-manage']);
- $this->get('/settings')->assertOk();
+ $this->get('/settings/features')->assertOk();
- $resp = $this->post('/settings', []);
- $resp->assertRedirect('/settings');
- $resp = $this->get('/settings');
+ $resp = $this->post('/settings/features', []);
+ $resp->assertRedirect('/settings/features');
+ $resp = $this->get('/settings/features');
$resp->assertSee('Settings saved');
}
public function test_public_role_visible_in_default_role_setting()
{
- $this->asAdmin()->get('/settings')
+ $this->asAdmin()->get('/settings/registration')
->assertElementExists('[data-system-role-name="admin"]')
->assertElementExists('[data-system-role-name="public"]');
}
$this->giveUserPermissions($this->user, ['image-update-all']);
/** @var Page $page */
$page = Page::query()->first();
- $image = factory(Image::class)->create([
+ $image = Image::factory()->create([
'uploaded_to' => $page->id,
'created_by' => $this->user->id,
'updated_by' => $this->user->id,
$admin = $this->getAdmin();
/** @var Page $page */
$page = Page::query()->first();
- $image = factory(Image::class)->create(['uploaded_to' => $page->id, 'created_by' => $admin->id, 'updated_by' => $admin->id]);
+ $image = Image::factory()->create(['uploaded_to' => $page->id, 'created_by' => $admin->id, 'updated_by' => $admin->id]);
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)->assertStatus(403);
{
$admin = $this->getAdmin();
// Book links
- $book = factory(Book::class)->create(['created_by' => $admin->id, 'updated_by' => $admin->id]);
+ $book = Book::factory()->create(['created_by' => $admin->id, 'updated_by' => $admin->id]);
$this->regenEntityPermissions($book);
$this->actingAs($this->getViewer())->get($book->getUrl())
->assertDontSee('Create a new page')
->assertDontSee('Add a chapter');
// Chapter links
- $chapter = factory(Chapter::class)->create(['created_by' => $admin->id, 'updated_by' => $admin->id, 'book_id' => $book->id]);
+ $chapter = Chapter::factory()->create(['created_by' => $admin->id, 'updated_by' => $admin->id, 'book_id' => $book->id]);
$this->regenEntityPermissions($chapter);
$this->actingAs($this->getViewer())->get($chapter->getUrl())
->assertDontSee('Create a new page')
private function addComment(Page $page): TestResponse
{
- $comment = factory(Comment::class)->make();
+ $comment = Comment::factory()->make();
return $this->postJson("/comment/$page->id", $comment->only('text', 'html'));
}
private function updateComment(Comment $comment): TestResponse
{
- $commentData = factory(Comment::class)->make();
+ $commentData = Comment::factory()->make();
return $this->putJson("/comment/{$comment->id}", $commentData->only('text', 'html'));
}