54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Livewire;
|
|
|
|
use App\Livewire\Settings;
|
|
use App\Models\Setting;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Livewire;
|
|
use Tests\TestCase;
|
|
|
|
class SettingsTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_mount_loads_feed_staleness_threshold(): void
|
|
{
|
|
Setting::setFeedStalenessThreshold(72);
|
|
|
|
Livewire::test(Settings::class)
|
|
->assertSet('feedStalenessThreshold', 72);
|
|
}
|
|
|
|
public function test_mount_loads_default_feed_staleness_threshold(): void
|
|
{
|
|
Livewire::test(Settings::class)
|
|
->assertSet('feedStalenessThreshold', 48);
|
|
}
|
|
|
|
public function test_update_feed_staleness_threshold_saves_value(): void
|
|
{
|
|
Livewire::test(Settings::class)
|
|
->set('feedStalenessThreshold', 24)
|
|
->call('updateFeedStalenessThreshold')
|
|
->assertHasNoErrors();
|
|
|
|
$this->assertSame(24, Setting::getFeedStalenessThreshold());
|
|
}
|
|
|
|
public function test_update_feed_staleness_threshold_validates_minimum(): void
|
|
{
|
|
Livewire::test(Settings::class)
|
|
->set('feedStalenessThreshold', -1)
|
|
->call('updateFeedStalenessThreshold')
|
|
->assertHasErrors(['feedStalenessThreshold' => 'min']);
|
|
}
|
|
|
|
public function test_update_feed_staleness_threshold_shows_success_message(): void
|
|
{
|
|
Livewire::test(Settings::class)
|
|
->set('feedStalenessThreshold', 24)
|
|
->call('updateFeedStalenessThreshold')
|
|
->assertSet('successMessage', 'Settings updated successfully!');
|
|
}
|
|
}
|