mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Added location API index test
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
4089b4cd68
commit
6da6411f3b
45
tests/Feature/Locations/Api/IndexLocationsTest.php
Normal file
45
tests/Feature/Locations/Api/IndexLocationsTest.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Locations\Api;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\Location;
|
||||
use App\Models\User;
|
||||
use Illuminate\Testing\Fluent\AssertableJson;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LocationIndexTest extends TestCase
|
||||
{
|
||||
public function testViewingLocationIndexRequiresAuthentication()
|
||||
{
|
||||
$this->getJson(route('api.locations.index'))->assertRedirect();
|
||||
}
|
||||
|
||||
public function testViewingLocationIndexRequiresPermission()
|
||||
{
|
||||
$this->actingAsForApi(User::factory()->create())
|
||||
->getJson(route('api.locations.index'))
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function testLocationIndexReturnsExpectedLocations()
|
||||
{
|
||||
Location::factory()->count(3)->create();
|
||||
|
||||
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||
->getJson(
|
||||
route('api.locations.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