Start to implement tests

This commit is contained in:
Marcus Moore 2025-02-18 16:24:52 -08:00
parent 3d69721af0
commit cf0ce1c5ea
No known key found for this signature in database
2 changed files with 22 additions and 2 deletions

View file

@ -25,7 +25,7 @@ class NotesController extends Controller
$item = Asset::findOrFail($validated['id']);
// @todo: authorization
$this->authorize('update', $item);
$logaction = new Actionlog();
$logaction->item_id = $item->id;

View file

@ -2,6 +2,8 @@
namespace Tests\Feature\Notes;
use App\Models\Asset;
use App\Models\User;
use Tests\TestCase;
class CreateNotesTest extends TestCase
@ -9,6 +11,10 @@ class CreateNotesTest extends TestCase
public function testRequiresPermission()
{
$this->markTestIncomplete();
$this->actingAs(User::factory()->create())
->post(route('notes.store'))
->assertForbidden();
}
public function testValidation()
@ -18,6 +24,20 @@ class CreateNotesTest extends TestCase
public function testCanCreateNote()
{
$this->markTestIncomplete();
// @todo: make dynamic?
$actor = User::factory()->editAssets()->create();
$asset = Asset::factory()->create();
$this->actingAs($actor)
->post(route('notes.store'), [
'id' => $asset->id,
'type' => 'asset',
'note' => 'my special note',
])
->assertRedirect(route('hardware.show', $asset->id) . '#history');
// @todo: assert action log created with expected data
}
}