presseportale/tests/Feature/PressReleasePhase7SchemaTest.php
Kevin Adametz d2ba22c0cf
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
create PM v0.5
2026-05-20 19:14:39 +02:00

54 lines
1.8 KiB
PHP

<?php
use App\Models\Company;
use App\Models\PressRelease;
use App\Models\PressReleaseAttachment;
test('press release accepts new phase 7 fields', function () {
$pr = PressRelease::factory()->create([
'subtitle' => 'Eine sinnvolle Subline',
'boilerplate_override' => 'PM-spezifischer Boilerplate-Text.',
'scheduled_at' => now()->addDay(),
'embargo_at' => now()->addDays(2),
]);
$fresh = $pr->fresh();
expect($fresh->subtitle)->toBe('Eine sinnvolle Subline');
expect($fresh->boilerplate_override)->toBe('PM-spezifischer Boilerplate-Text.');
expect($fresh->scheduled_at)->not->toBeNull();
expect($fresh->embargo_at)->not->toBeNull();
});
test('company accepts a boilerplate field', function () {
$company = Company::factory()->create([
'boilerplate' => 'Über die Beispiel GmbH: gegründet 1900, …',
]);
expect($company->fresh()->boilerplate)->toBe('Über die Beispiel GmbH: gegründet 1900, …');
});
test('press release attachments table works via factory and relation', function () {
$pr = PressRelease::factory()->create();
$attachment = PressReleaseAttachment::factory()->create([
'press_release_id' => $pr->id,
'original_name' => 'pressemappe.pdf',
'mime' => 'application/pdf',
'size' => 1_234_567,
'sort_order' => 1,
]);
expect($pr->fresh()->attachments)->toHaveCount(1);
expect($pr->fresh()->attachments->first()->original_name)->toBe('pressemappe.pdf');
expect($attachment->pressRelease->is($pr))->toBeTrue();
});
test('attachment is removed when press release is force-deleted', function () {
$pr = PressRelease::factory()->create();
PressReleaseAttachment::factory()->for($pr)->create();
$pr->forceDelete();
expect(PressReleaseAttachment::query()->withTrashed()->count())->toBe(0);
});