Get the tests for download and delete working

This commit is contained in:
Scarzy 2024-05-27 13:08:18 +01:00
parent 633bcbb6c4
commit ca9d4e3155

View file

@ -37,6 +37,8 @@ class AssetFilesTest extends TestCase
// Create a superuser to run this as // Create a superuser to run this as
$user = User::factory()->superuser()->create(); $user = User::factory()->superuser()->create();
// List the files
$this->actingAsForApi($user) $this->actingAsForApi($user)
->getJson( ->getJson(
route('api.assets.files', ['asset_id' => $asset[0]["id"]])) route('api.assets.files', ['asset_id' => $asset[0]["id"]]))
@ -63,14 +65,21 @@ class AssetFilesTest extends TestCase
->post( ->post(
route('api.assets.files', ['asset_id' => $asset[0]["id"]]), [ route('api.assets.files', ['asset_id' => $asset[0]["id"]]), [
'file' => [UploadedFile::fake()->create("test.jpg", 100)] '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 // Get the file
$this->actingAsForApi($user) $this->actingAsForApi($user)
->get( ->get(
route('api.assets.file', [ route('api.assets.file', [
'asset_id' => $asset[0]["id"], 'asset_id' => $asset[0]["id"],
'file_id' => 1, 'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"],
])) ]))
->assertOk(); ->assertOk();
} }
@ -93,12 +102,18 @@ class AssetFilesTest extends TestCase
]) ])
->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();
// Delete the file // Delete the file
$this->actingAsForApi($user) $this->actingAsForApi($user)
->delete( ->delete(
route('api.assets.file', [ route('api.assets.file', [
'asset_id' => $asset[0]["id"], 'asset_id' => $asset[0]["id"],
'file_id' => 1, 'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"],
])) ]))
->assertOk(); ->assertOk();
} }