Files
2026-01-06 15:35:59 -05:00

101 lines
2.4 KiB
PHP

<?php
namespace Tests\Feature\Http\Controllers;
use App\Models\Setting;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use JMac\Testing\Traits\AdditionalAssertions;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
/**
* @see \App\Http\Controllers\SettingController
*/
final class SettingControllerTest extends TestCase
{
use AdditionalAssertions, RefreshDatabase, WithFaker;
#[Test]
public function index_behaves_as_expected(): void
{
$settings = Setting::factory()->count(3)->create();
$response = $this->get(route('settings.index'));
$response->assertOk();
$response->assertJsonStructure([]);
}
#[Test]
public function store_uses_form_request_validation(): void
{
$this->assertActionUsesFormRequest(
\App\Http\Controllers\SettingController::class,
'store',
\App\Http\Requests\SettingStoreRequest::class
);
}
#[Test]
public function store_saves(): void
{
$response = $this->post(route('settings.store'));
$response->assertCreated();
$response->assertJsonStructure([]);
$this->assertDatabaseHas(settings, [ /* ... */ ]);
}
#[Test]
public function show_behaves_as_expected(): void
{
$setting = Setting::factory()->create();
$response = $this->get(route('settings.show', $setting));
$response->assertOk();
$response->assertJsonStructure([]);
}
#[Test]
public function update_uses_form_request_validation(): void
{
$this->assertActionUsesFormRequest(
\App\Http\Controllers\SettingController::class,
'update',
\App\Http\Requests\SettingUpdateRequest::class
);
}
#[Test]
public function update_behaves_as_expected(): void
{
$setting = Setting::factory()->create();
$response = $this->put(route('settings.update', $setting));
$setting->refresh();
$response->assertOk();
$response->assertJsonStructure([]);
}
#[Test]
public function destroy_deletes_and_responds_with(): void
{
$setting = Setting::factory()->create();
$response = $this->delete(route('settings.destroy', $setting));
$response->assertNoContent();
$this->assertModelMissing($setting);
}
}