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