diff --git a/app/Actions/Comment.php b/app/Actions/Comment.php index e652bf8a8..34fd84709 100644 --- a/app/Actions/Comment.php +++ b/app/Actions/Comment.php @@ -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 { diff --git a/app/Auth/Role.php b/app/Auth/Role.php index 2918fce52..46921caeb 100644 --- a/app/Auth/Role.php +++ b/app/Auth/Role.php @@ -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 diff --git a/app/Entities/Models/Book.php b/app/Entities/Models/Book.php index f77135480..1e4591bd7 100644 --- a/app/Entities/Models/Book.php +++ b/app/Entities/Models/Book.php @@ -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 diff --git a/tests/Auth/AuthTest.php b/tests/Auth/AuthTest.php index acf67cb9a..a718b14b6 100644 --- a/tests/Auth/AuthTest.php +++ b/tests/Auth/AuthTest.php @@ -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'); diff --git a/tests/Entity/PageEditorTest.php b/tests/Entity/PageEditorTest.php index 588de4f17..9b0a8f188 100644 --- a/tests/Entity/PageEditorTest.php +++ b/tests/Entity/PageEditorTest.php @@ -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, ]); } -} \ No newline at end of file +} diff --git a/tests/Entity/PageTest.php b/tests/Entity/PageTest.php index e7118aae5..313fc77f0 100644 --- a/tests/Entity/PageTest.php +++ b/tests/Entity/PageTest.php @@ -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); } - } diff --git a/tests/Permissions/EntityPermissionsTest.php b/tests/Permissions/EntityPermissionsTest.php index 97d9074b7..bb011cfc6 100644 --- a/tests/Permissions/EntityPermissionsTest.php +++ b/tests/Permissions/EntityPermissionsTest.php @@ -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(); diff --git a/tests/Permissions/RolesTest.php b/tests/Permissions/RolesTest.php index 5689caf7b..5248ae152 100644 --- a/tests/Permissions/RolesTest.php +++ b/tests/Permissions/RolesTest.php @@ -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')); } diff --git a/tests/SharedTestHelpers.php b/tests/SharedTestHelpers.php index 77bd5076b..e4d27c849 100644 --- a/tests/SharedTestHelpers.php +++ b/tests/SharedTestHelpers.php @@ -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 diff --git a/tests/User/UserManagementTest.php b/tests/User/UserManagementTest.php index f52a78a13..ed2fb5f04 100644 --- a/tests/User/UserManagementTest.php +++ b/tests/User/UserManagementTest.php @@ -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');