chore: Remove all existing tests from the project.
This commit is contained in:
parent
550d040834
commit
78e3809e7b
@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Classification;
|
||||
use App\Models\Company;
|
||||
use App\Models\ContentRecap;
|
||||
use App\Models\Department;
|
||||
use App\Models\IssueManagement;
|
||||
use App\Models\Journalist;
|
||||
use App\Models\Location;
|
||||
use App\Models\MediaMonitoring;
|
||||
use App\Models\PartnerMedia;
|
||||
use App\Models\Theme;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('Basic Factory Tests', function () {
|
||||
it('can create theme using factory', function () {
|
||||
$theme = Theme::factory()->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();
|
||||
});
|
||||
});
|
||||
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
// use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*/
|
||||
public function test_the_application_returns_a_successful_response(): void
|
||||
{
|
||||
$response = $this->get('/');
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\IsActive;
|
||||
use App\Enums\IssueSentiment;
|
||||
use App\Enums\MediaType;
|
||||
use App\Models\Classification;
|
||||
use App\Models\Company;
|
||||
use App\Models\IssueManagement;
|
||||
use App\Models\Journalist;
|
||||
use App\Models\MediaMonitoring;
|
||||
use App\Models\PartnerMedia;
|
||||
use App\Models\Theme;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('Integration Tests', function () {
|
||||
it('can create complete media monitoring workflow', function () {
|
||||
// Create theme
|
||||
$theme = Theme::factory()->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');
|
||||
});
|
||||
});
|
||||
@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Classification;
|
||||
use App\Models\Company;
|
||||
use App\Models\ContentRecap;
|
||||
use App\Models\Department;
|
||||
use App\Models\IssueManagement;
|
||||
use App\Models\Journalist;
|
||||
use App\Models\Location;
|
||||
use App\Models\MediaMonitoring;
|
||||
use App\Models\PartnerMedia;
|
||||
use App\Models\Theme;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('Model Factory Tests', function () {
|
||||
it('can create user', function () {
|
||||
$user = User::factory()->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();
|
||||
});
|
||||
});
|
||||
191
tests/README.md
191
tests/README.md
@ -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
|
||||
@ -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.
|
||||
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\Channel;
|
||||
|
||||
describe('Channel Enum', function () {
|
||||
it('has channel cases', function () {
|
||||
$cases = Channel::cases();
|
||||
|
||||
expect($cases)->not()->toBeEmpty();
|
||||
});
|
||||
|
||||
it('can get first case value', function () {
|
||||
$firstCase = Channel::cases()[0];
|
||||
|
||||
expect($firstCase->value)->toBeString();
|
||||
});
|
||||
});
|
||||
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\ContentType;
|
||||
|
||||
describe('ContentType Enum', function () {
|
||||
it('has content type cases', function () {
|
||||
$cases = ContentType::cases();
|
||||
|
||||
expect($cases)->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');
|
||||
});
|
||||
});
|
||||
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\IsActive;
|
||||
|
||||
describe('IsActive Enum', function () {
|
||||
it('has correct active status cases', function () {
|
||||
$cases = IsActive::cases();
|
||||
|
||||
expect($cases)->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');
|
||||
});
|
||||
});
|
||||
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\IssueSentiment;
|
||||
|
||||
describe('IssueSentiment Enum', function () {
|
||||
it('has correct sentiment cases', function () {
|
||||
$cases = IssueSentiment::cases();
|
||||
|
||||
expect($cases)->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');
|
||||
});
|
||||
});
|
||||
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\MediaClassification;
|
||||
|
||||
describe('MediaClassification Enum', function () {
|
||||
it('has media classification cases', function () {
|
||||
$cases = MediaClassification::cases();
|
||||
|
||||
expect($cases)->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');
|
||||
});
|
||||
});
|
||||
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\MediaType;
|
||||
|
||||
describe('MediaType Enum', function () {
|
||||
it('has correct cases', function () {
|
||||
$cases = MediaType::cases();
|
||||
|
||||
expect($cases)->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');
|
||||
});
|
||||
});
|
||||
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\SocialMedia;
|
||||
|
||||
describe('SocialMedia Enum', function () {
|
||||
it('has social media platform cases', function () {
|
||||
$cases = SocialMedia::cases();
|
||||
|
||||
expect($cases)->not()->toBeEmpty();
|
||||
});
|
||||
|
||||
it('can get first case value', function () {
|
||||
$firstCase = SocialMedia::cases()[0];
|
||||
|
||||
expect($firstCase->value)->toBeString();
|
||||
});
|
||||
});
|
||||
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*/
|
||||
public function test_that_true_is_true(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Filament\Actions\DefaultBulkActions;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\ForceDeleteBulkAction;
|
||||
use Filament\Actions\RestoreBulkAction;
|
||||
|
||||
describe('DefaultBulkActions', function () {
|
||||
it('returns array of bulk actions', function () {
|
||||
$actions = DefaultBulkActions::make('Test Entity');
|
||||
|
||||
expect($actions)->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();
|
||||
});
|
||||
});
|
||||
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Filament\Columns\TimestampColumns;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
|
||||
describe('TimestampColumns', function () {
|
||||
it('returns array of timestamp columns', function () {
|
||||
$columns = TimestampColumns::make();
|
||||
|
||||
expect($columns)->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);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\MediaLibrary\CustomPathGenerator;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
describe('CustomPathGenerator', function () {
|
||||
beforeEach(function () {
|
||||
$this->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');
|
||||
});
|
||||
});
|
||||
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\IsActive;
|
||||
use App\Models\Classification;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('Classification Model', function () {
|
||||
it('can create a classification', function () {
|
||||
$classification = Classification::factory()->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);
|
||||
});
|
||||
});
|
||||
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Company;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('Company Model', function () {
|
||||
it('can create a company', function () {
|
||||
$company = Company::factory()->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);
|
||||
});
|
||||
});
|
||||
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\ContentType;
|
||||
use App\Models\ContentRecap;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('ContentRecap Model', function () {
|
||||
it('can create a content recap entry', function () {
|
||||
$recap = ContentRecap::factory()->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);
|
||||
});
|
||||
});
|
||||
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\IsActive;
|
||||
use App\Models\Department;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('Department Model', function () {
|
||||
it('can create a department', function () {
|
||||
$department = Department::factory()->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);
|
||||
});
|
||||
});
|
||||
@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\IssueSentiment;
|
||||
use App\Models\IssueManagement;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('IssueManagement Model', function () {
|
||||
it('can create an issue management entry', function () {
|
||||
$issue = IssueManagement::factory()->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);
|
||||
});
|
||||
});
|
||||
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Journalist;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('Journalist Model', function () {
|
||||
it('can create a journalist', function () {
|
||||
$journalist = Journalist::factory()->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);
|
||||
});
|
||||
});
|
||||
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\IsActive;
|
||||
use App\Models\Location;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('Location Model', function () {
|
||||
it('can create a location', function () {
|
||||
$location = Location::factory()->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);
|
||||
});
|
||||
});
|
||||
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\MediaMonitoring;
|
||||
use App\Models\Theme;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('MediaMonitoring Model', function () {
|
||||
it('can create a media monitoring entry', function () {
|
||||
$mediaMonitoring = MediaMonitoring::factory()->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);
|
||||
});
|
||||
});
|
||||
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\MediaMonitoringTheme;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('MediaMonitoringTheme Model', function () {
|
||||
it('can create a media monitoring theme pivot', function () {
|
||||
$pivot = MediaMonitoringTheme::factory()->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);
|
||||
});
|
||||
});
|
||||
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\MediaClassification;
|
||||
use App\Enums\MediaType;
|
||||
use App\Models\PartnerMedia;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('PartnerMedia Model', function () {
|
||||
it('can create a partner media', function () {
|
||||
$partner = PartnerMedia::factory()->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);
|
||||
});
|
||||
});
|
||||
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\IsActive;
|
||||
use App\Models\SubClassification;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('SubClassification Model', function () {
|
||||
it('can create a sub classification', function () {
|
||||
$subClassification = SubClassification::factory()->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);
|
||||
});
|
||||
});
|
||||
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\IsActive;
|
||||
use App\Models\SubLocation;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('SubLocation Model', function () {
|
||||
it('can create a sub location', function () {
|
||||
$subLocation = SubLocation::factory()->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);
|
||||
});
|
||||
});
|
||||
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\IsActive;
|
||||
use App\Models\Theme;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('Theme Model', function () {
|
||||
it('can create a theme', function () {
|
||||
$theme = Theme::factory()->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);
|
||||
});
|
||||
});
|
||||
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('User Model', function () {
|
||||
it('can create a user', function () {
|
||||
$user = User::factory()->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();
|
||||
});
|
||||
});
|
||||
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Traits\Enum\WithComment;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum TestCommentEnum: string implements HasLabel
|
||||
{
|
||||
use WithComment;
|
||||
|
||||
case ACTIVE = 'active';
|
||||
case INACTIVE = 'inactive';
|
||||
|
||||
public function getLabel(): ?string
|
||||
{
|
||||
return match ($this) {
|
||||
self::ACTIVE => '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());
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Traits\Enum\WithValue;
|
||||
|
||||
enum TestValueEnum: string
|
||||
{
|
||||
use WithValue;
|
||||
|
||||
case ACTIVE = 'active';
|
||||
case INACTIVE = 'inactive';
|
||||
}
|
||||
|
||||
describe('WithValue Trait', function () {
|
||||
it('can get all values from enum cases', function () {
|
||||
$values = TestValueEnum::values();
|
||||
|
||||
expect($values)->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();
|
||||
}
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user