From 5f8693085dda85145f90799bcbc8baae603a3ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Mon, 7 Oct 2024 11:01:45 +0900 Subject: [PATCH 01/60] =?UTF-8?q?BcContentsHelper::getRelatedSiteLinks()?= =?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=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Model/Table/ContentsTable.php | 2 +- .../src/View/Helper/BcContentsHelper.php | 3 +++ .../View/Helper/BcContentsHelperTest.php | 24 +++++++------------ 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/plugins/baser-core/src/Model/Table/ContentsTable.php b/plugins/baser-core/src/Model/Table/ContentsTable.php index 8968817f53..2b049a09bf 100644 --- a/plugins/baser-core/src/Model/Table/ContentsTable.php +++ b/plugins/baser-core/src/Model/Table/ContentsTable.php @@ -1221,7 +1221,7 @@ public function getRelatedSiteContents(int $id, array $options = []): array ['Sites.status' => true] ]; if ($options['excludeIds']) { - $conditions['Contents.site_id <>'] = $options['excludeIds']; + $conditions['Contents.site_id NOT IN'] = $options['excludeIds']; } $conditions = array_merge($conditions, $this->getConditionAllowPublish()); diff --git a/plugins/baser-core/src/View/Helper/BcContentsHelper.php b/plugins/baser-core/src/View/Helper/BcContentsHelper.php index e7c1a068b7..ac541229bd 100644 --- a/plugins/baser-core/src/View/Helper/BcContentsHelper.php +++ b/plugins/baser-core/src/View/Helper/BcContentsHelper.php @@ -402,6 +402,9 @@ public function getRelatedSiteContents(?int $id = null, array $options = []): ar * * @param int $id * @return array + * @noTodo + * @checked + * @unitTest */ public function getRelatedSiteLinks($id = null, $options = []) { diff --git a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php index 3c4b522c83..1c6a02a4cd 100644 --- a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php +++ b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php @@ -14,6 +14,7 @@ use BaserCore\Model\Entity\Content; use BaserCore\Model\Entity\Site; use BaserCore\Test\Factory\ContentFactory; +use BaserCore\Test\Factory\SiteFactory; use BaserCore\Test\Scenario\ContentsScenario; use BaserCore\Test\Scenario\PermissionsScenario; use BaserCore\Test\Scenario\SitesScenario; @@ -377,9 +378,10 @@ public static function getRelatedSiteContentsDataProvider() */ public function testGetRelatedSiteLinks($id, $options, $expect) { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); - $this->BcContents->request = $this->_getRequest('/'); - $_SERVER['HTTP_USER_AGENT'] = 'iPhone'; + ContentFactory::make(['site_id' => 1, 'url' => '/'])->persist(); + ContentFactory::make(['site_id' => 2, 'main_site_content_id' => 1, 'url' => '/en/'])->persist(); + ContentFactory::make(['site_id' => 2, 'main_site_content_id' => 2, 'url' => '/en/about'])->persist(); + $result = $this->BcContents->getRelatedSiteLinks($id, $options); $this->assertEquals($expect, $result); } @@ -387,18 +389,10 @@ public function testGetRelatedSiteLinks($id, $options, $expect) public static function getRelatedSiteLinksDataProvider() { return [ - // IDが空 オプションも空 - [null, [], [['prefix' => '', 'name' => 'パソコン', 'url' => '/index'], ['prefix' => 'mobile', 'name' => 'ケータイ', 'url' => '/m/index'], ['prefix' => 'smartphone', 'name' => 'スマートフォン', 'url' => '/s/index']]], - // IDが空 オプション excludeIds 0~2 - ['', ['excludeIds' => [0]], [0 => ['prefix' => 'mobile', 'name' => 'ケータイ', 'url' => '/m/index'], 1 => ['prefix' => 'smartphone', 'name' => 'スマートフォン', 'url' => '/s/index']]], - [false, ['excludeIds' => [1]], [['prefix' => '', 'name' => 'パソコン', 'url' => '/index'], ['prefix' => 'smartphone', 'name' => 'スマートフォン', 'url' => '/s/index']]], - [0, ['excludeIds' => [2]], [['prefix' => '', 'name' => 'パソコン', 'url' => '/index'], ['prefix' => 'mobile', 'name' => 'ケータイ', 'url' => '/m/index']]], - // IDが空 オプション excludeIds 3~ - [0, ['excludeIds' => [3]], [['prefix' => '', 'name' => 'パソコン', 'url' => '/index'], ['prefix' => 'mobile', 'name' => 'ケータイ', 'url' => '/m/index'], ['prefix' => 'smartphone', 'name' => 'スマートフォン', 'url' => '/s/index']]], - [0, ['excludeIds' => [99]], [['prefix' => '', 'name' => 'パソコン', 'url' => '/index'], ['prefix' => 'mobile', 'name' => 'ケータイ', 'url' => '/m/index'], ['prefix' => 'smartphone', 'name' => 'スマートフォン', 'url' => '/s/index']]], - // IDに値が入っていれば、false - [1, ['excludeIds' => [0]], [['prefix' => 'mobile', 'name' => 'ケータイ', 'url' => '/m/'], ['prefix' => 'smartphone', 'name' => 'スマートフォン', 'url' => '/s/']]], - [99, [], []], + [null, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/index']]], + [0, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/index']]], + [1, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/index'], ['prefix' => 'en', 'name' => '英語サイト', 'url' => '/en/']]], + [1, ['excludeIds' => [1]], [['prefix' => 'en', 'name' => '英語サイト', 'url' => '/en/']]], ]; } From eddd3dcae3312ec5f69934592a41a2d155b54878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Mon, 7 Oct 2024 11:33:45 +0900 Subject: [PATCH 02/60] =?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 --- .../tests/TestCase/View/Helper/BcContentsHelperTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php index 1c6a02a4cd..e83feb542f 100644 --- a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php +++ b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php @@ -378,6 +378,7 @@ public static function getRelatedSiteContentsDataProvider() */ public function testGetRelatedSiteLinks($id, $options, $expect) { + $this->truncateTable('contents'); ContentFactory::make(['site_id' => 1, 'url' => '/'])->persist(); ContentFactory::make(['site_id' => 2, 'main_site_content_id' => 1, 'url' => '/en/'])->persist(); ContentFactory::make(['site_id' => 2, 'main_site_content_id' => 2, 'url' => '/en/about'])->persist(); From bbab69f88dd6fb8cdb4b1d82bb8ff3ff523bbad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Mon, 7 Oct 2024 12:02:53 +0900 Subject: [PATCH 03/60] =?UTF-8?q?=20=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 --- .../tests/TestCase/View/Helper/BcContentsHelperTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php index e83feb542f..c5a91f1634 100644 --- a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php +++ b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php @@ -378,7 +378,6 @@ public static function getRelatedSiteContentsDataProvider() */ public function testGetRelatedSiteLinks($id, $options, $expect) { - $this->truncateTable('contents'); ContentFactory::make(['site_id' => 1, 'url' => '/'])->persist(); ContentFactory::make(['site_id' => 2, 'main_site_content_id' => 1, 'url' => '/en/'])->persist(); ContentFactory::make(['site_id' => 2, 'main_site_content_id' => 2, 'url' => '/en/about'])->persist(); @@ -391,7 +390,7 @@ public static function getRelatedSiteLinksDataProvider() { return [ [null, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/index']]], - [0, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/index']]], + [0, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/']]], [1, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/index'], ['prefix' => 'en', 'name' => '英語サイト', 'url' => '/en/']]], [1, ['excludeIds' => [1]], [['prefix' => 'en', 'name' => '英語サイト', 'url' => '/en/']]], ]; From 327da733c53e2acf1cbc9bd155526895d7237f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Tue, 8 Oct 2024 09:14:15 +0900 Subject: [PATCH 04/60] =?UTF-8?q?=20=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 --- .../tests/TestCase/View/Helper/BcContentsHelperTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php index c5a91f1634..00414dec71 100644 --- a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php +++ b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php @@ -378,7 +378,7 @@ public static function getRelatedSiteContentsDataProvider() */ public function testGetRelatedSiteLinks($id, $options, $expect) { - ContentFactory::make(['site_id' => 1, 'url' => '/'])->persist(); + ContentFactory::make(['site_id' => 1, 'url' => '/index'])->persist(); ContentFactory::make(['site_id' => 2, 'main_site_content_id' => 1, 'url' => '/en/'])->persist(); ContentFactory::make(['site_id' => 2, 'main_site_content_id' => 2, 'url' => '/en/about'])->persist(); @@ -390,7 +390,7 @@ public static function getRelatedSiteLinksDataProvider() { return [ [null, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/index']]], - [0, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/']]], + [0, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/index']]], [1, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/index'], ['prefix' => 'en', 'name' => '英語サイト', 'url' => '/en/']]], [1, ['excludeIds' => [1]], [['prefix' => 'en', 'name' => '英語サイト', 'url' => '/en/']]], ]; From 33d2ad9cef132e7ce8f6a74d626b496b842c2cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Wed, 9 Oct 2024 08:53:36 +0900 Subject: [PATCH 05/60] =?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 --- .../tests/TestCase/View/Helper/BcContentsHelperTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php index 00414dec71..7520a615b8 100644 --- a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php +++ b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php @@ -378,7 +378,7 @@ public static function getRelatedSiteContentsDataProvider() */ public function testGetRelatedSiteLinks($id, $options, $expect) { - ContentFactory::make(['site_id' => 1, 'url' => '/index'])->persist(); + ContentFactory::make(['site_id' => 1, 'url' => '/'])->persist(); ContentFactory::make(['site_id' => 2, 'main_site_content_id' => 1, 'url' => '/en/'])->persist(); ContentFactory::make(['site_id' => 2, 'main_site_content_id' => 2, 'url' => '/en/about'])->persist(); @@ -390,8 +390,8 @@ public static function getRelatedSiteLinksDataProvider() { return [ [null, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/index']]], - [0, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/index']]], - [1, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/index'], ['prefix' => 'en', 'name' => '英語サイト', 'url' => '/en/']]], + [0, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/']]], + [1, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/'], ['prefix' => 'en', 'name' => '英語サイト', 'url' => '/en/']]], [1, ['excludeIds' => [1]], [['prefix' => 'en', 'name' => '英語サイト', 'url' => '/en/']]], ]; } From da8c294f82e37e2a9152e17eb31db165baf6acd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Tue, 15 Oct 2024 10:43:19 +0900 Subject: [PATCH 06/60] =?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 --- .../tests/TestCase/View/Helper/BcContentsHelperTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php index 7520a615b8..23376adea8 100644 --- a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php +++ b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php @@ -390,7 +390,7 @@ public static function getRelatedSiteLinksDataProvider() { return [ [null, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/index']]], - [0, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/']]], + [0, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/index']]], [1, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/'], ['prefix' => 'en', 'name' => '英語サイト', 'url' => '/en/']]], [1, ['excludeIds' => [1]], [['prefix' => 'en', 'name' => '英語サイト', 'url' => '/en/']]], ]; From cb63a3c277054dca1357a6b1dbf8b04eaa3d6fd9 Mon Sep 17 00:00:00 2001 From: thangnn Date: Wed, 16 Oct 2024 14:23:33 +0700 Subject: [PATCH 07/60] Add unitTest_BlogContentsService_findByUrl --- .../src/Service/BlogContentsService.php | 3 ++ .../Service/BlogContentsServiceTest.php | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/plugins/bc-blog/src/Service/BlogContentsService.php b/plugins/bc-blog/src/Service/BlogContentsService.php index 6a193633d8..dbf20dbe24 100755 --- a/plugins/bc-blog/src/Service/BlogContentsService.php +++ b/plugins/bc-blog/src/Service/BlogContentsService.php @@ -331,6 +331,9 @@ public function getContentsTemplateRelativePath(array $options): string * * @param string $url * @return EntityInterface|null + * @checked + * @noTodo + * @unitTest */ public function findByUrl(string $url): ?EntityInterface { diff --git a/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php b/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php index edf2a15c06..d26f604987 100755 --- a/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php +++ b/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php @@ -324,4 +324,36 @@ public function test_getContentsTemplateRelativePath() } + /** + * test findByUrl + * @param $url + * @param $expected + * @dataProvider findByUrlDataProvider + */ + public function test_findByUrl($url, $expected) + { + //generate data + BlogContentFactory::make(['id' => 60])->persist(); + ContentFactory::make(['id' => 60, 'type' => 'BlogContent', 'entity_id' => 60, 'title' => 'url test', 'url' => '/test', 'site_id' => 60])->persist(); + ContentFactory::make(['id' => 61, 'type' => 'BlogContent', 'entity_id' => 60,'title' => 'url demo', 'url' => '/demo', 'site_id' => 60])->persist(); + SiteFactory::make(['id' => 60, 'theme' => 'BcBlog'])->persist(); + + $rs = $this->BlogContentsService->findByUrl($url); + + if (empty($url)) { + $this->assertEmpty($expected); + }else{ + $this->assertEquals($expected, $rs->content->title); + } + } + + public static function findByUrlDataProvider() + { + return [ + ['', ''], + ['/test', 'url test'], + ['/demo', 'url demo'], + ]; + } + } From da04bb558f7ece7b3337e95cee43dedc87c97116 Mon Sep 17 00:00:00 2001 From: thangnn Date: Thu, 17 Oct 2024 10:11:39 +0700 Subject: [PATCH 08/60] modified --- .../tests/TestCase/Service/BlogContentsServiceTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php b/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php index d26f604987..82a850f665 100755 --- a/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php +++ b/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php @@ -333,10 +333,10 @@ public function test_getContentsTemplateRelativePath() public function test_findByUrl($url, $expected) { //generate data - BlogContentFactory::make(['id' => 60])->persist(); - ContentFactory::make(['id' => 60, 'type' => 'BlogContent', 'entity_id' => 60, 'title' => 'url test', 'url' => '/test', 'site_id' => 60])->persist(); - ContentFactory::make(['id' => 61, 'type' => 'BlogContent', 'entity_id' => 60,'title' => 'url demo', 'url' => '/demo', 'site_id' => 60])->persist(); - SiteFactory::make(['id' => 60, 'theme' => 'BcBlog'])->persist(); + BlogContentFactory::make(['id' => 1])->persist(); + ContentFactory::make(['id' => 1, 'type' => 'BlogContent', 'entity_id' => 1, 'title' => 'url test', 'url' => '/test', 'site_id' => 1])->persist(); + ContentFactory::make(['id' => 2, 'type' => 'BlogContent', 'entity_id' => 1,'title' => 'url demo', 'url' => '/demo', 'site_id' => 1])->persist(); + SiteFactory::make(['id' => 1, 'theme' => 'BcBlog'])->persist(); $rs = $this->BlogContentsService->findByUrl($url); From 4cf5eef4612456700a85478f377f861a474b516d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Mon, 21 Oct 2024 09:44:50 +0900 Subject: [PATCH 09/60] =?UTF-8?q?InstallationsService::executeDefaultUpdat?= =?UTF-8?q?es=E3=81=AE=E3=80=80=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Service/InstallationsService.php | 1 + .../Service/InstallationsServiceTest.php | 53 +------------------ 2 files changed, 2 insertions(+), 52 deletions(-) diff --git a/plugins/bc-installer/src/Service/InstallationsService.php b/plugins/bc-installer/src/Service/InstallationsService.php index d7e076edc2..f1c57c684f 100644 --- a/plugins/bc-installer/src/Service/InstallationsService.php +++ b/plugins/bc-installer/src/Service/InstallationsService.php @@ -337,6 +337,7 @@ public function setSiteName(string $name) * @return bool * @checked * @noTodo + * @unitTest */ public function executeDefaultUpdates(): bool { diff --git a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php index 6ea99e31fd..aa7b7a3698 100644 --- a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php @@ -18,7 +18,6 @@ use BaserCore\TestSuite\BcTestCase; use BaserCore\Utility\BcContainerTrait; use BaserCore\Utility\BcFile; -use BaserCore\Utility\BcFolder; use BcInstaller\Service\InstallationsService; use BcInstaller\Service\InstallationsServiceInterface; use Cake\Core\Configure; @@ -238,57 +237,7 @@ public function test_deployAdminAssets() */ public function testExecuteDefaultUpdates() { - $this->markTestIncomplete('このテストは未実装です。BcManagerComponentから移植中です。'); - $dbConfig = [ - 'datasource' => 'Database/BcMysql', - 'persistent' => false, - 'host' => 'localhost', - 'port' => '8889', - 'login' => 'root', - 'password' => 'root', - 'database' => 'basercms', - 'schema' => '', - 'prefix' => 'mysite_', - 'encoding' => 'utf8', - ]; - - // プラグイン有効化チェック用準備(ダミーのプラグインディレクトリを作成) - $testPluginPath = BASER_PLUGINS . 'Test' . DS; - $testPluginConfigPath = $testPluginPath . 'config.php'; - $Folder = new BcFolder($testPluginPath); - $Folder->create(); - $File = new BcFile($testPluginConfigPath); - $File->write('BcManager->executeDefaultUpdates($dbConfig); - - - // ===================== - // プラグイン有効化チェック - // ===================== - $File->delete(); - $Folder->delete($testPluginPath); - - $this->Plugin = ClassRegistry::init('Plugin'); - $plugin = $this->Plugin->find('first', [ - 'conditions' => ['id' => 4], - 'fields' => ['title', 'status'], - ] - ); - $expected = [ - 'Plugin' => [ - 'title' => 'テスト', - 'status' => 1, - ] - ]; - $this->Plugin->delete(4); - unset($this->Plugin); - $this->assertEquals($expected, $plugin, 'プラグインのステータスを正しく更新できません'); - $this->assertTrue($result, 'データベースのデータに初期更新に失敗しました'); + $this->assertTrue($this->Installations->executeDefaultUpdates()); } /** From 39ed635cfdea80d3f0c90dee62c672b44d4f1e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Tue, 22 Oct 2024 13:53:03 +0900 Subject: [PATCH 10/60] =?UTF-8?q?InstallationsAdminService::deleteAllTable?= =?UTF-8?q?s()=20=E3=81=AE=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/InstallationsAdminService.php | 4 +- .../Admin/InstallationsAdminServiceTest.php | 51 ++++++++++++++++++- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php index 34bfcb95e1..062205fd67 100644 --- a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php +++ b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php @@ -232,13 +232,11 @@ public function readDbSetting(ServerRequest $request, array $installationData = * @return bool * @checked * @noTodo + * @unitTest */ public function deleteAllTables(ServerRequest $request): bool { $dbConfig = $this->readDbSetting($request); - if (!$dbConfig) { - $dbConfig = ConnectionManager::getConfig('default'); - } return $this->BcDatabase->deleteTables('default', $dbConfig); } diff --git a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php index 2856216447..17dbb9359a 100644 --- a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php @@ -12,6 +12,7 @@ namespace BcInstaller\Test\TestCase\Service\Admin; +use BaserCore\Service\BcDatabaseServiceInterface; use BaserCore\TestSuite\BcTestCase; use BaserCore\Utility\BcContainerTrait; use BcInstaller\Service\Admin\InstallationsAdminService; @@ -19,6 +20,7 @@ use Cake\Core\Configure; use Cake\Http\ServerRequest; use Cake\Http\Session; +use Migrations\Migrations; /** * InstallationsAdminServiceTest @@ -416,7 +418,54 @@ public static function readDbSettingDataProvider() */ public function test_deleteAllTables() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + //準備 + $bcDatabaseService = $this->getService(BcDatabaseServiceInterface::class); + $config = [ + 'dbType' => 'mysql', + 'dbHost' => 'localhost', + 'dbPrefix' => '', + 'dbPort' => '3306', + 'dbUsername' => 'dbUsername', + 'dbPassword' => 'dbPassword', + 'dbSchema' => 'dbSchema', + 'dbName' => 'basercms', + 'dbEncoding' => 'utf-8', + 'dbDataPattern' => 'BcThemeSample.default' + ]; + $session = new Session(); + $request = new ServerRequest(['session' => $session->write('Installation', $config)]); + + //テストを実行 + $this->Installations->deleteAllTables($request); + + //全てテーブルを削除できるか確認 + $db = $bcDatabaseService->getDataSource(); + $tables = $db->getSchemaCollection()->listTables(); + $this->assertCount(0, $tables); + + //テーブルを復活 + $migrations = new Migrations(); + $plugins = [ + 'BaserCore', + 'BcBlog', + 'BcContentLink', + 'BcCustomContent', + 'BcEditorTemplate', + 'BcFavorite', + 'BcMail', + 'BcSearchIndex', + 'BcThemeConfig', + 'BcThemeFile', + 'BcUploader', + 'BcWidgetArea', + ]; + foreach ($plugins as $plugin) { + $migrate = $migrations->migrate([ + 'connection' => 'test', + 'plugin' => $plugin, + ]); + $this->assertTrue($migrate); + } } /** From a442eb83b329ec0957ed80f7b9c3872a493fb014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=E1=BB=97=20V=C4=83n=20H=C3=B9ng?= Date: Tue, 22 Oct 2024 13:54:51 +0900 Subject: [PATCH 11/60] =?UTF-8?q?InstallationsAdminService::deleteAllTable?= =?UTF-8?q?s()=20=E3=81=AE=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TestCase/Service/Admin/InstallationsAdminServiceTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php index 17dbb9359a..9bfaf396c2 100644 --- a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php @@ -433,7 +433,8 @@ public function test_deleteAllTables() 'dbDataPattern' => 'BcThemeSample.default' ]; $session = new Session(); - $request = new ServerRequest(['session' => $session->write('Installation', $config)]); + $session->write('Installation', $config); + $request = new ServerRequest(['session' => $session]); //テストを実行 $this->Installations->deleteAllTables($request); From e95e1c143603441e3f04f5b1ee24271e8ed9b3af Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Thu, 24 Oct 2024 11:05:12 +0900 Subject: [PATCH 12/60] =?UTF-8?q?InstallationsAdminService::login()=20?= =?UTF-8?q?=E3=81=AE=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 --- .../src/Service/Admin/InstallationsAdminService.php | 1 + .../Service/Admin/InstallationsAdminServiceTest.php | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php index fc79636031..6d50d57837 100644 --- a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php +++ b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php @@ -316,6 +316,7 @@ public function connectDb(ServerRequest $request): \Cake\Datasource\ConnectionIn * @return void * @checked * @noTodo + * @unitTest */ public function login(ServerRequest $request, Response $response): void { diff --git a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php index 71d743a13b..1a0c2eccb2 100644 --- a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php @@ -21,6 +21,7 @@ use BcInstaller\Service\Admin\InstallationsAdminService; use BcInstaller\Service\Admin\InstallationsAdminServiceInterface; use Cake\Core\Configure; +use Cake\Http\Response; use Cake\Http\ServerRequest; use Cake\Http\Session; use Cake\ORM\Exception\PersistenceFailedException; @@ -497,7 +498,15 @@ public function test_connectDb() */ public function test_login() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + //準備 + $this->loadFixtureScenario(InitAppScenario::class); + $request = $this->getRequest('/baser/admin/baser-core/users/index'); + $request->getSession()->write('Installation.id', 1); + $response = new Response(); + //テストを実行 + $this->Installations->login($request, $response); + //ログインできるか確認 + $this->assertEquals(1, $request->getSession()->read('AuthAdmin')->id); } /** From f12a94b4a4863cf47e444de7af6e7a9a3ac1f6b5 Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Thu, 24 Oct 2024 13:18:28 +0900 Subject: [PATCH 13/60] =?UTF-8?q?InstallationsAdminService::initFiles()=20?= =?UTF-8?q?=E3=81=AE=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 --- .../Admin/InstallationsAdminService.php | 1 + .../Admin/InstallationsAdminServiceTest.php | 43 ++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php index fc79636031..f99fd77b71 100644 --- a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php +++ b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php @@ -281,6 +281,7 @@ public function initAdmin(ServerRequest $request): void * @param ServerRequest $request * @checked * @noTodo + * @unitTest */ public function initFiles(ServerRequest $request): void { diff --git a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php index 71d743a13b..0b771023c0 100644 --- a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php @@ -18,6 +18,7 @@ use BaserCore\Test\Scenario\InitAppScenario; use BaserCore\TestSuite\BcTestCase; use BaserCore\Utility\BcContainerTrait; +use BaserCore\Utility\BcFile; use BcInstaller\Service\Admin\InstallationsAdminService; use BcInstaller\Service\Admin\InstallationsAdminServiceInterface; use Cake\Core\Configure; @@ -481,7 +482,47 @@ public function test_initAdmin() */ public function test_initFiles() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + // install.phpをバックアップ + $configPath = ROOT . DS . 'config' . DS; + copy($configPath . 'install.php', $configPath . 'install.php.copy'); + //準備 + $config = [ + 'dbType' => 'mysql', + 'dbHost' => 'localhost', + 'dbPrefix' => '', + 'dbPort' => '3306', + 'dbUsername' => 'dbUsername', + 'dbPassword' => 'dbPassword', + 'dbSchema' => 'dbSchema', + 'dbName' => 'basercms', + 'dbEncoding' => 'utf-8', + 'dbDataPattern' => 'BcThemeSample.default' + ]; + $session = new Session(); + $session->write('Installation', $config); + $request = new ServerRequest(['session' => $session]); + + //テストを実行 + $this->Installations->initFiles($request); + + // インストールファイルが生成できるか確認する + $file = new BcFile($configPath . 'install.php'); + $result = $file->read(); + $this->assertMatchesRegularExpression("/'username' => 'dbUsername'.*'password' => 'dbPassword'.*'database' => 'basercms'/s", $result); + + // JWTキーを作成できるか確認する + $this->assertFileExists(CONFIG . 'jwt.key'); + $this->assertFileExists(CONFIG . 'jwt.pem'); + + // アップロード用初期フォルダが生成できるか確認する + $this->assertTrue(is_dir(WWW_ROOT . 'files' . DS . 'blog')); + + // エディタテンプレート用の画像を配置 + $this->assertFileExists(WWW_ROOT . 'files' . DS . 'editor' . DS); + $this->assertFileExists(WWW_ROOT . 'files' . DS . 'editor' . DS . 'template1.gif'); + + // 生成されたファイルを削除し、バックアップしたファイルに置き換える + rename($configPath . 'install.php.copy', $configPath . 'install.php'); } /** From c3295c59d7426e9f501c482c0e0a80346abf7224 Mon Sep 17 00:00:00 2001 From: ryuring Date: Thu, 24 Oct 2024 15:15:45 +0900 Subject: [PATCH 14/60] =?UTF-8?q?basercms-5.1.3=20=E3=82=92=E3=83=AA?= =?UTF-8?q?=E3=83=AA=E3=83=BC=E3=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 68 +++++++++++++++++----------------- plugins/baser-core/VERSION.txt | 19 ++++++++++ 2 files changed, 53 insertions(+), 34 deletions(-) diff --git a/composer.json b/composer.json index 068053b3f7..603c82d7fe 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { "name": "baserproject/basercms", "description": "baserCMS plugin for CakePHP", - "homepage": "https://basercms.net", "license": "MIT", "type": "project", + "homepage": "https://basercms.net", "require": { "php": ">=8.1", "ext-gd": "*", @@ -31,6 +31,32 @@ "vierge-noire/cakephp-fixture-factories": "^3.0", "vierge-noire/cakephp-test-suite-light": "^3.0" }, + "replace": { + "baserproject/baser-core": "5.1.2", + "baserproject/bc-admin-third": "5.1.2", + "baserproject/bc-blog": "5.1.2", + "baserproject/bc-column": "5.1.2", + "baserproject/bc-content-link": "5.1.2", + "baserproject/bc-custom-content": "5.1.2", + "baserproject/bc-editor-template": "5.1.2", + "baserproject/bc-favorite": "5.1.2", + "baserproject/bc-front": "5.1.2", + "baserproject/bc-installer": "5.1.2", + "baserproject/bc-mail": "5.1.2", + "baserproject/bc-plugin-sample": "5.1.2", + "baserproject/bc-search-index": "5.1.2", + "baserproject/bc-theme-config": "5.1.2", + "baserproject/bc-theme-file": "5.1.2", + "baserproject/bc-theme-sample": "5.1.2", + "baserproject/bc-uploader": "5.1.2", + "baserproject/bc-widget-area": "5.1.2" + }, + "suggest": { + "markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.", + "dereuromark/cakephp-ide-helper": "After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan/Psalm compatibility.", + "phpstan/phpstan": "PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even before you write tests for the code.", + "cakephp/repl": "Console tools for a REPL interface for CakePHP applications." + }, "autoload": { "psr-4": { "App\\": "src/", @@ -72,6 +98,13 @@ "BcWidgetArea\\Test\\": "plugins/bc-widget-area/tests/" } }, + "config": { + "sort-packages": true, + "allow-plugins": { + "cakephp/plugin-installer": true, + "dealerdirect/phpcodesniffer-composer-installer": true + } + }, "scripts": { "post-install-cmd": "App\\Console\\Installer::postInstall", "post-update-cmd": "App\\Console\\Installer::postInstall", @@ -93,38 +126,5 @@ "Composer\\Config::disableProcessTimeout", "vendor/bin/phpunit --colors=always" ] - }, - "suggest": { - "markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.", - "dereuromark/cakephp-ide-helper": "After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan/Psalm compatibility.", - "phpstan/phpstan": "PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even before you write tests for the code.", - "cakephp/repl": "Console tools for a REPL interface for CakePHP applications." - }, - "config": { - "sort-packages": true, - "allow-plugins": { - "cakephp/plugin-installer": true, - "dealerdirect/phpcodesniffer-composer-installer": true - } - }, - "replace": { - "baserproject/baser-core": "5.1.2", - "baserproject/bc-admin-third": "5.1.2", - "baserproject/bc-blog": "5.1.2", - "baserproject/bc-column": "5.1.2", - "baserproject/bc-content-link": "5.1.2", - "baserproject/bc-custom-content": "5.1.2", - "baserproject/bc-editor-template": "5.1.2", - "baserproject/bc-favorite": "5.1.2", - "baserproject/bc-front": "5.1.2", - "baserproject/bc-installer": "5.1.2", - "baserproject/bc-mail": "5.1.2", - "baserproject/bc-plugin-sample": "5.1.2", - "baserproject/bc-search-index": "5.1.2", - "baserproject/bc-theme-config": "5.1.2", - "baserproject/bc-theme-file": "5.1.2", - "baserproject/bc-theme-sample": "5.1.2", - "baserproject/bc-uploader": "5.1.2", - "baserproject/bc-widget-area": "5.1.2" } } diff --git a/plugins/baser-core/VERSION.txt b/plugins/baser-core/VERSION.txt index 7c36643021..9c4b75f78e 100644 --- a/plugins/baser-core/VERSION.txt +++ b/plugins/baser-core/VERSION.txt @@ -14,6 +14,25 @@ CHG: 変更内容 / BUG: バグフィックス / NEW: 機能追加 +[2024-10-24] basercms-5.1.3 +- NEW [BC] さくらのVPSのSSLに対応 +- CHG [BC] baserCMS4系で使用していたときのパスワードが引き継げない問題を解決 +- BUG [BC] プラグイン一覧に開発者の表記にbrタグが入ってる問題を調整 +- BUG [BC] 初期ユーザー以外のシステム管理ユーザーは自分のユーザー情報を編集しようとすると運営ユーザーしか選択できなくなる問題を解決 +- BUG [BC] 利用可能バージョンの取得処理を調整 +- BUG [BC] サブフォルダ環境でログイン時のリダイレクト先が間違っている問題を改善 +- BUG [BC] 固定ページをエレメントとして読み込めない問題を改善 +- BUG [BC] メインサイトの管理画面からサブサイト記事にアクセスするとURLが正しく生成されない問題を解消 +- BUG [BC] カスタムコンテンツ:エラーメッセージに情報不足な部分がある問題を改善 +- BUG [BC] メインサイトでブログのエイリアスを作成すると、Blog->Posts()で呼び出された記事のURLがすべて1つ目のエイリアスのURLになってしまう問題を改善 +- BUG [BC] SitesTable::findByUrl() の判定を調整 +- BUG [BC] サブサイト(独自ドメイン)で作成したページがエイリアス付きサブサイトと混同される問題を改善 +- BUG [BC] カスタムコンテンツにてファイル項目を含むエントリーをプレビュー時にエラーとなる問題を改善 +- BUG [BC] エディタをなしに設定しても、ブログ記事の編集画面でCKEditorが選択されてしまう問題を改善 +- BUG [BC] 管理画面テーマの選択の不具合を改善 fix #3884 +- BUG [UL] フロント側のログインユーザーに公開期間外のアップロードファイルが表示されてしまう問題を改善 + + [2024-09-26] basercms-5.1.2 - NEW [BC] JWTキー生成コマンド追加 - BUG [BC] BcUploadで作成したフォルダの権限が書き込み可能になっていない問題を改善 From 1504dc7fdf4012478e12b38ef88dcbf826c4b73e Mon Sep 17 00:00:00 2001 From: thangnn Date: Thu, 24 Oct 2024 13:35:49 +0700 Subject: [PATCH 15/60] modified --- .../Service/BlogContentsServiceTest.php | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php b/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php index 6fb26f3120..f798f47e45 100755 --- a/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php +++ b/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php @@ -344,34 +344,20 @@ public function test_findByContentId() } /** * test findByUrl - * @param $url - * @param $expected - * @dataProvider findByUrlDataProvider */ - public function test_findByUrl($url, $expected) + public function test_findByUrl() { //generate data BlogContentFactory::make(['id' => 1])->persist(); ContentFactory::make(['id' => 1, 'type' => 'BlogContent', 'entity_id' => 1, 'title' => 'url test', 'url' => '/test', 'site_id' => 1])->persist(); - ContentFactory::make(['id' => 2, 'type' => 'BlogContent', 'entity_id' => 1,'title' => 'url demo', 'url' => '/demo', 'site_id' => 1])->persist(); SiteFactory::make(['id' => 1, 'theme' => 'BcBlog'])->persist(); - $rs = $this->BlogContentsService->findByUrl($url); + $rs = $this->BlogContentsService->findByUrl('/test'); + $this->assertEquals('url test', $rs->content->title); - if (empty($url)) { - $this->assertEquals($expected, $rs); - }else{ - $this->assertEquals($expected, $rs->content->title); - } - } - - public static function findByUrlDataProvider() - { - return [ - ['', ''], - ['/test', 'url test'], - ['/demo', 'url demo'], - ]; + //with empty url + $rs = $this->BlogContentsService->findByUrl(''); + $this->assertNull($rs); } } From de7d52c3b3d106cbf73f31d154807385271c0c9b Mon Sep 17 00:00:00 2001 From: thangnn Date: Thu, 24 Oct 2024 13:36:56 +0700 Subject: [PATCH 16/60] modified --- .../bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php b/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php index f798f47e45..345e2688cf 100755 --- a/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php +++ b/plugins/bc-blog/tests/TestCase/Service/BlogContentsServiceTest.php @@ -350,6 +350,7 @@ public function test_findByUrl() //generate data BlogContentFactory::make(['id' => 1])->persist(); ContentFactory::make(['id' => 1, 'type' => 'BlogContent', 'entity_id' => 1, 'title' => 'url test', 'url' => '/test', 'site_id' => 1])->persist(); + ContentFactory::make(['id' => 2, 'type' => 'BlogContent', 'entity_id' => 1,'title' => 'url demo', 'url' => '/demo', 'site_id' => 1])->persist(); SiteFactory::make(['id' => 1, 'theme' => 'BcBlog'])->persist(); $rs = $this->BlogContentsService->findByUrl('/test'); From 9471c84ffc1945f4429ae98d78be807974f283cf Mon Sep 17 00:00:00 2001 From: thangnn Date: Thu, 24 Oct 2024 13:38:17 +0700 Subject: [PATCH 17/60] Add unitTest_MailFieldsController_index --- .../Api/Admin/MailFieldsController.php | 1 + .../Api/Admin/MailFieldsControllerTest.php | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/plugins/bc-mail/src/Controller/Api/Admin/MailFieldsController.php b/plugins/bc-mail/src/Controller/Api/Admin/MailFieldsController.php index 646a0933c4..006f7f9a42 100644 --- a/plugins/bc-mail/src/Controller/Api/Admin/MailFieldsController.php +++ b/plugins/bc-mail/src/Controller/Api/Admin/MailFieldsController.php @@ -118,6 +118,7 @@ public function update_sort(MailFieldsServiceInterface $service, int $mailConten * * @checked * @noTodo + * @unitTest */ public function index(MailFieldsServiceInterface $service) { diff --git a/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailFieldsControllerTest.php b/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailFieldsControllerTest.php index eec3169f51..b539943b1b 100644 --- a/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailFieldsControllerTest.php +++ b/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailFieldsControllerTest.php @@ -271,4 +271,33 @@ public function testUpdateSort() $result = json_decode((string)$this->_response->getBody()); $this->assertEquals($result->message, 'メールフィールド「性」の並び替えを更新しました。'); } + + /** + * test index + */ + public function testIndex() + { + //Create data + $this->loadFixtureScenario(MailFieldsScenario::class); + $this->loadFixtureScenario(MailContentsScenario::class); + + //mail_content_id is not set + $this->get("/baser/api/admin/bc-mail/mail_fields/index.json?token=" . $this->accessToken); + $this->assertResponseCode(400); + $vars = $this->_controller->viewBuilder()->getVars(); + $this->assertEquals('パラメーターに mail_content_id を指定してください。', $vars['message']); + + //mail_content_id is set + $this->get("/baser/api/admin/bc-mail/mail_fields/index.json?mail_content_id=1&token=" . $this->accessToken); + $this->assertResponseOk(); + + $result = json_decode((string)$this->_response->getBody()); + $this->assertNotNull($result->mailFields); + + //mail_content_id fails + $this->get("/baser/api/admin/bc-mail/mail_fields/index.json?mail_content_id=tt&token=" . $this->accessToken); + $this->assertResponseCode(500); + $vars = $this->_controller->viewBuilder()->getVars(); + $this->assertTextContains('データベース処理中にエラーが発生しました。', $vars['message']); + } } From d68e88ee4a5cd026feb58b4f339d2eb128f6edf4 Mon Sep 17 00:00:00 2001 From: ryuring Date: Thu, 24 Oct 2024 15:40:01 +0900 Subject: [PATCH 18/60] =?UTF-8?q?baser-core=20=E3=81=AE=20composer.json=20?= =?UTF-8?q?=E3=81=AE=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3=E7=95=AA?= =?UTF-8?q?=E5=8F=B7=E3=82=92=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/baser-core/composer.json | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/baser-core/composer.json b/plugins/baser-core/composer.json index 7d9afd3715..eb45d5c7fc 100644 --- a/plugins/baser-core/composer.json +++ b/plugins/baser-core/composer.json @@ -15,20 +15,20 @@ "firebase/php-jwt": "6.1.0", "mobiledetect/mobiledetectlib": "^3.74", "ext-json": "*", - "baserproject/bc-admin-third": "5.1.x-dev", - "baserproject/bc-blog": "5.1.x-dev", - "baserproject/bc-content-link": "5.1.x-dev", - "baserproject/bc-custom-content": "5.1.x-dev", - "baserproject/bc-editor-template": "5.1.x-dev", - "baserproject/bc-favorite": "5.1.x-dev", - "baserproject/bc-front": "5.1.x-dev", - "baserproject/bc-installer": "5.1.x-dev", - "baserproject/bc-mail": "5.1.x-dev", - "baserproject/bc-search-index": "5.1.x-dev", - "baserproject/bc-theme-config": "5.1.x-dev", - "baserproject/bc-theme-file": "5.1.x-dev", - "baserproject/bc-uploader": "5.1.x-dev", - "baserproject/bc-widget-area": "5.1.x-dev", + "baserproject/bc-admin-third": "5.1.3", + "baserproject/bc-blog": "5.1.3", + "baserproject/bc-content-link": "5.1.3", + "baserproject/bc-custom-content": "5.1.3", + "baserproject/bc-editor-template": "5.1.3", + "baserproject/bc-favorite": "5.1.3", + "baserproject/bc-front": "5.1.3", + "baserproject/bc-installer": "5.1.3", + "baserproject/bc-mail": "5.1.3", + "baserproject/bc-search-index": "5.1.3", + "baserproject/bc-theme-config": "5.1.3", + "baserproject/bc-theme-file": "5.1.3", + "baserproject/bc-uploader": "5.1.3", + "baserproject/bc-widget-area": "5.1.3", "ext-mbstring": "*", "ext-zip": "*", "ext-gd": "*" From c80ec6a5562299c1e35acc5151d60cc0d075402a Mon Sep 17 00:00:00 2001 From: ryuring Date: Thu, 24 Oct 2024 15:40:35 +0900 Subject: [PATCH 19/60] prepare release --- composer.json | 68 +++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/composer.json b/composer.json index 603c82d7fe..9e0246e601 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { "name": "baserproject/basercms", "description": "baserCMS plugin for CakePHP", + "homepage": "https://basercms.net", "license": "MIT", "type": "project", - "homepage": "https://basercms.net", "require": { "php": ">=8.1", "ext-gd": "*", @@ -31,32 +31,6 @@ "vierge-noire/cakephp-fixture-factories": "^3.0", "vierge-noire/cakephp-test-suite-light": "^3.0" }, - "replace": { - "baserproject/baser-core": "5.1.2", - "baserproject/bc-admin-third": "5.1.2", - "baserproject/bc-blog": "5.1.2", - "baserproject/bc-column": "5.1.2", - "baserproject/bc-content-link": "5.1.2", - "baserproject/bc-custom-content": "5.1.2", - "baserproject/bc-editor-template": "5.1.2", - "baserproject/bc-favorite": "5.1.2", - "baserproject/bc-front": "5.1.2", - "baserproject/bc-installer": "5.1.2", - "baserproject/bc-mail": "5.1.2", - "baserproject/bc-plugin-sample": "5.1.2", - "baserproject/bc-search-index": "5.1.2", - "baserproject/bc-theme-config": "5.1.2", - "baserproject/bc-theme-file": "5.1.2", - "baserproject/bc-theme-sample": "5.1.2", - "baserproject/bc-uploader": "5.1.2", - "baserproject/bc-widget-area": "5.1.2" - }, - "suggest": { - "markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.", - "dereuromark/cakephp-ide-helper": "After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan/Psalm compatibility.", - "phpstan/phpstan": "PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even before you write tests for the code.", - "cakephp/repl": "Console tools for a REPL interface for CakePHP applications." - }, "autoload": { "psr-4": { "App\\": "src/", @@ -98,13 +72,6 @@ "BcWidgetArea\\Test\\": "plugins/bc-widget-area/tests/" } }, - "config": { - "sort-packages": true, - "allow-plugins": { - "cakephp/plugin-installer": true, - "dealerdirect/phpcodesniffer-composer-installer": true - } - }, "scripts": { "post-install-cmd": "App\\Console\\Installer::postInstall", "post-update-cmd": "App\\Console\\Installer::postInstall", @@ -126,5 +93,38 @@ "Composer\\Config::disableProcessTimeout", "vendor/bin/phpunit --colors=always" ] + }, + "suggest": { + "markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.", + "dereuromark/cakephp-ide-helper": "After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan/Psalm compatibility.", + "phpstan/phpstan": "PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even before you write tests for the code.", + "cakephp/repl": "Console tools for a REPL interface for CakePHP applications." + }, + "config": { + "sort-packages": true, + "allow-plugins": { + "cakephp/plugin-installer": true, + "dealerdirect/phpcodesniffer-composer-installer": true + } + }, + "replace": { + "baserproject/baser-core": "5.1.3", + "baserproject/bc-admin-third": "5.1.3", + "baserproject/bc-blog": "5.1.3", + "baserproject/bc-column": "5.1.3", + "baserproject/bc-content-link": "5.1.3", + "baserproject/bc-custom-content": "5.1.3", + "baserproject/bc-editor-template": "5.1.3", + "baserproject/bc-favorite": "5.1.3", + "baserproject/bc-front": "5.1.3", + "baserproject/bc-installer": "5.1.3", + "baserproject/bc-mail": "5.1.3", + "baserproject/bc-plugin-sample": "5.1.3", + "baserproject/bc-search-index": "5.1.3", + "baserproject/bc-theme-config": "5.1.3", + "baserproject/bc-theme-file": "5.1.3", + "baserproject/bc-theme-sample": "5.1.3", + "baserproject/bc-uploader": "5.1.3", + "baserproject/bc-widget-area": "5.1.3" } } From a38d874a5138ded9c68b6b9bd3e2ea3c230533ea Mon Sep 17 00:00:00 2001 From: ryuring Date: Thu, 24 Oct 2024 15:51:26 +0900 Subject: [PATCH 20/60] =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=82=925.1.4=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/baser-core/VERSION.txt | 2 +- plugins/baser-core/composer.json | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/baser-core/VERSION.txt b/plugins/baser-core/VERSION.txt index 9c4b75f78e..9aa994355a 100644 --- a/plugins/baser-core/VERSION.txt +++ b/plugins/baser-core/VERSION.txt @@ -1,4 +1,4 @@ -5.1.3 +5.1.4 /////////////////////////////////////////////////////////////////////////////////////////////////////////// // +---------------------------------------------------------------------------------------------------+ // diff --git a/plugins/baser-core/composer.json b/plugins/baser-core/composer.json index eb45d5c7fc..7d9afd3715 100644 --- a/plugins/baser-core/composer.json +++ b/plugins/baser-core/composer.json @@ -15,20 +15,20 @@ "firebase/php-jwt": "6.1.0", "mobiledetect/mobiledetectlib": "^3.74", "ext-json": "*", - "baserproject/bc-admin-third": "5.1.3", - "baserproject/bc-blog": "5.1.3", - "baserproject/bc-content-link": "5.1.3", - "baserproject/bc-custom-content": "5.1.3", - "baserproject/bc-editor-template": "5.1.3", - "baserproject/bc-favorite": "5.1.3", - "baserproject/bc-front": "5.1.3", - "baserproject/bc-installer": "5.1.3", - "baserproject/bc-mail": "5.1.3", - "baserproject/bc-search-index": "5.1.3", - "baserproject/bc-theme-config": "5.1.3", - "baserproject/bc-theme-file": "5.1.3", - "baserproject/bc-uploader": "5.1.3", - "baserproject/bc-widget-area": "5.1.3", + "baserproject/bc-admin-third": "5.1.x-dev", + "baserproject/bc-blog": "5.1.x-dev", + "baserproject/bc-content-link": "5.1.x-dev", + "baserproject/bc-custom-content": "5.1.x-dev", + "baserproject/bc-editor-template": "5.1.x-dev", + "baserproject/bc-favorite": "5.1.x-dev", + "baserproject/bc-front": "5.1.x-dev", + "baserproject/bc-installer": "5.1.x-dev", + "baserproject/bc-mail": "5.1.x-dev", + "baserproject/bc-search-index": "5.1.x-dev", + "baserproject/bc-theme-config": "5.1.x-dev", + "baserproject/bc-theme-file": "5.1.x-dev", + "baserproject/bc-uploader": "5.1.x-dev", + "baserproject/bc-widget-area": "5.1.x-dev", "ext-mbstring": "*", "ext-zip": "*", "ext-gd": "*" From cd035c209717d5668dfdf3c57f89fb5bb9b62c9d Mon Sep 17 00:00:00 2001 From: thangnn Date: Thu, 24 Oct 2024 13:55:45 +0700 Subject: [PATCH 21/60] Add unitTest_MailMessagesContrller_beforeFilter --- .../src/Controller/Api/MailMessagesController.php | 1 + .../Api/Admin/MailMessagesControllerTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/plugins/bc-mail/src/Controller/Api/MailMessagesController.php b/plugins/bc-mail/src/Controller/Api/MailMessagesController.php index 6f8fcc0257..a7485bdc00 100644 --- a/plugins/bc-mail/src/Controller/Api/MailMessagesController.php +++ b/plugins/bc-mail/src/Controller/Api/MailMessagesController.php @@ -36,6 +36,7 @@ class MailMessagesController extends BcApiController * @return \Cake\Http\Response|void * @checked * @noTodo + * @unitTest */ public function beforeFilter(EventInterface $event) { diff --git a/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailMessagesControllerTest.php b/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailMessagesControllerTest.php index 99f9a1c342..71b6758e2b 100644 --- a/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailMessagesControllerTest.php +++ b/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailMessagesControllerTest.php @@ -15,9 +15,11 @@ use BaserCore\Test\Factory\ContentFactory; use BaserCore\Test\Scenario\InitAppScenario; use BaserCore\TestSuite\BcTestCase; +use BcMail\Controller\Api\MailMessagesController; use BcMail\Service\MailMessagesServiceInterface; use BcMail\Test\Factory\MailContentFactory; use BcMail\Test\Scenario\MailContentsScenario; +use Cake\Event\Event; use Cake\ORM\Entity; use Cake\ORM\TableRegistry; use Cake\TestSuite\IntegrationTestTrait; @@ -56,6 +58,19 @@ public function tearDown(): void parent::tearDown(); } + + /** + * test beforeFilter + */ + public function testBeforeFilter() + { + $this->MailMessagesController = new MailMessagesController($this->getRequest()); + $event = new Event('Controller.beforeFilter', $this->MailMessagesController); + $this->MailMessagesController->beforeFilter($event); + $config = $this->MailMessagesController->FormProtection->getConfig('validate'); + $this->assertFalse($config); + } + /** * [API] 受信メール一覧 */ From 15b0ad20d289084b263b2f097f1c7917429c1c24 Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Fri, 25 Oct 2024 11:52:01 +0900 Subject: [PATCH 22/60] =?UTF-8?q?InstallationsAdminService::initDb()=20?= =?UTF-8?q?=E3=81=AE=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 --- .../Admin/InstallationsAdminService.php | 1 + .../Admin/InstallationsAdminServiceTest.php | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php index fc79636031..402c0d3f7c 100644 --- a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php +++ b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php @@ -332,6 +332,7 @@ public function login(ServerRequest $request, Response $response): void * @param ServerRequest $request * @checked * @noTodo + * @unitTest */ public function initDb(ServerRequest $request): void { diff --git a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php index 71d743a13b..9636e351fa 100644 --- a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php @@ -12,6 +12,7 @@ namespace BcInstaller\Test\TestCase\Service\Admin; +use BaserCore\Service\PermissionGroupsServiceInterface; use BaserCore\Test\Factory\ContentFactory; use BaserCore\Test\Factory\ContentFolderFactory; use BaserCore\Test\Factory\UserFactory; @@ -20,6 +21,7 @@ use BaserCore\Utility\BcContainerTrait; use BcInstaller\Service\Admin\InstallationsAdminService; use BcInstaller\Service\Admin\InstallationsAdminServiceInterface; +use BcSearchIndex\Test\Scenario\Service\SearchIndexesServiceScenario; use Cake\Core\Configure; use Cake\Http\ServerRequest; use Cake\Http\Session; @@ -505,7 +507,22 @@ public function test_login() */ public function test_initDb() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + //準備 + $PermissionGroupsService = $this->getService(PermissionGroupsServiceInterface::class); + $this->loadFixtureScenario(SearchIndexesServiceScenario::class); + //テスト前、アクセスルールを確認 + $this->assertCount(0, $PermissionGroupsService->getList()); + + //テストを実行 + $this->Installations->initDb(new ServerRequest()); + + // データベースのデータを初期設定に更新できるか確認 + $searchIndexesTable = $this->getTableLocator()->get('SearchIndexes'); + $this->assertEquals(3, $searchIndexesTable->find()->count()); + //テスト後、アクセスルールを確認 + $this->assertCount(28, $PermissionGroupsService->getList()); + // SITE_URL更新 + $this->assertEquals('https://localhost/', env('SITE_URL')); } } From c9a5f6ae03bbb1893e0762d269f5c60e0c99cf3d Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Fri, 25 Oct 2024 12:16:47 +0900 Subject: [PATCH 23/60] =?UTF-8?q?InstallationsAdminService::connectDb()=20?= =?UTF-8?q?=E3=81=AE=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 --- .../Admin/InstallationsAdminService.php | 1 + .../Admin/InstallationsAdminServiceTest.php | 23 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php index fc79636031..2fc27d1ba6 100644 --- a/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php +++ b/plugins/bc-installer/src/Service/Admin/InstallationsAdminService.php @@ -301,6 +301,7 @@ public function initFiles(ServerRequest $request): void * @return \Cake\Datasource\ConnectionInterface * @checked * @noTodo + * @unitTest */ public function connectDb(ServerRequest $request): \Cake\Datasource\ConnectionInterface { diff --git a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php index 71d743a13b..cb41975db9 100644 --- a/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/Admin/InstallationsAdminServiceTest.php @@ -489,7 +489,28 @@ public function test_initFiles() */ public function test_connectDb() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + //準備 + $session = new Session(); + $request = new ServerRequest(['session' => $session]); + $session->write('Installation', [ + "datasource" => "MySQL", + "dbSchema" => "test_basercms", + 'dbType' => 'mysql', + 'dbName' => 'test_db', + 'dbHost' => 'bc-db', + 'dbPrefix' => '', + 'dbPort' => '3306', + 'dbEncoding' => 'utf-8', + 'dbDataPattern' => 'BcThemeSample.default', + "dbUsername" => "root", + "dbPassword" => "root", + ]); + //準備 + $rs = $this->Installations->connectDb($request); + + // 接続できていること + $this->assertNotEmpty($rs); + $this->assertTrue($rs->getDriver()->isConnected()); } /** From ef57c52707064cf3495251d929544f7dac9cbb78 Mon Sep 17 00:00:00 2001 From: thangnn Date: Fri, 25 Oct 2024 13:59:11 +0700 Subject: [PATCH 24/60] Add unitTest_BcThemeConfigControllerEventListener_baserCoreThemesAfterApply --- .../BcThemeConfigControllerEventListener.php | 3 ++ ...ThemeConfigControllerEventListenerTest.php | 48 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 plugins/bc-theme-config/tests/TestCase/Event/BcThemeConfigControllerEventListenerTest.php diff --git a/plugins/bc-theme-config/src/Event/BcThemeConfigControllerEventListener.php b/plugins/bc-theme-config/src/Event/BcThemeConfigControllerEventListener.php index 451e078718..1b6dce75ff 100644 --- a/plugins/bc-theme-config/src/Event/BcThemeConfigControllerEventListener.php +++ b/plugins/bc-theme-config/src/Event/BcThemeConfigControllerEventListener.php @@ -32,6 +32,9 @@ class BcThemeConfigControllerEventListener extends BcControllerEventListener * テーマ適用後イベント * @param Event $event * @return void + * @checked + * @noTodo + * @unitTest */ public function baserCoreThemesAfterApply(Event $event) { diff --git a/plugins/bc-theme-config/tests/TestCase/Event/BcThemeConfigControllerEventListenerTest.php b/plugins/bc-theme-config/tests/TestCase/Event/BcThemeConfigControllerEventListenerTest.php new file mode 100644 index 0000000000..53e4cb29cd --- /dev/null +++ b/plugins/bc-theme-config/tests/TestCase/Event/BcThemeConfigControllerEventListenerTest.php @@ -0,0 +1,48 @@ +BcThemeConfigControllerEventListener = new BcThemeConfigControllerEventListener(); + } + + public function tearDown(): void + { + parent::tearDown(); + } + + /** + * Test baserCoreThemesAfterApply + */ + public function test_baserCoreThemesAfterApply() + { + $path = WWW_ROOT . 'files' . DS . 'theme_configs' . DS . 'config.css'; + + if (!is_dir(dirname($path))) { + mkdir(dirname($path), 0777, true); + } + file_put_contents($path, 'test content'); + $this->assertFileExists($path); + + $event = new Event('BaserCore.Themes.afterApply'); + $this->BcThemeConfigControllerEventListener->baserCoreThemesAfterApply($event); + + $this->assertFileDoesNotExist($path); + + // cleanup + if (file_exists($path)) { + unlink($path); + } + if (is_dir(dirname($path))) { + rmdir(dirname($path)); + } + } +} From 0a65e0f83b47f185c629f53eda6de327aaf8d515 Mon Sep 17 00:00:00 2001 From: thangnn Date: Fri, 25 Oct 2024 14:00:07 +0700 Subject: [PATCH 25/60] Add unitTest_PluginsAdminService_isPluginsDirWritable --- .../baser-core/src/Service/Admin/PluginsAdminService.php | 1 + .../TestCase/Service/Admin/PluginsAdminServiceTest.php | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/plugins/baser-core/src/Service/Admin/PluginsAdminService.php b/plugins/baser-core/src/Service/Admin/PluginsAdminService.php index 4cedbe29c0..6c56864554 100644 --- a/plugins/baser-core/src/Service/Admin/PluginsAdminService.php +++ b/plugins/baser-core/src/Service/Admin/PluginsAdminService.php @@ -206,6 +206,7 @@ public function getViewVarsForAdd() * @return bool * @checked * @noTodo + * @unitTest */ public function isPluginsDirWritable() { diff --git a/plugins/baser-core/tests/TestCase/Service/Admin/PluginsAdminServiceTest.php b/plugins/baser-core/tests/TestCase/Service/Admin/PluginsAdminServiceTest.php index cc77f54d8b..b902aeae38 100644 --- a/plugins/baser-core/tests/TestCase/Service/Admin/PluginsAdminServiceTest.php +++ b/plugins/baser-core/tests/TestCase/Service/Admin/PluginsAdminServiceTest.php @@ -149,4 +149,13 @@ public function test_getViewVarsForAdd() $this->assertTrue(isset($vars['isPluginsDirWritable'])); } + /** + * test isPluginsDirWritable + */ + public function test_isPluginsDirWritable() + { + $result = $this->PluginsAdmin->isPluginsDirWritable(); + $this->assertTrue($result); + } + } From 7710fcfe23f9871184cdeaf133d7ae7d4b9335e4 Mon Sep 17 00:00:00 2001 From: ryuring Date: Sun, 27 Oct 2024 14:25:18 +0900 Subject: [PATCH 26/60] =?UTF-8?q?BcFreezeHelper=20=E3=81=AB=E3=81=A6?= =?UTF-8?q?=E3=80=81=E3=83=95=E3=83=AA=E3=83=BC=E3=82=BA=E3=81=97=E3=81=9F?= =?UTF-8?q?=E9=9A=9B=E3=81=AB=E3=80=81=E5=85=A5=E5=8A=9B=E6=AC=84=E3=81=8C?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=81=A6=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=86=E5=A0=B4=E5=90=88=E3=81=8C=E3=81=82=E3=82=8B=E5=95=8F?= =?UTF-8?q?=E9=A1=8C=E3=82=92=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit control() メソッド経由で呼び出した場合に再現 --- plugins/baser-core/src/View/Helper/BcFreezeHelper.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/baser-core/src/View/Helper/BcFreezeHelper.php b/plugins/baser-core/src/View/Helper/BcFreezeHelper.php index 66f1ab46cb..cd2a4f5ef3 100755 --- a/plugins/baser-core/src/View/Helper/BcFreezeHelper.php +++ b/plugins/baser-core/src/View/Helper/BcFreezeHelper.php @@ -68,7 +68,7 @@ public function text(string $fieldName, array $options = []): string $field = $fieldName; } if (isset($options)) { - $options = $options + ['type' => 'hidden']; + $options = array_merge($options, ['type' => 'hidden']); } else { $options = ['type' => 'hidden']; } @@ -349,7 +349,11 @@ public function textarea($fieldName, $options = []): string } else { $field = $fieldName; } - $options = $options + ['type' => 'hidden']; + if (isset($options)) { + $options = array_merge($options, ['type' => 'hidden']); + } else { + $options = ['type' => 'hidden']; + } if (isset($options["value"])) { $value = $options["value"]; } else { From 7ffad4dd5257a9c69561036fbe97e3e574416846 Mon Sep 17 00:00:00 2001 From: ryuring Date: Sun, 27 Oct 2024 16:04:07 +0900 Subject: [PATCH 27/60] =?UTF-8?q?profiler=E3=81=AE=E7=84=A1=E8=A6=96?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 3fe0c16511..3adc23e451 100644 --- a/.gitignore +++ b/.gitignore @@ -131,6 +131,8 @@ node_modules # db /db/* !/db/.gitkeep +# profiler +/profiler/* # etc LOCAL_TODO.md LOCAL_Q&A.md From 2a8c584285ba40723b43e6779df242ea84cebd10 Mon Sep 17 00:00:00 2001 From: thangnn Date: Mon, 28 Oct 2024 14:05:38 +0700 Subject: [PATCH 28/60] Add unitTest_BcContentsBehavior_onAlias --- .../src/Model/Behavior/BcContentsBehavior.php | 1 + .../Model/Behavior/BcContentsBehaviorTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php b/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php index 8bfe6cb5b0..3adb3220d4 100644 --- a/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php +++ b/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php @@ -99,6 +99,7 @@ public function offAlias(): void * アソシエーション時に alias を含める * @checked * @noTodo + * @unitTest */ public function onAlias(): void { diff --git a/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php b/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php index a484fa1418..f591967327 100644 --- a/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php +++ b/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php @@ -49,6 +49,7 @@ public function setUp(): void $this->table->setPrimaryKey(['id']); $this->table->addBehavior('BaserCore.BcContents'); $this->contentService = new ContentsService(); + $this->BcContentsBehavior = new BcContentsBehavior($this->table); } /** @@ -200,4 +201,17 @@ public function testAfterDelete() } + /** + * test onAlias + */ + public function testOnAlias() + { + $this->BcContentsBehavior->onAlias(); + + $conditions = $this->BcContentsBehavior->Contents->getConditions(); + + $this->assertArrayHasKey('Contents.type', $conditions); + $this->assertEquals('ContentFolder', $conditions['Contents.type']); + } + } From 24b72f9e9d927d0c6cc29d8ba30517b71cc12de6 Mon Sep 17 00:00:00 2001 From: thangnn Date: Mon, 28 Oct 2024 14:06:31 +0700 Subject: [PATCH 29/60] Add unitTest_BcContentsBahavior_offAlias --- .../src/Model/Behavior/BcContentsBehavior.php | 1 + .../Model/Behavior/BcContentsBehaviorTest.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php b/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php index 8bfe6cb5b0..1a826b6fc6 100644 --- a/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php +++ b/plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php @@ -86,6 +86,7 @@ public function getType(): string * アソシエーション時に alias を除外する * @checked * @noTodo + * @unitTest */ public function offAlias(): void { diff --git a/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php b/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php index a484fa1418..387ff9f7f1 100644 --- a/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php +++ b/plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php @@ -49,6 +49,7 @@ public function setUp(): void $this->table->setPrimaryKey(['id']); $this->table->addBehavior('BaserCore.BcContents'); $this->contentService = new ContentsService(); + $this->BcContentsBehavior = new BcContentsBehavior($this->table); } /** @@ -200,4 +201,21 @@ public function testAfterDelete() } + /** + * test offAlias + * + */ + public function testOffAlias() + { + $this->BcContentsBehavior->offAlias(); + + $conditions = $this->BcContentsBehavior->Contents->getConditions(); + + $this->assertArrayHasKey('Contents.type', $conditions); + $this->assertArrayHasKey('Contents.alias_id IS', $conditions); + + $this->assertNull($conditions['Contents.alias_id IS']); + $this->assertEquals('ContentFolder', $conditions['Contents.type']); + } + } From b6f61c5f038f697c7064698b17ad81067355b587 Mon Sep 17 00:00:00 2001 From: HungDV2022 <110375578+HungDV2022@users.noreply.github.com> Date: Tue, 29 Oct 2024 06:39:15 +0900 Subject: [PATCH 30/60] =?UTF-8?q?BcContentsHelper::getTree()=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?= =?UTF-8?q?=20(#3923)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Đỗ Văn Hùng Co-authored-by: TPGF00003 --- .../src/View/Helper/BcContentsHelper.php | 1 + .../View/Helper/BcContentsHelperTest.php | 58 ++++++++++++------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/plugins/baser-core/src/View/Helper/BcContentsHelper.php b/plugins/baser-core/src/View/Helper/BcContentsHelper.php index e7c1a068b7..25ee2d4e7c 100644 --- a/plugins/baser-core/src/View/Helper/BcContentsHelper.php +++ b/plugins/baser-core/src/View/Helper/BcContentsHelper.php @@ -279,6 +279,7 @@ public function getCurrentRelatedSiteUrl($siteName) * - `siteId` : サイトID * @checked * @noTodo + * @unitTest */ public function getTree(int $id = 1, ?int $level = null, array $options = []): ResultSetDecorator { diff --git a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php index 3c4b522c83..442097577a 100644 --- a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php +++ b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php @@ -125,24 +125,42 @@ public function test_getExistsTitles() * @param string $message テストが失敗した時に表示されるメッセージ * @dataProvider getPageListDataProvider */ - public function testGetTree($id, $level, $expectedCount, $expectedTitle, $message = null) - { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); - $result = $this->BcContents->getTree($id, $level); + public function testGetTree($id, $level, $expectedCount, $expectedTitle) + { + $this->truncateTable('contents'); + //データ生成 + ContentFactory::make(['id' => 1, 'lft' => 1, 'rght' => 100, 'site_root' => true])->persist(); + //'id' => 1の子 + ContentFactory::make(['id' => 2, 'lft' => 2, 'rght' => 14, 'title' => 'トップページ', 'parent_id' => 1])->persist(); + ContentFactory::make(['id' => 3, 'lft' => 15, 'rght' => 16, 'parent_id' => 1])->persist(); + ContentFactory::make(['id' => 4, 'lft' => 17, 'rght' => 18, 'parent_id' => 1])->persist(); + ContentFactory::make(['id' => 5, 'lft' => 19, 'rght' => 20, 'parent_id' => 1])->persist(); + + //'id' => 2の子 + ContentFactory::make(['id' => 6, 'lft' => 3, 'rght' => 7, 'title' => 'サービス', 'parent_id' => 2])->persist(); + ContentFactory::make(['id' => 7, 'lft' => 8, 'rght' => 9, 'parent_id' => 2])->persist(); + ContentFactory::make(['id' => 8, 'lft' => 10, 'rght' => 11, 'parent_id' => 2])->persist(); + ContentFactory::make(['id' => 9, 'lft' => 12, 'rght' => 13, 'parent_id' => 2])->persist(); + //'id' => 6の子 + ContentFactory::make(['id' => 10, 'lft' => 5, 'rght' => 6, 'title' => 'サブサービス1', 'parent_id' => 6])->persist(); + //'id' => 3の子 + + $result = $this->BcContents->getTree($id, $level)->toArray(); + $resultTitle = null; $resultCount = null; - switch($level) { + switch ($level) { case 1: - if (!empty($result[0]['Content']['title'])) { - $resultTitle = $result[0]['Content']['title']; + if (!empty($result[0]['title'])) { + $resultTitle = $result[0]['title']; $resultCount = count($result); } break; case 2: if ($result) { - foreach($result as $data) { + foreach ($result as $data) { if ($data['children']) { - $resultTitle = $data['children'][0]['Content']['title']; + $resultTitle = $data['children'][0]['title']; $resultCount = count($data['children']); } } @@ -150,11 +168,11 @@ public function testGetTree($id, $level, $expectedCount, $expectedTitle, $messag break; case 3: if ($result) { - foreach($result as $data) { + foreach ($result as $data) { if ($data['children']) { - foreach($data['children'] as $data2) { + foreach ($data['children'] as $data2) { if ($data2['children']) { - $resultTitle = $data2['children'][0]['Content']['title']; + $resultTitle = $data2['children'][0]['title']; $resultCount = count($data2['children']); } } @@ -163,22 +181,19 @@ public function testGetTree($id, $level, $expectedCount, $expectedTitle, $messag } break; } - $this->assertEquals($expectedCount, $resultCount, 'カウントエラー:' . $message); - $this->assertEquals($expectedTitle, $resultTitle, 'タイトルエラー:' . $message); + $this->assertEquals($expectedCount, $resultCount); + $this->assertEquals($expectedTitle, $resultTitle); } public static function getPageListDataProvider() { return [ // PC版 - [1, 1, 7, 'トップページ', 'PC版1階層目のデータが正常に取得できません'], - [1, 2, 4, 'サービス', 'PC版2階層目のデータが正常に取得できません'], - [1, 3, 1, 'サブサービス1', 'PC版3階層目のデータが正常に取得できません'], + [1, 1, 4, 'トップページ'], + [1, 2, 4, 'サービス'], + [1, 3, 1, 'サブサービス1'], // ケータイ - [2, 1, 3, 'トップページ', 'ケータイ版1階層目のデータが正常に取得できません'], - // スマホ - [3, 1, 7, 'トップページ', 'スマホ版1階層目のデータが正常に取得できません'], - [3, 2, 1, 'サービス1', 'スマホ版2階層目のデータが正常に取得できません'] + [2, 1, 4, 'サービス'] ]; } @@ -910,4 +925,5 @@ public function test_isFolder() $rs = $this->BcContents->isFolder(); $this->assertTrue($rs); } + } From 237dd1bb9299266c3e983a7417dd21f0f6cba12d Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Tue, 29 Oct 2024 09:47:04 +0900 Subject: [PATCH 31/60] =?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 --- .../tests/TestCase/View/Helper/BcContentsHelperTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php index 8ae2130961..37c0e370fc 100644 --- a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php +++ b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php @@ -395,7 +395,7 @@ public function testGetRelatedSiteLinks($id, $options, $expect) { ContentFactory::make(['site_id' => 1, 'url' => '/'])->persist(); ContentFactory::make(['site_id' => 2, 'main_site_content_id' => 1, 'url' => '/en/'])->persist(); - ContentFactory::make(['site_id' => 2, 'main_site_content_id' => 2, 'url' => '/en/about'])->persist(); + ContentFactory::make(['site_id' => 3, 'main_site_content_id' => 3, 'url' => '/en/about'])->persist(); $result = $this->BcContents->getRelatedSiteLinks($id, $options); $this->assertEquals($expect, $result); @@ -408,6 +408,7 @@ public static function getRelatedSiteLinksDataProvider() [0, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/index']]], [1, [], [['prefix' => '', 'name' => 'メインサイト', 'url' => '/'], ['prefix' => 'en', 'name' => '英語サイト', 'url' => '/en/']]], [1, ['excludeIds' => [1]], [['prefix' => 'en', 'name' => '英語サイト', 'url' => '/en/']]], + [3, [], [['prefix' => 'en', 'name' => '英語サイト', 'url' => '/en/about']]], ]; } From 82704ed563d05745981f3b1d7e828196784395e6 Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Tue, 29 Oct 2024 09:47:50 +0900 Subject: [PATCH 32/60] =?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 --- .../tests/TestCase/View/Helper/BcContentsHelperTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php index 37c0e370fc..91f1566a29 100644 --- a/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php +++ b/plugins/baser-core/tests/TestCase/View/Helper/BcContentsHelperTest.php @@ -14,7 +14,6 @@ use BaserCore\Model\Entity\Content; use BaserCore\Model\Entity\Site; use BaserCore\Test\Factory\ContentFactory; -use BaserCore\Test\Factory\SiteFactory; use BaserCore\Test\Scenario\ContentsScenario; use BaserCore\Test\Scenario\PermissionsScenario; use BaserCore\Test\Scenario\SitesScenario; From ea7979cabc9b96231d74d60ce64dcc4b6769fc74 Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Tue, 29 Oct 2024 10:20:40 +0900 Subject: [PATCH 33/60] =?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 --- .../tests/TestCase/Service/InstallationsServiceTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php index aa7b7a3698..63734a69cb 100644 --- a/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php +++ b/plugins/bc-installer/tests/TestCase/Service/InstallationsServiceTest.php @@ -20,6 +20,7 @@ use BaserCore\Utility\BcFile; use BcInstaller\Service\InstallationsService; use BcInstaller\Service\InstallationsServiceInterface; +use BcSearchIndex\Test\Scenario\Service\SearchIndexesServiceScenario; use Cake\Core\Configure; use Cake\ORM\Exception\PersistenceFailedException; use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; @@ -237,7 +238,15 @@ public function test_deployAdminAssets() */ public function testExecuteDefaultUpdates() { + //準備 + $this->loadFixtureScenario(SearchIndexesServiceScenario::class); + $searchIndexesTable = $this->getTableLocator()->get('SearchIndexes'); + //テスト前、search_indexes テーブルにデータを確認 + $this->assertEquals(1, $searchIndexesTable->find()->count()); + //テストを実行 $this->assertTrue($this->Installations->executeDefaultUpdates()); + //テスト後、search_indexes テーブルにデータを確認 + $this->assertEquals(3, $searchIndexesTable->find()->count()); } /** From 4d0385852f154a70d6cc00b3a0984779bf63d663 Mon Sep 17 00:00:00 2001 From: thangnn Date: Tue, 29 Oct 2024 10:10:57 +0700 Subject: [PATCH 34/60] modified --- .../Event/BcThemeConfigControllerEventListenerTest.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/plugins/bc-theme-config/tests/TestCase/Event/BcThemeConfigControllerEventListenerTest.php b/plugins/bc-theme-config/tests/TestCase/Event/BcThemeConfigControllerEventListenerTest.php index 53e4cb29cd..7d895584ae 100644 --- a/plugins/bc-theme-config/tests/TestCase/Event/BcThemeConfigControllerEventListenerTest.php +++ b/plugins/bc-theme-config/tests/TestCase/Event/BcThemeConfigControllerEventListenerTest.php @@ -36,13 +36,5 @@ public function test_baserCoreThemesAfterApply() $this->BcThemeConfigControllerEventListener->baserCoreThemesAfterApply($event); $this->assertFileDoesNotExist($path); - - // cleanup - if (file_exists($path)) { - unlink($path); - } - if (is_dir(dirname($path))) { - rmdir(dirname($path)); - } } } From 10147867869f01b24a62c7c2cd57877bc6f410e3 Mon Sep 17 00:00:00 2001 From: thangnn Date: Wed, 30 Oct 2024 13:37:16 +0700 Subject: [PATCH 35/60] Add unitTest_BcAbstractDetector_construct --- .../src/Utility/BcAbstractDetector.php | 1 + .../Utility/BcAbstractDetectorTest.php | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/plugins/baser-core/src/Utility/BcAbstractDetector.php b/plugins/baser-core/src/Utility/BcAbstractDetector.php index fb831f875b..d65a4da4d6 100644 --- a/plugins/baser-core/src/Utility/BcAbstractDetector.php +++ b/plugins/baser-core/src/Utility/BcAbstractDetector.php @@ -62,6 +62,7 @@ abstract class BcAbstractDetector * @param array $config 設定の配列 * @checked * @noTodo + * @unitTest */ public function __construct($name, array $config) { diff --git a/plugins/baser-core/tests/TestCase/Utility/BcAbstractDetectorTest.php b/plugins/baser-core/tests/TestCase/Utility/BcAbstractDetectorTest.php index f5ab3fac85..bca1600b6c 100644 --- a/plugins/baser-core/tests/TestCase/Utility/BcAbstractDetectorTest.php +++ b/plugins/baser-core/tests/TestCase/Utility/BcAbstractDetectorTest.php @@ -100,4 +100,24 @@ public static function findCurrentDataProvider(): array ['hoge', null], ]; } + + /** + * test __construct + */ + public function testConstruct() + { + $name = 'TestName'; + $config = [ + 'agents' => [ + 'iPhone', // Apple iPhone + 'iPod', // Apple iPod touch + 'Android', // 1.5+ Android + 'dream', // Pre 1.5 Android + ] + ]; + $instance = new BcAgent($name, $config); + $this->assertEquals('TestName', $instance->name); + $this->assertEquals($config['agents'][0], $instance->decisionKeys[0]); + $this->assertFalse($instance->sessionId); + } } From 19a90068053e3606d1b42cc9a6acb109f3aa6b9e Mon Sep 17 00:00:00 2001 From: thangnn Date: Wed, 30 Oct 2024 13:38:16 +0700 Subject: [PATCH 36/60] Add unitTest_SetupTestCommand_execute --- .../src/Command/SetupTestCommand.php | 1 + .../TestCase/Command/SetupTestCommandTest.php | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 plugins/baser-core/tests/TestCase/Command/SetupTestCommandTest.php diff --git a/plugins/baser-core/src/Command/SetupTestCommand.php b/plugins/baser-core/src/Command/SetupTestCommand.php index a08822660e..4efa255db0 100644 --- a/plugins/baser-core/src/Command/SetupTestCommand.php +++ b/plugins/baser-core/src/Command/SetupTestCommand.php @@ -39,6 +39,7 @@ class SetupTestCommand extends Command * @return int|void|null * @checked * @noTodo + * @unitTest */ public function execute(Arguments $args, ConsoleIo $io) { diff --git a/plugins/baser-core/tests/TestCase/Command/SetupTestCommandTest.php b/plugins/baser-core/tests/TestCase/Command/SetupTestCommandTest.php new file mode 100644 index 0000000000..04d3f25028 --- /dev/null +++ b/plugins/baser-core/tests/TestCase/Command/SetupTestCommandTest.php @@ -0,0 +1,32 @@ +command = new SetupTestCommand(); + } + + public function tearDown(): void + { + parent::tearDown(); + } + + public function testExecute() + { + $args = new Arguments([], [], []); + $io = new ConsoleIo(); + $this->command->execute($args, $io); + $this->assertEquals('true', env('DEBUG')); + $this->assertEquals('true' ,env('USE_CORE_API')); + $this->assertEquals('true' ,env('USE_CORE_ADMIN_API')); + } +} From a7a46ff57325be9e8beebca2bb8e96ac3ef30f89 Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Thu, 31 Oct 2024 11:16:50 +0900 Subject: [PATCH 37/60] =?UTF-8?q?MailController::index()=20=E3=83=A6?= =?UTF-8?q?=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 --- .../bc-mail/src/Controller/MailController.php | 1 + .../Controller/MailControllerTest.php | 33 +++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/plugins/bc-mail/src/Controller/MailController.php b/plugins/bc-mail/src/Controller/MailController.php index fa4fde61be..ccae3c4762 100755 --- a/plugins/bc-mail/src/Controller/MailController.php +++ b/plugins/bc-mail/src/Controller/MailController.php @@ -134,6 +134,7 @@ public function beforeRender(EventInterface $event): void * @return void * @checked * @noTodo + * @unitTest */ public function index( MailFrontServiceInterface $service, diff --git a/plugins/bc-mail/tests/TestCase/Controller/MailControllerTest.php b/plugins/bc-mail/tests/TestCase/Controller/MailControllerTest.php index 604c4da8d9..88a552da50 100644 --- a/plugins/bc-mail/tests/TestCase/Controller/MailControllerTest.php +++ b/plugins/bc-mail/tests/TestCase/Controller/MailControllerTest.php @@ -11,10 +11,22 @@ namespace BcMail\Test\TestCase\Controller; +use BaserCore\Test\Factory\ContentFactory; +use BaserCore\Test\Factory\SiteFactory; use BaserCore\TestSuite\BcTestCase; +use BaserCore\Utility\BcContainerTrait; +use BcMail\Test\Factory\MailContentFactory; +use BcMail\Test\Factory\MailFieldsFactory; +use Cake\TestSuite\IntegrationTestTrait; +use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; class MailControllerTest extends BcTestCase { + + use ScenarioAwareTrait; + use IntegrationTestTrait; + use BcContainerTrait; + /** * set up * @@ -53,11 +65,28 @@ public function testBeforeRender() /** * [test_index description] - * @return [type] [description] */ public function test_index() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + //準備 + SiteFactory::make(['id' => 1])->persist(); + MailFieldsFactory::make(['mail_content_id' => 1, 'no' => 1])->persist(); + ContentFactory::make(['id' => 1, 'plugin' => 'BcMail', 'type' => 'MailContent', 'entity_id' => 1, 'url' => '/contact/', 'site_id' => 1, 'lft' => 1, 'rght' => 2])->persist(); + MailContentFactory::make(['id' => 1, 'form_template' => 'default', 'mail_template' => 'mail_default'])->persist(); + //正常テスト + $this->get('/contact/'); + + $this->assertResponseOk(); + $vars = $this->_controller->viewBuilder()->getVars(); + $this->assertNotNull($vars['mailContent']); + $this->assertNotNull($vars['mailFields']); + $this->assertNotNull($vars['mailMessage']); + $this->assertNotNull($vars['description']); + $this->assertTrue($_SESSION["BcMail"]["valid"]); + + //異常テスト + $this->get('/contact-test/'); + $this->assertResponseCode(404); } /** From 6068b139e801d63259c475f03d6b075baf35103a Mon Sep 17 00:00:00 2001 From: thangnn Date: Thu, 31 Oct 2024 14:08:17 +0700 Subject: [PATCH 38/60] Add unitTest_MailFieldsTable_duplicateMailField --- .../src/Model/Table/MailFieldsTable.php | 1 + .../Model/Table/MailFieldsTableTest.php | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/plugins/bc-mail/src/Model/Table/MailFieldsTable.php b/plugins/bc-mail/src/Model/Table/MailFieldsTable.php index a5de9fdada..228f6cff6d 100755 --- a/plugins/bc-mail/src/Model/Table/MailFieldsTable.php +++ b/plugins/bc-mail/src/Model/Table/MailFieldsTable.php @@ -207,6 +207,7 @@ public function getControlSource($field = null) * @return boolean * @checked * @noTodo + * @unitTest */ public function duplicateMailField(string $value, array $context) { diff --git a/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php b/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php index 1664de4fd7..4aa429f809 100755 --- a/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php +++ b/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php @@ -14,6 +14,9 @@ use BaserCore\TestSuite\BcTestCase; use BcMail\Model\Table\MailFieldsTable; use BcMail\Test\Factory\MailFieldsFactory; +use BcMail\Test\Scenario\MailContentsScenario; +use BcMail\Test\Scenario\MailFieldsScenario; +use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; /** * @property MailFieldsTable $MailFieldsTable @@ -21,6 +24,8 @@ class MailFieldsTableTest extends BcTestCase { + use ScenarioAwareTrait; + /** * Set Up * @@ -167,7 +172,22 @@ public function testGetControlSource() */ public function testDuplicateMailField() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + $this->loadFixtureScenario(MailFieldsScenario::class); + $this->loadFixtureScenario(MailContentsScenario::class); + + $context = [ + 'field' => 'field_name', + 'data' => ['mail_content_id' => 1, 'id' => 2], + 'newRecord' => true + ]; + //case false + $result = $this->MailFieldsTable->duplicateMailField('name_1', $context); + $this->assertFalse($result); + + //case true + $result = $this->MailFieldsTable->duplicateMailField('name_test', $context); + $this->assertTrue($result); + } /** From 54ef298e250e601105fcbafb2265e6737dae986f Mon Sep 17 00:00:00 2001 From: thangnn Date: Thu, 31 Oct 2024 14:09:23 +0700 Subject: [PATCH 39/60] Add unitTest_MailContent_getNumberOfMessages --- .../bc-mail/src/Model/Entity/MailContent.php | 1 + .../TestCase/Model/Entity/MailContentTest.php | 67 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 plugins/bc-mail/tests/TestCase/Model/Entity/MailContentTest.php diff --git a/plugins/bc-mail/src/Model/Entity/MailContent.php b/plugins/bc-mail/src/Model/Entity/MailContent.php index e40f6c1740..5babb22437 100755 --- a/plugins/bc-mail/src/Model/Entity/MailContent.php +++ b/plugins/bc-mail/src/Model/Entity/MailContent.php @@ -60,6 +60,7 @@ class MailContent extends Entity * @return int * @checked * @noTodo + * @unitTest */ public function getNumberOfMessages() { diff --git a/plugins/bc-mail/tests/TestCase/Model/Entity/MailContentTest.php b/plugins/bc-mail/tests/TestCase/Model/Entity/MailContentTest.php new file mode 100644 index 0000000000..e35781ed72 --- /dev/null +++ b/plugins/bc-mail/tests/TestCase/Model/Entity/MailContentTest.php @@ -0,0 +1,67 @@ +MailContent = new MailContent(); + } + + public function tearDown(): void + { + parent::tearDown(); + } + + + /** + * Test getNumberOfMessages + */ + public function testGetNumberOfMessages() + { + $MailMessagesService = $this->getService(MailMessagesServiceInterface::class); + + $rs = $this->MailContent->getNumberOfMessages(); + $this->assertEquals(0, $rs); + + //テストデータベースを生成 + $MailMessagesService->createTable(1); + $mailMessageTable = TableRegistry::getTableLocator()->get('BcMail.MailMessages'); + $mailContentId = 1; + $mailMessageTable->setup($mailContentId); + $mailMessageTable->save(new Entity(['id' => 1])); + $mailMessageTable->save(new Entity(['id' => 2])); + // テストデータを作成する + ContentFactory::make([ + 'id' => 9, + 'name' => 'contact', + 'plugin' => 'BcMail', + 'type' => 'MailContent', + 'entity_id' => 1, + 'url' => '/contact/', + 'site_id' => 1, + 'title' => 'お問い合わせ(※関連Fixture未完了)', + 'status' => true, + ])->persist(); + MailContentFactory::make(['id' => 1, 'save_info' => 1])->persist(); + + $this->MailContent->id = $mailContentId; + + $rs = $this->MailContent->getNumberOfMessages(); + $this->assertEquals(2, $rs); + + //不要なテーブルを削除 + $MailMessagesService->dropTable(1); + } + +} From 1779ae964d2980acaed48df9b4e8a8fe3521430d Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Fri, 1 Nov 2024 12:07:37 +0900 Subject: [PATCH 40/60] =?UTF-8?q?ComposerCommand::execute()=20=E3=83=A6?= =?UTF-8?q?=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 --- plugins/baser-core/src/Command/ComposerCommand.php | 1 + .../tests/TestCase/Command/ComposerCommandTest.php | 12 ++---------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/plugins/baser-core/src/Command/ComposerCommand.php b/plugins/baser-core/src/Command/ComposerCommand.php index 5fe2637907..6f0775c996 100644 --- a/plugins/baser-core/src/Command/ComposerCommand.php +++ b/plugins/baser-core/src/Command/ComposerCommand.php @@ -34,6 +34,7 @@ class ComposerCommand extends Command * @return \Cake\Console\ConsoleOptionParser * @checked * @noTodo + * @unitTest */ protected function buildOptionParser(\Cake\Console\ConsoleOptionParser $parser): \Cake\Console\ConsoleOptionParser { diff --git a/plugins/baser-core/tests/TestCase/Command/ComposerCommandTest.php b/plugins/baser-core/tests/TestCase/Command/ComposerCommandTest.php index c1a471b2f7..1eb5afb4b8 100644 --- a/plugins/baser-core/tests/TestCase/Command/ComposerCommandTest.php +++ b/plugins/baser-core/tests/TestCase/Command/ComposerCommandTest.php @@ -57,7 +57,6 @@ public function testBuildOptionParser() */ public function testExecute() { - $this->markTestIncomplete('CakePHPのバージョンの問題があるので、baserCMS 5.1.0 をリリースしてから再実装する'); // バージョン指定なし $this->exec('composer'); $this->assertErrorContains('Missing required argument. The `version` argument is required'); @@ -68,23 +67,16 @@ public function testExecute() copy(ROOT . DS . 'composer.lock', ROOT . DS . 'composer.lock.bak'); // composer実行(composer.json を配布用にセットアップなし) - $this->exec('composer 5.0.15'); + $this->exec('composer 9999.9999.9999'); $this->assertExitError(); $this->assertErrorContains('Composer によるアップデートが失敗しました。update ログを確認してください。'); // composer実行(composer.json を配布用にセットアップ) BcComposer::setup('', ROOT . DS); - BcComposer::setupComposerForDistribution('5.0.15'); - $this->exec('composer 5.0.15'); + $this->exec('composer 5.1.3.0'); $this->assertExitCode(Command::CODE_SUCCESS); $this->assertOutputContains('Composer によるアップデートが完了しました。'); - // バージョンを確認 - $file = new BcFile(ROOT . DS . 'vendor' . DS . 'baserproject' . DS . 'baser-core' . DS . 'VERSION.txt'); - $versionData = $file->read(); - $aryVersionData = explode("\n", $versionData); - $this->assertEquals('5.0.15', $aryVersionData[0]); - // バックアップをリストア rename(ROOT . DS . 'composer.json.bak', ROOT . DS . 'composer.json'); rename(ROOT . DS . 'composer.lock.bak', ROOT . DS . 'composer.lock'); From 70308c659cc2e1b423435d51d6e736d7cedd411a Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Fri, 1 Nov 2024 13:15:25 +0900 Subject: [PATCH 41/60] =?UTF-8?q?CreateReleaseCommand::execute()=20?= =?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 --- .../src/Command/CreateReleaseCommand.php | 1 + .../Command/CreateReleaseCommandTest.php | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/plugins/baser-core/src/Command/CreateReleaseCommand.php b/plugins/baser-core/src/Command/CreateReleaseCommand.php index 4e2df2a4f8..e5bdbc3bac 100644 --- a/plugins/baser-core/src/Command/CreateReleaseCommand.php +++ b/plugins/baser-core/src/Command/CreateReleaseCommand.php @@ -59,6 +59,7 @@ protected function buildOptionParser(\Cake\Console\ConsoleOptionParser $parser): * @return int|void|null * @checked * @noTodo + * @unitTest */ public function execute(Arguments $args, ConsoleIo $io) { diff --git a/plugins/baser-core/tests/TestCase/Command/CreateReleaseCommandTest.php b/plugins/baser-core/tests/TestCase/Command/CreateReleaseCommandTest.php index d2d730c943..9faf113ef3 100644 --- a/plugins/baser-core/tests/TestCase/Command/CreateReleaseCommandTest.php +++ b/plugins/baser-core/tests/TestCase/Command/CreateReleaseCommandTest.php @@ -4,12 +4,19 @@ use BaserCore\Command\CreateReleaseCommand; use BaserCore\TestSuite\BcTestCase; +use Cake\Command\Command; use Cake\Console\ConsoleOptionParser; use BaserCore\Utility\BcFolder; use Cake\Core\Configure; +use Cake\Console\TestSuite\ConsoleIntegrationTestTrait; class CreateReleaseCommandTest extends BcTestCase { + /** + * Trait + */ + use ConsoleIntegrationTestTrait; + private $packagePath; private $zipFile; public function setUp(): void @@ -68,6 +75,22 @@ public function testBuildOptionParser() $this->assertEquals('master', $options['branch']->defaultValue()); } + /** + * test execute + */ + public function testExecute() + { + //異常テスト + $this->exec('create release'); + $this->assertExitCode(Command::CODE_ERROR); + + //正常テスト + $this->exec('create release 5.1.1'); + $this->assertExitCode(Command::CODE_SUCCESS); + $this->assertOutputContains('リリースパッケージの作成が完了しました。/tmp/basercms.zip を確認してください。'); + $this->assertTrue(file_exists(TMP . 'basercms-5.1.1.zip')); + unlink(TMP . 'basercms-5.1.1.zip'); + } /** * Test deleteExcludeFiles From c14b44739950fa2ae26430e41f078c7b81541ccb Mon Sep 17 00:00:00 2001 From: thangnn Date: Fri, 1 Nov 2024 15:25:21 +0700 Subject: [PATCH 42/60] Add unitTest_SetupInstallCommand_execute --- .../src/Command/SetupInstallCommand.php | 1 + .../Command/SetupInstallCommandTest.php | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 plugins/baser-core/tests/TestCase/Command/SetupInstallCommandTest.php diff --git a/plugins/baser-core/src/Command/SetupInstallCommand.php b/plugins/baser-core/src/Command/SetupInstallCommand.php index 412a7fd266..7db47d451f 100644 --- a/plugins/baser-core/src/Command/SetupInstallCommand.php +++ b/plugins/baser-core/src/Command/SetupInstallCommand.php @@ -41,6 +41,7 @@ class SetupInstallCommand extends Command * @return int|void|null * @checked * @noTodo + * @unitTest */ public function execute(Arguments $args, ConsoleIo $io) { diff --git a/plugins/baser-core/tests/TestCase/Command/SetupInstallCommandTest.php b/plugins/baser-core/tests/TestCase/Command/SetupInstallCommandTest.php new file mode 100644 index 0000000000..160db8bcef --- /dev/null +++ b/plugins/baser-core/tests/TestCase/Command/SetupInstallCommandTest.php @@ -0,0 +1,51 @@ +exec('setup install test'); + $this->assertExitCode(Command::CODE_SUCCESS); + $this->assertOutputContains('インストールの準備ができました。'); + + //backup + rename(ROOT . DS . 'config' . DS . 'install.php.bak', ROOT . DS . 'config' . DS . 'install.php'); + } +} From 1306f1deb20e39c4bda45312b881f4a6c79a6cd2 Mon Sep 17 00:00:00 2001 From: thangnn Date: Fri, 1 Nov 2024 15:34:21 +0700 Subject: [PATCH 43/60] modified --- .../tests/TestCase/Command/SetupInstallCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/baser-core/tests/TestCase/Command/SetupInstallCommandTest.php b/plugins/baser-core/tests/TestCase/Command/SetupInstallCommandTest.php index 160db8bcef..e63f04b1c3 100644 --- a/plugins/baser-core/tests/TestCase/Command/SetupInstallCommandTest.php +++ b/plugins/baser-core/tests/TestCase/Command/SetupInstallCommandTest.php @@ -41,7 +41,7 @@ public function testExecute() //backup file copy(ROOT . DS . 'config' . DS . 'install.php', ROOT . DS . 'config' . DS . 'install.php.bak'); //test - $this->exec('setup install test'); + $this->exec('setup install'); $this->assertExitCode(Command::CODE_SUCCESS); $this->assertOutputContains('インストールの準備ができました。'); From 2e91324431165a067d5fe78c039ff6b7d37aa6b2 Mon Sep 17 00:00:00 2001 From: thangnn Date: Tue, 5 Nov 2024 11:18:01 +0700 Subject: [PATCH 44/60] Add unitTest_AppController_checkPermission --- .../src/Controller/AppController.php | 1 + .../TestCase/Controller/AppControllerTest.php | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/plugins/baser-core/src/Controller/AppController.php b/plugins/baser-core/src/Controller/AppController.php index 61e7822740..042326c8f9 100644 --- a/plugins/baser-core/src/Controller/AppController.php +++ b/plugins/baser-core/src/Controller/AppController.php @@ -195,6 +195,7 @@ public function beforeFilter(EventInterface $event) * @return bool * @noTodo * @checked + * @unitTest */ private function checkPermission() { diff --git a/plugins/baser-core/tests/TestCase/Controller/AppControllerTest.php b/plugins/baser-core/tests/TestCase/Controller/AppControllerTest.php index dc11139e95..14c27cb706 100644 --- a/plugins/baser-core/tests/TestCase/Controller/AppControllerTest.php +++ b/plugins/baser-core/tests/TestCase/Controller/AppControllerTest.php @@ -11,6 +11,7 @@ namespace BaserCore\Test\TestCase\Controller; +use BaserCore\Service\PermissionsServiceInterface; use BaserCore\Service\SiteConfigsServiceInterface; use BaserCore\Test\Scenario\ContentsScenario; use BaserCore\Test\Scenario\InitAppScenario; @@ -147,6 +148,28 @@ public function test_beforeRender() $this->assertEquals('BcAdminThird', $this->AppController->viewBuilder()->getVars()['currentAdminTheme']); } + /** + * test checkPermission + */ + public function testCheckPermission() + { + //準備 + $permissionsService = $this->getService(PermissionsServiceInterface::class); + $permissionsService->addCheck("/fuga", false); + $permissionsService->addCheck("/piyo", true); + + Configure::write('BcApp.adminGroupId', 2); + $this->loginAdmin($this->getRequest('/')); + + //result = false test + $this->AppController->setRequest($this->getRequest('/fuga')); + $this->assertFalse($this->execPrivateMethod($this->AppController, 'checkPermission', [])); + + //result = true test + $this->AppController->setRequest($this->getRequest('/piyo')); + $this->assertTrue($this->execPrivateMethod($this->AppController, 'checkPermission', [])); + } + /** * Test setupFrontView */ From 9f69e67f31f7a1643ad3aa5bbb13475205ee4178 Mon Sep 17 00:00:00 2001 From: thangnn Date: Tue, 5 Nov 2024 11:22:31 +0700 Subject: [PATCH 45/60] Add unitTest_BcFrontAppController_beforeRender --- .../src/Controller/BcFrontAppController.php | 1 + .../TestCase/Controller/BcFrontAppControllerTest.php | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/baser-core/src/Controller/BcFrontAppController.php b/plugins/baser-core/src/Controller/BcFrontAppController.php index afa0637b86..4939ffcada 100644 --- a/plugins/baser-core/src/Controller/BcFrontAppController.php +++ b/plugins/baser-core/src/Controller/BcFrontAppController.php @@ -73,6 +73,7 @@ public function beforeFilter(EventInterface $event) * @param EventInterface $event * @checked * @noTodo + * @unitTest */ public function beforeRender(EventInterface $event): void { diff --git a/plugins/baser-core/tests/TestCase/Controller/BcFrontAppControllerTest.php b/plugins/baser-core/tests/TestCase/Controller/BcFrontAppControllerTest.php index ae24866337..02af962119 100644 --- a/plugins/baser-core/tests/TestCase/Controller/BcFrontAppControllerTest.php +++ b/plugins/baser-core/tests/TestCase/Controller/BcFrontAppControllerTest.php @@ -17,6 +17,7 @@ use BaserCore\TestSuite\BcTestCase; use BaserCore\Utility\BcContainer; use Cake\Core\Configure; +use Cake\Event\Event; use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; /** @@ -95,14 +96,11 @@ public function testBeforeFilter() */ public function testBeforeRender() { - $this->markTestIncomplete('このテストはまだ実装されていません。'); - // TODO ucmitz 本体側の実装要 - /* >>> - $this->BcFrontAppController->setRequest($this->getRequest('/en/サイトID3の固定ページ')); + $this->BcFrontAppController->setRequest($this->getRequest()); $this->BcFrontAppController->beforeRender(new Event('beforeRender')); - $this->assertEquals('en', $this->BcFrontAppController->viewBuilder()->getLayoutPath()); - $this->assertEquals('en', $this->BcFrontAppController->viewBuilder()->getTemplatePath()); - <<< */ + $viewBuilder = $this->BcFrontAppController->viewBuilder(); + $this->assertEquals('BaserCore.BcFrontApp', $viewBuilder->getClassName()); + $this->assertEquals('BcFront', $viewBuilder->getTheme()); } } From bc3b7b77151ce3d6b590036de1072dca5ebe61da Mon Sep 17 00:00:00 2001 From: ryuring Date: Tue, 5 Nov 2024 13:55:02 +0900 Subject: [PATCH 46/60] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=AE?= =?UTF-8?q?=E5=A4=B1=E6=95=97=E3=81=8C=E8=A7=A3=E6=B1=BA=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=81=9F=E3=82=81=E3=82=B9=E3=82=AD=E3=83=83?= =?UTF-8?q?=E3=83=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TestCase/Service/ContentsServiceTest.php | 1 + .../tests/TestCase/Utility/BcComposerTest.php | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/baser-core/tests/TestCase/Service/ContentsServiceTest.php b/plugins/baser-core/tests/TestCase/Service/ContentsServiceTest.php index 69b4508dc2..bbe9198230 100644 --- a/plugins/baser-core/tests/TestCase/Service/ContentsServiceTest.php +++ b/plugins/baser-core/tests/TestCase/Service/ContentsServiceTest.php @@ -453,6 +453,7 @@ public function testGetParentLayoutTemplate() */ public function testGetUrlById($id, $full, $expects) { + $this->loadFixtureScenario(SitesScenario::class); $this->loadFixtureScenario(ContentsScenario::class); $siteUrl = Configure::read('BcEnv.siteUrl'); Configure::write('BcEnv.siteUrl', 'http://main.com'); diff --git a/plugins/baser-core/tests/TestCase/Utility/BcComposerTest.php b/plugins/baser-core/tests/TestCase/Utility/BcComposerTest.php index d063c0dd48..05faaf46ed 100644 --- a/plugins/baser-core/tests/TestCase/Utility/BcComposerTest.php +++ b/plugins/baser-core/tests/TestCase/Utility/BcComposerTest.php @@ -238,12 +238,19 @@ public function testInstall() */ public function testSelfUpdate() { + /** + * 次のエラーが発生するため、テストをスキップ + * The repository at "/var/www/html" does not have the correct ownership and git refuses to use it: + * 次のコマンドを実行するように調整しても解決しなかった + * git config --global --add safe.directory /var/www/html/ + */ + $this->markTestIncomplete('このメソッドを利用すると全体のテストが失敗してしまうためスキップ。対応方法検討要'); BcComposer::setup(); $rs = BcComposer::selfUpdate(); $this->assertEquals(0, $rs['code']); $this->assertEquals("A script named install would override a Composer command and has been skipped", $rs['out'][0]); - $this->assertStringContainsString("You are already using the latest available Composer version", $rs['out'][1]); + $this->assertMatchesRegularExpression("/(You are already using the latest available Composer version|Upgrading to version)/", $rs['out'][1]); } /** @@ -337,6 +344,13 @@ public function testDeleteReplace() */ public function testExecCommand() { + /** + * 次のエラーが発生するため、テストをスキップ + * The repository at "/var/www/html" does not have the correct ownership and git refuses to use it: + * 次のコマンドを実行するように調整しても解決しなかった + * git config --global --add safe.directory /var/www/html/ + */ + $this->markTestIncomplete('このメソッドを利用すると全体のテストが失敗してしまうためスキップ。対応方法検討要'); BcComposer::setup(); $rs = BcComposer::execCommand('update --with-all-dependencies --ignore-platform-req=ext-xdebug'); From d19cdba458093fb4fb04619f18296d79fe09952c Mon Sep 17 00:00:00 2001 From: thangnn Date: Tue, 5 Nov 2024 14:08:12 +0700 Subject: [PATCH 47/60] Add unitTest_UploadsController_tmp --- .../src/Controller/UploadsController.php | 1 + .../Controller/UploadsControllerTest.php | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/baser-core/src/Controller/UploadsController.php b/plugins/baser-core/src/Controller/UploadsController.php index 532c24c2e2..dec30fed63 100644 --- a/plugins/baser-core/src/Controller/UploadsController.php +++ b/plugins/baser-core/src/Controller/UploadsController.php @@ -31,6 +31,7 @@ class UploadsController extends AppController * @return \Cake\Http\Response * @checked * @noTodo + * @unitTest */ public function tmp() { diff --git a/plugins/baser-core/tests/TestCase/Controller/UploadsControllerTest.php b/plugins/baser-core/tests/TestCase/Controller/UploadsControllerTest.php index e11edad2ad..5e5782f645 100644 --- a/plugins/baser-core/tests/TestCase/Controller/UploadsControllerTest.php +++ b/plugins/baser-core/tests/TestCase/Controller/UploadsControllerTest.php @@ -48,8 +48,22 @@ public function tearDown(): void */ public function testTmp() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); - $this->get('/baser/baser-core/uploads/tmp/medium/00000001_eyecatch_png'); + mkdir(TMP . 'uploads'); + touch(TMP . 'uploads/test.gif'); + copy(ROOT . '/plugins/bc-admin-third/webroot/img/baser.power.gif', TMP . 'uploads/test.gif'); + + $this->session([ + 'Upload.test_gif.data' => base64_encode(file_get_contents(TMP . 'uploads/test.gif')), + 'Upload.test_gif.type' => 'image/gif', + 'Upload.test_gif.imagecopy.medium' => ['width' => 100, 'height' => 100], + ]); + + $this->get('/baser-core/uploads/tmp/thumb/test.gif'); + $this->assertResponseSuccess(); + $this->assertNotEmpty($this->_controller->getResponse()->getBody()); + + @unlink(TMP . 'uploads/test.gif'); + rmdir(TMP . 'uploads'); } /** * セッションに保存した一時ファイルを出力する From 3adf29a671828f9a8b49309d36b179ee5371e654 Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Wed, 6 Nov 2024 10:01:41 +0900 Subject: [PATCH 48/60] =?UTF-8?q?CreateReleaseCommand::clonePackage()=20?= =?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 --- .../src/Command/CreateReleaseCommand.php | 1 + .../Command/CreateReleaseCommandTest.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/plugins/baser-core/src/Command/CreateReleaseCommand.php b/plugins/baser-core/src/Command/CreateReleaseCommand.php index 4e2df2a4f8..1ff681c918 100644 --- a/plugins/baser-core/src/Command/CreateReleaseCommand.php +++ b/plugins/baser-core/src/Command/CreateReleaseCommand.php @@ -109,6 +109,7 @@ public function execute(Arguments $args, ConsoleIo $io) * @param string $packagePath * @checked * @noTodo + * @unitTest */ public function clonePackage(string $packagePath, string $branch) { diff --git a/plugins/baser-core/tests/TestCase/Command/CreateReleaseCommandTest.php b/plugins/baser-core/tests/TestCase/Command/CreateReleaseCommandTest.php index d2d730c943..f407c38743 100644 --- a/plugins/baser-core/tests/TestCase/Command/CreateReleaseCommandTest.php +++ b/plugins/baser-core/tests/TestCase/Command/CreateReleaseCommandTest.php @@ -146,4 +146,20 @@ public function test_deletePlugins() //clean up $folder->delete($pluginsPath); } + + /** + * test clonePackage + */ + public function testClonePackage() + { + //テストを実行 + $this->CreateReleaseCommand->clonePackage('/var/www/html/tmp/basercms/', 'master'); + + //パッケージを GitHub よりクローンできるか確認 + $this->assertTrue(is_dir(TMP . 'basercms')); + $this->assertTrue(file_exists(TMP . 'basercms')); + + //不要フォルダを削除 + (new BcFolder(TMP . 'basercms'))->delete(); + } } From b4a62e59441b5f0a9270fbf4a7bd4095eeb7c074 Mon Sep 17 00:00:00 2001 From: TPGF00003 Date: Wed, 6 Nov 2024 10:15:35 +0900 Subject: [PATCH 49/60] =?UTF-8?q?UsersController::initialize()=20=E3=83=A6?= =?UTF-8?q?=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 --- .../src/Controller/UsersController.php | 1 + .../Controller/UsersControllerTest.php | 72 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 plugins/baser-core/tests/TestCase/Controller/UsersControllerTest.php diff --git a/plugins/baser-core/src/Controller/UsersController.php b/plugins/baser-core/src/Controller/UsersController.php index ecc41e1c41..a7b5b34bc2 100644 --- a/plugins/baser-core/src/Controller/UsersController.php +++ b/plugins/baser-core/src/Controller/UsersController.php @@ -33,6 +33,7 @@ class UsersController extends BcFrontAppController * @return void * @checked * @noTodo + * @unitTest */ public function initialize(): void { diff --git a/plugins/baser-core/tests/TestCase/Controller/UsersControllerTest.php b/plugins/baser-core/tests/TestCase/Controller/UsersControllerTest.php new file mode 100644 index 0000000000..870d035a30 --- /dev/null +++ b/plugins/baser-core/tests/TestCase/Controller/UsersControllerTest.php @@ -0,0 +1,72 @@ + + * Copyright (c) NPO baser foundation + * + * @copyright Copyright (c) NPO baser foundation + * @link https://basercms.net baserCMS Project + * @since 5.0.0 + * @license https://basercms.net/license/index.html MIT License + */ + +namespace BaserCore\Test\TestCase\Controller; + +use BaserCore\Controller\UsersController; +use BaserCore\TestSuite\BcTestCase; +use BaserCore\Utility\BcContainerTrait; +use Cake\Core\Configure; +use Cake\TestSuite\IntegrationTestTrait; +use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; + +/** + * BaserCore\Controller\UsersController Test Case + */ +class UsersControllerTest extends BcTestCase +{ + + /** + * Trait + */ + use IntegrationTestTrait; + use BcContainerTrait; + use ScenarioAwareTrait; + + /** + * UsersController + * @var UsersController + */ + public $UsersController; + + /** + * set up + */ + public function setUp(): void + { + parent::setUp(); + Configure::write('BcPrefixAuth.Front.disabled', false); + $this->UsersController = new UsersController($this->getRequest('/')); + } + + /** + * Tear Down + * + * @return void + */ + public function tearDown(): void + { + unset($this->UsersController); + parent::tearDown(); + } + + /** + * Test index method + * + * @return void + */ + public function testInitialize() + { + $this->assertEquals($this->UsersController->Authentication->getUnauthenticatedActions(), ['login']); + $this->assertNotEmpty($this->UsersController->Authentication->getConfig('logoutRedirect')); + } + +} From acc987b8cb45d76429a66bf2d4e8665323840b94 Mon Sep 17 00:00:00 2001 From: seto1 <30764014+seto1@users.noreply.github.com> Date: Wed, 6 Nov 2024 19:05:38 +0900 Subject: [PATCH 50/60] =?UTF-8?q?=E3=82=B5=E3=82=A4=E3=83=88=E7=B7=A8?= =?UTF-8?q?=E9=9B=86=E7=94=BB=E9=9D=A2=E3=81=ABBcFormTable=E3=82=A4?= =?UTF-8?q?=E3=83=99=E3=83=B3=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0=20(#3981?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/bc-admin-third/templates/Admin/Sites/edit.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/bc-admin-third/templates/Admin/Sites/edit.php b/plugins/bc-admin-third/templates/Admin/Sites/edit.php index 7059abb1d7..a802ad956d 100644 --- a/plugins/bc-admin-third/templates/Admin/Sites/edit.php +++ b/plugins/bc-admin-third/templates/Admin/Sites/edit.php @@ -26,8 +26,12 @@ BcAdminForm->create($site) ?> +BcFormTable->dispatchBefore() ?> + BcBaser->element('Sites/form') ?> +BcFormTable->dispatchAfter() ?> +
BcHtml->link(__d('baser_core', '一覧に戻る'), ['action' => 'index'], [ From 1a533f37b71b5b4d865ef902917afac6cf1eaa7d Mon Sep 17 00:00:00 2001 From: seto1 <30764014+seto1@users.noreply.github.com> Date: Wed, 6 Nov 2024 19:06:50 +0900 Subject: [PATCH 51/60] =?UTF-8?q?=E3=82=AB=E3=83=A9=E3=83=A0=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E8=AA=BF=E6=95=B4=20(#3982)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/baser-core/src/Model/Table/ContentsTable.php | 2 +- plugins/baser-core/src/Model/Table/SitesTable.php | 4 ++-- plugins/bc-blog/src/Service/BlogCategoriesService.php | 2 +- .../src/Model/Behavior/BcSearchIndexManagerBehavior.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/baser-core/src/Model/Table/ContentsTable.php b/plugins/baser-core/src/Model/Table/ContentsTable.php index 2b049a09bf..1c760fef5e 100644 --- a/plugins/baser-core/src/Model/Table/ContentsTable.php +++ b/plugins/baser-core/src/Model/Table/ContentsTable.php @@ -409,7 +409,7 @@ public function getUniqueName($name, $parentId, $contentId = null) $query = $this->find()->where(['name LIKE' => $name . '%', 'site_root' => false]); if (isset($parentId)) $query = $query->andWhere(['parent_id' => $parentId]); if ($contentId) { - $query = $query->andWhere(['id <>' => $contentId]); + $query = $query->andWhere(['Contents.id <>' => $contentId]); } $datas = $query->select('name')->orderBy('name')->all()->toArray(); $datas = Hash::extract($datas, '{n}.name'); diff --git a/plugins/baser-core/src/Model/Table/SitesTable.php b/plugins/baser-core/src/Model/Table/SitesTable.php index 41852631d1..db3ddffbbb 100644 --- a/plugins/baser-core/src/Model/Table/SitesTable.php +++ b/plugins/baser-core/src/Model/Table/SitesTable.php @@ -212,7 +212,7 @@ public function pluginExistsByDasherize($value) */ public function getPublishedAll(): ResultSetInterface { - return $this->find()->where(['status' => true])->all(); + return $this->find()->where(['Sites.status' => true])->all(); } /** @@ -236,7 +236,7 @@ public function getList($mainSiteId = null, $options = []) $conditions = []; if (!is_null($options['status'])) { - $conditions = ['status' => $options['status']]; + $conditions = ['Sites.status' => $options['status']]; } if (!is_null($mainSiteId)) { diff --git a/plugins/bc-blog/src/Service/BlogCategoriesService.php b/plugins/bc-blog/src/Service/BlogCategoriesService.php index 76f84ad6fa..f714fdb9a1 100755 --- a/plugins/bc-blog/src/Service/BlogCategoriesService.php +++ b/plugins/bc-blog/src/Service/BlogCategoriesService.php @@ -119,7 +119,7 @@ public function getTreeIndex(int $blogContentId, array $queryParams): array $categories = []; foreach ($srcCategories->toArray() as $key => $value) { /* @var BlogCategory $category */ - $category = $this->BlogCategories->find()->where(['id' => $key])->first(); + $category = $this->BlogCategories->find()->where(['BlogCategories.id' => $key])->first(); if (!preg_match("/^([_]+)/i", $value, $matches)) { $category->depth = 0; $category->layered_title = $category->title; diff --git a/plugins/bc-search-index/src/Model/Behavior/BcSearchIndexManagerBehavior.php b/plugins/bc-search-index/src/Model/Behavior/BcSearchIndexManagerBehavior.php index c702af7d8e..454d2c5e57 100755 --- a/plugins/bc-search-index/src/Model/Behavior/BcSearchIndexManagerBehavior.php +++ b/plugins/bc-search-index/src/Model/Behavior/BcSearchIndexManagerBehavior.php @@ -191,7 +191,7 @@ public function saveSearchIndex($searchIndex) } if (!empty($searchIndex['content_id'])) { - $content = $this->Contents->find()->select(['lft', 'rght'])->where(['id' => $searchIndex['content_id']])->first(); + $content = $this->Contents->find()->select(['lft', 'rght'])->where(['Contents.id' => $searchIndex['content_id']])->first(); $searchIndex['lft'] = $content->lft; $searchIndex['rght'] = $content->rght; } else { From 323b7888a169003b26a27de19f91e3685ee72913 Mon Sep 17 00:00:00 2001 From: CUkomori <102940192+CUkomori@users.noreply.github.com> Date: Wed, 6 Nov 2024 19:08:42 +0900 Subject: [PATCH 52/60] =?UTF-8?q?mailFormLink=E3=83=A1=E3=82=BD=E3=83=83?= =?UTF-8?q?=E3=83=89=E4=BF=AE=E6=AD=A3=20(#3985)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bc-blog/src/View/Helper/BlogHelper.php | 2 +- .../bc-mail/src/View/Helper/MailHelper.php | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/plugins/bc-blog/src/View/Helper/BlogHelper.php b/plugins/bc-blog/src/View/Helper/BlogHelper.php index 5de84141fe..c4ffe43324 100755 --- a/plugins/bc-blog/src/View/Helper/BlogHelper.php +++ b/plugins/bc-blog/src/View/Helper/BlogHelper.php @@ -49,6 +49,7 @@ use BaserCore\Annotation\NoTodo; use BaserCore\Annotation\Checked; use BaserCore\Annotation\UnitTest; +use BcMail\View\Helper\MailHelper; /** * ブログヘルパー @@ -1296,7 +1297,6 @@ public function getEyeCatch($post, $options = []) */ public function mailFormLink($title, $contentsName, $datas = [], $options = []) { - App::uses('MailHelper', 'BcMail.View/Helper'); $MailHelper = new MailHelper($this->_View); $MailHelper->link($title, $contentsName, $datas, $options); } diff --git a/plugins/bc-mail/src/View/Helper/MailHelper.php b/plugins/bc-mail/src/View/Helper/MailHelper.php index 3a65c94d86..1236b3a709 100755 --- a/plugins/bc-mail/src/View/Helper/MailHelper.php +++ b/plugins/bc-mail/src/View/Helper/MailHelper.php @@ -198,6 +198,7 @@ public function descriptionExists() /** * メールフォームへのリンクを生成する + * $contentsNameはコンテンツ管理上の1階層のみ対応 * * @param string $title リンクのタイトル * @param string $contentsName メールフォームのコンテンツ名 @@ -212,10 +213,26 @@ public function link($title, $contentsName, $datas = [], $options = []) { if ($datas && is_array($datas)) { foreach ($datas as $key => $data) { - $datas[$key] = base64UrlsafeEncode($data); + $datas[$key] = BcUtil::base64UrlsafeEncode($data); } } - $link = array_merge(['plugin' => '', 'controller' => $contentsName, 'action' => 'index'], $datas); + + $contentsTable = TableRegistry::getTableLocator()->get('BaserCore.Contents'); + $content = $contentsTable->find('all') + ->where([ + 'Contents.name' => $contentsName, + 'Contents.plugin' => 'BcMail', + 'Contents.type' => 'MailContent', + ]) + ->first(); + + $link = [ + 'plugin' => 'BcMail', + 'controller' => 'Mail', + 'action' => 'index', + 'entityId' => $content->entity_id, + '?' => $datas, + ]; $this->BcBaser->link($title, $link, $options); } From a0b3c2eda11d3f0b53fb260b65ed1976c559db39 Mon Sep 17 00:00:00 2001 From: CUkomori <102940192+CUkomori@users.noreply.github.com> Date: Wed, 6 Nov 2024 19:09:13 +0900 Subject: [PATCH 53/60] =?UTF-8?q?fileLink=E3=83=A1=E3=82=BD=E3=83=83?= =?UTF-8?q?=E3=83=89=E3=81=AE=E4=BF=AE=E6=AD=A3=20(#3986)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/baser-core/src/View/Helper/BcUploadHelper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/baser-core/src/View/Helper/BcUploadHelper.php b/plugins/baser-core/src/View/Helper/BcUploadHelper.php index 446b363fa3..20753d44ec 100755 --- a/plugins/baser-core/src/View/Helper/BcUploadHelper.php +++ b/plugins/baser-core/src/View/Helper/BcUploadHelper.php @@ -26,6 +26,7 @@ use BaserCore\Event\BcEventDispatcherTrait; use BaserCore\Service\SiteConfigsServiceInterface; use Cake\View\Helper\HtmlHelper; +use Laminas\Diactoros\UploadedFile; use Throwable; /** @@ -159,7 +160,7 @@ public function fileLink($fieldName, $entity, $options = []) $basePath = '/baser-core/uploads/tmp/'; } - if (is_array($value)) { + if (is_array($value) || $value instanceof UploadedFile) { return false; } From c687318ddb128ad72c9a64b0987a960276ad5239 Mon Sep 17 00:00:00 2001 From: ryuring Date: Thu, 7 Nov 2024 06:58:57 +0900 Subject: [PATCH 54/60] =?UTF-8?q?=E3=83=86=E3=83=BC=E3=83=9E=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=81=AB=E3=81=A6=20css=20=E8=AA=AD=E3=81=BF=E8=BE=BC?= =?UTF-8?q?=E3=81=BF=E3=81=AE=20Warning=20=E3=81=8C=E5=87=BA=E5=8A=9B?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=81=9F=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/plugin/BcThemeConfig/Admin/ThemeConfigs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/bc-admin-third/templates/plugin/BcThemeConfig/Admin/ThemeConfigs/index.php b/plugins/bc-admin-third/templates/plugin/BcThemeConfig/Admin/ThemeConfigs/index.php index 70a3ad0a8b..9ca47785ec 100644 --- a/plugins/bc-admin-third/templates/plugin/BcThemeConfig/Admin/ThemeConfigs/index.php +++ b/plugins/bc-admin-third/templates/plugin/BcThemeConfig/Admin/ThemeConfigs/index.php @@ -17,7 +17,7 @@ * @noTodo * @unitTest */ -$this->BcBaser->css('vendor/colpick', ['inline' => false]); +$this->BcBaser->css('vendor/colpick', false); $this->BcBaser->js(['vendor/colpick'], false); $this->BcAdmin->setTitle(__d('baser_core', 'テーマ設定')); $this->BcAdmin->setHelp('theme_configs_form'); From d8b2b37e2549539482b8d98104d25c7400f057b7 Mon Sep 17 00:00:00 2001 From: thangnnmd <150879641+thangnnmd@users.noreply.github.com> Date: Thu, 7 Nov 2024 08:32:52 +0700 Subject: [PATCH 55/60] Add unitTest_MailMessagesController_download (#3983) Co-authored-by: thangnn --- .../Api/Admin/MailMessagesController.php | 1 + .../src/Service/Admin/MailMessagesAdminService.php | 3 ++- .../Api/Admin/MailMessagesControllerTest.php | 14 +++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/bc-mail/src/Controller/Api/Admin/MailMessagesController.php b/plugins/bc-mail/src/Controller/Api/Admin/MailMessagesController.php index 4ce9eb1a09..663fe68f36 100644 --- a/plugins/bc-mail/src/Controller/Api/Admin/MailMessagesController.php +++ b/plugins/bc-mail/src/Controller/Api/Admin/MailMessagesController.php @@ -314,6 +314,7 @@ public function batch(MailMessagesServiceInterface $service, $mailContentId) * * @checked * @noTodo + * @unitTest */ public function download(MailMessagesAdminServiceInterface $service, int $mailContentId) { diff --git a/plugins/bc-mail/src/Service/Admin/MailMessagesAdminService.php b/plugins/bc-mail/src/Service/Admin/MailMessagesAdminService.php index 93c3543a04..1ed4547989 100644 --- a/plugins/bc-mail/src/Service/Admin/MailMessagesAdminService.php +++ b/plugins/bc-mail/src/Service/Admin/MailMessagesAdminService.php @@ -86,11 +86,12 @@ public function getViewVarsForView(int $mailContentId, int $mailMessageId) */ public function getViewVarsForDownloadCsv(int $mailContentId, ServerRequest $request) { + $currentContent = $request->getAttribute('currentContent'); $this->setup($mailContentId); return [ 'encoding' => $request->getQuery('encoding') ?? 'utf-8', 'messages' => $this->MailMessages->convertMessageToCsv($this->getIndex()->all()->toArray()), - 'contentName' => $request->getAttribute('currentContent')?->name, + 'contentName' => $currentContent ? $request->getAttribute('currentContent')?->name : '', ]; } diff --git a/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailMessagesControllerTest.php b/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailMessagesControllerTest.php index 71b6758e2b..69e134efa9 100644 --- a/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailMessagesControllerTest.php +++ b/plugins/bc-mail/tests/TestCase/Controller/Api/Admin/MailMessagesControllerTest.php @@ -362,6 +362,18 @@ public function testBatch() */ public function testDownload() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + // メールメッセージのデータを作成する + $MailMessagesService = $this->getService(MailMessagesServiceInterface::class); + //テストデータベースを生成 + $MailMessagesService->createTable(1); + $mailMessageTable = TableRegistry::getTableLocator()->get('BcMail.MailMessages'); + $mailContentId = 1; + $mailMessageTable->setup($mailContentId); + $mailMessageTable->save(new Entity(['id' => 2])); + + ob_start(); + $this->get("/baser/api/admin/bc-mail/mail_messages/download/1.json?token=$this->accessToken"); + $actual = ob_get_clean(); + $this->assertNotEmpty($actual); } } From 74b66d730699d45a7e691917fd682e2efe0b51cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8A=A0=E8=97=A4=20=E6=9C=97?= Date: Thu, 7 Nov 2024 10:35:45 +0900 Subject: [PATCH 56/60] =?UTF-8?q?fix=20#3959=20=E3=80=90blog=E3=80=91?= =?UTF-8?q?=E4=B8=80=E8=A6=A7=E8=A1=A8=E7=A4=BA=E3=81=A7=E3=83=96=E3=83=AD?= =?UTF-8?q?=E3=82=B0ID=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=99=E3=82=8B?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=80=81ID=E3=81=8C=E8=A4=87=E6=95=B0?= =?UTF-8?q?=E3=81=AE=E5=A0=B4=E5=90=88=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=82=8B=E5=95=8F=E9=A1=8C=E3=82=92=E8=A7=A3=E6=B1=BA?= =?UTF-8?q?=20(#3960)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: kato --- plugins/bc-blog/src/Service/BlogPostsService.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/bc-blog/src/Service/BlogPostsService.php b/plugins/bc-blog/src/Service/BlogPostsService.php index 750f422029..b16aa2cd4b 100755 --- a/plugins/bc-blog/src/Service/BlogPostsService.php +++ b/plugins/bc-blog/src/Service/BlogPostsService.php @@ -271,8 +271,14 @@ protected function createIndexConditions(Query $query, array $params) } else { $conditions = []; } - // ID - if ($params['id']) $conditions["BlogPosts.id"] = $params['id']; + // ID【blog】一覧表示でブログIDを指定する時、IDが複数の場合エラーになる問題を解決 + if ($params['id']) { + if (is_array($params['id'])) { + $conditions["BlogPosts.id IN"] = $params['id']; + } else { + $conditions["BlogPosts.id"] = $params['id']; + } + } // タイトル if (!is_null($params['title'])) $conditions['BlogPosts.title LIKE'] = '%' . $params['title'] . '%'; // ユーザーID From d2efe4fffaf21141525edba334e4578849a05a43 Mon Sep 17 00:00:00 2001 From: hideichi saito Date: Thu, 7 Nov 2024 11:57:36 +0900 Subject: [PATCH 57/60] =?UTF-8?q?Theme=E3=81=AE=E8=AA=AD=E3=81=BF=E8=BE=BC?= =?UTF-8?q?=E3=81=BF=E9=A0=86=E5=A4=89=E6=9B=B4=E3=80=82bc=5Fform.php?= =?UTF-8?q?=E3=82=92setting.php=E3=81=A7=E5=A4=89=E6=9B=B4=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=80=82=20(#3973?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/baser-core/config/setting.php | 10 ++ plugins/baser-core/src/BaserCorePlugin.php | 119 ++++++++++++------ plugins/baser-core/src/View/AppView.php | 3 +- .../baser-core/src/View/BcAdminAppView.php | 2 +- ...PluginTest.php => BaserCorePluginTest.php} | 2 +- plugins/bc-mail/config/setting.php | 9 +- plugins/bc-mail/src/View/MailFrontAppView.php | 3 +- 7 files changed, 108 insertions(+), 40 deletions(-) rename plugins/baser-core/tests/TestCase/{PluginTest.php => BaserCorePluginTest.php} (99%) diff --git a/plugins/baser-core/config/setting.php b/plugins/baser-core/config/setting.php index 857c6cd3d2..1ff0108ae9 100644 --- a/plugins/baser-core/config/setting.php +++ b/plugins/baser-core/config/setting.php @@ -417,6 +417,16 @@ */ 'enableRootRoutes' => false, + /** + * bc_formのテンプレートを指定 + * config/bc_form.phpを差し替える + * プラグイン記法 (プラグイン名.テンプレート名) + */ + //basercms/plugins/baser-core/src/View/AppView.php + 'AppFormTemplate' => 'BaserCore.bc_form', + //basercms/plugins/baser-core/src/View/BcAdminAppView.php + 'AdminFormTemplate' => 'BaserCore.bc_form', + /** * システムナビ * diff --git a/plugins/baser-core/src/BaserCorePlugin.php b/plugins/baser-core/src/BaserCorePlugin.php index 703f272e07..0165c97b3b 100644 --- a/plugins/baser-core/src/BaserCorePlugin.php +++ b/plugins/baser-core/src/BaserCorePlugin.php @@ -151,7 +151,7 @@ public function bootstrap(PluginApplicationInterface $app): void } /** - * プラグインロード + * テーマ・プラグインロード */ if (!filter_var(env('USE_DEBUG_KIT', true), FILTER_VALIDATE_BOOLEAN)) { // 明示的に指定がない場合、DebugKitは重すぎるのでデバッグモードでも利用しない @@ -164,19 +164,19 @@ public function bootstrap(PluginApplicationInterface $app): void } if (BcUtil::isTest()) $app->addPlugin('CakephpFixtureFactories'); - $app->addPlugin('Authentication'); - $app->addPlugin('Migrations'); - $this->addTheme($app); - - $plugins = BcUtil::getEnablePlugins(); - if ($plugins) { - foreach($plugins as $plugin) { - if (BcUtil::includePluginClass($plugin->name)) { - $this->loadPlugin($app, $plugin->name, $plugin->priority); - } - } - } + // 利用可能なテーマを取得 + $themes = $this->getAvailableThemes(); + // プラグインを追加する前にテーマが保有するプラグインのパスをセット + $this->setupThemePlugin($themes); + // テーマが保有するプラグインも含めてプラグインを読み込む + $this->addPlugin($app); + // ====================================================== + // テーマはプラグインの後に読み込む + // テーマもプラグインとして扱う場合があるため、 + // その場合に、テーマでプラグインの設定等を上書きできるようにする + // ====================================================== + $this->addTheme($app, $themes); /** * デフォルトテンプレートを設定する @@ -194,42 +194,65 @@ public function bootstrap(PluginApplicationInterface $app): void $event->on(new BcAuthenticationEventListener()); } + /** + * プラグインを追加する + * @param PluginApplicationInterface $app + * @return void + * @checked + * @noTodo + */ + public function addPlugin(PluginApplicationInterface $app): void + { + $app->addPlugin('Authentication'); + $app->addPlugin('Migrations'); + + $plugins = BcUtil::getEnablePlugins(); + if(!$plugins) return; + foreach($plugins as $plugin) { + if (!BcUtil::includePluginClass($plugin->name)) continue; + $this->loadPlugin($app, $plugin->name, $plugin->priority); + } + } + /** * テーマを追加する * - * テーマ内のプラグインも追加する - * * @param PluginApplicationInterface $application * @noTodo * @checked */ - public function addTheme(PluginApplicationInterface $application) + public function addTheme(PluginApplicationInterface $application, array $themes): void { $application->addPlugin(Inflector::camelize(Configure::read('BcApp.coreAdminTheme'), '-')); $application->addPlugin(Inflector::camelize(Configure::read('BcApp.coreFrontTheme'), '-')); if (!BcUtil::isInstalled()) return; - $sitesTable = TableRegistry::getTableLocator()->get('BaserCore.Sites'); - try { - $sites = $sitesTable->find()->where(['Sites.status' => true]); - } catch (MissingConnectionException) { - return; - } - $path = []; - foreach($sites as $site) { - if ($site->theme) { - if(!BcUtil::includePluginClass($site->theme)) continue; - try { - $application->addPlugin($site->theme); - $pluginPath = CorePlugin::path($site->theme) . 'plugins' . DS; - if (!is_dir($pluginPath)) continue; - $path[] = $pluginPath; - } catch (MissingPluginException $e) { - $this->log($e->getMessage()); - } + foreach($themes as $theme) { + if(!BcUtil::includePluginClass($theme)) continue; + try { + $application->addPlugin($theme); + } catch (MissingPluginException $e) { + $this->log($e->getMessage()); } } - // テーマプラグインを追加 + } + + /** + * テーマが保有するプラグインのパスを追加する + * @param array $themes + * @return void + * @checked + * @noTodo + */ + public function setupThemePlugin(array $themes): void + { + if (!BcUtil::isInstalled()) return; + if(!$themes) return; + foreach($themes as $theme) { + $pluginsPath = CorePlugin::path($theme) . 'plugins' . DS; + if (!is_dir($pluginsPath)) continue; + $path[] = $pluginsPath; + } if($path) { Configure::write('App.paths.plugins', array_merge( Configure::read('App.paths.plugins'), @@ -238,6 +261,32 @@ public function addTheme(PluginApplicationInterface $application) } } + /** + * 利用可能なテーマを取得する + * @return array + * @checked + * @noTodo + */ + public function getAvailableThemes(): array + { + if (!BcUtil::isInstalled()) return []; + $sitesTable = TableRegistry::getTableLocator()->get('BaserCore.Sites'); + try { + $sites = $sitesTable->find()->where(['Sites.status' => true]); + } catch (MissingConnectionException) { + return []; + } + $themes = []; + foreach($sites as $site) { + if ($site->theme) { + if (!is_dir(CorePlugin::path($site->theme))) continue; + if(in_array($site->theme, $themes)) continue; + $themes[] = $site->theme; + } + } + return $themes; + } + /** * デフォルトテンプレートを設定する * @checked diff --git a/plugins/baser-core/src/View/AppView.php b/plugins/baser-core/src/View/AppView.php index 5be106520a..3160f2134e 100644 --- a/plugins/baser-core/src/View/AppView.php +++ b/plugins/baser-core/src/View/AppView.php @@ -16,6 +16,7 @@ use BaserCore\View\Helper\BcToolbarHelper; use BaserCore\View\Helper\BcUploadHelper; use Cake\View\View; +use Cake\Core\Configure; use BaserCore\Annotation\NoTodo; use BaserCore\Annotation\Checked; use BaserCore\Annotation\UnitTest; @@ -53,7 +54,7 @@ public function initialize(): void { parent::initialize(); $this->addHelper('BaserCore.BcTime'); - $this->addHelper('BaserCore.BcForm', ['templates' => 'BaserCore.bc_form']); + $this->addHelper('BaserCore.BcForm', ['templates' => Configure::read('BcApp.AppFormTemplate')]); $this->addHelper('BaserCore.BcAdmin'); $this->addHelper('BaserCore.BcContents'); $this->addHelper('BaserCore.BcPage'); diff --git a/plugins/baser-core/src/View/BcAdminAppView.php b/plugins/baser-core/src/View/BcAdminAppView.php index ab89a0fa3a..8b586067b8 100644 --- a/plugins/baser-core/src/View/BcAdminAppView.php +++ b/plugins/baser-core/src/View/BcAdminAppView.php @@ -56,7 +56,7 @@ class BcAdminAppView extends AppView public function initialize(): void { parent::initialize(); - $this->addHelper('BaserCore.BcAdminForm', ['templates' => 'BaserCore.bc_form']); + $this->addHelper('BaserCore.BcAdminForm', ['templates' => Configure::read('BcApp.AdminFormTemplate')]); $this->addHelper('BaserCore.BcAuth'); $this->addHelper('BaserCore.BcText'); $this->addHelper('BaserCore.BcContents'); diff --git a/plugins/baser-core/tests/TestCase/PluginTest.php b/plugins/baser-core/tests/TestCase/BaserCorePluginTest.php similarity index 99% rename from plugins/baser-core/tests/TestCase/PluginTest.php rename to plugins/baser-core/tests/TestCase/BaserCorePluginTest.php index 346438ad39..07516be77a 100644 --- a/plugins/baser-core/tests/TestCase/PluginTest.php +++ b/plugins/baser-core/tests/TestCase/BaserCorePluginTest.php @@ -42,7 +42,7 @@ * Class PluginTest * @property BaserCorePlugin $Plugin */ -class PluginTest extends BcTestCase +class BaserCorePluginTest extends BcTestCase { use ScenarioAwareTrait; diff --git a/plugins/bc-mail/config/setting.php b/plugins/bc-mail/config/setting.php index 9c8bec4378..caed5a3e3d 100755 --- a/plugins/bc-mail/config/setting.php +++ b/plugins/bc-mail/config/setting.php @@ -154,6 +154,13 @@ ['name' => 'email', 'title' => 'Eメールアドレス'], ['name' => 'impp', 'title' => 'インスタントメッセージングプロトコルの端点'], ['name' => 'on', 'title' => '自動設定'], - ] + ], + /** + * bc_formのテンプレートを指定 + * config/bc_form.phpを差し替える + * プラグイン記法 (プラグイン名.テンプレート名) + * basercms/plugins/bc-mail/src/View/MailFrontAppView.php + */ + 'formTemplate' => 'BaserCore.bc_form' ] ]; diff --git a/plugins/bc-mail/src/View/MailFrontAppView.php b/plugins/bc-mail/src/View/MailFrontAppView.php index 24d0908844..aefa4a2a18 100644 --- a/plugins/bc-mail/src/View/MailFrontAppView.php +++ b/plugins/bc-mail/src/View/MailFrontAppView.php @@ -11,6 +11,7 @@ namespace BcMail\View; +use Cake\Core\Configure; use BaserCore\View\BcFrontAppView; use BaserCore\Annotation\UnitTest; use BaserCore\Annotation\NoTodo; @@ -39,7 +40,7 @@ public function initialize(): void parent::initialize(); $this->addHelper('BcMail.Mail'); $this->addHelper('BcMail.Mailfield'); - $this->addHelper('BcMail.Mailform', ['templates' => 'BaserCore.bc_form']); + $this->addHelper('BcMail.Mailform', ['templates' => Configure::read('BcMail.formTemplate')]); } } From 34ec5d21d5b88df99745c7d783aa37022267d1d1 Mon Sep 17 00:00:00 2001 From: ryuring Date: Thu, 7 Nov 2024 12:19:32 +0900 Subject: [PATCH 58/60] =?UTF-8?q?BaserCorePlugin=20=E3=81=AB=E3=81=A6=20Wa?= =?UTF-8?q?rning=20=E3=81=8C=E5=87=BA=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE?= =?UTF-8?q?=E3=81=A7=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/baser-core/src/BaserCorePlugin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/baser-core/src/BaserCorePlugin.php b/plugins/baser-core/src/BaserCorePlugin.php index 0165c97b3b..f23deb8969 100644 --- a/plugins/baser-core/src/BaserCorePlugin.php +++ b/plugins/baser-core/src/BaserCorePlugin.php @@ -248,6 +248,7 @@ public function setupThemePlugin(array $themes): void { if (!BcUtil::isInstalled()) return; if(!$themes) return; + $path = []; foreach($themes as $theme) { $pluginsPath = CorePlugin::path($theme) . 'plugins' . DS; if (!is_dir($pluginsPath)) continue; From e1ecf55793c6bb430a908e2aee998179b115573e Mon Sep 17 00:00:00 2001 From: ryuring Date: Thu, 7 Nov 2024 12:26:38 +0900 Subject: [PATCH 59/60] =?UTF-8?q?=E3=82=B5=E3=82=A4=E3=83=88=E7=B7=A8?= =?UTF-8?q?=E9=9B=86=E7=94=BB=E9=9D=A2=E3=81=AB=E3=81=A6=E3=83=87=E3=83=90?= =?UTF-8?q?=E3=82=A4=E3=82=B9=E3=83=BB=E8=A8=80=E8=AA=9E=E3=81=AE=E3=82=A2?= =?UTF-8?q?=E3=82=AF=E3=82=BB=E3=82=B9=E8=A8=AD=E5=AE=9A=E3=81=AE=E5=8B=95?= =?UTF-8?q?=E4=BD=9C=E4=B8=8D=E8=89=AF=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/bc-admin-third/templates/Admin/Sites/edit.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/bc-admin-third/templates/Admin/Sites/edit.php b/plugins/bc-admin-third/templates/Admin/Sites/edit.php index a802ad956d..0fedc7dbca 100644 --- a/plugins/bc-admin-third/templates/Admin/Sites/edit.php +++ b/plugins/bc-admin-third/templates/Admin/Sites/edit.php @@ -17,6 +17,9 @@ */ $this->BcAdmin->setTitle(__d('baser_core', 'サイト編集')); $this->BcAdmin->setHelp('sites_form'); +$this->BcBaser->js('admin/sites/form.bundle', false, [ + 'defer' => true +]); $this->BcAdmin->addAdminMainBodyHeaderLinks([ 'url' => ['action' => 'add'], 'title' => __d('baser_core', '新規追加'), From 4ad5093e5311930d0576c4371641673d87a73c6a Mon Sep 17 00:00:00 2001 From: ryuring Date: Thu, 7 Nov 2024 13:51:08 +0900 Subject: [PATCH 60/60] =?UTF-8?q?=E3=82=AB=E3=82=B9=E3=82=BF=E3=83=A0?= =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=83=86=E3=83=B3=E3=83=84=E3=81=A7=E9=96=A2?= =?UTF-8?q?=E9=80=A3=E3=83=95=E3=82=A3=E3=83=BC=E3=83=AB=E3=83=89=E3=81=AE?= =?UTF-8?q?=E8=AA=AC=E6=98=8E=E6=96=87=E8=A1=A8=E7=A4=BA=E3=82=92=E3=82=B5?= =?UTF-8?q?=E3=83=8B=E3=82=BF=E3=82=A4=E3=82=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/View/Helper/CustomContentAdminHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/bc-custom-content/src/View/Helper/CustomContentAdminHelper.php b/plugins/bc-custom-content/src/View/Helper/CustomContentAdminHelper.php index 20b4a2d9d7..c812732534 100644 --- a/plugins/bc-custom-content/src/View/Helper/CustomContentAdminHelper.php +++ b/plugins/bc-custom-content/src/View/Helper/CustomContentAdminHelper.php @@ -231,7 +231,7 @@ public function description(CustomLink $link) if ($link->description) { return '' . '
' . - $link->description . + preg_replace('/]*>(.*?)<\/script>/is', '', $link->description) . '
'; } return '';