mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Begin to add some tests
There is currently only really a test for listing, and only for the empty list response
This commit is contained in:
parent
45329912e6
commit
2d4af61e6c
|
@ -3,11 +3,55 @@
|
||||||
namespace Tests\Feature\Api\Assets;
|
namespace Tests\Feature\Api\Assets;
|
||||||
|
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Asset;
|
||||||
|
|
||||||
class AssetFilesTest extends TestCase
|
class AssetFilesTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testExample()
|
public function testAssetApiAcceptsFileUpload()
|
||||||
{
|
{
|
||||||
|
// Upload a file to an asset
|
||||||
|
|
||||||
|
// Create an asset to work with
|
||||||
|
$asset = Asset::factory()->count(1)->create();
|
||||||
//
|
//
|
||||||
|
//// Upload a file
|
||||||
|
//// Create a superuser to run this as
|
||||||
|
//$this->actingAsForApi(User::factory()->superuser()->create())
|
||||||
|
// ->postJson(
|
||||||
|
// route('api.asset.files', $asset), [
|
||||||
|
// 'file[]' =>
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAssetApiListsFiles()
|
||||||
|
{
|
||||||
|
// List all files on an asset
|
||||||
|
|
||||||
|
// Create an asset to work with
|
||||||
|
$asset = Asset::factory()->count(1)->create();
|
||||||
|
|
||||||
|
print($asset);
|
||||||
|
|
||||||
|
// Create a superuser to run this as
|
||||||
|
$user = User::factory()->superuser()->create();
|
||||||
|
$this->actingAsForApi($user)
|
||||||
|
->getJson(
|
||||||
|
route('api.assets.files', ['asset_id' => $asset[0]["id"]]))
|
||||||
|
->assertOk()
|
||||||
|
->assertJsonStructure([
|
||||||
|
'status',
|
||||||
|
'messages',
|
||||||
|
'payload',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAssetApiDownloadsFile()
|
||||||
|
{
|
||||||
|
// Download a file from an asset
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAssetApiDeletesFile()
|
||||||
|
{
|
||||||
|
// Delete a file from an asset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue