2FAuth/tests/Unit/Settings/OptionTest.php

74 lines
1.6 KiB
PHP
Raw Normal View History

2020-03-01 23:00:01 +01:00
<?php
namespace Tests\Unit\Settings;
2020-03-01 23:00:01 +01:00
use App\User;
use Tests\TestCase;
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')
->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')
->json('GET', '/api/settings/options')
2020-03-01 23:00:01 +01:00
->assertStatus(200)
->assertJson([
'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
]
]);
}
}