koel/tests/SettingTest.php

45 lines
1.1 KiB
PHP
Raw Normal View History

2015-12-13 04:42:28 +00:00
<?php
use App\Models\Setting;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class SettingTest extends TestCase
{
use DatabaseTransactions;
public function testSetSingleKeyValue()
{
Setting::set('foo', 'bar');
$this->seeInDatabase('settings', ['key' => 'foo', 'value' => 's:3:"bar";']);
}
public function testSetMultipleKeyValue()
{
Setting::set([
'foo' => 'bar',
'baz' => 'qux',
]);
$this->seeInDatabase('settings', ['key' => 'foo', 'value' => 's:3:"bar";']);
$this->seeInDatabase('settings', ['key' => 'baz', 'value' => 's:3:"qux";']);
}
public function testExistingShouldBeUpdated()
{
Setting::set('foo', 'bar');
Setting::set('foo', 'baz');
$this->assertEquals('baz', Setting::get('foo'));
}
public function testGet()
{
Setting::set('foo', 'bar');
Setting::set('bar', ['baz' => 'qux']);
$this->assertEquals('bar', Setting::get('foo'));
$this->assertEquals(['baz' => 'qux'], Setting::get('bar'));
}
}