- 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
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?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());
|
|
}
|
|
});
|
|
});
|