title = 'Deutsche Überschrift'; $news->trans_title = ['en' => 'English Title']; app()->setLocale('de'); $this->assertEquals('Deutsche Überschrift', $news->getLang('title')); } /** @test */ public function it_returns_translated_title_when_locale_is_set(): void { $news = new DashboardNews(); $news->title = 'Deutsche Überschrift'; $news->trans_title = ['en' => 'English Title']; app()->setLocale('en'); $this->assertEquals('English Title', $news->getLang('title')); } /** @test */ public function it_falls_back_to_german_when_translation_is_missing(): void { $news = new DashboardNews(); $news->title = 'Deutsche Überschrift'; $news->trans_title = ['en' => '']; app()->setLocale('en'); $this->assertEquals('Deutsche Überschrift', $news->getLang('title')); } /** @test */ public function it_formats_display_date_correctly(): void { $news = new DashboardNews(); $news->display_date = Carbon::create(2026, 2, 19); $this->assertEquals('19.02.2026', $news->getDisplayDateFormatted()); } /** @test */ public function it_falls_back_to_created_at_when_display_date_is_null(): void { $news = new DashboardNews(); $news->display_date = null; $news->created_at = Carbon::create(2025, 12, 1); $this->assertEquals('01.12.2025', $news->getDisplayDateFormatted()); } /** @test */ public function it_returns_empty_string_when_no_dates_are_set(): void { $news = new DashboardNews(); $news->display_date = null; $news->created_at = null; $this->assertEquals('', $news->getDisplayDateFormatted()); } /** @test */ public function it_detects_no_file_links_when_empty(): void { $news = new DashboardNews(); $news->file_links = null; $this->assertFalse($news->hasFileLinks()); } }