diff --git a/plugins/bc-blog/src/View/Helper/BlogHelper.php b/plugins/bc-blog/src/View/Helper/BlogHelper.php index 71d95638ef..398cbc5917 100755 --- a/plugins/bc-blog/src/View/Helper/BlogHelper.php +++ b/plugins/bc-blog/src/View/Helper/BlogHelper.php @@ -1198,6 +1198,7 @@ public function isYear() * @return boolean 現在のページが個別ページの場合は true を返す * @checked * @noTodo + * @unitTest */ public function isSingle() { @@ -1206,8 +1207,7 @@ public function isSingle() } return ($this->_View->getRequest()->getParam('plugin') == 'BcBlog' && $this->_View->getRequest()->getParam('controller') == 'Blog' && - $this->_View->getRequest()->getParam('action') == 'archives' && - !$this->getBlogArchiveType()); + $this->_View->getRequest()->getParam('action') == 'archives' && !$this->getBlogArchiveType()); } /** diff --git a/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php b/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php index fccfafa390..399797d096 100755 --- a/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php +++ b/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php @@ -1761,6 +1761,30 @@ public static function isYearDataProvider() ]; } + /** + * test isSingle + */ + public function test_isSingle() + { + SiteFactory::make(['id' => 1])->persist(); + //param is empty + $this->Blog->getView()->setRequest($this->getRequest()->withAttribute('currentSite', SiteFactory::get(1))); + $result = $this->Blog->isSingle(); + $this->assertFalse($result); + + //param is not empty + $this->Blog->getView()->setRequest($this->getRequest('/news/archives/1')->withAttribute('currentSite', SiteFactory::get(1))); + $result = $this->Blog->isSingle(); + $this->assertTrue($result); + + //BlogArchiveType is not empty + $this->Blog->getView()->setRequest($this->getRequest('/news/archives/2016/02/10/post-1')->withAttribute('currentSite', SiteFactory::get(1))); + $this->Blog->getView()->set('blogArchiveType', 'daily'); + $result = $this->Blog->isSingle(); + $this->assertFalse($result); + + } + public static function isTagDataProvider() { return [