Applied styleci style changes

This commit is contained in:
Dan Brown 2021-09-18 21:21:44 +01:00
parent 6454e24657
commit c08c8d7aa3
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
10 changed files with 51 additions and 55 deletions

View File

@ -7,11 +7,11 @@ use BookStack\Traits\HasCreatorAndUpdater;
use Illuminate\Database\Eloquent\Relations\MorphTo;
/**
* @property int $id
* @property string $text
* @property string $html
* @property int $id
* @property string $text
* @property string $html
* @property int|null $parent_id
* @property int $local_id
* @property int $local_id
*/
class Comment extends Model
{

View File

@ -13,12 +13,12 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* Class Role.
*
* @property int $id
* @property string $display_name
* @property string $description
* @property string $external_auth_id
* @property string $system_name
* @property bool $mfa_enforced
* @property int $id
* @property string $display_name
* @property string $description
* @property string $external_auth_id
* @property string $system_name
* @property bool $mfa_enforced
* @property Collection $users
*/
class Role extends Model implements Loggable

View File

@ -12,9 +12,9 @@ use Illuminate\Support\Collection;
/**
* Class Book.
*
* @property string $description
* @property int $image_id
* @property Image|null $cover
* @property string $description
* @property int $image_id
* @property Image|null $cover
* @property \Illuminate\Database\Eloquent\Collection $chapters
* @property \Illuminate\Database\Eloquent\Collection $pages
* @property \Illuminate\Database\Eloquent\Collection $directPages

View File

@ -77,8 +77,8 @@ class AuthTest extends TestCase
$this->get('/register');
$resp = $this->followingRedirects()->post('/register', [
'name' => '1',
'email' => '1',
'name' => '1',
'email' => '1',
'password' => '1',
]);
$resp->assertSee('The name must be at least 2 characters.');
@ -241,10 +241,10 @@ class AuthTest extends TestCase
->assertSee('Reset Password');
$resp = $this->post('/password/reset', [
'email' => 'admin@admin.com',
'password' => 'randompass',
'email' => 'admin@admin.com',
'password' => 'randompass',
'password_confirmation' => 'randompass',
'token' => $n->first()->token
'token' => $n->first()->token,
]);
$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->assertDontSee('We can\'t find a user');
$this->get('/password/reset/arandometokenvalue')->assertSee('Reset Password');
$resp = $this->post('/password/reset', [
'email' => 'barry@admin.com',
'password' => 'randompass',
'email' => 'barry@admin.com',
'password' => 'randompass',
'password_confirmation' => 'randompass',
'token' => 'arandometokenvalue'
'token' => 'arandometokenvalue',
]);
$resp->assertRedirect('/password/reset/arandometokenvalue');

View File

@ -8,7 +8,7 @@ use Tests\TestCase;
class PageEditorTest extends TestCase
{
/** @var Page */
/** @var Page */
protected $page;
public function setUp(): void
@ -74,4 +74,4 @@ class PageEditorTest extends TestCase
'draft' => false,
]);
}
}
}

View File

@ -227,7 +227,7 @@ class PageTest extends TestCase
// Need to save twice since revisions are not generated in seeder.
$this->asAdmin()->put($page->getUrl(), [
'name' => 'super test',
'html' => '<p></p>'
'html' => '<p></p>',
]);
$page->refresh();
@ -235,7 +235,7 @@ class PageTest extends TestCase
$this->put($pageUrl, [
'name' => 'super test page',
'html' => '<p></p>'
'html' => '<p></p>',
]);
$this->get($pageUrl)
@ -280,5 +280,4 @@ class PageTest extends TestCase
$this->get('/')
->assertElementContains('#recently-updated-pages', $page->name);
}
}

View File

@ -162,12 +162,11 @@ class EntityPermissionsTest extends TestCase
$this->setRestrictionsForTestRoles($book, ['view', 'create']);
$resp = $this->post($book->getUrl('/create-chapter'), [
'name' => 'test chapter',
'name' => 'test chapter',
'description' => 'desc',
]);
$resp->assertRedirect($book->getUrl('/chapter/test-chapter'));
$this->get($book->getUrl('/create-page'));
/** @var Page $page */
$page = Page::query()->where('draft', '=', true)->orderBy('id', 'desc')->first();
@ -401,11 +400,11 @@ class EntityPermissionsTest extends TestCase
->assertSee($title);
$this->put($modelInstance->getUrl('/permissions'), [
'restricted' => 'true',
'restricted' => 'true',
'restrictions' => [
$roleId => [
$permission => 'true'
]
$permission => 'true',
],
],
]);
@ -556,12 +555,11 @@ class EntityPermissionsTest extends TestCase
$this->setRestrictionsForTestRoles($book, ['view', 'create']);
$resp = $this->post($book->getUrl('/create-chapter'), [
'name' => 'test chapter',
'name' => 'test chapter',
'description' => 'test desc',
]);
$resp->assertRedirect($book->getUrl('/chapter/test-chapter'));
$this->get($book->getUrl('/create-page'));
/** @var Page $page */
$page = Page::query()->where('draft', '=', true)->orderByDesc('id')->first();
@ -730,7 +728,6 @@ class EntityPermissionsTest extends TestCase
$this->setRestrictionsForTestRoles($bookChapter, ['view', 'create']);
$this->get($bookChapter->getUrl('/create-page'));
/** @var Page $page */
$page = Page::query()->where('draft', '=', true)->orderByDesc('id')->first();

