From 2d4af61e6c2aae011fd549d8668d90833de6faac Mon Sep 17 00:00:00 2001 From: Scarzy Date: Mon, 27 May 2024 11:38:30 +0100 Subject: [PATCH] Begin to add some tests There is currently only really a test for listing, and only for the empty list response --- tests/Feature/Api/Assets/AssetFilesTest.php | 46 ++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/tests/Feature/Api/Assets/AssetFilesTest.php b/tests/Feature/Api/Assets/AssetFilesTest.php index 2f69c31885..af00619287 100644 --- a/tests/Feature/Api/Assets/AssetFilesTest.php +++ b/tests/Feature/Api/Assets/AssetFilesTest.php @@ -3,11 +3,55 @@ namespace Tests\Feature\Api\Assets; use Tests\TestCase; +use App\Models\User; +use App\Models\Asset; 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 } }