Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unitTest_BlogHelper_isSingle #3187

Merged
merged 4 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/bc-blog/src/View/Helper/BlogHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,7 @@ public function isYear()
* @return boolean 現在のページが個別ページの場合は true を返す
* @checked
* @noTodo
* @unitTest
*/
public function isSingle()
{
Expand All @@ -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());
}

/**
Expand Down
24 changes: 24 additions & 0 deletions plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,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/1')->withAttribute('currentSite', SiteFactory::get(1)));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HungDV2022 こっちは前のURLの方が正しかったです

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryuring こちらを修正しました。確認お願いします。

$this->Blog->getView()->set('blogArchiveType', 'daily');
$result = $this->Blog->isSingle();
$this->assertFalse($result);

}

public static function isTagDataProvider()
{
return [
Expand Down
Loading