From f1fbedfd511499842b93ef43bf23bbf8baa12b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Fri, 13 Oct 2023 09:39:39 +0700 Subject: [PATCH] =?UTF-8?q?admin=5FThemeFilesController::delete=5Ffolder?= =?UTF-8?q?=20=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/Admin/ThemeFilesController.php | 1 + .../Admin/ThemeFilesControllerTest.php | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/bc-theme-file/src/Controller/Admin/ThemeFilesController.php b/plugins/bc-theme-file/src/Controller/Admin/ThemeFilesController.php index 4367e5d966..43e2a86e09 100644 --- a/plugins/bc-theme-file/src/Controller/Admin/ThemeFilesController.php +++ b/plugins/bc-theme-file/src/Controller/Admin/ThemeFilesController.php @@ -248,6 +248,7 @@ public function delete(ThemeFilesAdminServiceInterface $service) * @return void * @checked * @noTodo + * @unitTest */ public function delete_folder(ThemeFoldersAdminServiceInterface $service) { diff --git a/plugins/bc-theme-file/tests/TestCase/Controller/Admin/ThemeFilesControllerTest.php b/plugins/bc-theme-file/tests/TestCase/Controller/Admin/ThemeFilesControllerTest.php index f32d8d9fbe..4dc0bd8c8c 100644 --- a/plugins/bc-theme-file/tests/TestCase/Controller/Admin/ThemeFilesControllerTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Controller/Admin/ThemeFilesControllerTest.php @@ -13,6 +13,7 @@ use BaserCore\Test\Scenario\InitAppScenario; use BaserCore\TestSuite\BcTestCase; use BaserCore\Utility\BcContainerTrait; +use BaserCore\Utility\BcFolder; use BcThemeFile\Controller\Admin\ThemeFilesController; use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; @@ -132,7 +133,20 @@ public function test_delete() */ public function test_delete_folder() { - $this->markTestIncomplete('このテストは未実装です。'); + $this->enableSecurityToken(); + $this->enableCsrfToken(); + //テストテーマフォルダを作成 + $fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout'; + $folder = new BcFolder($fullpath . DS . 'delete_folder'); + $folder->create(); + //Postメソッドを検証場合 + $this->post('/baser/admin/bc-theme-file/theme_files/delete_folder/BcThemeSample/layout/delete_folder'); + //戻る値を確認 + $this->assertResponseCode(302); + $this->assertFlashMessage('フォルダ delete_folder を削除しました。'); + $this->assertRedirect('/baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout/'); + //実際にフォルダが削除されいてるか確認すること + $this->assertFalse(file_exists($fullpath . 'delete_folder')); } /**