Updated tests
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
f29146b319
commit
8892a11e7e
1 changed files with 34 additions and 55 deletions
|
@ -16,13 +16,13 @@ class AssetFilesTest extends TestCase
|
|||
// Create an asset to work with
|
||||
$asset = Asset::factory()->count(1)->create();
|
||||
|
||||
// Create a superuser to run this as
|
||||
$user = User::factory()->superuser()->create();
|
||||
// Create a superuser to run this as
|
||||
$user = User::factory()->superuser()->create();
|
||||
|
||||
//Upload a file
|
||||
$this->actingAsForApi($user)
|
||||
//Upload a file
|
||||
$this->actingAsForApi($user)
|
||||
->post(
|
||||
route('api.assets.files.store', ['asset_id' => $asset[0]["id"]]), [
|
||||
route('api.assets.files.store', $asset), [
|
||||
'file' => [UploadedFile::fake()->create("test.jpg", 100)]
|
||||
])
|
||||
->assertOk();
|
||||
|
@ -35,19 +35,17 @@ class AssetFilesTest extends TestCase
|
|||
// Create an asset to work with
|
||||
$asset = Asset::factory()->count(1)->create();
|
||||
|
||||
// Create a superuser to run this as
|
||||
$user = User::factory()->superuser()->create();
|
||||
// Create a superuser to run this as
|
||||
$user = User::factory()->superuser()->create();
|
||||
|
||||
// List the files
|
||||
$this->actingAsForApi($user)
|
||||
->getJson(
|
||||
route('api.assets.files.index', ['asset_id' => $asset[0]["id"]]))
|
||||
// List the files
|
||||
$this->actingAsForApi($user)
|
||||
->getJson(route('api.assets.files.index', $asset))
|
||||
->assertOk()
|
||||
->assertJsonStructure([
|
||||
'status',
|
||||
'messages',
|
||||
'payload',
|
||||
]);
|
||||
->assertJsonStructure([
|
||||
'rows',
|
||||
'total',
|
||||
]);
|
||||
}
|
||||
|
||||
public function testAssetApiDownloadsFile()
|
||||
|
@ -57,31 +55,20 @@ class AssetFilesTest extends TestCase
|
|||
// Create an asset to work with
|
||||
$asset = Asset::factory()->count(1)->create();
|
||||
|
||||
// Create a superuser to run this as
|
||||
$user = User::factory()->superuser()->create();
|
||||
// Create a superuser to run this as
|
||||
$user = User::factory()->superuser()->create();
|
||||
|
||||
//Upload a file
|
||||
$this->actingAsForApi($user)
|
||||
->post(
|
||||
route('api.assets.files.store', ['asset_id' => $asset[0]["id"]]), [
|
||||
//Upload a file
|
||||
$this->actingAsForApi($user)
|
||||
->post(route('api.assets.files.store', $asset), [
|
||||
'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.index', ['asset_id' => $asset[0]["id"]]))
|
||||
->assertOk();
|
||||
|
||||
// Get the file
|
||||
$this->actingAsForApi($user)
|
||||
->get(
|
||||
route('api.assets.files.show', [
|
||||
'asset_id' => $asset[0]["id"],
|
||||
'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"],
|
||||
]))
|
||||
->assertOk();
|
||||
// List the files to get the file ID
|
||||
$result = $this->actingAsForApi($user)
|
||||
->getJson(route('api.assets.files.index', $asset))
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
public function testAssetApiDeletesFile()
|
||||
|
@ -91,30 +78,22 @@ class AssetFilesTest extends TestCase
|
|||
// Create an asset to work with
|
||||
$asset = Asset::factory()->count(1)->create();
|
||||
|
||||
// Create a superuser to run this as
|
||||
$user = User::factory()->superuser()->create();
|
||||
// Create a superuser to run this as
|
||||
$user = User::factory()->superuser()->create();
|
||||
|
||||
//Upload a file
|
||||
$this->actingAsForApi($user)
|
||||
//Upload a file
|
||||
$this->actingAsForApi($user)
|
||||
->post(
|
||||
route('api.assets.files.store', ['asset_id' => $asset[0]["id"]]), [
|
||||
route('api.assets.files.store', $asset), [
|
||||
'file' => [UploadedFile::fake()->create("test.jpg", 100)]
|
||||
])
|
||||
->assertOk();
|
||||
|
||||
// List the files to get the file ID
|
||||
$result = $this->actingAsForApi($user)
|
||||
// List the files to get the file ID
|
||||
$result = $this->actingAsForApi($user)
|
||||
->getJson(
|
||||
route('api.assets.files.index', ['asset_id' => $asset[0]["id"]]))
|
||||
route('api.assets.files.index', $asset))
|
||||
->assertOk();
|
||||
|
||||
// Delete the file
|
||||
$this->actingAsForApi($user)
|
||||
->delete(
|
||||
route('api.assets.files.destroy', [
|
||||
'asset_id' => $asset[0]["id"],
|
||||
'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"],
|
||||
]))
|
||||
->assertOk();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue