From ca9d4e31552b7f3a07543e3cfc6f4df0e2fcc5f8 Mon Sep 17 00:00:00 2001 From: Scarzy Date: Mon, 27 May 2024 13:08:18 +0100 Subject: [PATCH] Get the tests for download and delete working --- tests/Feature/Api/Assets/AssetFilesTest.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/Feature/Api/Assets/AssetFilesTest.php b/tests/Feature/Api/Assets/AssetFilesTest.php index e799ba1a31..2c19d5dc77 100644 --- a/tests/Feature/Api/Assets/AssetFilesTest.php +++ b/tests/Feature/Api/Assets/AssetFilesTest.php @@ -37,6 +37,8 @@ class AssetFilesTest extends TestCase // Create a superuser to run this as $user = User::factory()->superuser()->create(); + + // List the files $this->actingAsForApi($user) ->getJson( route('api.assets.files', ['asset_id' => $asset[0]["id"]])) @@ -63,14 +65,21 @@ class AssetFilesTest extends TestCase ->post( route('api.assets.files', ['asset_id' => $asset[0]["id"]]), [ 'file' => [UploadedFile::fake()->create("test.jpg", 100)] - ])->assertOk(); + ]) + ->assertOk(); + + // List the files to get the file ID + $result = $this->actingAsForApi($user) + ->getJson( + route('api.assets.files', ['asset_id' => $asset[0]["id"]])) + ->assertOk(); // Get the file $this->actingAsForApi($user) ->get( route('api.assets.file', [ 'asset_id' => $asset[0]["id"], - 'file_id' => 1, + 'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"], ])) ->assertOk(); } @@ -93,12 +102,18 @@ class AssetFilesTest extends TestCase ]) ->assertOk(); + // List the files to get the file ID + $result = $this->actingAsForApi($user) + ->getJson( + route('api.assets.files', ['asset_id' => $asset[0]["id"]])) + ->assertOk(); + // Delete the file $this->actingAsForApi($user) ->delete( route('api.assets.file', [ 'asset_id' => $asset[0]["id"], - 'file_id' => 1, + 'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"], ])) ->assertOk(); }