43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Tests\Unit\Models;
|
||
|
|
|
||
|
|
use App\Models\Setting;
|
||
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||
|
|
use Tests\TestCase;
|
||
|
|
|
||
|
|
class SettingTest extends TestCase
|
||
|
|
{
|
||
|
|
use RefreshDatabase;
|
||
|
|
|
||
|
|
public function test_get_article_publishing_interval_returns_default_when_not_set(): void
|
||
|
|
{
|
||
|
|
$this->assertSame(5, Setting::getArticlePublishingInterval());
|
||
|
|
}
|
||
|
|
|
||
|
|
public function test_get_article_publishing_interval_returns_stored_value(): void
|
||
|
|
{
|
||
|
|
Setting::set('article_publishing_interval', '10');
|
||
|
|
|
||
|
|
$this->assertSame(10, Setting::getArticlePublishingInterval());
|
||
|
|
}
|
||
|
|
|
||
|
|
public function test_set_article_publishing_interval_persists_value(): void
|
||
|
|
{
|
||
|
|
Setting::setArticlePublishingInterval(15);
|
||
|
|
|
||
|
|
$this->assertSame(15, Setting::getArticlePublishingInterval());
|
||
|
|
$this->assertDatabaseHas('settings', [
|
||
|
|
'key' => 'article_publishing_interval',
|
||
|
|
'value' => '15',
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function test_set_article_publishing_interval_zero(): void
|
||
|
|
{
|
||
|
|
Setting::setArticlePublishingInterval(0);
|
||
|
|
|
||
|
|
$this->assertSame(0, Setting::getArticlePublishingInterval());
|
||
|
|
}
|
||
|
|
}
|