From 508b2afcc60d28a175dc4dd1ccf5086bf1524633 Mon Sep 17 00:00:00 2001 From: HungDV2022 <110375578+HungDV2022@users.noreply.github.com> Date: Sat, 17 Feb 2024 12:04:03 +0900 Subject: [PATCH] =?UTF-8?q?BlogHelper::isArchive=20=E3=81=AE=E3=83=A6?= =?UTF-8?q?=E3=83=8B=E3=83=83=E3=83=88=E3=83=86=E3=82=B9=E3=83=88=20(#3122?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Đỗ Văn Hùng --- .../bc-blog/src/View/Helper/BlogHelper.php | 1 + .../TestCase/View/Helper/BlogHelperTest.php | 28 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/plugins/bc-blog/src/View/Helper/BlogHelper.php b/plugins/bc-blog/src/View/Helper/BlogHelper.php index ee95827f1d..d33f803a04 100755 --- a/plugins/bc-blog/src/View/Helper/BlogHelper.php +++ b/plugins/bc-blog/src/View/Helper/BlogHelper.php @@ -1119,6 +1119,7 @@ public function getBlogArchiveType() * @return boolean 現在のページがアーカイブページの場合は true を返す * @checked * @noTodo + * @unitTest */ public function isArchive() { diff --git a/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php b/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php index 966a3d28bf..1e378238e1 100755 --- a/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php +++ b/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php @@ -1558,7 +1558,7 @@ public function testIsTag($type, $expects) /** - * test isArchive + * test isCategory * @dataProvider isCategoryDataProvider * */ @@ -1584,6 +1584,32 @@ public static function isCategoryDataProvider() ]; } + /** + * test isArchive + * @dataProvider isArchiveDataProvider + */ + public function test_isArchive($type, $expects) + { + SiteFactory::make(['id' => 1, 'status' => true])->persist(); + $this->Blog->getView()->setRequest($this->getRequest()->withAttribute('currentSite', SiteFactory::get(1))); + $this->Blog->getView()->set('blogArchiveType', $type); + $result = $this->Blog->isArchive(); + $this->assertEquals($expects, $result); + } + + public static function isArchiveDataProvider() + { + return [ + ['category', true], + ['tag', true], + ['yearly', true], + ['monthly', true], + ['daily', true], + ['hoge', true], // 存在しないアーカイブの場合 + ['', false], // アーカイブ指定がない場合 + ]; + } + /** * test isDate