<?php
declare(strict_types=1);
namespace Tests\Feature\Admin;
use App\Jobs\SendWebMentions;
use App\Models\Note;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class NotesTest extends TestCase
{
use RefreshDatabase;
#[Test]
public function notesPageLoads(): void
$user = User::factory()->make();
$response = $this->actingAs($user)->get('/admin/notes');
$response->assertViewIs('admin.notes.index');
}
public function noteCreatePageLoads(): void
$response = $this->actingAs($user)->get('/admin/notes/create');
$response->assertViewIs('admin.notes.create');
public function adminCanCreateNewNote(): void
$this->actingAs($user)->post('/admin/notes', [
'content' => 'A new test note',
]);
$this->assertDatabaseHas('notes', [
'note' => 'A new test note',
public function noteEditFormLoads(): void
$note = Note::factory()->create();
$response = $this->actingAs($user)->get('/admin/notes/' . $note->id . '/edit');
$response->assertViewIs('admin.notes.edit');
public function adminCanEditNote(): void
Queue::fake();
$this->actingAs($user)->post('/admin/notes/' . $note->id, [
'_method' => 'PUT',
'content' => 'An edited note',
'webmentions' => true,
'note' => 'An edited note',
Queue::assertPushed(SendWebMentions::class);
public function adminCanDeleteNote(): void
'_method' => 'DELETE',
$this->assertSoftDeleted('notes', [
'id' => $note->id,