diff --git a/plugins/bc-theme-file/src/Controller/Api/Admin/ThemeFoldersController.php b/plugins/bc-theme-file/src/Controller/Api/Admin/ThemeFoldersController.php index 097c1171e4..c482410958 100644 --- a/plugins/bc-theme-file/src/Controller/Api/Admin/ThemeFoldersController.php +++ b/plugins/bc-theme-file/src/Controller/Api/Admin/ThemeFoldersController.php @@ -37,6 +37,7 @@ class ThemeFoldersController extends BcAdminApiController * @param ThemeFoldersService $service * @checked * @noTodo + * @unitTest */ public function batch(ThemeFoldersServiceInterface $service) { diff --git a/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFoldersControllerTest.php b/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFoldersControllerTest.php index b0672b8e5a..2467784eff 100644 --- a/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFoldersControllerTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFoldersControllerTest.php @@ -52,6 +52,36 @@ public function tearDown(): void parent::tearDown(); } + /** + * test batch + */ + public function test_batch() + { + $fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout/'; + (new Folder())->create($fullpath . 'delete_folder', 0777); + //APIをコール + $this->post('/baser/api/admin/bc-theme-file/theme_folders/batch.json?token=' . $this->accessToken, + [ + 'batch' => 'delete', + 'batch_targets' => [$fullpath] + ]); + //レスポンスコードを確認 + $this->assertResponseSuccess(); + //戻る値を確認 + $result = json_decode((string)$this->_response->getBody()); + $this->assertEquals('一括処理が完了しました。', $result->message); + //実際にフォルダが削除されいてるか確認すること + $this->assertFalse(file_exists($fullpath . 'delete_folder')); + + //$allowMethodは削除ではない場合、 + $this->post('/baser/api/admin/bc-theme-file/theme_folders/batch.json?token=' . $this->accessToken, + [ + 'batch' => 'create', + 'batch_targets' => [$fullpath] + ]); + $this->assertResponseCode(500); + } + /** * [API] テーマフォルダ 一覧取得 */