From c04027bf1774b69389ebd88784ef855160fe7f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Mon, 6 Nov 2023 17:49:54 +0700 Subject: [PATCH 1/5] =?UTF-8?q?=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/bc-theme-config/src/Service/ThemeConfigsService.php | 3 ++- .../tests/TestCase/Service/ThemeConfigsServiceTest.php | 1 - .../TestCase/Controller/Api/Admin/ThemeFilesControllerTest.php | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/bc-theme-config/src/Service/ThemeConfigsService.php b/plugins/bc-theme-config/src/Service/ThemeConfigsService.php index 46fe4ea757..b0e4b6ed1b 100644 --- a/plugins/bc-theme-config/src/Service/ThemeConfigsService.php +++ b/plugins/bc-theme-config/src/Service/ThemeConfigsService.php @@ -157,7 +157,8 @@ public function saveImage($entity) // サムネイルを保存 $imageresizer = new Imageresizer(); $thumbPath = $saveDir . $image . $thumbSuffix . '.' . $ext; - $imageresizer->resize($filePath, $thumbPath, 320, 320); + if (file_exists($filePath)) + $imageresizer->resize($filePath, $thumbPath, 320, 320); // エンティティを更新 $entity->{$image} = $fileName; diff --git a/plugins/bc-theme-config/tests/TestCase/Service/ThemeConfigsServiceTest.php b/plugins/bc-theme-config/tests/TestCase/Service/ThemeConfigsServiceTest.php index 08adb43c5c..63a447a4f2 100644 --- a/plugins/bc-theme-config/tests/TestCase/Service/ThemeConfigsServiceTest.php +++ b/plugins/bc-theme-config/tests/TestCase/Service/ThemeConfigsServiceTest.php @@ -13,7 +13,6 @@ use BaserCore\Model\Entity\SiteConfig; use BaserCore\Test\Factory\SiteFactory; -use BaserCore\Test\Factory\UserFactory; use BaserCore\TestSuite\BcTestCase; use BaserCore\Utility\BcContainerTrait; use BcThemeConfig\Model\Entity\ThemeConfig; diff --git a/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFilesControllerTest.php b/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFilesControllerTest.php index a82d9765a9..c813d795a8 100644 --- a/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFilesControllerTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFilesControllerTest.php @@ -61,6 +61,7 @@ public function test_add() $fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout/'; $data = [ 'theme' => 'BcThemeSample', + 'parent' => $fullpath, 'type' => 'layout', 'path' => '', 'base_name' => 'base_name_1', From fb2cdc3a13fd52d8047516e4a13dfee7107c9a38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Mon, 6 Nov 2023 18:15:56 +0700 Subject: [PATCH 2/5] =?UTF-8?q?=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/Admin/ThemeFilesControllerTest.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFilesControllerTest.php b/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFilesControllerTest.php index c813d795a8..febfeed736 100644 --- a/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFilesControllerTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Controller/Api/Admin/ThemeFilesControllerTest.php @@ -14,6 +14,8 @@ use BaserCore\Test\Factory\SiteFactory; use BaserCore\Test\Factory\UserFactory; use BaserCore\TestSuite\BcTestCase; +use BaserCore\Utility\BcFile; +use BaserCore\Utility\BcFolder; use Cake\Filesystem\File; use Cake\Filesystem\Folder; use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; @@ -317,13 +319,17 @@ public function test_upload() { //テストテーマフォルダを作成 $fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout/'; - (new Folder())->create($fullpath . 'new_folder', 0777); + $folder = new BcFolder($fullpath . 'new_folder'); + $folder->create(); //テストファイルを作成 - $filePath = TMP . 'test_upload' . DS; - (new Folder())->create($filePath, 0777); + $filePath = TMP . 'test_upload' . DS; + $folder = new BcFolder($filePath); + $folder->create(); + $testFile = $filePath . 'uploadTestFile.html'; - new File($testFile, true); + $file = new BcFile($testFile); + $file->create(); //Postデータを生成 $data = [ @@ -345,8 +351,6 @@ public function test_upload() $this->assertTrue(file_exists($fullpath . 'new_folder/uploadTestFile.html')); //テストファイルとフォルダを削除 - rmdir($filePath); - unlink($fullpath . 'new_folder/uploadTestFile.html'); - rmdir($fullpath . 'new_folder'); + $folder->delete(); } } From fc14d96a28d6d64a915f4875b3d14193687078b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Tue, 7 Nov 2023 11:44:05 +0700 Subject: [PATCH 3/5] =?UTF-8?q?=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TestCase/Controller/Admin/ThemeFilesControllerTest.php | 5 ----- 1 file changed, 5 deletions(-) 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 3b0acc42ef..38a54ab4c7 100644 --- a/plugins/bc-theme-file/tests/TestCase/Controller/Admin/ThemeFilesControllerTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Controller/Admin/ThemeFilesControllerTest.php @@ -358,11 +358,6 @@ public function test_upload() //テストファイルとフォルダを削除 rmdir($filePath); unlink($fullpath . 'uploadTestFile.html'); - - //エラーを発生した場合 - $this->post('/baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout3'); - //ステータスを確認 - $this->assertResponseCode(500); } /** From 8d44ea8293f1e5ff15c899593fd7c482d4df6939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Wed, 8 Nov 2023 07:01:14 +0700 Subject: [PATCH 4/5] =?UTF-8?q?=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/Admin/ThemeFilesControllerTest.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 38a54ab4c7..8dc942b9c2 100644 --- a/plugins/bc-theme-file/tests/TestCase/Controller/Admin/ThemeFilesControllerTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Controller/Admin/ThemeFilesControllerTest.php @@ -338,7 +338,8 @@ public function test_upload() //テストファイルを作成 $filePath = TMP . 'test_upload' . DS; - (new BcFolder($filePath))->create(); + $folder = new BcFolder($filePath); + $folder->create(); $testFile = $filePath . 'uploadTestFile.html'; $tmpFile = new BcFile($testFile); $tmpFile->create(); @@ -358,6 +359,13 @@ public function test_upload() //テストファイルとフォルダを削除 rmdir($filePath); unlink($fullpath . 'uploadTestFile.html'); + + $folder->create(); + $tmpFile->create(); + //エラーを発生した場合 + $this->post('/baser/admin/bc-theme-file/theme_files/index/BcThemeSample333333/layout3'); + //ステータスを確認 + $this->assertResponseCode(500); } /** From da63d3868a1cb26c84519af0ea9f553fcde5b1b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Wed, 8 Nov 2023 07:02:05 +0700 Subject: [PATCH 5/5] =?UTF-8?q?=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TestCase/Controller/Admin/ThemeFilesControllerTest.php | 2 ++ 1 file changed, 2 insertions(+) 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 8dc942b9c2..53c106a0e9 100644 --- a/plugins/bc-theme-file/tests/TestCase/Controller/Admin/ThemeFilesControllerTest.php +++ b/plugins/bc-theme-file/tests/TestCase/Controller/Admin/ThemeFilesControllerTest.php @@ -366,6 +366,8 @@ public function test_upload() $this->post('/baser/admin/bc-theme-file/theme_files/index/BcThemeSample333333/layout3'); //ステータスを確認 $this->assertResponseCode(500); + //テストファイルとフォルダを削除 + $folder->delete(); } /**