View File

@ -69,7 +69,7 @@ class RolesTest extends TestCase
$resp = $this->post('/settings/roles/new', [
'display_name' => $testRoleName,
'description' => $testRoleDesc,
'description' => $testRoleDesc,
]);
$resp->assertRedirect('/settings/roles');
@ -78,7 +78,7 @@ class RolesTest extends TestCase
$resp->assertSee($testRoleDesc);
$this->assertDatabaseHas('roles', [
'display_name' => $testRoleName,
'description' => $testRoleDesc,
'description' => $testRoleDesc,
'mfa_enforced' => false,
]);
@ -93,13 +93,13 @@ class RolesTest extends TestCase
$resp = $this->put('/settings/roles/' . $role->id, [
'display_name' => $testRoleUpdateName,
'description' => $testRoleDesc,
'description' => $testRoleDesc,
'mfa_enforced' => 'true',
]);
$resp->assertRedirect('/settings/roles');
$this->assertDatabaseHas('roles', [
'display_name' => $testRoleUpdateName,
'description' => $testRoleDesc,
'description' => $testRoleDesc,
'mfa_enforced' => true,
]);
@ -321,7 +321,7 @@ class RolesTest extends TestCase
]);
$this->post('/shelves', [
'name' => 'test shelf',
'name' => 'test shelf',
'description' => 'shelf desc',
])->assertRedirect('/shelves/test-shelf');
}
@ -402,7 +402,7 @@ class RolesTest extends TestCase
]);
$this->post('/books', [
'name' => 'test book',
'name' => 'test book',
'description' => 'book desc',
])->assertRedirect('/books/test-book');
}
@ -480,7 +480,7 @@ class RolesTest extends TestCase
]);
$this->post($ownBook->getUrl('/create-chapter'), [
'name' => 'test chapter',
'name' => 'test chapter',
'description' => 'chapter desc',
])->assertRedirect($ownBook->getUrl('/chapter/test-chapter'));
@ -499,7 +499,7 @@ class RolesTest extends TestCase
]);
$this->post($book->getUrl('/create-chapter'), [
'name' => 'test chapter',
'name' => 'test chapter',
'description' => 'chapter desc',
])->assertRedirect($book->getUrl('/chapter/test-chapter'));
}
@ -771,8 +771,8 @@ class RolesTest extends TestCase
$page = Page::query()->first();
$image = factory(Image::class)->create([
'uploaded_to' => $page->id,
'created_by' => $this->user->id,
'updated_by' => $this->user->id,
'created_by' => $this->user->id,
'updated_by' => $this->user->id,
]);
$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
{
$comment = factory(Comment::class)->make();
return $this->postJson("/comment/$page->id", $comment->only('text', 'html'));
}
private function updateComment(Comment $comment): TestResponse
{
$commentData = factory(Comment::class)->make();
return $this->putJson("/comment/{$comment->id}", $commentData->only('text', 'html'));
}

View File

@ -213,6 +213,7 @@ trait SharedTestHelpers
/**
* Create a group of entities that belong to a specific user.
*
* @return array{book: Book, chapter: Chapter, page: Page}
*/
protected function createEntityChainBelongingToUser(User $creatorUser, ?User $updaterUser = null): array

View File

@ -12,7 +12,6 @@ use Tests\TestCase;
class UserManagementTest extends TestCase
{
public function test_user_creation()
{
/** @var User $user */
@ -26,10 +25,10 @@ class UserManagementTest extends TestCase
->assertElementContains('form[action="' . url('/settings/users/create') . '"]', 'Save');
$resp = $this->post('/settings/users/create', [
'name' => $user->name,
'email' => $user->email,
'password' => $user->password,
'password-confirm' => $user->password,
'name' => $user->name,
'email' => $user->email,
'password' => $user->password,
'password-confirm' => $user->password,
'roles[' . $adminRole->id . ']' => 'true',
]);
$resp->assertRedirect('/settings/users');
@ -48,12 +47,11 @@ class UserManagementTest extends TestCase
$user = $this->getNormalUser();
$password = $user->password;
$resp = $this->asAdmin()->get('/settings/users/' . $user->id);
$resp->assertSee($user->email);
$this->put($user->getEditUrl(), [
'name' => 'Barry Scott'
'name' => 'Barry Scott',
])->assertRedirect('/settings/users');
$this->assertDatabaseHas('users', ['id' => $user->id, 'name' => 'Barry Scott', 'password' => $password]);
@ -70,13 +68,13 @@ class UserManagementTest extends TestCase
$this->asAdmin()->get($userProfilePage);
$this->put($userProfilePage, [
'password' => 'newpassword'
'password' => 'newpassword',
])->assertRedirect($userProfilePage);
$this->get($userProfilePage)->assertSee('Password confirmation required');
$this->put($userProfilePage, [
'password' => 'newpassword',
'password' => 'newpassword',
'password-confirm' => 'newpassword',
])->assertRedirect('/settings/users');
@ -161,7 +159,7 @@ class UserManagementTest extends TestCase
$resp->assertSee('Guest');
$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 = $this->followRedirects($resp);
$resp->assertSee('cannot delete the guest user');