From 431da6c903aa9062a7f6e102dec1c04a27d7df3f Mon Sep 17 00:00:00 2001 From: Daniel Albertsen Date: Fri, 12 Jul 2024 21:58:04 +0200 Subject: [PATCH 1/2] add test to ensure artisan optimize works --- tests/Feature/Console/OptimizeTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/Feature/Console/OptimizeTest.php diff --git a/tests/Feature/Console/OptimizeTest.php b/tests/Feature/Console/OptimizeTest.php new file mode 100644 index 0000000000..93db05627a --- /dev/null +++ b/tests/Feature/Console/OptimizeTest.php @@ -0,0 +1,14 @@ +artisan('optimize')->assertSuccessful(); + } +} From a175b6a38bb2cbe727ce57566c27924369a7527b Mon Sep 17 00:00:00 2001 From: Daniel Albertsen Date: Fri, 12 Jul 2024 21:58:17 +0200 Subject: [PATCH 2/2] fix routes and tests --- routes/api.php | 8 ++++---- tests/Feature/Assets/Api/AssetFilesTest.php | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/routes/api.php b/routes/api.php index 1f43af7431..5f122b2a18 100644 --- a/routes/api.php +++ b/routes/api.php @@ -549,28 +549,28 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi Api\AssetFilesController::class, 'store' ] - )->name('api.assets.files'); + )->name('api.assets.files.store'); Route::get('{asset_id}/files', [ Api\AssetFilesController::class, 'list' ] - )->name('api.assets.files'); + )->name('api.assets.files.index'); Route::get('{asset_id}/file/{file_id}', [ Api\AssetFilesController::class, 'show' ] - )->name('api.assets.file'); + )->name('api.assets.files.show'); Route::delete('{asset_id}/file/{file_id}', [ Api\AssetFilesController::class, 'destroy' ] - )->name('api.assets.file'); + )->name('api.assets.files.destroy'); }); diff --git a/tests/Feature/Assets/Api/AssetFilesTest.php b/tests/Feature/Assets/Api/AssetFilesTest.php index 199c67e118..bc5b6043e4 100644 --- a/tests/Feature/Assets/Api/AssetFilesTest.php +++ b/tests/Feature/Assets/Api/AssetFilesTest.php @@ -22,7 +22,7 @@ class AssetFilesTest extends TestCase //Upload a file $this->actingAsForApi($user) ->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)] ]) ->assertOk(); @@ -41,7 +41,7 @@ class AssetFilesTest extends TestCase // List the files $this->actingAsForApi($user) ->getJson( - route('api.assets.files', ['asset_id' => $asset[0]["id"]])) + route('api.assets.files.index', ['asset_id' => $asset[0]["id"]])) ->assertOk() ->assertJsonStructure([ 'status', @@ -63,7 +63,7 @@ class AssetFilesTest extends TestCase //Upload a file $this->actingAsForApi($user) ->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)] ]) ->assertOk(); @@ -71,13 +71,13 @@ class AssetFilesTest extends TestCase // List the files to get the file ID $result = $this->actingAsForApi($user) ->getJson( - route('api.assets.files', ['asset_id' => $asset[0]["id"]])) + route('api.assets.files.index', ['asset_id' => $asset[0]["id"]])) ->assertOk(); // Get the file $this->actingAsForApi($user) ->get( - route('api.assets.file', [ + route('api.assets.files.show', [ 'asset_id' => $asset[0]["id"], 'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"], ])) @@ -97,7 +97,7 @@ class AssetFilesTest extends TestCase //Upload a file $this->actingAsForApi($user) ->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)] ]) ->assertOk(); @@ -105,13 +105,13 @@ class AssetFilesTest extends TestCase // List the files to get the file ID $result = $this->actingAsForApi($user) ->getJson( - route('api.assets.files', ['asset_id' => $asset[0]["id"]])) + route('api.assets.files.index', ['asset_id' => $asset[0]["id"]])) ->assertOk(); // Delete the file $this->actingAsForApi($user) ->delete( - route('api.assets.file', [ + route('api.assets.files.destroy', [ 'asset_id' => $asset[0]["id"], 'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"], ]))