A free open source IT asset/license management system
Start to implement tests
Marcus Moorecf0ce1c5ea2f
diff --git a/app/Http/Controllers/NotesController.php b/app/Http/Controllers/NotesController.phpindex dd32b17ebc..e24436e5ad 100644--- a/app/Http/Controllers/NotesController.php+++ b/app/Http/Controllers/NotesController.php@@ -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;diff --git a/tests/Feature/Notes/CreateNotesTest.php b/tests/Feature/Notes/CreateNotesTest.phpindex a993e7508f..a42d501bb9 100644--- a/tests/Feature/Notes/CreateNotesTest.php+++ b/tests/Feature/Notes/CreateNotesTest.php@@ -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 TestCasepublic function testRequiresPermission(){$this->markTestIncomplete();++ $this->actingAs(User::factory()->create())+ ->post(route('notes.store'))+ ->assertForbidden();}public function testValidation()@@ -18,6 +24,20 @@ class CreateNotesTest extends TestCasepublic 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}}