Skip to content

Commit

Permalink
ユニットテスト調整
Browse files Browse the repository at this point in the history
  • Loading branch information
dovanhung committed Feb 21, 2024
1 parent ffcdde2 commit 1344899
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,36 +611,36 @@ public function testPrevLink($blogContentId, $id, $posts_date, $expected)
{
//データ生成
ContentFactory::make(['plugin' => 'BcBlog', 'type' => 'BlogContent', 'alias_id' => 1])
->treeNode(3, 1, 3, 'news-2', '/news/', 3)->persist();
BlogContentFactory::make(['id' => 3])->persist();
->treeNode($blogContentId, 1, 3, 'news-2', '/news/', $blogContentId)->persist();
BlogContentFactory::make(['id' => $blogContentId])->persist();
SiteFactory::make()->main()->persist();

BlogPostFactory::make([
'id' => 1,
'no' => 1,
'blog_content_id' => 3,
'blog_content_id' => $blogContentId,
'title' => 'title 1',
'posted' => '2022-10-02 09:00:00'
'posted' => $posts_date
])->persist();
BlogPostFactory::make([
'id' => 2,
'no' => 2,
'blog_content_id' => 3,
'blog_content_id' => $blogContentId,
'title' => 'title 2',
'posted' => '2022-10-02 09:00:00'
'posted' => $posts_date
])->persist();
BlogPostFactory::make([
'id' => 3,
'no' => 3,
'blog_content_id' => 3,
'blog_content_id' => 30,
'title' => 'title 3',
'posted' => '2022-08-02 09:00:00'
'posted' => $posts_date
])->persist();

//currentContentをリセット
$view = new BlogFrontAppView($this->getRequest());
$blogContent = BlogContentFactory::get(3);
$blogContent->content = ContentFactory::get(3);
$blogContent = BlogContentFactory::get($blogContentId);
$blogContent->content = ContentFactory::get($blogContentId);
$view->set('blogContent', $blogContent);
$this->Blog = new BlogHelper($view);

Expand All @@ -651,10 +651,10 @@ public function testPrevLink($blogContentId, $id, $posts_date, $expected)
public static function prevLinkDataProvider()
{
return [
[1, 1, '9000-08-10 18:58:07', '<a href="/news/archives/3" class="prev-link">≪ title 3</a>'],
[1, 3, '1000-08-10 18:58:07', ''],
[1, 2, '9000-08-10 18:58:07', '<a href="/news/archives/1" class="prev-link">≪ title 1</a>'], // 存在しないブログコンテンツ
[2, 3, '1000-08-10 18:58:07', ''],
[4, 2, '9000-08-10 18:58:07', '<a href="/news/archives/1" class="prev-link">≪ title 1</a>'],
[4, 1, '1000-08-10 18:58:07', ''],
[3, 3, '9000-08-10 18:58:07', ''], // 存在しないブログコンテンツ
[3, 2, '1000-08-10 18:58:07', '<a href="/news/archives/1" class="prev-link">≪ title 1</a>'],
];
}

Expand Down

0 comments on commit 1344899

Please sign in to comment.