diff --git a/plugins/bc-blog/src/View/Helper/BlogHelper.php b/plugins/bc-blog/src/View/Helper/BlogHelper.php index 9363245739..8c024306d6 100755 --- a/plugins/bc-blog/src/View/Helper/BlogHelper.php +++ b/plugins/bc-blog/src/View/Helper/BlogHelper.php @@ -1118,10 +1118,11 @@ public function getBlogArchiveType() * @return boolean 現在のページがアーカイブページの場合は true を返す * @checked * @noTodo + * @unitTest */ public function isArchive() { - return ($this->getBlogArchiveType()); + return ($this->getBlogArchiveType() == 'archive'); } /** diff --git a/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php b/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php index b8cf296b2e..9cc959e6ef 100755 --- a/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php +++ b/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php @@ -1533,7 +1533,7 @@ public function testIsTag($type, $expects) /** - * test isArchive + * test isCategory * @dataProvider isCategoryDataProvider * */ @@ -1559,6 +1559,33 @@ 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 [ + ['archive', true], + ['category', false], + ['tag', false], + ['yearly', false], + ['monthly', false], + ['daily', false], + ['hoge', false], // 存在しないアーカイブの場合 + ['', false], // アーカイブ指定がない場合 + ]; + } + /** * test isDate