published()->create(['portal' => Portal::Presseecho->value]); $future = PressRelease::factory()->published()->create(['portal' => Portal::Presseecho->value, 'published_at' => now()->addDays(3)]); $draft = PressRelease::factory()->create(['status' => PressReleaseStatus::Draft->value, 'portal' => Portal::Presseecho->value]); $review = PressRelease::factory()->inReview()->create(['portal' => Portal::Presseecho->value]); $dateless = PressRelease::factory()->create(['status' => PressReleaseStatus::Published->value, 'published_at' => null, 'portal' => Portal::Presseecho->value]); $ids = PressRelease::withoutGlobalScopes()->published()->pluck('id'); expect($ids)->toContain($live->id) ->toContain($future->id) ->not->toContain($draft->id) ->not->toContain($review->id) ->not->toContain($dateless->id); }); test('visibleInArchive excludes future-dated releases', function () { $live = PressRelease::factory()->published()->create(['portal' => Portal::Presseecho->value]); $future = PressRelease::factory()->published()->create(['portal' => Portal::Presseecho->value, 'published_at' => now()->addDay()]); $ids = PressRelease::withoutGlobalScopes()->visibleInArchive()->pluck('id'); expect($ids)->toContain($live->id)->not->toContain($future->id); }); test('forPortalValues and forLanguage filter as expected', function () { $match = PressRelease::factory()->published()->create(['portal' => Portal::Presseecho->value, 'language' => 'de']); $otherPortal = PressRelease::factory()->published()->create(['portal' => Portal::Businessportal24->value, 'language' => 'de']); $otherLang = PressRelease::factory()->published()->create(['portal' => Portal::Presseecho->value, 'language' => 'en']); $ids = PressRelease::withoutGlobalScopes() ->forPortalValues([Portal::Presseecho->value, Portal::Both->value]) ->forLanguage('de') ->pluck('id'); expect($ids)->toContain($match->id) ->not->toContain($otherPortal->id) ->not->toContain($otherLang->id); });