Skip to content

Commit

Permalink
add unitTest_BlogHelper_isHome (#3188)
Browse files Browse the repository at this point in the history
Co-authored-by: thangnn <[email protected]>
  • Loading branch information
thangnnmd and thangnn authored Mar 5, 2024
1 parent 8135483 commit 7bdc8c4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/bc-blog/src/View/Helper/BlogHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,7 @@ public function isSingle()
* @return boolean 現在のページがインデックスページの場合は true を返す
* @checked
* @noTodo
* @unitTest
*/
public function isHome()
{
Expand Down
16 changes: 16 additions & 0 deletions plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7bdc8c4

Please sign in to comment.