Files
relaticle-comments/tests/TestCase.php
manukminasyan 6c96fb900b fix: update tests for RichEditor form data paths and service providers
Update all tests to use new form state paths (commentData.body,
editData.body, replyData.body) instead of removed public properties.
Remove searchUsers() tests (method replaced by MentionProvider).
Add BladeUI Icons service providers to TestCase for RichEditor views.
2026-03-27 19:20:56 +04:00

144 lines
5.0 KiB
PHP

<?php
namespace Relaticle\Comments\Tests;
use BladeUI\Heroicons\BladeHeroiconsServiceProvider;
use BladeUI\Icons\BladeIconsServiceProvider;
use Filament\Actions\ActionsServiceProvider;
use Filament\FilamentServiceProvider;
use Filament\Forms\FormsServiceProvider;
use Filament\Schemas\SchemasServiceProvider;
use Filament\Support\SupportServiceProvider;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Livewire\LivewireServiceProvider;
use Livewire\Mechanisms\DataStore;
use Orchestra\Testbench\TestCase as Orchestra;
use Relaticle\Comments\CommentsServiceProvider;
use Relaticle\Comments\Tests\Models\User;
abstract class TestCase extends Orchestra
{
protected function setUp(): void
{
parent::setUp();
$this->app->singleton(DataStore::class);
}
/** @return array<int, class-string> */
protected function getPackageProviders($app): array
{
return [
LivewireServiceProvider::class,
BladeIconsServiceProvider::class,
BladeHeroiconsServiceProvider::class,
SupportServiceProvider::class,
SchemasServiceProvider::class,
FormsServiceProvider::class,
ActionsServiceProvider::class,
FilamentServiceProvider::class,
CommentsServiceProvider::class,
];
}
protected function defineDatabaseMigrations(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email');
$table->string('password');
$table->timestamps();
});
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->timestamps();
});
Schema::create(config('comments.table_names.comments', 'comments'), function (Blueprint $table) {
$table->id();
$table->morphs('commentable');
$table->morphs('commenter');
$table->foreignId('parent_id')
->nullable()
->constrained(config('comments.table_names.comments', 'comments'))
->cascadeOnDelete();
$table->text('body');
$table->timestamp('edited_at')->nullable();
$table->softDeletes();
$table->timestamps();
$table->index(['commentable_type', 'commentable_id', 'parent_id']);
});
Schema::create('comment_mentions', function (Blueprint $table) {
$table->id();
$table->foreignId('comment_id')
->constrained(config('comments.table_names.comments', 'comments'))
->cascadeOnDelete();
$table->morphs('commenter');
$table->timestamps();
$table->unique(['comment_id', 'commenter_id', 'commenter_type']);
});
Schema::create('comment_reactions', function (Blueprint $table) {
$table->id();
$table->foreignId('comment_id')
->constrained(config('comments.table_names.comments', 'comments'))
->cascadeOnDelete();
$table->morphs('commenter');
$table->string('reaction');
$table->timestamps();
$table->unique(['comment_id', 'commenter_id', 'commenter_type', 'reaction']);
});
Schema::create('comment_attachments', function (Blueprint $table) {
$table->id();
$table->foreignId('comment_id')
->constrained(config('comments.table_names.comments', 'comments'))
->cascadeOnDelete();
$table->string('file_path');
$table->string('original_name');
$table->string('mime_type');
$table->unsignedBigInteger('size');
$table->string('disk');
$table->timestamps();
});
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
Schema::create('comment_subscriptions', function (Blueprint $table) {
$table->id();
$table->morphs('commentable');
$table->morphs('commenter');
$table->timestamp('created_at')->nullable();
$table->unique(['commentable_type', 'commentable_id', 'commenter_type', 'commenter_id'], 'comment_subscriptions_unique');
});
}
protected function getEnvironmentSetUp($app): void
{
$app['config']->set('app.key', 'base64:'.base64_encode(random_bytes(32)));
$app['config']->set('database.default', 'testing');
$app['config']->set('database.connections.testing', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]);
$app['config']->set('comments.commenter.model', User::class);
}
}