diff --git a/app/Filament/Resources/Master/Categories/CategoryResource.php b/app/Filament/Resources/Master/Categories/CategoryResource.php deleted file mode 100644 index d7e07fe..0000000 --- a/app/Filament/Resources/Master/Categories/CategoryResource.php +++ /dev/null @@ -1,46 +0,0 @@ - ManageCategories::route('/'), - ]; - } -} diff --git a/app/Filament/Resources/Master/Categories/Pages/ManageCategories.php b/app/Filament/Resources/Master/Categories/Pages/ManageCategories.php deleted file mode 100644 index acd535f..0000000 --- a/app/Filament/Resources/Master/Categories/Pages/ManageCategories.php +++ /dev/null @@ -1,33 +0,0 @@ -label('Tambah') - ->modalHeading(fn () => CheerfulNotification::getByKey('category.create_title')) - ->modalDescription(fn () => CheerfulNotification::getByKey('category.create_desc')) - ->modalSubmitActionLabel('Simpan') - ->modalCancelActionLabel('Batal') - ->extraModalFooterActions(fn (CreateAction $action): array => [ - $action->makeModalSubmitAction('createAknother', arguments: ['another' => true]) - ->label('Simpan dan Tambah Lagi'), - ]) - ->modalWidth(Width::Large), - ]; - } -} diff --git a/app/Filament/Resources/Master/Categories/Schemas/CategoryForm.php b/app/Filament/Resources/Master/Categories/Schemas/CategoryForm.php deleted file mode 100644 index 094f900..0000000 --- a/app/Filament/Resources/Master/Categories/Schemas/CategoryForm.php +++ /dev/null @@ -1,24 +0,0 @@ -components([ - TextInput::make('name') - ->label('Nama Kategori') - ->placeholder('Ekonomi') - ->autocomplete(false) - ->autofocus() - ->required() - ->maxLength(50), - ]) - ->columns(1); - } -} diff --git a/app/Filament/Resources/Master/Categories/Tables/CategoryTable.php b/app/Filament/Resources/Master/Categories/Tables/CategoryTable.php deleted file mode 100644 index 7bc287b..0000000 --- a/app/Filament/Resources/Master/Categories/Tables/CategoryTable.php +++ /dev/null @@ -1,84 +0,0 @@ -columns([ - ...RowIndexColumn::make(), - - TextColumn::make('name') - ->label('Nama') - ->searchable() - ->sortable(), - - ToggleColumn::make('is_active') - ->label('Aktif?') - ->sortable() - ->getStateUsing(fn (Category $record): bool => $record->is_active === IsActive::ACTIVE) - ->updateStateUsing(function (Category $record, bool $state): void { - $record->is_active = $state ? IsActive::ACTIVE : IsActive::INACTIVE; - $record->save(); - - CheerfulNotification::statusUpdated()->send(); - }), - - ...TimestampColumns::make(), - ]) - ->filters([ - SelectFilter::make('is_active') - ->label('Status') - ->options(IsActive::class) - ->native(false), - - TrashedFilter::make() - ->native(false) - ->visible(fn () => auth()->user()?->hasRole(RoleEnum::DEVELOPER->value)), - ]) - ->recordActions([ - EditAction::make() - ->modalWidth(Width::Large), - - DeleteAction::make(), - - ForceDeleteAction::make(), - - RestoreAction::make(), - ]) - ->toolbarActions([ - BulkActionGroup::make([ - ...DefaultBulkActions::make('kategori'), - ]), - ]) - ->emptyStateIcon(Heroicon::OutlinedListBullet) - ->emptyStateHeading(fn () => CheerfulNotification::getByKey('category.empty_state_heading')) - ->emptyStateDescription(fn () => CheerfulNotification::getByKey('category.empty_state')) - ->defaultSort('created_at', 'desc') - ->deferFilters(false) - ->paginated([25, 50, 100, 'all']) - ->deferLoading(); - } -} diff --git a/app/Filament/Resources/Publication/News/Schemas/NewsForm.php b/app/Filament/Resources/Publication/News/Schemas/NewsForm.php index 5a96b2b..7aaf1ef 100644 --- a/app/Filament/Resources/Publication/News/Schemas/NewsForm.php +++ b/app/Filament/Resources/Publication/News/Schemas/NewsForm.php @@ -9,14 +9,12 @@ use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Radio; use Filament\Forms\Components\RichEditor; -use Filament\Forms\Components\Select; use Filament\Forms\Components\SpatieMediaLibraryFileUpload; use Filament\Forms\Components\TagsInput; use Filament\Forms\Components\TextInput; use Filament\Schemas\Components\Section; use Filament\Schemas\Components\Utilities\Set; use Filament\Schemas\Schema; -use Illuminate\Database\Eloquent\Builder; class NewsForm { @@ -52,8 +50,8 @@ public static function configure(Schema $schema): Schema ->columnSpanFull(), ])->columnSpan(2), - Section::make(CheerfulNotification::getByKey('news.content.category_title')) - ->description(CheerfulNotification::getByKey('news.content.category_desc')) + Section::make(CheerfulNotification::getByKey('news.content.publication_title')) + ->description(CheerfulNotification::getByKey('news.content.publication_desc')) ->icon(CheerfulNotification::getNotifStyle() === NotifStyle::CHEERFUL ? 'heroicon-o-tag' : null) ->schema([ TextInput::make('link') @@ -64,16 +62,6 @@ public static function configure(Schema $schema): Schema ->maxLength(255) ->url(), - Select::make('categories') - ->label('Kategori') - ->relationship('categories', 'name', function (Builder $query): Builder { - return $query->active(); - }) - ->native(false) - ->multiple() - ->preload() - ->required(), - TagsInput::make('tags') ->label('Tag Berita') ->reactive() diff --git a/app/Filament/Resources/Publication/News/Tables/NewsTable.php b/app/Filament/Resources/Publication/News/Tables/NewsTable.php index ead4bfa..dbee36c 100644 --- a/app/Filament/Resources/Publication/News/Tables/NewsTable.php +++ b/app/Filament/Resources/Publication/News/Tables/NewsTable.php @@ -42,14 +42,6 @@ public static function configure(Table $table): Table ->sortable() ->placeholder('Tidak ada'), - TextColumn::make('categories.name') - ->label('Kategori') - ->listWithLineBreaks() - ->limitList(3) - ->expandableLimitedList() - ->badge() - ->placeholder('Tidak ada kategori'), - TextColumn::make('tags.name') ->label('Tag') ->listWithLineBreaks() @@ -85,13 +77,6 @@ public static function configure(Table $table): Table ->options(NewsStatus::class) ->native(false), - SelectFilter::make('categories') - ->label('Kategori') - ->relationship('categories', 'name') - ->multiple() - ->preload() - ->native(false), - SelectFilter::make('tags') ->label('Tag') ->relationship('tags', 'name') diff --git a/app/Livewire/Home/News/Index.php b/app/Livewire/Home/News/Index.php index c210f19..955433a 100644 --- a/app/Livewire/Home/News/Index.php +++ b/app/Livewire/Home/News/Index.php @@ -2,7 +2,6 @@ namespace App\Livewire\Home\News; -use App\Models\Category; use App\Models\News; use Livewire\Attributes\Title; use Livewire\Attributes\Url; @@ -18,9 +17,6 @@ class Index extends Component #[Url(as: 'q')] public $search = ''; - #[Url(as: 'category')] - public $category = ''; - #[Url(as: 'tag')] public $tag = ''; @@ -29,11 +25,6 @@ public function updatedSearch() $this->resetPage(); } - public function updatedCategory() - { - $this->resetPage(); - } - public function updatedTag() { $this->resetPage(); @@ -42,16 +33,11 @@ public function updatedTag() public function render() { $news = News::published() - ->with(['categories', 'author']) + ->with('author') ->when($this->search, function ($query) { $query->where('title', 'like', '%'.$this->search.'%') ->orWhere('content', 'like', '%'.$this->search.'%'); }) - ->when($this->category, function ($query) { - $query->whereHas('categories', function ($query) { - $query->where('categories.id', $this->category); - }); - }) ->when($this->tag, function ($query) { $query->withAnyTags([$this->tag]); }) @@ -67,13 +53,6 @@ public function render() return $news; }); - $categories = Category::active() - ->withCount(['news' => function ($query) { - $query->published(); - }]) - ->orderBy('name') - ->get(); - $popularPosts = News::published() ->latest('views') ->limit(3) @@ -90,7 +69,6 @@ public function render() 'pageDescription' => 'Jelajahi berita terbaru seputar purwakarta.', 'news' => $news, 'popularPosts' => $popularPosts, - 'categories' => $categories, 'tags' => Tag::all(), ]); } diff --git a/app/Livewire/Home/News/Show.php b/app/Livewire/Home/News/Show.php index be8296d..8d1a1e6 100644 --- a/app/Livewire/Home/News/Show.php +++ b/app/Livewire/Home/News/Show.php @@ -24,7 +24,7 @@ public function mount(News $news) #[Title('Detail Berita')] public function render() { - $this->news->load(['categories', 'author', 'tags']); + $this->news->load(['author', 'tags']); // Format main news $this->news->thumbnail = $this->news->getFirstMediaUrl('news') ?: 'https://images.pexels.com/photos/12199409/pexels-photo-12199409.jpeg'; @@ -35,26 +35,14 @@ public function render() $relatedNews = News::published() ->where('id', '!=', $this->news->id) - ->whereHas('categories', function ($query) { - $query->whereIn('categories.id', $this->news->categories->pluck('id')); - }) ->latest('published_at') ->limit(4) ->get(); - if ($relatedNews->isEmpty()) { - $relatedNews = News::published() - ->where('id', '!=', $this->news->id) - ->latest('published_at') - ->limit(4) - ->get(); - } - // Format related news $relatedNews = $relatedNews->map(function ($news) { $news->thumbnail = $news->getFirstMediaUrl('news') ?: 'https://images.pexels.com/photos/12199409/pexels-photo-12199409.jpeg'; $news->formatted_date = $news->published_at?->translatedFormat('d F Y') ?: '-'; - $news->primary_category = $news->categories->first(); return $news; }); diff --git a/app/Models/Category.php b/app/Models/Category.php deleted file mode 100644 index 1c6944c..0000000 --- a/app/Models/Category.php +++ /dev/null @@ -1,43 +0,0 @@ - IsActive::class, - ]; - } - - #[Scope] - protected function active(Builder $query): void - { - $query->where('is_active', IsActive::ACTIVE); - } - - #[Scope] - protected function inactive(Builder $query): void - { - $query->where('is_active', IsActive::INACTIVE); - } - - public function news(): BelongsToMany - { - return $this->belongsToMany(News::class); - } -} diff --git a/app/Models/CategoryNews.php b/app/Models/CategoryNews.php deleted file mode 100644 index ccd307d..0000000 --- a/app/Models/CategoryNews.php +++ /dev/null @@ -1,25 +0,0 @@ -belongsTo(Category::class); - } - - public function news(): BelongsTo - { - return $this->belongsTo(News::class); - } -} diff --git a/app/Models/News.php b/app/Models/News.php index a888a0b..53d7b20 100644 --- a/app/Models/News.php +++ b/app/Models/News.php @@ -8,7 +8,6 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; -use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\SoftDeletes; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; @@ -61,9 +60,4 @@ public function author(): BelongsTo { return $this->belongsTo(User::class, 'author_id'); } - - public function categories(): BelongsToMany - { - return $this->belongsToMany(Category::class); - } } diff --git a/app/Policies/CategoryPolicy.php b/app/Policies/CategoryPolicy.php deleted file mode 100644 index 5cb2ec5..0000000 --- a/app/Policies/CategoryPolicy.php +++ /dev/null @@ -1,69 +0,0 @@ -can('ViewAny:Category'); - } - - public function view(AuthUser $authUser, Category $category): bool - { - return $authUser->can('View:Category'); - } - - public function create(AuthUser $authUser): bool - { - return $authUser->can('Create:Category'); - } - - public function update(AuthUser $authUser, Category $category): bool - { - return $authUser->can('Update:Category'); - } - - public function delete(AuthUser $authUser, Category $category): bool - { - return $authUser->can('Delete:Category'); - } - - public function restore(AuthUser $authUser, Category $category): bool - { - return $authUser->can('Restore:Category'); - } - - public function forceDelete(AuthUser $authUser, Category $category): bool - { - return $authUser->can('ForceDelete:Category'); - } - - public function forceDeleteAny(AuthUser $authUser): bool - { - return $authUser->can('ForceDeleteAny:Category'); - } - - public function restoreAny(AuthUser $authUser): bool - { - return $authUser->can('RestoreAny:Category'); - } - - public function replicate(AuthUser $authUser, Category $category): bool - { - return $authUser->can('Replicate:Category'); - } - - public function reorder(AuthUser $authUser): bool - { - return $authUser->can('Reorder:Category'); - } -} diff --git a/database/factories/CategoryFactory.php b/database/factories/CategoryFactory.php deleted file mode 100644 index 2eea52f..0000000 --- a/database/factories/CategoryFactory.php +++ /dev/null @@ -1,26 +0,0 @@ - - */ -class CategoryFactory extends Factory -{ - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'name' => fake()->unique()->word(), - 'is_active' => IsActive::ACTIVE, - ]; - } -} diff --git a/database/factories/CategoryNewsFactory.php b/database/factories/CategoryNewsFactory.php deleted file mode 100644 index d98689a..0000000 --- a/database/factories/CategoryNewsFactory.php +++ /dev/null @@ -1,27 +0,0 @@ - - */ -class CategoryNewsFactory extends Factory -{ - /** - * Define the model's default state. - * - * @return array - */ - public function definition(): array - { - return [ - 'category_id' => Category::factory(), - 'news_id' => News::factory(), - ]; - } -} diff --git a/database/migrations/2025_12_11_155214_create_categories_table.php b/database/migrations/2025_12_11_155214_create_categories_table.php deleted file mode 100644 index 8b37025..0000000 --- a/database/migrations/2025_12_11_155214_create_categories_table.php +++ /dev/null @@ -1,32 +0,0 @@ -id(); - $table->string('name', 50); - $table->enum('is_active', IsActive::values())->default(IsActive::ACTIVE->value)->comment(IsActive::comment()); - $table->timestamp('created_at')->useCurrent(); - $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); - $table->softDeletes(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('categories'); - } -}; diff --git a/database/migrations/2025_12_12_083015_create_category_news_table.php b/database/migrations/2025_12_12_083015_create_category_news_table.php deleted file mode 100644 index 31ec40e..0000000 --- a/database/migrations/2025_12_12_083015_create_category_news_table.php +++ /dev/null @@ -1,33 +0,0 @@ -id(); - $table->foreignIdFor(Category::class); - $table->foreignIdFor(News::class); - $table->timestamp('created_at')->useCurrent(); - $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); - $table->softDeletes(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::dropIfExists('category_news'); - } -}; diff --git a/database/seeders/ShieldSeeder.php b/database/seeders/ShieldSeeder.php index a3b0368..0a74afa 100644 --- a/database/seeders/ShieldSeeder.php +++ b/database/seeders/ShieldSeeder.php @@ -36,17 +36,6 @@ public function run(): void "View:BudgetRealizationChart", - "ViewAny:Category", - "View:Category", - "Create:Category", - "Update:Category", - "Delete:Category", - "Restore:Category", - "ForceDelete:Category", - "ForceDeleteAny:Category", - "RestoreAny:Category", - "Replicate:Category", - "Reorder:Category", "View:CompanyStatusChart", @@ -307,17 +296,6 @@ public function run(): void "View:BudgetRealizationChart", - "ViewAny:Category", - "View:Category", - "Create:Category", - "Update:Category", - "Delete:Category", - "Restore:Category", - "ForceDelete:Category", - "ForceDeleteAny:Category", - "RestoreAny:Category", - "Replicate:Category", - "Reorder:Category", "View:CompanyStatusChart", @@ -559,7 +537,7 @@ public function run(): void "RestoreAny:Classification", "Replicate:Classification", "Reorder:Classification", - + "View:Dashboard", "ViewAny:IssueManagement", @@ -573,7 +551,7 @@ public function run(): void "RestoreAny:IssueManagement", "Replicate:IssueManagement", "Reorder:IssueManagement", - + "ViewAny:Location", "View:Location", "Create:Location", @@ -653,19 +631,6 @@ public function run(): void "permissions": [ "View:Analytic", - "ViewAny:Category", - - "View:Category", - "Create:Category", - "Update:Category", - "Delete:Category", - "Restore:Category", - "ForceDelete:Category", - "ForceDeleteAny:Category", - "RestoreAny:Category", - "Replicate:Category", - "Reorder:Category", - "ViewAny:Classification", "View:Classification", "Create:Classification", diff --git a/lang/id/notif.php b/lang/id/notif.php index 0dae3c2..a65519b 100644 --- a/lang/id/notif.php +++ b/lang/id/notif.php @@ -787,14 +787,6 @@ 'cheerful' => 'Masukkan informasi lengkap mengenai pemberitaan media biar makin lengkap! 📰✨', 'formal' => 'Masukkan informasi lengkap mengenai pemberitaan media.', ], - 'category_title' => [ - 'cheerful' => 'Kategori & Metadata 🏷️', - 'formal' => 'Kategori & Metadata', - ], - 'category_desc' => [ - 'cheerful' => 'Tentukan kategori berita dan informasi tambahan lainnya biar makin rapi! 🏷️✨', - 'formal' => 'Tentukan kategori berita dan informasi tambahan lainnya.', - ], 'empty_state' => [ 'cheerful' => 'Belum ada data Monitoring Media nih! Mulai buat data pertama sekarang biar makin rame! 🚀✨', 'formal' => 'Belum ada data Monitoring Media yang tersedia saat ini.', @@ -812,13 +804,13 @@ 'cheerful' => 'Yuk, tuliskan judul, ringkasan, dan isi lengkap berita Anda biar makin menarik! 🚀😊', 'formal' => 'Silakan tuliskan judul, ringkasan, dan isi lengkap berita Anda.', ], - 'category_title' => [ - 'cheerful' => 'Kategori & Publikasi 🏷️', - 'formal' => 'Kategori & Publikasi', + 'publication_title' => [ + 'cheerful' => 'Publikasi & Metadata 🏷️', + 'formal' => 'Publikasi & Metadata', ], - 'category_desc' => [ - 'cheerful' => 'Tentukan kategori, tautan media, dan status publikasi biar berita kita gampang dicari! 🏷️✨', - 'formal' => 'Tentukan kategori, tautan media, dan status publikasi.', + 'publication_desc' => [ + 'cheerful' => 'Tentukan tautan media, tag, dan status publikasi agar berita lebih mudah ditemukan! 🏷️✨', + 'formal' => 'Tentukan tautan media, tag, dan status publikasi.', ], 'empty_state' => [ 'cheerful' => 'Belum ada data Berita nih! Mulai buat data pertama sekarang biar makin rame! 🚀✨', @@ -916,24 +908,6 @@ 'formal' => 'Tidak Ada Data Tema', ], ], - 'category' => [ - 'create_title' => [ - 'cheerful' => 'Tambah Kategori Baru 🏷️✨', - 'formal' => 'Tambah Kategori', - ], - 'create_desc' => [ - 'cheerful' => 'Tambahkan kategori baru biar data makin teratur dan rapi! 📁😊', - 'formal' => 'Silakan masukkan detail kategori data di bawah ini.', - ], - 'empty_state' => [ - 'cheerful' => 'Belum ada data Kategori nih! Mulai buat data pertama sekarang biar makin rame! 🚀✨', - 'formal' => 'Belum ada data Kategori yang tersedia saat ini.', - ], - 'empty_state_heading' => [ - 'cheerful' => 'Belum Ada Data Kategori! 🏷️✨', - 'formal' => 'Tidak Ada Data Kategori', - ], - ], 'classification' => [ 'create_title' => [ 'cheerful' => 'Tambah Klasifikasi Baru 📂✨', diff --git a/resources/views/livewire/home/news/index.blade.php b/resources/views/livewire/home/news/index.blade.php index 181e26d..f6b847c 100644 --- a/resources/views/livewire/home/news/index.blade.php +++ b/resources/views/livewire/home/news/index.blade.php @@ -41,13 +41,6 @@ class="bi bi-megaphone text-white icon-small me-10px">{{ $pageTitle }} -
- @foreach ($item->categories as $itemCategory) - {{ $itemCategory->name }} - @endforeach -
@endif
@@ -121,28 +114,6 @@ class="d-inline-block fs-15">{{ $post->formatted_date }}
-
-
- Kategori
- -
@if ($tags->count() > 0)
diff --git a/resources/views/livewire/home/news/show.blade.php b/resources/views/livewire/home/news/show.blade.php index 76a66cc..91b3764 100644 --- a/resources/views/livewire/home/news/show.blade.php +++ b/resources/views/livewire/home/news/show.blade.php @@ -33,10 +33,6 @@ class="bi bi-megaphone text-white icon-small me-10px">{{ $pageTitle }}
- @foreach ($news->categories as $category) - {{ $category->name }} - @endforeach

{{ $news->title }}

{{ $news->author_name }} @@ -122,10 +118,6 @@ class="w-100" />
- @if ($related->primary_category) - {{ $related->primary_category->name }} - @endif {{ $related->formatted_date }} diff --git a/tests/Feature/Filament/Resources/Master/Categories/CategoryResourceTest.php b/tests/Feature/Filament/Resources/Master/Categories/CategoryResourceTest.php deleted file mode 100644 index 175fc9b..0000000 --- a/tests/Feature/Filament/Resources/Master/Categories/CategoryResourceTest.php +++ /dev/null @@ -1,167 +0,0 @@ -user = User::factory()->create(['is_active' => IsActive::ACTIVE]); - - // Setup Permissions - $permissions = [ - 'ViewAny:Category', - 'Create:Category', - 'Update:Category', - 'Delete:Category', - 'Restore:Category', - 'ForceDelete:Category', - ]; - - foreach ($permissions as $permission) { - Permission::firstOrCreate(['name' => $permission, 'guard_name' => 'web']); - } - - $this->user->givePermissionTo($permissions); -}); - -test('can render category list page', function () { - $this->actingAs($this->user); - - Livewire::test(ManageCategories::class) - ->assertSuccessful(); -}); - -test('can list categories', function () { - $categories = Category::factory()->count(5)->create(); - - $this->actingAs($this->user); - - Livewire::test(ManageCategories::class) - ->call('loadTable') - ->assertCanSeeTableRecords($categories); -}); - -test('can create category', function () { - $this->actingAs($this->user); - - Livewire::test(ManageCategories::class) - ->mountAction('create') - ->setActionData([ - 'name' => 'Kategori Baru', - ]) - ->callMountedAction() - ->assertHasNoActionErrors(); - - $this->assertDatabaseHas('categories', [ - 'name' => 'Kategori Baru', - 'is_active' => IsActive::ACTIVE->value, - ]); -}); - -test('cannot create category with empty name', function () { - $this->actingAs($this->user); - - Livewire::test(ManageCategories::class) - ->mountAction('create') - ->setActionData(['name' => '']) - ->callMountedAction() - ->assertHasActionErrors(['name' => 'required']); -}); - -test('cannot create category with name exceeding 50 characters', function () { - $this->actingAs($this->user); - - Livewire::test(ManageCategories::class) - ->mountAction('create') - ->setActionData(['name' => str_repeat('a', 51)]) - ->callMountedAction() - ->assertHasActionErrors(['name' => 'max']); -}); - -test('can edit category', function () { - $category = Category::factory()->create(); - - $this->actingAs($this->user); - - Livewire::test(ManageCategories::class) - ->mountTableAction('edit', $category) - ->setActionData([ - 'name' => 'Kategori Updated', - ]) - ->callMountedTableAction() - ->assertHasNoActionErrors(); - - expect($category->refresh()->name)->toBe('Kategori Updated'); -}); - -test('can toggle is_active status', function () { - $category = Category::factory()->create(['is_active' => IsActive::INACTIVE]); - - $this->actingAs($this->user); - - Livewire::test(ManageCategories::class) - ->call('updateTableColumnState', 'is_active', $category->getKey(), true); - - expect($category->refresh()->is_active)->toBe(IsActive::ACTIVE); -}); - -test('unauthorized user cannot render category page', function () { - $unauthorizedUser = User::factory()->create(['is_active' => IsActive::ACTIVE]); - - $this->actingAs($unauthorizedUser); - - Livewire::test(ManageCategories::class) - ->assertForbidden(); -}); - -test('can delete category', function () { - $category = Category::factory()->create(); - - $this->actingAs($this->user); - - Livewire::test(ManageCategories::class) - ->callTableAction('delete', $category); - - $this->assertSoftDeleted($category); -}); - -test('can restore deleted category', function () { - $roleDev = Role::firstOrCreate(['name' => RoleEnum::DEVELOPER->value, 'guard_name' => 'web']); - $this->user->assignRole($roleDev); - - $category = Category::factory()->create(['deleted_at' => now()]); - - $this->actingAs($this->user); - - Livewire::test(ManageCategories::class) - ->filterTable('trashed', 'with') - ->callTableAction('restore', $category); - - $this->assertDatabaseHas('categories', [ - 'id' => $category->id, - 'deleted_at' => null, - ]); -}); - -test('can force delete category', function () { - $roleDev = Role::firstOrCreate(['name' => RoleEnum::DEVELOPER->value, 'guard_name' => 'web']); - $this->user->assignRole($roleDev); - - $category = Category::factory()->create(['deleted_at' => now()]); - - $this->actingAs($this->user); - - Livewire::test(ManageCategories::class) - ->filterTable('trashed', 'only') - ->callTableAction('forceDelete', $category); - - $this->assertDatabaseMissing('categories', ['id' => $category->id]); -}); diff --git a/tests/Feature/Models/CategoryNewsTest.php b/tests/Feature/Models/CategoryNewsTest.php deleted file mode 100644 index 6fcb342..0000000 --- a/tests/Feature/Models/CategoryNewsTest.php +++ /dev/null @@ -1,21 +0,0 @@ -create(); - $category = Category::factory()->create(); - - $categoryNews = CategoryNews::factory()->create([ - 'news_id' => $news->id, - 'category_id' => $category->id, - ]); - - expect($categoryNews->news->id)->toBe($news->id); - expect($categoryNews->category->id)->toBe($category->id); -}); diff --git a/tests/Feature/Models/CategoryTest.php b/tests/Feature/Models/CategoryTest.php deleted file mode 100644 index 3d4e5f6..0000000 --- a/tests/Feature/Models/CategoryTest.php +++ /dev/null @@ -1,13 +0,0 @@ -create(['name' => 'Politik']); - expect($category->name)->toBe('Politik'); - expect($category->is_active)->toBe(IsActive::ACTIVE); -});