2020-03-01 23:00:01 +01:00
|
|
|
<?php
|
|
|
|
|
2020-03-09 20:24:25 +01:00
|
|
|
namespace Tests\Unit\Settings;
|
2020-03-01 23:00:01 +01:00
|
|
|
|
|
|
|
use App\User;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
2020-03-09 20:24:25 +01:00
|
|
|
class OptionTest extends TestCase
|
2020-03-01 23:00:01 +01:00
|
|
|
{
|
|
|
|
/** @var \App\User */
|
|
|
|
protected $user;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->user = factory(User::class)->create();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* test Settings storage via API
|
|
|
|
*
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function testSettingsStorage()
|
|
|
|
{
|
|
|
|
$response = $this->actingAs($this->user, 'api')
|
2020-03-09 20:24:25 +01:00
|
|
|
->json('POST', '/api/settings/options', [
|
2020-03-01 23:00:01 +01:00
|
|
|
'setting_1' => 'value_1',
|
2020-03-23 21:58:15 +01:00
|
|
|
'setting_2' => true,
|
|
|
|
'setting_3' => false,
|
2020-03-01 23:00:01 +01:00
|
|
|
])
|
|
|
|
->assertStatus(200)
|
|
|
|
->assertJson([
|
|
|
|
'message' => __('settings.forms.setting_saved'),
|
|
|
|
'settings' => [
|
|
|
|
'setting_1' => 'value_1',
|
2020-03-23 21:58:15 +01:00
|
|
|
'setting_2' => true,
|
|
|
|
'setting_3' => false,
|
2020-03-01 23:00:01 +01:00
|
|
|
]
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* test Settings list fetching via API
|
|
|
|
*
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function testSettingsIndexListing()
|
|
|
|
{
|
|
|
|
option(['setting_1' => 'value_1']);
|
2020-03-23 21:58:15 +01:00
|
|
|
option(['setting_2' => true]);
|
|
|
|
option(['setting_3' => false]);
|
2020-03-01 23:00:01 +01:00
|
|
|
|
|
|
|
$response = $this->actingAs($this->user, 'api')
|
2020-03-09 20:24:25 +01:00
|
|
|
->json('GET', '/api/settings/options')
|
2020-03-01 23:00:01 +01:00
|
|
|
->assertStatus(200)
|
|
|
|
->assertJson([
|
|
|
|
'settings' => [
|
2020-03-13 22:10:36 +01:00
|
|
|
'setting_1' => 'value_1',
|
2020-03-23 21:58:15 +01:00
|
|
|
'setting_2' => true,
|
|
|
|
'setting_3' => false,
|
2020-03-01 23:00:01 +01:00
|
|
|
]
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|