mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Start to implement tests
This commit is contained in:
parent
3d69721af0
commit
cf0ce1c5ea
|
@ -25,7 +25,7 @@ class NotesController extends Controller
|
||||||
|
|
||||||
$item = Asset::findOrFail($validated['id']);
|
$item = Asset::findOrFail($validated['id']);
|
||||||
|
|
||||||
// @todo: authorization
|
$this->authorize('update', $item);
|
||||||
|
|
||||||
$logaction = new Actionlog();
|
$logaction = new Actionlog();
|
||||||
$logaction->item_id = $item->id;
|
$logaction->item_id = $item->id;
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace Tests\Feature\Notes;
|
namespace Tests\Feature\Notes;
|
||||||
|
|
||||||
|
use App\Models\Asset;
|
||||||
|
use App\Models\User;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class CreateNotesTest extends TestCase
|
class CreateNotesTest extends TestCase
|
||||||
|
@ -9,6 +11,10 @@ class CreateNotesTest extends TestCase
|
||||||
public function testRequiresPermission()
|
public function testRequiresPermission()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$this->markTestIncomplete();
|
||||||
|
|
||||||
|
$this->actingAs(User::factory()->create())
|
||||||
|
->post(route('notes.store'))
|
||||||
|
->assertForbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidation()
|
public function testValidation()
|
||||||
|
@ -18,6 +24,20 @@ class CreateNotesTest extends TestCase
|
||||||
|
|
||||||
public function testCanCreateNote()
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue