Files
ppeasy_vg12/tests/Feature/Api/SettingsControllerTest.php
T
2026-10-09 08:21:06 +02:00

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());
});