20-02-2026
This commit is contained in:
parent
a8b395e20d
commit
a00c42e770
252 changed files with 28785 additions and 8907 deletions
84
tests/Unit/DashboardNewsTest.php
Normal file
84
tests/Unit/DashboardNewsTest.php
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\DashboardNews;
|
||||
use Carbon\Carbon;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DashboardNewsTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function it_returns_german_title_when_locale_is_de(): void
|
||||
{
|
||||
$news = new DashboardNews();
|
||||
$news->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());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue