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