Skip to content

A free open source IT asset/license management system

Finish implementing test

Marcus Moore0190ccea27cc
diff --git a/tests/Feature/Notes/CreateNotesTest.php b/tests/Feature/Notes/CreateNotesTest.php
index a42d501bb9..789991adb0 100644
--- a/tests/Feature/Notes/CreateNotesTest.php
+++ b/tests/Feature/Notes/CreateNotesTest.php
@@ -22,22 +22,32 @@ class CreateNotesTest extends TestCase
$this->markTestIncomplete();
}
- public function testCanCreateNote()
+ public function testCanCreateNoteForAsset()
{
- // @todo: make dynamic?
-
$actor = User::factory()->editAssets()->create();
$asset = Asset::factory()->create();
$this->actingAs($actor)
+ ->withHeader('User-Agent', 'Custom User Agent For Test')
->post(route('notes.store'), [
+ '_token' => '_token-to-simulate-request-from-gui',
'id' => $asset->id,
'type' => 'asset',
'note' => 'my special note',
])
->assertRedirect(route('hardware.show', $asset->id) . '#history');
- // @todo: assert action log created with expected data
+ $this->assertDatabaseHas('action_logs', [
+ 'created_by' => $actor->id,
+ 'action_type' => 'note added',
+ 'target_id' => null,
+ 'target_type' => null,
+ 'note' => 'my special note',
+ 'item_type' => Asset::class,
+ 'item_id' => $asset->id,
+ 'action_source' => 'gui',
+ 'user_agent' => 'Custom User Agent For Test',
+ ]);
}
}