mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Add simple test case for assets
This commit is contained in:
parent
272cc1adac
commit
918239961a
35
tests/Feature/Api/Assets/AssetIndexTest.php
Normal file
35
tests/Feature/Api/Assets/AssetIndexTest.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Api\Assets;
|
||||
|
||||
use App\Models\Asset;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Illuminate\Testing\Fluent\AssertableJson;
|
||||
use Laravel\Passport\Passport;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AssetIndexTest extends TestCase
|
||||
{
|
||||
public function testAssetIndexReturnsExpectedAssets()
|
||||
{
|
||||
Setting::factory()->create();
|
||||
|
||||
Asset::factory()->count(3)->create();
|
||||
|
||||
Passport::actingAs(User::factory()->superuser()->create());
|
||||
$this->getJson(
|
||||
route('api.assets.index', [
|
||||
'sort' => 'name',
|
||||
'order' => 'asc',
|
||||
'offset' => '0',
|
||||
'limit' => '20',
|
||||
]))
|
||||
->assertOk()
|
||||
->assertJsonStructure([
|
||||
'total',
|
||||
'rows',
|
||||
])
|
||||
->assertJson(fn(AssertableJson $json) => $json->has('rows', 3)->etc());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue