Add setting route test

This commit is contained in:
An Phan 2016-05-27 17:07:52 +08:00
parent e5f77399fd
commit 2ca5047a9d

View file

@ -1,11 +1,13 @@
<?php
use App\Models\User;
use App\Models\Setting;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutMiddleware;
class SettingTest extends TestCase
{
use DatabaseTransactions;
use DatabaseTransactions, WithoutMiddleware;
public function testSetSingleKeyValue()
{
@ -41,4 +43,16 @@ class SettingTest extends TestCase
$this->assertEquals('bar', Setting::get('foo'));
$this->assertEquals(['baz' => 'qux'], Setting::get('bar'));
}
public function testApplicationSetting()
{
Media::shouldReceive('sync')->once();
$dir = dirname(__FILE__);
$this->actingAs(factory(User::class, 'admin')->create())
->post('/api/settings', ['media_path' => $dir])
->seeStatusCode(200);
$this->assertEquals($dir, Setting::get('media_path'));
}
}