From 8468981e118f88810fd280f8f33316934f3b53c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Wed, 1 Nov 2023 18:52:59 +0700 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AE?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Controller/Admin/ThemeFilesController.php | 10 +++++----- .../Controller/Admin/ThemeFilesControllerTest.php | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/bc-theme-file/src/Controller/Admin/ThemeFilesController.php b/plugins/bc-theme-file/src/Controller/Admin/ThemeFilesController.php index 610295ee04..7c1ea78f79 100644 --- a/plugins/bc-theme-file/src/Controller/Admin/ThemeFilesController.php +++ b/plugins/bc-theme-file/src/Controller/Admin/ThemeFilesController.php @@ -203,7 +203,7 @@ public function edit(ThemeFilesAdminServiceInterface $service) $this->BcMessage->setInfo(sprintf(__d('baser_core', 'ファイル %s を更新しました。'), $themeFile->name)); $this->redirect(array_merge( [$args['theme'], $args['plugin'], $args['type']], - explode('/', dirname($args['path'])), + (str_contains($args['path'], '/'))? explode('/', dirname($args['path'])) : [], [$themeFile->name] )); } catch (BcFormFailedException $e) { @@ -242,7 +242,7 @@ public function delete(ThemeFilesAdminServiceInterface $service) $this->redirect(array_merge( ['action' => 'index', $args['theme'], $args['plugin'], $args['type']], - explode('/', dirname($args['path'])) + (str_contains($args['path'], '/'))? explode('/', dirname($args['path'])) : [] )); } @@ -270,7 +270,7 @@ public function delete_folder(ThemeFoldersAdminServiceInterface $service) $this->redirect(array_merge( ['action' => 'index', $args['theme'], $args['plugin'], $args['type']], - explode('/', dirname($args['path'])) + (str_contains($args['path'], '/'))? explode('/', dirname($args['path'])) : [] )); } @@ -316,7 +316,7 @@ public function copy(ThemeFilesAdminServiceInterface $service) $this->redirect(array_merge( ['action' => 'index', $args['theme'], $args['plugin'], $args['type']], - explode('/', dirname($args['path'])) + (str_contains($args['path'], '/'))? explode('/', dirname($args['path'])) : [] )); } @@ -343,7 +343,7 @@ public function copy_folder(ThemeFoldersAdminServiceInterface $service) $this->redirect(array_merge( ['action' => 'index', $args['theme'], $args['plugin'], $args['type']], - explode('/', dirname($args['path'])) + (str_contains($args['path'], '/'))? explode('/', dirname($args['path'])) : [] )); } 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 20dd10fa99..3b0acc42ef 100644 --- a/plugins/bc-theme-file/tests/TestCase/Controller/Admin/ThemeFilesControllerTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Controller/Admin/ThemeFilesControllerTest.php @@ -215,7 +215,7 @@ public function test_edit() //戻る値を確認 $this->assertResponseCode(302); $this->assertFlashMessage('ファイル base_name_2.php を更新しました。'); - $this->assertRedirect(['action' => 'edit/BcThemeSample/layout/./base_name_2.php']); + $this->assertRedirect(['action' => 'edit/BcThemeSample/layout/base_name_2.php']); unlink($fullpath . 'base_name_2.php'); } @@ -235,7 +235,7 @@ public function test_delete() //戻る値を確認 $this->assertResponseCode(302); $this->assertFlashMessage('ファイル base_name_1.php を削除しました。'); - $this->assertRedirect('/baser/admin/bc-theme-file/theme_files/index/BcColumn/layout/.'); + $this->assertRedirect('/baser/admin/bc-theme-file/theme_files/index/BcColumn/layout'); //実際にファイルが削除されいてるか確認すること $this->assertFalse(file_exists($fullpath . 'base_name_1.php')); } @@ -256,7 +256,7 @@ public function test_delete_folder() //戻る値を確認 $this->assertResponseCode(302); $this->assertFlashMessage('フォルダ delete_folder を削除しました。'); - $this->assertRedirect('/baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout/.'); + $this->assertRedirect('/baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout'); //実際にフォルダが削除されいてるか確認すること $this->assertFalse(file_exists($fullpath . 'delete_folder')); } @@ -296,7 +296,7 @@ public function test_copy() //戻る値を確認 $this->assertResponseCode(302); $this->assertFlashMessage('ファイル default.php をコピーしました。'); - $this->assertRedirect('baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout/.'); + $this->assertRedirect('baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout'); unlink($fullpath . 'default_copy.php'); } @@ -317,7 +317,7 @@ public function test_copy_folder() //戻る値を確認 $this->assertResponseCode(302); $this->assertFlashMessage('フォルダ new_folder をコピーしました。'); - $this->assertRedirect('baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout/.'); + $this->assertRedirect('baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout'); //テスト後に不要なフォルダーを削除 $folder->delete();