diff --git a/tests/Feature/BasicFactoryTest.php b/tests/Feature/BasicFactoryTest.php deleted file mode 100644 index e38777e..0000000 --- a/tests/Feature/BasicFactoryTest.php +++ /dev/null @@ -1,97 +0,0 @@ -create(); - - expect($theme)->toBeInstanceOf(Theme::class) - ->and($theme->exists)->toBeTrue() - ->and($theme->name)->toBeString(); - }); - - it('can create classification using factory', function () { - $classification = Classification::factory()->create(); - - expect($classification)->toBeInstanceOf(Classification::class) - ->and($classification->exists)->toBeTrue() - ->and($classification->name)->toBeString(); - }); - - it('can create location using factory', function () { - $location = Location::factory()->create(); - - expect($location)->toBeInstanceOf(Location::class) - ->and($location->exists)->toBeTrue() - ->and($location->name)->toBeString(); - }); - - it('can create department using factory', function () { - $department = Department::factory()->create(); - - expect($department)->toBeInstanceOf(Department::class) - ->and($department->exists)->toBeTrue() - ->and($department->name)->toBeString() - ->and($department->alias)->toBeString(); - }); - - it('can create company using factory', function () { - $company = Company::factory()->create(); - expect($company)->toBeInstanceOf(Company::class) - ->and($company->exists)->toBeTrue() - ->and($company->name)->toBeString(); - }); - - it('can create partner media using factory', function () { - $partnerMedia = PartnerMedia::factory()->create(); - - expect($partnerMedia)->toBeInstanceOf(PartnerMedia::class) - ->and($partnerMedia->exists)->toBeTrue() - ->and($partnerMedia->name)->toBeString(); - }); - - it('can create journalist using factory', function () { - $journalist = Journalist::factory()->create(); - - expect($journalist)->toBeInstanceOf(Journalist::class) - ->and($journalist->exists)->toBeTrue() - ->and($journalist->name)->toBeString(); - }); - - it('can create media monitoring using factory', function () { - $mediaMonitoring = MediaMonitoring::factory()->create(); - - expect($mediaMonitoring)->toBeInstanceOf(MediaMonitoring::class) - ->and($mediaMonitoring->exists)->toBeTrue() - ->and($mediaMonitoring->title)->toBeString(); - }); - - it('can create content recap using factory', function () { - $contentRecap = ContentRecap::factory()->create(); - - expect($contentRecap)->toBeInstanceOf(ContentRecap::class) - ->and($contentRecap->exists)->toBeTrue() - ->and($contentRecap->title)->toBeString(); - }); - - it('can create issue management using factory', function () { - $issueManagement = IssueManagement::factory()->create(); - - expect($issueManagement)->toBeInstanceOf(IssueManagement::class) - ->and($issueManagement->exists)->toBeTrue() - ->and($issueManagement->description)->toBeString(); - }); -}); diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php deleted file mode 100644 index 8364a84..0000000 --- a/tests/Feature/ExampleTest.php +++ /dev/null @@ -1,19 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Feature/IntegrationTest.php b/tests/Feature/IntegrationTest.php deleted file mode 100644 index be17aad..0000000 --- a/tests/Feature/IntegrationTest.php +++ /dev/null @@ -1,98 +0,0 @@ -create(['name' => 'Politik']); - - // Create media monitoring - $mediaMonitoring = MediaMonitoring::factory()->create([ - 'title' => 'Berita Politik Terkini', - ]); - - // Attach theme to media monitoring - $mediaMonitoring->themes()->attach($theme->id); - - // Verify relationships - expect($mediaMonitoring->themes)->toHaveCount(1) - ->and($mediaMonitoring->themes->first()->name)->toBe('Politik'); - }); - - it('can create complete journalist workflow', function () { - // Create company - $company = Company::factory()->create(['name' => 'Media Indonesia']); - - // Create partner media - $partnerMedia = PartnerMedia::factory()->create([ - 'company_id' => $company->id, - 'name' => 'Kompas.com', - 'type' => MediaType::ONLINE, - ]); - - // Create journalist - $journalist = Journalist::factory()->create([ - 'partner_media_id' => $partnerMedia->id, - 'name' => 'John Doe', - ]); - - // Verify relationships - expect($journalist->partnerMedia->company->name)->toBe('Media Indonesia') - ->and($journalist->partnerMedia->type)->toBe(MediaType::ONLINE); - }); - - it('can create issue management with sentiment', function () { - // Create classification - $classification = Classification::factory()->create(['name' => 'Infrastruktur']); - - // Create media monitoring - $mediaMonitoring = MediaMonitoring::factory()->create(); - - // Create issue management - $issue = IssueManagement::factory()->create([ - 'classification_id' => $classification->id, - 'media_monitoring_id' => $mediaMonitoring->id, - 'issue' => IssueSentiment::POSITIVE, - 'response' => IssueSentiment::POSITIVE, - ]); - - // Verify data - expect($issue->classification->name)->toBe('Infrastruktur') - ->and($issue->issue)->toBe(IssueSentiment::POSITIVE) - ->and($issue->response)->toBe(IssueSentiment::POSITIVE); - }); - - it('can filter active records', function () { - // Create active and inactive themes - Theme::factory()->create(['is_active' => IsActive::ACTIVE]); - Theme::factory()->create(['is_active' => IsActive::INACTIVE]); - - $activeThemes = Theme::active()->get(); - - expect($activeThemes)->toHaveCount(1) - ->and($activeThemes->first()->is_active)->toBe(IsActive::ACTIVE); - }); - - it('verifies enum casting works correctly', function () { - $partnerMedia = PartnerMedia::factory()->create([ - 'type' => MediaType::TELEVISION, - ]); - - expect($partnerMedia->type)->toBeInstanceOf(MediaType::class) - ->and($partnerMedia->type)->toBe(MediaType::TELEVISION) - ->and($partnerMedia->type->getLabel())->toBe('Televisi'); - }); -}); diff --git a/tests/Feature/ModelFactoryTest.php b/tests/Feature/ModelFactoryTest.php deleted file mode 100644 index 87dafb1..0000000 --- a/tests/Feature/ModelFactoryTest.php +++ /dev/null @@ -1,73 +0,0 @@ -create(); - expect($user->exists)->toBeTrue(); - }); - - it('can create theme', function () { - $theme = Theme::factory()->create(); - expect($theme->exists)->toBeTrue(); - }); - - it('can create classification', function () { - $classification = Classification::factory()->create(); - expect($classification->exists)->toBeTrue(); - }); - - it('can create location', function () { - $location = Location::factory()->create(); - expect($location->exists)->toBeTrue(); - }); - - it('can create department', function () { - $department = Department::factory()->create(); - expect($department->exists)->toBeTrue(); - }); - - it('can create company', function () { - $company = Company::factory()->create(); - expect($company->exists)->toBeTrue(); - }); - - it('can create partner media', function () { - $partnerMedia = PartnerMedia::factory()->create(); - expect($partnerMedia->exists)->toBeTrue(); - }); - - it('can create journalist', function () { - $journalist = Journalist::factory()->create(); - expect($journalist->exists)->toBeTrue(); - }); - - it('can create media monitoring', function () { - $mediaMonitoring = MediaMonitoring::factory()->create(); - expect($mediaMonitoring->exists)->toBeTrue(); - }); - - it('can create content recap', function () { - $contentRecap = ContentRecap::factory()->create(); - expect($contentRecap->exists)->toBeTrue(); - }); - - it('can create issue management', function () { - $issueManagement = IssueManagement::factory()->create(); - expect($issueManagement->exists)->toBeTrue(); - }); -}); diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index bbd1f04..0000000 --- a/tests/README.md +++ /dev/null @@ -1,191 +0,0 @@ -# SIMEDKOM Testing Suite - -Comprehensive Pest testing suite for the SIMEDKOM media monitoring and management system. - -## Test Structure - -### Unit Tests (`tests/Unit/`) - -#### Enums (`tests/Unit/Enums/`) -- `MediaTypeTest.php` - Tests for media type enumeration -- `ContentTypeTest.php` - Tests for content type enumeration -- `IssueSentimentTest.php` - Tests for issue sentiment enumeration -- `IsActiveTest.php` - Tests for active status enumeration -- `ChannelTest.php` - Tests for channel enumeration -- `MediaClassificationTest.php` - Tests for media classification enumeration -- `SocialMediaTest.php` - Tests for social media platform enumeration - -#### Models (`tests/Unit/Models/`) -- `UserTest.php` - User model tests -- `ThemeTest.php` - Theme model tests and relationships -- `ClassificationTest.php` - Classification model tests and relationships -- `SubClassificationTest.php` - Sub-classification model tests -- `LocationTest.php` - Location model tests and relationships -- `SubLocationTest.php` - Sub-location model tests -- `DepartmentTest.php` - Department model tests -- `MediaMonitoringTest.php` - Media monitoring model tests and relationships -- `MediaMonitoringThemeTest.php` - Pivot model tests -- `IssueManagementTest.php` - Issue management model tests -- `ContentRecapTest.php` - Content recap model tests -- `JournalistTest.php` - Journalist model tests and relationships -- `CompanyTest.php` - Company model tests and relationships -- `PartnerMediaTest.php` - Partner media model tests - -#### Policies (`tests/Unit/Policies/`) -- `ThemePolicyTest.php` - Theme authorization policy tests -- `ClassificationPolicyTest.php` - Classification authorization policy tests - -#### Traits (`tests/Unit/Traits/`) -- `WithValueTest.php` - Enum value trait tests -- `WithCommentTest.php` - Enum comment trait tests - -#### Components (`tests/Unit/`) -- `MediaLibrary/CustomPathGeneratorTest.php` - File path generation tests -- `Filament/Actions/DefaultBulkActionsTest.php` - Bulk actions tests -- `Filament/Columns/TimestampColumnsTest.php` - Timestamp columns tests - -### Feature Tests (`tests/Feature/`) - -#### Filament Resources (`tests/Feature/Filament/`) - -##### Master Domain (`tests/Feature/Filament/Master/`) -- `ThemeResourceTest.php` - Theme resource CRUD operations -- `ClassificationResourceTest.php` - Classification resource CRUD operations -- `SubClassificationResourceTest.php` - Sub-classification resource CRUD operations -- `LocationResourceTest.php` - Location resource CRUD operations -- `SubLocationResourceTest.php` - Sub-location resource CRUD operations -- `DepartmentResourceTest.php` - Department resource CRUD operations -- `UserResourceTest.php` - User resource CRUD operations - -##### Manage Domain (`tests/Feature/Filament/Manage/`) -- `JournalistResourceTest.php` - Journalist resource CRUD operations -- `PartnerResourceTest.php` - Partner resource CRUD operations - -##### Monitoring Domain (`tests/Feature/Filament/Monitoring/`) -- `MediaMonitoringResourceTest.php` - Media monitoring resource CRUD operations -- `IssueManagementResourceTest.php` - Issue management resource CRUD operations -- `ContentRecapResourceTest.php` - Content recap resource CRUD operations - -#### Integration Tests (`tests/Feature/Integration/`) -- `MediaMonitoringWorkflowTest.php` - Complete media monitoring workflow -- `JournalistManagementWorkflowTest.php` - Complete journalist management workflow -- `IssueManagementWorkflowTest.php` - Complete issue management workflow - -## Test Coverage - -### Domain Coverage -- **Master Data**: Users, Themes, Classifications, Locations, Departments -- **Entity Management**: Journalists, Companies, Partners -- **Core Business**: Media Monitoring, Issue Management, Content Recaps - -### Component Coverage -- **Models**: All Eloquent models with relationships and scopes -- **Enums**: All business domain enumerations with traits -- **Policies**: Authorization policies for resources -- **Filament Resources**: CRUD operations, validation, filtering -- **Custom Components**: Path generators, bulk actions, columns -- **Workflows**: End-to-end business process testing - -## Running Tests - -### All Tests -```bash -composer run test -# or -php artisan test -``` - -### Specific Test Suites -```bash -# Unit tests only -php artisan test tests/Unit - -# Feature tests only -php artisan test tests/Feature - -# Specific domain -php artisan test tests/Feature/Filament/Master -php artisan test tests/Feature/Filament/Manage -php artisan test tests/Feature/Filament/Monitoring - -# Integration tests -php artisan test tests/Feature/Integration -``` - -### Specific Test Files -```bash -# Single test file -php artisan test tests/Unit/Models/MediaMonitoringTest.php - -# With filter -php artisan test --filter="can create media monitoring" -``` - -## Test Patterns - -### Model Tests -- Factory usage for test data creation -- Relationship testing -- Scope testing (active/inactive) -- Fillable attributes validation -- Enum casting verification - -### Resource Tests -- Livewire component rendering -- CRUD operations (Create, Read, Update, Delete) -- Form validation -- Table filtering and sorting -- Bulk actions -- Authorization checks - -### Integration Tests -- Complete workflow testing -- Multi-model interactions -- Business logic validation -- Data integrity checks - -## Test Data - -### Factories -All models have corresponding factories in `database/factories/` for consistent test data generation. - -### Database -Tests use SQLite in-memory database with `RefreshDatabase` trait for isolation. - -### Authentication -Tests use `actingAs()` helper with factory-created users for authentication. - -## Best Practices - -### Test Organization -- Group related tests using `describe()` blocks -- Use descriptive test names with `it()` statements -- Follow AAA pattern: Arrange, Act, Assert - -### Assertions -- Use Pest's fluent expectations: `expect($value)->toBe()` -- Chain assertions for related checks -- Test both positive and negative cases - -### Data Management -- Use factories for consistent test data -- Leverage `RefreshDatabase` for test isolation -- Create minimal required data for each test - -### Performance -- Keep tests focused and fast -- Use database transactions where possible -- Mock external dependencies - -## Maintenance - -### Adding New Tests -1. Follow existing naming conventions -2. Place tests in appropriate domain folders -3. Include both unit and feature tests for new components -4. Update this documentation - -### Test Updates -- Update tests when business logic changes -- Maintain test coverage for new features -- Refactor tests alongside code refactoring diff --git a/tests/README_WORKING_TESTS.md b/tests/README_WORKING_TESTS.md deleted file mode 100644 index 790c7b5..0000000 --- a/tests/README_WORKING_TESTS.md +++ /dev/null @@ -1,108 +0,0 @@ -# Working Test Suite for SIMEDKOM - -This is a clean, working test suite that has been verified to run without errors. - -## ✅ Working Tests - -### Unit Tests - Models (`tests/Unit/Models/`) -- `UserTest.php` - User model basic tests -- `ThemeTest.php` - Theme model with enum casting and relationships -- `ClassificationTest.php` - Classification model with relationships -- `SubClassificationTest.php` - Sub-classification model -- `LocationTest.php` - Location model with relationships -- `SubLocationTest.php` - Sub-location model -- `DepartmentTest.php` - Department model -- `CompanyTest.php` - Company model with relationships -- `PartnerMediaTest.php` - Partner media with enum casting -- `JournalistTest.php` - Journalist model -- `MediaMonitoringTest.php` - Media monitoring with relationships -- `IssueManagementTest.php` - Issue management with enum casting -- `ContentRecapTest.php` - Content recap model -- `MediaMonitoringThemeTest.php` - Pivot table model - -### Unit Tests - Enums (`tests/Unit/Enums/`) -- `MediaTypeTest.php` - Media type enum with labels and options -- `IsActiveTest.php` - Active status enum with colors -- `IssueSentimentTest.php` - Issue sentiment enum with colors -- `ContentTypeTest.php` - Content type enum -- `MediaClassificationTest.php` - Media classification enum -- `ChannelTest.php` - Channel enum -- `SocialMediaTest.php` - Social media enum - -### Feature Tests (`tests/Feature/`) -- `BasicFactoryTest.php` - Factory creation tests -- `ModelFactoryTest.php` - Simple model factory verification - -## 🏭 Working Factories (`database/factories/`) - -All factories are properly configured based on actual migration structures: - -### Master Domain -- `ThemeFactory.php` - Creates themes with proper enum values -- `ClassificationFactory.php` - Creates classifications with descriptions -- `SubClassificationFactory.php` - Creates sub-classifications with relationships -- `LocationFactory.php` - Creates locations (cities/regions) -- `SubLocationFactory.php` - Creates sub-locations with relationships -- `DepartmentFactory.php` - Creates departments with aliases - -### Manage Domain -- `CompanyFactory.php` - Creates companies with all required documents -- `PartnerMediaFactory.php` - Creates media partners with proper types -- `JournalistFactory.php` - Creates journalists with credentials - -### Monitoring Domain -- `MediaMonitoringFactory.php` - Creates media monitoring entries -- `ContentRecapFactory.php` - Creates content recaps with social media data -- `IssueManagementFactory.php` - Creates issues with sentiment analysis -- `MediaMonitoringThemeFactory.php` - Creates pivot relationships - -## 🚀 Running Tests - -```bash -# Run all working tests -php artisan test - -# Run specific test suites -php artisan test tests/Unit/Models -php artisan test tests/Unit/Enums -php artisan test tests/Feature - -# Run specific test files -php artisan test tests/Feature/ModelFactoryTest.php -php artisan test tests/Unit/Models/ThemeTest.php -``` - -## ✨ Key Features - -### Proper Enum Integration -- All enums use correct integer/string values from actual migrations -- Proper enum casting in models -- Label and color methods working correctly - -### Realistic Test Data -- Indonesian government department names -- Indonesian media company names (Kompas, Detik, Tribun, etc.) -- Proper document number formats -- Social media platforms and channels - -### Model Relationships -- All relationships properly tested -- Foreign key constraints respected -- Pivot table relationships working - -### Factory States -- `active()` / `inactive()` states for models with is_active -- `validated()` / `rejected()` / `pending()` for Company -- `online()` / `print()` / `television()` / `radio()` for PartnerMedia -- `positive()` / `negative()` / `neutral()` / `crisis()` for IssueManagement - -## 📋 Test Coverage - -- ✅ All core models tested -- ✅ All enums tested -- ✅ All factories working -- ✅ Model relationships verified -- ✅ Enum casting verified -- ✅ Database constraints respected - -This test suite provides a solid foundation for your SIMEDKOM project and can be extended as needed. diff --git a/tests/Unit/Enums/ChannelTest.php b/tests/Unit/Enums/ChannelTest.php deleted file mode 100644 index 7fe4a0c..0000000 --- a/tests/Unit/Enums/ChannelTest.php +++ /dev/null @@ -1,17 +0,0 @@ -not()->toBeEmpty(); - }); - - it('can get first case value', function () { - $firstCase = Channel::cases()[0]; - - expect($firstCase->value)->toBeString(); - }); -}); diff --git a/tests/Unit/Enums/ContentTypeTest.php b/tests/Unit/Enums/ContentTypeTest.php deleted file mode 100644 index 7f7ad80..0000000 --- a/tests/Unit/Enums/ContentTypeTest.php +++ /dev/null @@ -1,27 +0,0 @@ -not()->toBeEmpty() - ->and(collect($cases)->pluck('value')->toArray())->toBeArray(); - }); - - it('can get label from case', function () { - expect(ContentType::FOTO->getLabel())->toBe('Foto') - ->and(ContentType::TEXT->getLabel())->toBe('Teks') - ->and(ContentType::GRAPHIC->getLabel())->toBe('Grafis') - ->and(ContentType::VIDEO->getLabel())->toBe('Video'); - }); - - it('can get options array', function () { - $options = ContentType::options(); - - expect($options)->toBeArray() - ->and($options)->toHaveKey('Foto', 'Foto') - ->and($options)->toHaveKey('Teks', 'Teks'); - }); -}); diff --git a/tests/Unit/Enums/IsActiveTest.php b/tests/Unit/Enums/IsActiveTest.php deleted file mode 100644 index a61beb1..0000000 --- a/tests/Unit/Enums/IsActiveTest.php +++ /dev/null @@ -1,36 +0,0 @@ -toHaveCount(2) - ->and(collect($cases)->pluck('value')->toArray()) - ->toEqual([1, 2]); - }); - - it('can get value from case', function () { - expect(IsActive::ACTIVE->value)->toBe(1) - ->and(IsActive::INACTIVE->value)->toBe(2); - }); - - it('can get label from case', function () { - expect(IsActive::ACTIVE->getLabel())->toBe('Aktif') - ->and(IsActive::INACTIVE->getLabel())->toBe('Tidak Aktif'); - }); - - it('can get color from case', function () { - expect(IsActive::ACTIVE->getColor())->toBe('success') - ->and(IsActive::INACTIVE->getColor())->toBe('danger'); - }); - - it('can get options array', function () { - $options = IsActive::options(); - - expect($options)->toBeArray() - ->and($options)->toHaveKey(1, 'Aktif') - ->and($options)->toHaveKey(2, 'Tidak Aktif'); - }); -}); diff --git a/tests/Unit/Enums/IssueSentimentTest.php b/tests/Unit/Enums/IssueSentimentTest.php deleted file mode 100644 index cb420f0..0000000 --- a/tests/Unit/Enums/IssueSentimentTest.php +++ /dev/null @@ -1,44 +0,0 @@ -toHaveCount(4) - ->and(collect($cases)->pluck('value')->toArray()) - ->toEqual(['positive', 'negative', 'neutral', 'krisis']); - }); - - it('can get value from case', function () { - expect(IssueSentiment::POSITIVE->value)->toBe('positive') - ->and(IssueSentiment::NEGATIVE->value)->toBe('negative') - ->and(IssueSentiment::NEUTRAL->value)->toBe('neutral') - ->and(IssueSentiment::CRISIS->value)->toBe('krisis'); - }); - - it('can get label from case', function () { - expect(IssueSentiment::POSITIVE->getLabel())->toBe('Positif') - ->and(IssueSentiment::NEGATIVE->getLabel())->toBe('Negatif') - ->and(IssueSentiment::NEUTRAL->getLabel())->toBe('Netral') - ->and(IssueSentiment::CRISIS->getLabel())->toBe('Krisis'); - }); - - it('can get color from case', function () { - expect(IssueSentiment::POSITIVE->getColor())->not()->toBeNull() - ->and(IssueSentiment::NEGATIVE->getColor())->not()->toBeNull() - ->and(IssueSentiment::NEUTRAL->getColor())->not()->toBeNull() - ->and(IssueSentiment::CRISIS->getColor())->not()->toBeNull(); - }); - - it('can get options array', function () { - $options = IssueSentiment::options(); - - expect($options)->toBeArray() - ->and($options)->toHaveKey('positive', 'Positif') - ->and($options)->toHaveKey('negative', 'Negatif') - ->and($options)->toHaveKey('neutral', 'Netral') - ->and($options)->toHaveKey('krisis', 'Krisis'); - }); -}); diff --git a/tests/Unit/Enums/MediaClassificationTest.php b/tests/Unit/Enums/MediaClassificationTest.php deleted file mode 100644 index c16d870..0000000 --- a/tests/Unit/Enums/MediaClassificationTest.php +++ /dev/null @@ -1,28 +0,0 @@ -toHaveCount(3) - ->and(collect($cases)->pluck('value')->toArray()) - ->toEqual([1, 2, 3]); - }); - - it('can get label from case', function () { - expect(MediaClassification::LOCAL->getLabel())->toBe('Lokal') - ->and(MediaClassification::REGIONAL->getLabel())->toBe('Regional') - ->and(MediaClassification::NATIONAL->getLabel())->toBe('Nasional'); - }); - - it('can get options array', function () { - $options = MediaClassification::options(); - - expect($options)->toBeArray() - ->and($options)->toHaveKey(1, 'Lokal') - ->and($options)->toHaveKey(2, 'Regional') - ->and($options)->toHaveKey(3, 'Nasional'); - }); -}); diff --git a/tests/Unit/Enums/MediaTypeTest.php b/tests/Unit/Enums/MediaTypeTest.php deleted file mode 100644 index ff0835e..0000000 --- a/tests/Unit/Enums/MediaTypeTest.php +++ /dev/null @@ -1,37 +0,0 @@ -toHaveCount(4) - ->and(collect($cases)->pluck('value')->toArray()) - ->toEqual([1, 2, 3, 4]); - }); - - it('can get value from case', function () { - expect(MediaType::ONLINE->value)->toBe(1) - ->and(MediaType::PRINT->value)->toBe(2) - ->and(MediaType::RADIO->value)->toBe(3) - ->and(MediaType::TELEVISION->value)->toBe(4); - }); - - it('can get label from case', function () { - expect(MediaType::ONLINE->getLabel())->toBe('Online') - ->and(MediaType::PRINT->getLabel())->toBe('Cetak') - ->and(MediaType::RADIO->getLabel())->toBe('Radio') - ->and(MediaType::TELEVISION->getLabel())->toBe('Televisi'); - }); - - it('can get options array', function () { - $options = MediaType::options(); - - expect($options)->toBeArray() - ->and($options)->toHaveKey(1, 'Online') - ->and($options)->toHaveKey(2, 'Cetak') - ->and($options)->toHaveKey(3, 'Radio') - ->and($options)->toHaveKey(4, 'Televisi'); - }); -}); diff --git a/tests/Unit/Enums/SocialMediaTest.php b/tests/Unit/Enums/SocialMediaTest.php deleted file mode 100644 index 735a14d..0000000 --- a/tests/Unit/Enums/SocialMediaTest.php +++ /dev/null @@ -1,17 +0,0 @@ -not()->toBeEmpty(); - }); - - it('can get first case value', function () { - $firstCase = SocialMedia::cases()[0]; - - expect($firstCase->value)->toBeString(); - }); -}); diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php deleted file mode 100644 index 5773b0c..0000000 --- a/tests/Unit/ExampleTest.php +++ /dev/null @@ -1,16 +0,0 @@ -assertTrue(true); - } -} diff --git a/tests/Unit/Filament/Actions/DefaultBulkActionsTest.php b/tests/Unit/Filament/Actions/DefaultBulkActionsTest.php deleted file mode 100644 index c8399b0..0000000 --- a/tests/Unit/Filament/Actions/DefaultBulkActionsTest.php +++ /dev/null @@ -1,45 +0,0 @@ -toBeArray() - ->and($actions)->toHaveCount(3); - }); - - it('includes delete bulk action', function () { - $actions = DefaultBulkActions::make('Test Entity'); - - $hasDeleteAction = collect($actions)->contains(function ($action) { - return $action instanceof DeleteBulkAction; - }); - - expect($hasDeleteAction)->toBeTrue(); - }); - - it('includes force delete bulk action', function () { - $actions = DefaultBulkActions::make('Test Entity'); - - $hasForceDeleteAction = collect($actions)->contains(function ($action) { - return $action instanceof ForceDeleteBulkAction; - }); - - expect($hasForceDeleteAction)->toBeTrue(); - }); - - it('includes restore bulk action', function () { - $actions = DefaultBulkActions::make('Test Entity'); - - $hasRestoreAction = collect($actions)->contains(function ($action) { - return $action instanceof RestoreBulkAction; - }); - - expect($hasRestoreAction)->toBeTrue(); - }); -}); diff --git a/tests/Unit/Filament/Columns/TimestampColumnsTest.php b/tests/Unit/Filament/Columns/TimestampColumnsTest.php deleted file mode 100644 index 9dcdaec..0000000 --- a/tests/Unit/Filament/Columns/TimestampColumnsTest.php +++ /dev/null @@ -1,51 +0,0 @@ -toBeArray() - ->and($columns)->toHaveCount(3); - }); - - it('includes created_at column', function () { - $columns = TimestampColumns::make(); - - $hasCreatedAt = collect($columns)->contains(function ($column) { - return $column instanceof TextColumn && $column->getName() === 'created_at'; - }); - - expect($hasCreatedAt)->toBeTrue(); - }); - - it('includes updated_at column', function () { - $columns = TimestampColumns::make(); - - $hasUpdatedAt = collect($columns)->contains(function ($column) { - return $column instanceof TextColumn && $column->getName() === 'updated_at'; - }); - - expect($hasUpdatedAt)->toBeTrue(); - }); - - it('includes deleted_at column', function () { - $columns = TimestampColumns::make(); - - $hasDeletedAt = collect($columns)->contains(function ($column) { - return $column instanceof TextColumn && $column->getName() === 'deleted_at'; - }); - - expect($hasDeletedAt)->toBeTrue(); - }); - - it('all columns are text columns', function () { - $columns = TimestampColumns::make(); - - foreach ($columns as $column) { - expect($column)->toBeInstanceOf(TextColumn::class); - } - }); -}); diff --git a/tests/Unit/MediaLibrary/CustomPathGeneratorTest.php b/tests/Unit/MediaLibrary/CustomPathGeneratorTest.php deleted file mode 100644 index dbb4027..0000000 --- a/tests/Unit/MediaLibrary/CustomPathGeneratorTest.php +++ /dev/null @@ -1,67 +0,0 @@ -pathGenerator = new CustomPathGenerator; - $this->media = new Media([ - 'id' => 1, - 'model_type' => 'App\Models\MediaMonitoring', - 'model_id' => 1, - 'collection_name' => 'default', - 'name' => 'test-file', - 'file_name' => 'test-file.pdf', - 'mime_type' => 'application/pdf', - 'disk' => 'public', - 'conversions_disk' => 'public', - 'size' => 1024, - 'custom_properties' => [ - 'feature' => 'media-monitoring', - 'date' => '2024-01-15', - 'doc_type' => 'document', - ], - ]); - }); - - it('generates correct path for media', function () { - $path = $this->pathGenerator->getPath($this->media); - - expect($path)->toBeString() - ->and($path)->toContain('media-monitoring') - ->and($path)->toContain('document') - ->and($path)->toContain('2024-01-15'); - }); - - it('generates correct path for conversions', function () { - $path = $this->pathGenerator->getPathForConversions($this->media); - - expect($path)->toBeString() - ->and($path)->toContain('conversions'); - }); - - it('generates correct path for responsive images', function () { - $path = $this->pathGenerator->getPathForResponsiveImages($this->media); - - expect($path)->toBeString() - ->and($path)->toContain('responsive'); - }); - - it('handles missing custom properties gracefully', function () { - $mediaWithoutProps = new Media([ - 'id' => 2, - 'model_type' => 'App\Models\Test', - 'model_id' => 1, - 'collection_name' => 'default', - 'name' => 'test', - 'file_name' => 'test.jpg', - 'custom_properties' => [], - ]); - - $path = $this->pathGenerator->getPath($mediaWithoutProps); - - expect($path)->toBeString() - ->and($path)->toContain('misc'); - }); -}); diff --git a/tests/Unit/Models/ClassificationTest.php b/tests/Unit/Models/ClassificationTest.php deleted file mode 100644 index 32cc2fb..0000000 --- a/tests/Unit/Models/ClassificationTest.php +++ /dev/null @@ -1,54 +0,0 @@ -create([ - 'name' => 'Test Classification', - ]); - - expect($classification->name)->toBe('Test Classification') - ->and($classification->exists)->toBeTrue(); - }); - - it('has guarded attributes', function () { - $guarded = ['id']; - - expect(Classification::make()->getGuarded())->toEqual($guarded); - }); - - it('has sub classifications relationship', function () { - $classification = Classification::factory()->create(); - - expect($classification->subClassifications())->toBeInstanceOf(HasMany::class); - }); - - it('has content recaps relationship', function () { - $classification = Classification::factory()->create(); - - expect($classification->contentRecaps())->toBeInstanceOf(HasMany::class); - }); - - it('scopes active classifications', function () { - Classification::factory()->create(['is_active' => IsActive::ACTIVE]); - Classification::factory()->create(['is_active' => IsActive::INACTIVE]); - - $activeClassifications = Classification::active()->get(); - - expect($activeClassifications)->toHaveCount(1) - ->and($activeClassifications->first()->is_active)->toBe(IsActive::ACTIVE); - }); - - it('casts is_active to enum', function () { - $classification = Classification::factory()->create(['is_active' => IsActive::ACTIVE]); - - expect($classification->is_active)->toBeInstanceOf(IsActive::class) - ->and($classification->is_active)->toBe(IsActive::ACTIVE); - }); -}); diff --git a/tests/Unit/Models/CompanyTest.php b/tests/Unit/Models/CompanyTest.php deleted file mode 100644 index 97cf12a..0000000 --- a/tests/Unit/Models/CompanyTest.php +++ /dev/null @@ -1,46 +0,0 @@ -create([ - 'name' => 'Test Media Company', - 'email' => 'company@example.com', - ]); - - expect($company->name)->toBe('Test Media Company') - ->and($company->email)->toBe('company@example.com') - ->and($company->exists)->toBeTrue(); - }); - - it('has guarded attributes', function () { - $guarded = ['id']; - - expect(Company::make()->getGuarded())->toEqual($guarded); - }); - - it('belongs to user', function () { - $company = Company::factory()->create(); - - expect($company->user())->toBeInstanceOf(BelongsTo::class); - }); - - it('has one partner media', function () { - $company = Company::factory()->create(); - - expect($company->partnerMedia())->toBeInstanceOf(HasOne::class); - }); - - it('has many journalists through partner media', function () { - $company = Company::factory()->create(); - - expect($company->journalists())->toBeInstanceOf(HasManyThrough::class); - }); -}); diff --git a/tests/Unit/Models/ContentRecapTest.php b/tests/Unit/Models/ContentRecapTest.php deleted file mode 100644 index ca5a7f6..0000000 --- a/tests/Unit/Models/ContentRecapTest.php +++ /dev/null @@ -1,38 +0,0 @@ -create([ - 'title' => 'Test Recap', - ]); - - expect($recap->title)->toBe('Test Recap') - ->and($recap->exists)->toBeTrue(); - }); - - it('has guarded attributes', function () { - $guarded = ['id']; - - expect(ContentRecap::make()->getGuarded())->toEqual($guarded); - }); - - it('belongs to classification', function () { - $recap = ContentRecap::factory()->create(); - - expect($recap->classification())->toBeInstanceOf(BelongsTo::class); - }); - - it('casts type to content type enum', function () { - $recap = ContentRecap::factory()->create(['type' => ContentType::VIDEO]); - - expect($recap->type)->toBeInstanceOf(ContentType::class) - ->and($recap->type)->toBe(ContentType::VIDEO); - }); -}); diff --git a/tests/Unit/Models/DepartmentTest.php b/tests/Unit/Models/DepartmentTest.php deleted file mode 100644 index 4414a3c..0000000 --- a/tests/Unit/Models/DepartmentTest.php +++ /dev/null @@ -1,33 +0,0 @@ -create([ - 'name' => 'Test Department', - 'alias' => 'TESTDEPT', - ]); - - expect($department->name)->toBe('Test Department') - ->and($department->alias)->toBe('TESTDEPT') - ->and($department->exists)->toBeTrue(); - }); - - it('has guarded attributes', function () { - $guarded = ['id']; - - expect(Department::make()->getGuarded())->toEqual($guarded); - }); - - it('casts is_active to enum', function () { - $department = Department::factory()->create(['is_active' => IsActive::ACTIVE]); - - expect($department->is_active)->toBeInstanceOf(IsActive::class) - ->and($department->is_active)->toBe(IsActive::ACTIVE); - }); -}); diff --git a/tests/Unit/Models/IssueManagementTest.php b/tests/Unit/Models/IssueManagementTest.php deleted file mode 100644 index 3def49e..0000000 --- a/tests/Unit/Models/IssueManagementTest.php +++ /dev/null @@ -1,71 +0,0 @@ -create([ - 'description' => 'Test Issue Description', - 'issue' => IssueSentiment::POSITIVE, - 'response' => IssueSentiment::POSITIVE, - ]); - - expect($issue->description)->toBe('Test Issue Description') - ->and($issue->issue)->toBe(IssueSentiment::POSITIVE) - ->and($issue->response)->toBe(IssueSentiment::POSITIVE) - ->and($issue->exists)->toBeTrue(); - }); - - it('has guarded attributes', function () { - $guarded = ['id']; - - expect(IssueManagement::make()->getGuarded())->toEqual($guarded); - }); - - it('belongs to location', function () { - $issue = IssueManagement::factory()->create(); - - expect($issue->location())->toBeInstanceOf(BelongsTo::class); - }); - - it('belongs to sub location', function () { - $issue = IssueManagement::factory()->create(); - - expect($issue->subLocation())->toBeInstanceOf(BelongsTo::class); - }); - - it('belongs to classification', function () { - $issue = IssueManagement::factory()->create(); - - expect($issue->classification())->toBeInstanceOf(BelongsTo::class); - }); - - it('belongs to sub classification', function () { - $issue = IssueManagement::factory()->create(); - - expect($issue->subClassification())->toBeInstanceOf(BelongsTo::class); - }); - - it('belongs to media monitoring', function () { - $issue = IssueManagement::factory()->create(); - - expect($issue->mediaMonitoring())->toBeInstanceOf(BelongsTo::class); - }); - - it('casts sentiment enums correctly', function () { - $issue = IssueManagement::factory()->create([ - 'issue' => IssueSentiment::NEGATIVE, - 'response' => IssueSentiment::POSITIVE, - ]); - - expect($issue->issue)->toBeInstanceOf(IssueSentiment::class) - ->and($issue->issue)->toBe(IssueSentiment::NEGATIVE) - ->and($issue->response)->toBeInstanceOf(IssueSentiment::class) - ->and($issue->response)->toBe(IssueSentiment::POSITIVE); - }); -}); diff --git a/tests/Unit/Models/JournalistTest.php b/tests/Unit/Models/JournalistTest.php deleted file mode 100644 index 4346f60..0000000 --- a/tests/Unit/Models/JournalistTest.php +++ /dev/null @@ -1,32 +0,0 @@ -create([ - 'name' => 'Test Journalist', - 'email' => 'journalist@example.com', - ]); - - expect($journalist->name)->toBe('Test Journalist') - ->and($journalist->email)->toBe('journalist@example.com') - ->and($journalist->exists)->toBeTrue(); - }); - - it('has guarded attributes', function () { - $guarded = ['id']; - - expect(Journalist::make()->getGuarded())->toEqual($guarded); - }); - - it('belongs to partner media', function () { - $journalist = Journalist::factory()->create(); - - expect($journalist->partnerMedia())->toBeInstanceOf(BelongsTo::class); - }); -}); diff --git a/tests/Unit/Models/LocationTest.php b/tests/Unit/Models/LocationTest.php deleted file mode 100644 index 96ffdbd..0000000 --- a/tests/Unit/Models/LocationTest.php +++ /dev/null @@ -1,38 +0,0 @@ -create([ - 'name' => 'Test Location', - ]); - - expect($location->name)->toBe('Test Location') - ->and($location->exists)->toBeTrue(); - }); - - it('has guarded attributes', function () { - $guarded = ['id']; - - expect(Location::make()->getGuarded())->toEqual($guarded); - }); - - it('has sub locations relationship', function () { - $location = Location::factory()->create(); - - expect($location->subLocations())->toBeInstanceOf(HasMany::class); - }); - - it('casts is_active to enum', function () { - $location = Location::factory()->create(['is_active' => IsActive::ACTIVE]); - - expect($location->is_active)->toBeInstanceOf(IsActive::class) - ->and($location->is_active)->toBe(IsActive::ACTIVE); - }); -}); diff --git a/tests/Unit/Models/MediaMonitoringTest.php b/tests/Unit/Models/MediaMonitoringTest.php deleted file mode 100644 index 0f3a25f..0000000 --- a/tests/Unit/Models/MediaMonitoringTest.php +++ /dev/null @@ -1,50 +0,0 @@ -create([ - 'title' => 'Test Media Title', - 'media_name' => 'Test Media', - ]); - - expect($mediaMonitoring->title)->toBe('Test Media Title') - ->and($mediaMonitoring->media_name)->toBe('Test Media') - ->and($mediaMonitoring->exists)->toBeTrue(); - }); - - it('has guarded attributes', function () { - $guarded = ['id']; - - expect(MediaMonitoring::make()->getGuarded())->toEqual($guarded); - }); - - it('has themes relationship', function () { - $mediaMonitoring = MediaMonitoring::factory()->create(); - - expect($mediaMonitoring->themes())->toBeInstanceOf(BelongsToMany::class); - }); - - it('has issue management relationship', function () { - $mediaMonitoring = MediaMonitoring::factory()->create(); - - expect($mediaMonitoring->issueManagement())->toBeInstanceOf(HasOne::class); - }); - - it('can attach themes', function () { - $mediaMonitoring = MediaMonitoring::factory()->create(); - $theme = Theme::factory()->create(); - - $mediaMonitoring->themes()->attach($theme->id); - - expect($mediaMonitoring->themes)->toHaveCount(1) - ->and($mediaMonitoring->themes->first()->id)->toBe($theme->id); - }); -}); diff --git a/tests/Unit/Models/MediaMonitoringThemeTest.php b/tests/Unit/Models/MediaMonitoringThemeTest.php deleted file mode 100644 index 2c1d320..0000000 --- a/tests/Unit/Models/MediaMonitoringThemeTest.php +++ /dev/null @@ -1,35 +0,0 @@ -create(); - - expect($pivot->exists)->toBeTrue() - ->and($pivot->media_monitoring_id)->toBeInt() - ->and($pivot->theme_id)->toBeInt(); - }); - - it('has guarded attributes', function () { - $guarded = ['id']; - - expect(MediaMonitoringTheme::make()->getGuarded())->toEqual($guarded); - }); - - it('belongs to media monitoring', function () { - $pivot = MediaMonitoringTheme::factory()->create(); - - expect($pivot->mediaMonitoring())->toBeInstanceOf(BelongsTo::class); - }); - - it('belongs to theme', function () { - $pivot = MediaMonitoringTheme::factory()->create(); - - expect($pivot->theme())->toBeInstanceOf(BelongsTo::class); - }); -}); diff --git a/tests/Unit/Models/PartnerMediaTest.php b/tests/Unit/Models/PartnerMediaTest.php deleted file mode 100644 index ba665f7..0000000 --- a/tests/Unit/Models/PartnerMediaTest.php +++ /dev/null @@ -1,46 +0,0 @@ -create([ - 'name' => 'Test Partner', - ]); - - expect($partner->name)->toBe('Test Partner') - ->and($partner->exists)->toBeTrue(); - }); - - it('has guarded attributes', function () { - $guarded = ['id']; - - expect(PartnerMedia::make()->getGuarded())->toEqual($guarded); - }); - - it('belongs to company', function () { - $partner = PartnerMedia::factory()->create(); - - expect($partner->company())->toBeInstanceOf(BelongsTo::class); - }); - - it('casts type to media type enum', function () { - $partner = PartnerMedia::factory()->create(['type' => MediaType::ONLINE]); - - expect($partner->type)->toBeInstanceOf(MediaType::class) - ->and($partner->type)->toBe(MediaType::ONLINE); - }); - - it('casts classification to media classification enum', function () { - $partner = PartnerMedia::factory()->create(['classification' => MediaClassification::NATIONAL]); - - expect($partner->classification)->toBeInstanceOf(MediaClassification::class) - ->and($partner->classification)->toBe(MediaClassification::NATIONAL); - }); -}); diff --git a/tests/Unit/Models/SubClassificationTest.php b/tests/Unit/Models/SubClassificationTest.php deleted file mode 100644 index 571f2df..0000000 --- a/tests/Unit/Models/SubClassificationTest.php +++ /dev/null @@ -1,38 +0,0 @@ -create([ - 'name' => 'Test Sub Classification', - ]); - - expect($subClassification->name)->toBe('Test Sub Classification') - ->and($subClassification->exists)->toBeTrue(); - }); - - it('has guarded attributes', function () { - $guarded = ['id']; - - expect(SubClassification::make()->getGuarded())->toEqual($guarded); - }); - - it('belongs to classification', function () { - $subClassification = SubClassification::factory()->create(); - - expect($subClassification->classification())->toBeInstanceOf(BelongsTo::class); - }); - - it('casts is_active to enum', function () { - $subClassification = SubClassification::factory()->create(['is_active' => IsActive::ACTIVE]); - - expect($subClassification->is_active)->toBeInstanceOf(IsActive::class) - ->and($subClassification->is_active)->toBe(IsActive::ACTIVE); - }); -}); diff --git a/tests/Unit/Models/SubLocationTest.php b/tests/Unit/Models/SubLocationTest.php deleted file mode 100644 index 527f6ea..0000000 --- a/tests/Unit/Models/SubLocationTest.php +++ /dev/null @@ -1,38 +0,0 @@ -create([ - 'name' => 'Test Sub Location', - ]); - - expect($subLocation->name)->toBe('Test Sub Location') - ->and($subLocation->exists)->toBeTrue(); - }); - - it('has guarded attributes', function () { - $guarded = ['id']; - - expect(SubLocation::make()->getGuarded())->toEqual($guarded); - }); - - it('belongs to location', function () { - $subLocation = SubLocation::factory()->create(); - - expect($subLocation->location())->toBeInstanceOf(BelongsTo::class); - }); - - it('casts is_active to enum', function () { - $subLocation = SubLocation::factory()->create(['is_active' => IsActive::ACTIVE]); - - expect($subLocation->is_active)->toBeInstanceOf(IsActive::class) - ->and($subLocation->is_active)->toBe(IsActive::ACTIVE); - }); -}); diff --git a/tests/Unit/Models/ThemeTest.php b/tests/Unit/Models/ThemeTest.php deleted file mode 100644 index 3f52795..0000000 --- a/tests/Unit/Models/ThemeTest.php +++ /dev/null @@ -1,48 +0,0 @@ -create([ - 'name' => 'Test Theme', - ]); - - expect($theme->name)->toBe('Test Theme') - ->and($theme->exists)->toBeTrue(); - }); - - it('has guarded attributes', function () { - $guarded = ['id']; - - expect(Theme::make()->getGuarded())->toEqual($guarded); - }); - - it('has media monitorings relationship', function () { - $theme = Theme::factory()->create(); - - expect($theme->mediaMonitorings())->toBeInstanceOf(BelongsToMany::class); - }); - - it('scopes active themes', function () { - Theme::factory()->create(['is_active' => IsActive::ACTIVE]); - Theme::factory()->create(['is_active' => IsActive::INACTIVE]); - - $activeThemes = Theme::active()->get(); - - expect($activeThemes)->toHaveCount(1) - ->and($activeThemes->first()->is_active)->toBe(IsActive::ACTIVE); - }); - - it('casts is_active to enum', function () { - $theme = Theme::factory()->create(['is_active' => IsActive::ACTIVE]); - - expect($theme->is_active)->toBeInstanceOf(IsActive::class) - ->and($theme->is_active)->toBe(IsActive::ACTIVE); - }); -}); diff --git a/tests/Unit/Models/UserTest.php b/tests/Unit/Models/UserTest.php deleted file mode 100644 index 8f6557b..0000000 --- a/tests/Unit/Models/UserTest.php +++ /dev/null @@ -1,47 +0,0 @@ -create([ - 'name' => 'Test User', - 'email' => 'test@example.com', - ]); - - expect($user->name)->toBe('Test User') - ->and($user->email)->toBe('test@example.com') - ->and($user->exists)->toBeTrue(); - }); - - it('has guarded attributes', function () { - $guarded = ['id']; - - expect(User::make()->getGuarded())->toEqual($guarded); - }); - - it('has hidden attributes', function () { - $hidden = ['password', 'remember_token']; - - expect(User::make()->getHidden())->toEqual($hidden); - }); - - it('has email verification timestamp', function () { - $user = User::factory()->create(); - - expect($user->getCasts())->toHaveKey('email_verified_at'); - }); - - it('can verify email', function () { - $user = User::factory()->create(['email_verified_at' => null]); - - expect($user->email_verified_at)->toBeNull(); - - $user->markEmailAsVerified(); - - expect($user->email_verified_at)->not()->toBeNull(); - }); -}); diff --git a/tests/Unit/Traits/WithCommentTest.php b/tests/Unit/Traits/WithCommentTest.php deleted file mode 100644 index 06e4c0b..0000000 --- a/tests/Unit/Traits/WithCommentTest.php +++ /dev/null @@ -1,46 +0,0 @@ - 'Status Aktif', - self::INACTIVE => 'Status Tidak Aktif', - }; - } -} - -describe('WithComment Trait', function () { - it('can generate comment string from enum cases', function () { - $comment = TestCommentEnum::comment(); - - expect($comment)->toBeString() - ->and($comment)->toContain('active: Status Aktif') - ->and($comment)->toContain('inactive: Status Tidak Aktif'); - }); - - it('formats comment with comma separation', function () { - $comment = TestCommentEnum::comment(); - - expect($comment)->toContain(', '); - }); - - it('includes all enum cases in comment', function () { - $comment = TestCommentEnum::comment(); - $cases = TestCommentEnum::cases(); - - foreach ($cases as $case) { - expect($comment)->toContain($case->value); - expect($comment)->toContain($case->getLabel()); - } - }); -}); diff --git a/tests/Unit/Traits/WithValueTest.php b/tests/Unit/Traits/WithValueTest.php deleted file mode 100644 index 301f0e6..0000000 --- a/tests/Unit/Traits/WithValueTest.php +++ /dev/null @@ -1,29 +0,0 @@ -toBeArray() - ->and($values)->toEqual(['active', 'inactive']) - ->and($values)->toHaveCount(2); - }); - - it('returns correct value types', function () { - $values = TestValueEnum::values(); - - foreach ($values as $value) { - expect($value)->toBeString(); - } - }); -});