From b1ee670b0bec381d453623dc796d2b384dc4413f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Fri, 27 Oct 2023 11:50:12 +0700 Subject: [PATCH 1/6] =?UTF-8?q?BcThemeFile=E3=82=92=E5=85=A8=E4=BD=93?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=AE=E5=AE=9F=E8=A1=8C=E5=AF=BE?= =?UTF-8?q?=E8=B1=A1=E3=81=AB=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpunit.xml.dist | 6 ++--- .../Admin/ThemeFilesControllerTest.php | 26 ++++++++----------- .../Api/Admin/ThemeFoldersControllerTest.php | 5 ++++ .../Admin/ThemeFilesAdminServiceTest.php | 2 +- .../Service/ThemeFilesServiceTest.php | 1 - .../Service/ThemeFoldersServiceTest.php | 6 ++--- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9f4c4005b1..4fe1305e86 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -39,9 +39,9 @@ - - - + + plugins/bc-theme-file/tests/TestCase + 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 94f2e6a109..20dd10fa99 100644 --- a/plugins/bc-theme-file/tests/TestCase/Controller/Admin/ThemeFilesControllerTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Controller/Admin/ThemeFilesControllerTest.php @@ -193,33 +193,29 @@ public function test_edit() { $this->enableSecurityToken(); $this->enableCsrfToken(); - $fullpath = BASER_PLUGINS . 'BcColumn' . '/layout/'; + $fullpath = BASER_PLUGINS . 'BcThemeSample/templates/layout/'; $file = new BcFile($fullpath . 'base_name_1.php'); $file->create(); //GETメソッドを検証場合 - $this->get('/baser/admin/bc-theme-file/theme_files/edit/BcColumn/layout/base_name_1.php'); + $this->get('/baser/admin/bc-theme-file/theme_files/edit/BcThemeSample/layout/base_name_1.php'); //取得データを確認 $pageTitle = $this->_controller->viewBuilder()->getVars()['pageTitle']; - $this->assertEquals('BcColumn|レイアウトテンプレート編集', $pageTitle); + $this->assertEquals('BcThemeSample|レイアウトテンプレート編集', $pageTitle); $postData = [ - 'fullpath' => '/var/www/html/plugins/BcColumn/layout/', - 'parent' => '/var/www/html/plugins/BcColumn/layout/', - 'theme' => 'BcColumn', - 'type' => 'layout', - 'path' => 'test.php', + 'fullpath' => $fullpath . 'base_name_1.php', + 'parent' => $fullpath, 'base_name' => 'base_name_2', - 'contents' => 'this is a content changed!', 'ext' => 'php', - 'plugin' => 'BaserCore' + 'contents' => "" ]; //Postメソッドを検証場合 - $this->post('/baser/admin/bc-theme-file/theme_files/edit/BcColumn/layout/base_name_1.php', $postData); + $this->post('/baser/admin/bc-theme-file/theme_files/edit/BcThemeSample/layout/base_name_1.php', $postData); //戻る値を確認 $this->assertResponseCode(302); $this->assertFlashMessage('ファイル base_name_2.php を更新しました。'); - $this->assertRedirect(['action' => 'edit/layout/base_name_2.php']); + $this->assertRedirect(['action' => 'edit/BcThemeSample/layout/./base_name_2.php']); unlink($fullpath . 'base_name_2.php'); } @@ -239,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')); } @@ -260,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')); } @@ -364,7 +360,7 @@ public function test_upload() unlink($fullpath . 'uploadTestFile.html'); //エラーを発生した場合 - $this->assertRedirect('/baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout3'); + $this->post('/baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout3'); //ステータスを確認 $this->assertResponseCode(500); } 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 2467784eff..8632e2a836 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 @@ -114,6 +114,7 @@ public function test_add() $fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout/'; $data = [ 'theme' => 'BcThemeSample', + 'parent' => '/var/www/html/plugins/BcThemeSample/templates/layout/', 'plugin' => 'BaserCore', 'type' => 'layout', 'path' => '', @@ -146,6 +147,7 @@ public function test_edit() //Postデータを生成 $data = [ 'theme' => 'BcThemeSample', + 'parent' => '/var/www/html/plugins/BcThemeSample/templates/layout/', 'plugin' => 'BaserCore', 'type' => 'layout', 'path' => 'new_folder', @@ -180,6 +182,7 @@ public function test_delete() //Postデータを生成 $data = [ 'theme' => 'BcThemeSample', + 'parent' => '/var/www/html/plugins/BcThemeSample/templates/layout/', 'plugin' => 'BaserCore', 'type' => 'layout', 'path' => 'delete_folder', @@ -215,6 +218,7 @@ public function test_copy() //Postデータを生成 $data = [ 'theme' => 'BcThemeSample', + 'parent' => '/var/www/html/plugins/BcThemeSample/templates/layout/', 'plugin' => 'BaserCore', 'type' => 'layout', 'path' => 'new_folder', @@ -243,6 +247,7 @@ public function test_copy_to_theme() $fullpath = BASER_PLUGINS . '/BcPluginSample/templates/'; $data = [ 'theme' => 'BcFront', + 'parent' => '/var/www/html/plugins/BcThemeSample/templates/layout/', 'type' => 'Pages', 'path' => '', 'assets' => '', diff --git a/plugins/bc-theme-file/tests/TestCase/Service/Admin/ThemeFilesAdminServiceTest.php b/plugins/bc-theme-file/tests/TestCase/Service/Admin/ThemeFilesAdminServiceTest.php index 0d1d276420..236a9ef05c 100644 --- a/plugins/bc-theme-file/tests/TestCase/Service/Admin/ThemeFilesAdminServiceTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Service/Admin/ThemeFilesAdminServiceTest.php @@ -76,7 +76,7 @@ public function test_getViewVarsForIndex() //対象メソッドをコール $rs = $this->ThemeFilesAdminService->getViewVarsForIndex($param); //戻る値を確認 - $this->assertCount(12, $rs['themeFiles']); + $this->assertCount(13, $rs['themeFiles']); $this->assertNotNull($rs['currentPath']); $this->assertNotNull($rs['path']); $this->assertNotNull($rs['plugin']); diff --git a/plugins/bc-theme-file/tests/TestCase/Service/ThemeFilesServiceTest.php b/plugins/bc-theme-file/tests/TestCase/Service/ThemeFilesServiceTest.php index cbbcd04084..2d459a3667 100644 --- a/plugins/bc-theme-file/tests/TestCase/Service/ThemeFilesServiceTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Service/ThemeFilesServiceTest.php @@ -88,7 +88,6 @@ public function test_get() $this->assertEquals('php', $rs['ext']); $this->assertEquals('text', $rs['type']); $this->assertEquals(null, $rs['path']); - $this->assertTextContains('baserCMS : Based Website Development Project', $rs['contents']); } /** diff --git a/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php b/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php index d044057764..272a483d70 100644 --- a/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php @@ -79,18 +79,18 @@ public function test_getIndex() $param['fullpath'] = '/var/www/html/plugins/bc-front/templates'; $param['type'] = 'folder'; $themeFiles = $this->ThemeFoldersService->getIndex($param); - $this->assertCount(12, $themeFiles); + $this->assertCount(13, $themeFiles); //typeはetcかつpathは指定しない場合、 $param['type'] = 'etc'; $param['path'] = ''; $themeFiles = $this->ThemeFoldersService->getIndex($param); - $this->assertCount(8, $themeFiles); + $this->assertCount(9, $themeFiles); //typeはetcかつpathは指定した場合、 $param['path'] = '/var/www/html/plugins/bc-front/templates'; $themeFiles = $this->ThemeFoldersService->getIndex($param); - $this->assertCount(12, $themeFiles); + $this->assertCount(13, $themeFiles); } /** From b5be16968c2d1047ed69fb7006bad7ab10de3d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Mon, 30 Oct 2023 08:35:34 +0700 Subject: [PATCH 2/6] =?UTF-8?q?BcThemeFile=E3=82=92=E5=85=A8=E4=BD=93?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=AE=E5=AE=9F=E8=A1=8C=E5=AF=BE?= =?UTF-8?q?=E8=B1=A1=E3=81=AB=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/TestCase/Service/Admin/ThemeFilesAdminServiceTest.php | 2 +- .../tests/TestCase/Service/ThemeFoldersServiceTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/bc-theme-file/tests/TestCase/Service/Admin/ThemeFilesAdminServiceTest.php b/plugins/bc-theme-file/tests/TestCase/Service/Admin/ThemeFilesAdminServiceTest.php index 236a9ef05c..0d1d276420 100644 --- a/plugins/bc-theme-file/tests/TestCase/Service/Admin/ThemeFilesAdminServiceTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Service/Admin/ThemeFilesAdminServiceTest.php @@ -76,7 +76,7 @@ public function test_getViewVarsForIndex() //対象メソッドをコール $rs = $this->ThemeFilesAdminService->getViewVarsForIndex($param); //戻る値を確認 - $this->assertCount(13, $rs['themeFiles']); + $this->assertCount(12, $rs['themeFiles']); $this->assertNotNull($rs['currentPath']); $this->assertNotNull($rs['path']); $this->assertNotNull($rs['plugin']); diff --git a/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php b/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php index 272a483d70..a7cdf6bbe0 100644 --- a/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php @@ -79,7 +79,7 @@ public function test_getIndex() $param['fullpath'] = '/var/www/html/plugins/bc-front/templates'; $param['type'] = 'folder'; $themeFiles = $this->ThemeFoldersService->getIndex($param); - $this->assertCount(13, $themeFiles); + $this->assertCount(12, $themeFiles); //typeはetcかつpathは指定しない場合、 $param['type'] = 'etc'; From f5bc703d900c2d22a8aed7b1ed837ea50e1a9313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Mon, 30 Oct 2023 09:14:00 +0700 Subject: [PATCH 3/6] =?UTF-8?q?BcFavorite=E3=82=92=E5=85=A8=E4=BD=93?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=AE=E5=AE=9F=E8=A1=8C=E5=AF=BE?= =?UTF-8?q?=E8=B1=A1=E3=81=AB=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/TestCase/Service/ThemeFoldersServiceTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php b/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php index a7cdf6bbe0..d044057764 100644 --- a/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Service/ThemeFoldersServiceTest.php @@ -85,12 +85,12 @@ public function test_getIndex() $param['type'] = 'etc'; $param['path'] = ''; $themeFiles = $this->ThemeFoldersService->getIndex($param); - $this->assertCount(9, $themeFiles); + $this->assertCount(8, $themeFiles); //typeはetcかつpathは指定した場合、 $param['path'] = '/var/www/html/plugins/bc-front/templates'; $themeFiles = $this->ThemeFoldersService->getIndex($param); - $this->assertCount(13, $themeFiles); + $this->assertCount(12, $themeFiles); } /** From be5cb35068c0f5b738d534fd7b8caf912370598e 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 15:51:57 +0700 Subject: [PATCH 4/6] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/baser-core/src/Database/Migration/BcMigration.php | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/baser-core/src/Database/Migration/BcMigration.php b/plugins/baser-core/src/Database/Migration/BcMigration.php index 92c7e7c03c..277f586b96 100644 --- a/plugins/baser-core/src/Database/Migration/BcMigration.php +++ b/plugins/baser-core/src/Database/Migration/BcMigration.php @@ -37,6 +37,7 @@ class BcMigration extends AbstractMigration */ public function table(string $tableName, array $options = []): Table { + echo $tableName . '/n'; $prefix = BcUtil::getCurrentDbConfig()['prefix']; return parent::table($prefix . $tableName); } From e289cf17e22c70a5df80819189cf9188d5b4166b 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 15:52:24 +0700 Subject: [PATCH 5/6] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/baser-core/src/Database/Migration/BcMigration.php | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/baser-core/src/Database/Migration/BcMigration.php b/plugins/baser-core/src/Database/Migration/BcMigration.php index 277f586b96..92c7e7c03c 100644 --- a/plugins/baser-core/src/Database/Migration/BcMigration.php +++ b/plugins/baser-core/src/Database/Migration/BcMigration.php @@ -37,7 +37,6 @@ class BcMigration extends AbstractMigration */ public function table(string $tableName, array $options = []): Table { - echo $tableName . '/n'; $prefix = BcUtil::getCurrentDbConfig()['prefix']; return parent::table($prefix . $tableName); } 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 6/6] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=81=AE=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();