From a6d9f4844bcff8896215d29b52ebd5191d55a090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Wed, 27 Sep 2023 11:55:20 +0700 Subject: [PATCH] =?UTF-8?q?ThemeFoldersController::batch=20=E3=81=AE?= =?UTF-8?q?=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88=E3=83=86=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/Admin/ThemeFoldersController.php | 1 + .../Api/Admin/ThemeFoldersControllerTest.php | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) 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] テーマフォルダ 一覧取得 */