- Rename IsCommenter trait to CanComment, Commenter interface to Commentator - Move models to Models/ namespace (Comment, Reaction, Attachment, Subscription) - Rename user_type/user_id polymorphic columns to commenter_type/commenter_id - Rename Config class to CommentsConfig, update config key tables->table_names - Rename getCommentName() to getCommentDisplayName() on commentator models - Add column_names config section for commenter morph customization - Add table_names config with all 5 tables individually configurable - Expand translation file with structured i18n groups - Update all Blade views, Livewire components, events, listeners, and tests
42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
use Relaticle\Comments\Filament\Actions\CommentsTableAction;
|
|
use Relaticle\Comments\Models\Comment;
|
|
use Relaticle\Comments\Tests\Models\Post;
|
|
use Relaticle\Comments\Tests\Models\User;
|
|
|
|
it('can be instantiated via make', function () {
|
|
$action = CommentsTableAction::make('comments');
|
|
|
|
expect($action)->toBeInstanceOf(CommentsTableAction::class);
|
|
});
|
|
|
|
it('configures as a slide-over', function () {
|
|
$action = CommentsTableAction::make('comments');
|
|
|
|
expect($action->isModalSlideOver())->toBeTrue();
|
|
});
|
|
|
|
it('has modal content configured', function () {
|
|
$action = CommentsTableAction::make('comments');
|
|
|
|
expect($action->hasModalContent())->toBeTrue();
|
|
});
|
|
|
|
it('shows badge with comment count for the record', function () {
|
|
$user = User::factory()->create();
|
|
$post = Post::factory()->create();
|
|
|
|
Comment::factory()->count(5)->create([
|
|
'commentable_id' => $post->id,
|
|
'commentable_type' => $post->getMorphClass(),
|
|
'commenter_id' => $user->getKey(),
|
|
'commenter_type' => $user->getMorphClass(),
|
|
]);
|
|
|
|
$action = CommentsTableAction::make('comments');
|
|
$action->record($post);
|
|
|
|
expect($action->getBadge())->toBe(5);
|
|
});
|