From fee9045dacd5deca3ae88b17a22b3fff60c01195 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Wed, 31 Jan 2024 16:35:58 +0000 Subject: [PATCH] Comments: Removed remaining uses of redundant 'text' field Opened #4821 to remove the DB field in a few releases time. --- app/Activity/Models/Comment.php | 4 ++-- database/factories/Activity/Models/CommentFactory.php | 1 - tests/Entity/CommentTest.php | 4 ++-- tests/Permissions/RolePermissionsTest.php | 8 ++------ 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/Activity/Models/Comment.php b/app/Activity/Models/Comment.php index 038788afb..7d1c54646 100644 --- a/app/Activity/Models/Comment.php +++ b/app/Activity/Models/Comment.php @@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo; /** * @property int $id - * @property string $text + * @property string $text - Deprecated & now unused (#4821) * @property string $html * @property int|null $parent_id - Relates to local_id, not id * @property int $local_id @@ -25,7 +25,7 @@ class Comment extends Model implements Loggable use HasFactory; use HasCreatorAndUpdater; - protected $fillable = ['text', 'parent_id']; + protected $fillable = ['parent_id']; protected $appends = ['created', 'updated']; /** diff --git a/database/factories/Activity/Models/CommentFactory.php b/database/factories/Activity/Models/CommentFactory.php index 35d6db9bd..efbd183b3 100644 --- a/database/factories/Activity/Models/CommentFactory.php +++ b/database/factories/Activity/Models/CommentFactory.php @@ -25,7 +25,6 @@ class CommentFactory extends Factory return [ 'html' => $html, - 'text' => $text, 'parent_id' => null, 'local_id' => 1, ]; diff --git a/tests/Entity/CommentTest.php b/tests/Entity/CommentTest.php index 76e014e80..eb4bccb7c 100644 --- a/tests/Entity/CommentTest.php +++ b/tests/Entity/CommentTest.php @@ -18,10 +18,10 @@ class CommentTest extends TestCase $resp = $this->postJson("/comment/$page->id", $comment->getAttributes()); $resp->assertStatus(200); - $resp->assertSee($comment->text); + $resp->assertSee($comment->html, false); $pageResp = $this->get($page->getUrl()); - $pageResp->assertSee($comment->text); + $pageResp->assertSee($comment->html, false); $this->assertDatabaseHas('comments', [ 'local_id' => 1, diff --git a/tests/Permissions/RolePermissionsTest.php b/tests/Permissions/RolePermissionsTest.php index ccb158faf..d3146bd47 100644 --- a/tests/Permissions/RolePermissionsTest.php +++ b/tests/Permissions/RolePermissionsTest.php @@ -738,16 +738,12 @@ class RolePermissionsTest extends TestCase private function addComment(Page $page): TestResponse { - $comment = Comment::factory()->make(); - - return $this->postJson("/comment/$page->id", $comment->only('text', 'html')); + return $this->postJson("/comment/$page->id", ['html' => '

New comment content

']); } private function updateComment(Comment $comment): TestResponse { - $commentData = Comment::factory()->make(); - - return $this->putJson("/comment/{$comment->id}", $commentData->only('text', 'html')); + return $this->putJson("/comment/{$comment->id}", ['html' => '

Updated comment content

']); } private function deleteComment(Comment $comment): TestResponse