simedkom/tests/Unit/Enums/IssueSentimentTest.php
Yoga Pangestu 97cdfd6e0b test: add comprehensive test suite and model factories
- Add HasFactory trait to all model classes for factory support
- Create factory classes for all models (Classification, Company, ContentRecap, Department, IssueManagement, Journalist, Location, MediaMonitoring, MediaMonitoringTheme, PartnerMedia, SubClassification, SubLocation, Theme, User)
- Add unit tests for all models with relationship and attribute validation
- Add unit tests for all enums (Channel, ContentType, IsActive, IssueSentiment, MediaClassification, MediaType, SocialMedia)
- Add feature tests for factory integration and basic application functionality
- Add tests for Filament actions, columns, and media library utilities
- Add tests for model policies (Classification, Theme) and traits (WithComment, WithValue)
- Update phpunit.xml configuration for test environment
- Add test documentation and working tests reference guide
- Add ContentType enum casting to ContentRecap model
- Add MediaMonitoringTheme relationships and factory support
- Establish comprehensive testing infrastructure for improved code quality and reliability
2025-12-11 14:50:37 +07:00

45 lines
1.7 KiB
PHP

<?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');
});
});