mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Applied styleci style changes
This commit is contained in:
parent
6454e24657
commit
c08c8d7aa3
@ -7,11 +7,11 @@ use BookStack\Traits\HasCreatorAndUpdater;
|
|||||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property string $text
|
* @property string $text
|
||||||
* @property string $html
|
* @property string $html
|
||||||
* @property int|null $parent_id
|
* @property int|null $parent_id
|
||||||
* @property int $local_id
|
* @property int $local_id
|
||||||
*/
|
*/
|
||||||
class Comment extends Model
|
class Comment extends Model
|
||||||
{
|
{
|
||||||
|
@ -13,12 +13,12 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
/**
|
/**
|
||||||
* Class Role.
|
* Class Role.
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property string $display_name
|
* @property string $display_name
|
||||||
* @property string $description
|
* @property string $description
|
||||||
* @property string $external_auth_id
|
* @property string $external_auth_id
|
||||||
* @property string $system_name
|
* @property string $system_name
|
||||||
* @property bool $mfa_enforced
|
* @property bool $mfa_enforced
|
||||||
* @property Collection $users
|
* @property Collection $users
|
||||||
*/
|
*/
|
||||||
class Role extends Model implements Loggable
|
class Role extends Model implements Loggable
|
||||||
|
@ -12,9 +12,9 @@ use Illuminate\Support\Collection;
|
|||||||
/**
|
/**
|
||||||
* Class Book.
|
* Class Book.
|
||||||
*
|
*
|
||||||
* @property string $description
|
* @property string $description
|
||||||
* @property int $image_id
|
* @property int $image_id
|
||||||
* @property Image|null $cover
|
* @property Image|null $cover
|
||||||
* @property \Illuminate\Database\Eloquent\Collection $chapters
|
* @property \Illuminate\Database\Eloquent\Collection $chapters
|
||||||
* @property \Illuminate\Database\Eloquent\Collection $pages
|
* @property \Illuminate\Database\Eloquent\Collection $pages
|
||||||
* @property \Illuminate\Database\Eloquent\Collection $directPages
|
* @property \Illuminate\Database\Eloquent\Collection $directPages
|
||||||
|
@ -77,8 +77,8 @@ class AuthTest extends TestCase
|
|||||||
|
|
||||||
$this->get('/register');
|
$this->get('/register');
|
||||||
$resp = $this->followingRedirects()->post('/register', [
|
$resp = $this->followingRedirects()->post('/register', [
|
||||||
'name' => '1',
|
'name' => '1',
|
||||||
'email' => '1',
|
'email' => '1',
|
||||||
'password' => '1',
|
'password' => '1',
|
||||||
]);
|
]);
|
||||||
$resp->assertSee('The name must be at least 2 characters.');
|
$resp->assertSee('The name must be at least 2 characters.');
|
||||||
@ -241,10 +241,10 @@ class AuthTest extends TestCase
|
|||||||
->assertSee('Reset Password');
|
->assertSee('Reset Password');
|
||||||
|
|
||||||
$resp = $this->post('/password/reset', [
|
$resp = $this->post('/password/reset', [
|
||||||
'email' => 'admin@admin.com',
|
'email' => 'admin@admin.com',
|
||||||
'password' => 'randompass',
|
'password' => 'randompass',
|
||||||
'password_confirmation' => 'randompass',
|
'password_confirmation' => 'randompass',
|
||||||
'token' => $n->first()->token
|
'token' => $n->first()->token,
|
||||||
]);
|
]);
|
||||||
$resp->assertRedirect('/');
|
$resp->assertRedirect('/');
|
||||||
|
|
||||||
@ -260,13 +260,12 @@ class AuthTest extends TestCase
|
|||||||
$resp->assertSee('A password reset link will be sent to barry@admin.com if that email address is found in the system.');
|
$resp->assertSee('A password reset link will be sent to barry@admin.com if that email address is found in the system.');
|
||||||
$resp->assertDontSee('We can\'t find a user');
|
$resp->assertDontSee('We can\'t find a user');
|
||||||
|
|
||||||
|
|
||||||
$this->get('/password/reset/arandometokenvalue')->assertSee('Reset Password');
|
$this->get('/password/reset/arandometokenvalue')->assertSee('Reset Password');
|
||||||
$resp = $this->post('/password/reset', [
|
$resp = $this->post('/password/reset', [
|
||||||
'email' => 'barry@admin.com',
|
'email' => 'barry@admin.com',
|
||||||
'password' => 'randompass',
|
'password' => 'randompass',
|
||||||
'password_confirmation' => 'randompass',
|
'password_confirmation' => 'randompass',
|
||||||
'token' => 'arandometokenvalue'
|
'token' => 'arandometokenvalue',
|
||||||
]);
|
]);
|
||||||
$resp->assertRedirect('/password/reset/arandometokenvalue');
|
$resp->assertRedirect('/password/reset/arandometokenvalue');
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ use Tests\TestCase;
|
|||||||
|
|
||||||
class PageEditorTest extends TestCase
|
class PageEditorTest extends TestCase
|
||||||
{
|
{
|
||||||
/** @var Page */
|
/** @var Page */
|
||||||
protected $page;
|
protected $page;
|
||||||
|
|
||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
@ -74,4 +74,4 @@ class PageEditorTest extends TestCase
|
|||||||
'draft' => false,
|
'draft' => false,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ class PageTest extends TestCase
|
|||||||
// Need to save twice since revisions are not generated in seeder.
|
// Need to save twice since revisions are not generated in seeder.
|
||||||
$this->asAdmin()->put($page->getUrl(), [
|
$this->asAdmin()->put($page->getUrl(), [
|
||||||
'name' => 'super test',
|
'name' => 'super test',
|
||||||
'html' => '<p></p>'
|
'html' => '<p></p>',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$page->refresh();
|
$page->refresh();
|
||||||
@ -235,7 +235,7 @@ class PageTest extends TestCase
|
|||||||
|
|
||||||
$this->put($pageUrl, [
|
$this->put($pageUrl, [
|
||||||
'name' => 'super test page',
|
'name' => 'super test page',
|
||||||
'html' => '<p></p>'
|
'html' => '<p></p>',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->get($pageUrl)
|
$this->get($pageUrl)
|
||||||
@ -280,5 +280,4 @@ class PageTest extends TestCase
|
|||||||
$this->get('/')
|
$this->get('/')
|
||||||
->assertElementContains('#recently-updated-pages', $page->name);
|
->assertElementContains('#recently-updated-pages', $page->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -162,12 +162,11 @@ class EntityPermissionsTest extends TestCase
|
|||||||
$this->setRestrictionsForTestRoles($book, ['view', 'create']);
|
$this->setRestrictionsForTestRoles($book, ['view', 'create']);
|
||||||
|
|
||||||
$resp = $this->post($book->getUrl('/create-chapter'), [
|
$resp = $this->post($book->getUrl('/create-chapter'), [
|
||||||
'name' => 'test chapter',
|
'name' => 'test chapter',
|
||||||
'description' => 'desc',
|
'description' => 'desc',
|
||||||
]);
|
]);
|
||||||
$resp->assertRedirect($book->getUrl('/chapter/test-chapter'));
|
$resp->assertRedirect($book->getUrl('/chapter/test-chapter'));
|
||||||
|
|
||||||
|
|
||||||
$this->get($book->getUrl('/create-page'));
|
$this->get($book->getUrl('/create-page'));
|
||||||
/** @var Page $page */
|
/** @var Page $page */
|
||||||
$page = Page::query()->where('draft', '=', true)->orderBy('id', 'desc')->first();
|
$page = Page::query()->where('draft', '=', true)->orderBy('id', 'desc')->first();
|
||||||
@ -401,11 +400,11 @@ class EntityPermissionsTest extends TestCase
|
|||||||
->assertSee($title);
|
->assertSee($title);
|
||||||
|
|
||||||
$this->put($modelInstance->getUrl('/permissions'), [
|
$this->put($modelInstance->getUrl('/permissions'), [
|
||||||
'restricted' => 'true',
|
'restricted' => 'true',
|
||||||
'restrictions' => [
|
'restrictions' => [
|
||||||
$roleId => [
|
$roleId => [
|
||||||
$permission => 'true'
|
$permission => 'true',
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -556,12 +555,11 @@ class EntityPermissionsTest extends TestCase
|
|||||||
$this->setRestrictionsForTestRoles($book, ['view', 'create']);
|
$this->setRestrictionsForTestRoles($book, ['view', 'create']);
|
||||||
|
|
||||||
$resp = $this->post($book->getUrl('/create-chapter'), [
|
$resp = $this->post($book->getUrl('/create-chapter'), [
|
||||||
'name' => 'test chapter',
|
'name' => 'test chapter',
|
||||||
'description' => 'test desc',
|
'description' => 'test desc',
|
||||||
]);
|
]);
|
||||||
$resp->assertRedirect($book->getUrl('/chapter/test-chapter'));
|
$resp->assertRedirect($book->getUrl('/chapter/test-chapter'));
|
||||||
|
|
||||||
|
|
||||||
$this->get($book->getUrl('/create-page'));
|
$this->get($book->getUrl('/create-page'));
|
||||||
/** @var Page $page */
|
/** @var Page $page */
|
||||||
$page = Page::query()->where('draft', '=', true)->orderByDesc('id')->first();
|
$page = Page::query()->where('draft', '=', true)->orderByDesc('id')->first();
|
||||||
@ -730,7 +728,6 @@ class EntityPermissionsTest extends TestCase
|
|||||||
|
|
||||||
$this->setRestrictionsForTestRoles($bookChapter, ['view', 'create']);
|
$this->setRestrictionsForTestRoles($bookChapter, ['view', 'create']);
|
||||||
|
|
||||||
|
|
||||||
$this->get($bookChapter->getUrl('/create-page'));
|
$this->get($bookChapter->getUrl('/create-page'));
|
||||||
/** @var Page $page */
|
/** @var Page $page */
|
||||||
$page = Page::query()->where('draft', '=', true)->orderByDesc('id')->first();
|
$page = Page::query()->where('draft', '=', true)->orderByDesc('id')->first();
|
||||||
|
@ -69,7 +69,7 @@ class RolesTest extends TestCase
|
|||||||
|
|
||||||
$resp = $this->post('/settings/roles/new', [
|
$resp = $this->post('/settings/roles/new', [
|
||||||
'display_name' => $testRoleName,
|
'display_name' => $testRoleName,
|
||||||
'description' => $testRoleDesc,
|
'description' => $testRoleDesc,
|
||||||
]);
|
]);
|
||||||
$resp->assertRedirect('/settings/roles');
|
$resp->assertRedirect('/settings/roles');
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ class RolesTest extends TestCase
|
|||||||
$resp->assertSee($testRoleDesc);
|
$resp->assertSee($testRoleDesc);
|
||||||
$this->assertDatabaseHas('roles', [
|
$this->assertDatabaseHas('roles', [
|
||||||
'display_name' => $testRoleName,
|
'display_name' => $testRoleName,
|
||||||
'description' => $testRoleDesc,
|
'description' => $testRoleDesc,
|
||||||
'mfa_enforced' => false,
|
'mfa_enforced' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -93,13 +93,13 @@ class RolesTest extends TestCase
|
|||||||
|
|
||||||
$resp = $this->put('/settings/roles/' . $role->id, [
|
$resp = $this->put('/settings/roles/' . $role->id, [
|
||||||
'display_name' => $testRoleUpdateName,
|
'display_name' => $testRoleUpdateName,
|
||||||
'description' => $testRoleDesc,
|
'description' => $testRoleDesc,
|
||||||
'mfa_enforced' => 'true',
|
'mfa_enforced' => 'true',
|
||||||
]);
|
]);
|
||||||
$resp->assertRedirect('/settings/roles');
|
$resp->assertRedirect('/settings/roles');
|
||||||
$this->assertDatabaseHas('roles', [
|
$this->assertDatabaseHas('roles', [
|
||||||
'display_name' => $testRoleUpdateName,
|
'display_name' => $testRoleUpdateName,
|
||||||
'description' => $testRoleDesc,
|
'description' => $testRoleDesc,
|
||||||
'mfa_enforced' => true,
|
'mfa_enforced' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -321,7 +321,7 @@ class RolesTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$this->post('/shelves', [
|
$this->post('/shelves', [
|
||||||
'name' => 'test shelf',
|
'name' => 'test shelf',
|
||||||
'description' => 'shelf desc',
|
'description' => 'shelf desc',
|
||||||
])->assertRedirect('/shelves/test-shelf');
|
])->assertRedirect('/shelves/test-shelf');
|
||||||
}
|
}
|
||||||
@ -402,7 +402,7 @@ class RolesTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$this->post('/books', [
|
$this->post('/books', [
|
||||||
'name' => 'test book',
|
'name' => 'test book',
|
||||||
'description' => 'book desc',
|
'description' => 'book desc',
|
||||||
])->assertRedirect('/books/test-book');
|
])->assertRedirect('/books/test-book');
|
||||||
}
|
}
|
||||||
@ -480,7 +480,7 @@ class RolesTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$this->post($ownBook->getUrl('/create-chapter'), [
|
$this->post($ownBook->getUrl('/create-chapter'), [
|
||||||
'name' => 'test chapter',
|
'name' => 'test chapter',
|
||||||
'description' => 'chapter desc',
|
'description' => 'chapter desc',
|
||||||
])->assertRedirect($ownBook->getUrl('/chapter/test-chapter'));
|
])->assertRedirect($ownBook->getUrl('/chapter/test-chapter'));
|
||||||
|
|
||||||
@ -499,7 +499,7 @@ class RolesTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$this->post($book->getUrl('/create-chapter'), [
|
$this->post($book->getUrl('/create-chapter'), [
|
||||||
'name' => 'test chapter',
|
'name' => 'test chapter',
|
||||||
'description' => 'chapter desc',
|
'description' => 'chapter desc',
|
||||||
])->assertRedirect($book->getUrl('/chapter/test-chapter'));
|
])->assertRedirect($book->getUrl('/chapter/test-chapter'));
|
||||||
}
|
}
|
||||||
@ -771,8 +771,8 @@ class RolesTest extends TestCase
|
|||||||
$page = Page::query()->first();
|
$page = Page::query()->first();
|
||||||
$image = factory(Image::class)->create([
|
$image = factory(Image::class)->create([
|
||||||
'uploaded_to' => $page->id,
|
'uploaded_to' => $page->id,
|
||||||
'created_by' => $this->user->id,
|
'created_by' => $this->user->id,
|
||||||
'updated_by' => $this->user->id,
|
'updated_by' => $this->user->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)->assertStatus(403);
|
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)->assertStatus(403);
|
||||||
@ -927,12 +927,14 @@ class RolesTest extends TestCase
|
|||||||
private function addComment(Page $page): TestResponse
|
private function addComment(Page $page): TestResponse
|
||||||
{
|
{
|
||||||
$comment = factory(Comment::class)->make();
|
$comment = factory(Comment::class)->make();
|
||||||
|
|
||||||
return $this->postJson("/comment/$page->id", $comment->only('text', 'html'));
|
return $this->postJson("/comment/$page->id", $comment->only('text', 'html'));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateComment(Comment $comment): TestResponse
|
private function updateComment(Comment $comment): TestResponse
|
||||||
{
|
{
|
||||||
$commentData = factory(Comment::class)->make();
|
$commentData = factory(Comment::class)->make();
|
||||||
|
|
||||||
return $this->putJson("/comment/{$comment->id}", $commentData->only('text', 'html'));
|
return $this->putJson("/comment/{$comment->id}", $commentData->only('text', 'html'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +213,7 @@ trait SharedTestHelpers
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a group of entities that belong to a specific user.
|
* Create a group of entities that belong to a specific user.
|
||||||
|
*
|
||||||
* @return array{book: Book, chapter: Chapter, page: Page}
|
* @return array{book: Book, chapter: Chapter, page: Page}
|
||||||
*/
|
*/
|
||||||
protected function createEntityChainBelongingToUser(User $creatorUser, ?User $updaterUser = null): array
|
protected function createEntityChainBelongingToUser(User $creatorUser, ?User $updaterUser = null): array
|
||||||
|
@ -12,7 +12,6 @@ use Tests\TestCase;
|
|||||||
|
|
||||||
class UserManagementTest extends TestCase
|
class UserManagementTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
public function test_user_creation()
|
public function test_user_creation()
|
||||||
{
|
{
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
@ -26,10 +25,10 @@ class UserManagementTest extends TestCase
|
|||||||
->assertElementContains('form[action="' . url('/settings/users/create') . '"]', 'Save');
|
->assertElementContains('form[action="' . url('/settings/users/create') . '"]', 'Save');
|
||||||
|
|
||||||
$resp = $this->post('/settings/users/create', [
|
$resp = $this->post('/settings/users/create', [
|
||||||
'name' => $user->name,
|
'name' => $user->name,
|
||||||
'email' => $user->email,
|
'email' => $user->email,
|
||||||
'password' => $user->password,
|
'password' => $user->password,
|
||||||
'password-confirm' => $user->password,
|
'password-confirm' => $user->password,
|
||||||
'roles[' . $adminRole->id . ']' => 'true',
|
'roles[' . $adminRole->id . ']' => 'true',
|
||||||
]);
|
]);
|
||||||
$resp->assertRedirect('/settings/users');
|
$resp->assertRedirect('/settings/users');
|
||||||
@ -48,12 +47,11 @@ class UserManagementTest extends TestCase
|
|||||||
$user = $this->getNormalUser();
|
$user = $this->getNormalUser();
|
||||||
$password = $user->password;
|
$password = $user->password;
|
||||||
|
|
||||||
|
|
||||||
$resp = $this->asAdmin()->get('/settings/users/' . $user->id);
|
$resp = $this->asAdmin()->get('/settings/users/' . $user->id);
|
||||||
$resp->assertSee($user->email);
|
$resp->assertSee($user->email);
|
||||||
|
|
||||||
$this->put($user->getEditUrl(), [
|
$this->put($user->getEditUrl(), [
|
||||||
'name' => 'Barry Scott'
|
'name' => 'Barry Scott',
|
||||||
])->assertRedirect('/settings/users');
|
])->assertRedirect('/settings/users');
|
||||||
|
|
||||||
$this->assertDatabaseHas('users', ['id' => $user->id, 'name' => 'Barry Scott', 'password' => $password]);
|
$this->assertDatabaseHas('users', ['id' => $user->id, 'name' => 'Barry Scott', 'password' => $password]);
|
||||||
@ -70,13 +68,13 @@ class UserManagementTest extends TestCase
|
|||||||
|
|
||||||
$this->asAdmin()->get($userProfilePage);
|
$this->asAdmin()->get($userProfilePage);
|
||||||
$this->put($userProfilePage, [
|
$this->put($userProfilePage, [
|
||||||
'password' => 'newpassword'
|
'password' => 'newpassword',
|
||||||
])->assertRedirect($userProfilePage);
|
])->assertRedirect($userProfilePage);
|
||||||
|
|
||||||
$this->get($userProfilePage)->assertSee('Password confirmation required');
|
$this->get($userProfilePage)->assertSee('Password confirmation required');
|
||||||
|
|
||||||
$this->put($userProfilePage, [
|
$this->put($userProfilePage, [
|
||||||
'password' => 'newpassword',
|
'password' => 'newpassword',
|
||||||
'password-confirm' => 'newpassword',
|
'password-confirm' => 'newpassword',
|
||||||
])->assertRedirect('/settings/users');
|
])->assertRedirect('/settings/users');
|
||||||
|
|
||||||
@ -161,7 +159,7 @@ class UserManagementTest extends TestCase
|
|||||||
$resp->assertSee('Guest');
|
$resp->assertSee('Guest');
|
||||||
$resp->assertElementContains('form[action$="/settings/users/' . $guestUser->id . '"] button', 'Confirm');
|
$resp->assertElementContains('form[action$="/settings/users/' . $guestUser->id . '"] button', 'Confirm');
|
||||||
|
|
||||||
$resp = $this->delete('/settings/users/' . $guestUser->id);
|
$resp = $this->delete('/settings/users/' . $guestUser->id);
|
||||||
$resp->assertRedirect('/settings/users/' . $guestUser->id);
|
$resp->assertRedirect('/settings/users/' . $guestUser->id);
|
||||||
$resp = $this->followRedirects($resp);
|
$resp = $this->followRedirects($resp);
|
||||||
$resp->assertSee('cannot delete the guest user');
|
$resp->assertSee('cannot delete the guest user');
|
||||||
|
Loading…
Reference in New Issue
Block a user