27 lines
698 B
PHP
27 lines
698 B
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use Facades\Tests\Setup\UserFactory;
|
|
use Tests\Feature\ApiTestCase;
|
|
|
|
test('only authenticated users can view app settings', function () {
|
|
$this->getJson('/api/settings')->assertStatus(401);
|
|
});
|
|
|
|
test('get settings without permission', function () {
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user, ApiTestCase::API_GUARD)
|
|
->getJson('/api/settings')
|
|
->assertStatus(403);
|
|
});
|
|
|
|
test('get settings', function () {
|
|
$user = UserFactory::withPermissions('settings.general')->create();
|
|
|
|
$this->actingAs($user, ApiTestCase::API_GUARD)
|
|
->getJson('/api/settings')
|
|
->assertOk()
|
|
->assertJson(Setting::all());
|
|
});
|