Merge pull request #15082 from dbakan/fix/optimize-command

Fixed #10224: fix route names for optimize command
This commit is contained in:
snipe 2024-07-13 16:08:32 +01:00 committed by GitHub
commit be4317361d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 12 deletions

View file

@ -549,28 +549,28 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
Api\AssetFilesController::class, Api\AssetFilesController::class,
'store' 'store'
] ]
)->name('api.assets.files'); )->name('api.assets.files.store');
Route::get('{asset_id}/files', Route::get('{asset_id}/files',
[ [
Api\AssetFilesController::class, Api\AssetFilesController::class,
'list' 'list'
] ]
)->name('api.assets.files'); )->name('api.assets.files.index');
Route::get('{asset_id}/file/{file_id}', Route::get('{asset_id}/file/{file_id}',
[ [
Api\AssetFilesController::class, Api\AssetFilesController::class,
'show' 'show'
] ]
)->name('api.assets.file'); )->name('api.assets.files.show');
Route::delete('{asset_id}/file/{file_id}', Route::delete('{asset_id}/file/{file_id}',
[ [
Api\AssetFilesController::class, Api\AssetFilesController::class,
'destroy' 'destroy'
] ]
)->name('api.assets.file'); )->name('api.assets.files.destroy');
}); });

View file

@ -22,7 +22,7 @@ class AssetFilesTest extends TestCase
//Upload a file //Upload a file
$this->actingAsForApi($user) $this->actingAsForApi($user)
->post( ->post(
route('api.assets.files', ['asset_id' => $asset[0]["id"]]), [ route('api.assets.files.store', ['asset_id' => $asset[0]["id"]]), [
'file' => [UploadedFile::fake()->create("test.jpg", 100)] 'file' => [UploadedFile::fake()->create("test.jpg", 100)]
]) ])
->assertOk(); ->assertOk();
@ -41,7 +41,7 @@ class AssetFilesTest extends TestCase
// List the files // List the files
$this->actingAsForApi($user) $this->actingAsForApi($user)
->getJson( ->getJson(
route('api.assets.files', ['asset_id' => $asset[0]["id"]])) route('api.assets.files.index', ['asset_id' => $asset[0]["id"]]))
->assertOk() ->assertOk()
->assertJsonStructure([ ->assertJsonStructure([
'status', 'status',
@ -63,7 +63,7 @@ class AssetFilesTest extends TestCase
//Upload a file //Upload a file
$this->actingAsForApi($user) $this->actingAsForApi($user)
->post( ->post(
route('api.assets.files', ['asset_id' => $asset[0]["id"]]), [ route('api.assets.files.store', ['asset_id' => $asset[0]["id"]]), [
'file' => [UploadedFile::fake()->create("test.jpg", 100)] 'file' => [UploadedFile::fake()->create("test.jpg", 100)]
]) ])
->assertOk(); ->assertOk();
@ -71,13 +71,13 @@ class AssetFilesTest extends TestCase
// List the files to get the file ID // List the files to get the file ID
$result = $this->actingAsForApi($user) $result = $this->actingAsForApi($user)
->getJson( ->getJson(
route('api.assets.files', ['asset_id' => $asset[0]["id"]])) route('api.assets.files.index', ['asset_id' => $asset[0]["id"]]))
->assertOk(); ->assertOk();
// Get the file // Get the file
$this->actingAsForApi($user) $this->actingAsForApi($user)
->get( ->get(
route('api.assets.file', [ route('api.assets.files.show', [
'asset_id' => $asset[0]["id"], 'asset_id' => $asset[0]["id"],
'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"], 'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"],
])) ]))
@ -97,7 +97,7 @@ class AssetFilesTest extends TestCase
//Upload a file //Upload a file
$this->actingAsForApi($user) $this->actingAsForApi($user)
->post( ->post(
route('api.assets.files', ['asset_id' => $asset[0]["id"]]), [ route('api.assets.files.store', ['asset_id' => $asset[0]["id"]]), [
'file' => [UploadedFile::fake()->create("test.jpg", 100)] 'file' => [UploadedFile::fake()->create("test.jpg", 100)]
]) ])
->assertOk(); ->assertOk();
@ -105,13 +105,13 @@ class AssetFilesTest extends TestCase
// List the files to get the file ID // List the files to get the file ID
$result = $this->actingAsForApi($user) $result = $this->actingAsForApi($user)
->getJson( ->getJson(
route('api.assets.files', ['asset_id' => $asset[0]["id"]])) route('api.assets.files.index', ['asset_id' => $asset[0]["id"]]))
->assertOk(); ->assertOk();
// Delete the file // Delete the file
$this->actingAsForApi($user) $this->actingAsForApi($user)
->delete( ->delete(
route('api.assets.file', [ route('api.assets.files.destroy', [
'asset_id' => $asset[0]["id"], 'asset_id' => $asset[0]["id"],
'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"], 'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"],
])) ]))

View file

@ -0,0 +1,14 @@
<?php
namespace Tests\Feature\Console;
use Illuminate\Support\Facades\Artisan;
use Tests\TestCase;
class OptimizeTest extends TestCase
{
public function testOptimizeSucceeds()
{
$this->artisan('optimize')->assertSuccessful();
}
}