snipe-it/tests/Feature/Api/Assets/AssetFilesTest.php
Scarzy 2d4af61e6c Begin to add some tests
There is currently only really a test for listing, and only for the
empty list response
2024-05-29 22:01:49 +01:00

58 lines
1.3 KiB
PHP

<?php
namespace Tests\Feature\Api\Assets;
use Tests\TestCase;
use App\Models\User;
use App\Models\Asset;
class AssetFilesTest extends TestCase
{
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
}
}