From 7bdc8c481e1bfd5490c00c764c1982e42109d8ca Mon Sep 17 00:00:00 2001 From: thangnnmd <150879641+thangnnmd@users.noreply.github.com> Date: Tue, 5 Mar 2024 12:46:22 +0700 Subject: [PATCH] add unitTest_BlogHelper_isHome (#3188) Co-authored-by: thangnn --- plugins/bc-blog/src/View/Helper/BlogHelper.php | 1 + .../TestCase/View/Helper/BlogHelperTest.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/plugins/bc-blog/src/View/Helper/BlogHelper.php b/plugins/bc-blog/src/View/Helper/BlogHelper.php index 82d8560e1e..71d95638ef 100755 --- a/plugins/bc-blog/src/View/Helper/BlogHelper.php +++ b/plugins/bc-blog/src/View/Helper/BlogHelper.php @@ -1216,6 +1216,7 @@ public function isSingle() * @return boolean 現在のページがインデックスページの場合は true を返す * @checked * @noTodo + * @unitTest */ public function isHome() { diff --git a/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php b/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php index 365db7005e..fccfafa390 100755 --- a/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php +++ b/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php @@ -1774,6 +1774,22 @@ public static function isTagDataProvider() ]; } + /** + * isHome + */ + public function test_isHome() + { + SiteFactory::make(['id' => 1])->persist(); + $this->Blog->getView()->setRequest($this->getRequest()->withAttribute('currentSite', SiteFactory::get(1))); + //param is empty + $result = $this->Blog->isHome(); + $this->assertFalse($result); + //param is not empty + $this->Blog->getView()->setRequest($this->getRequest('/news/')); + $result = $this->Blog->isHome(); + $this->assertTrue($result); + } + /** * 現在のブログタグアーカイブのブログタグ情報を取得する * @dataProvider getCurrentBlogTagDataProvider