- 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
44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
use App\Models\Company;
|
|
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(\Illuminate\Database\Eloquent\Relations\BelongsTo::class);
|
|
});
|
|
|
|
it('has one partner media', function () {
|
|
$company = Company::factory()->create();
|
|
|
|
expect($company->partnerMedia())->toBeInstanceOf(\Illuminate\Database\Eloquent\Relations\HasOne::class);
|
|
});
|
|
|
|
it('has many journalists through partner media', function () {
|
|
$company = Company::factory()->create();
|
|
|
|
expect($company->journalists())->toBeInstanceOf(\Illuminate\Database\Eloquent\Relations\HasManyThrough::class);
|
|
});
|
|
});
|