Skip to content

Commit

Permalink
Merge branch 'dev-5.1' of github.com:baserproject/basercms into dev-5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Feb 23, 2024
2 parents 20bca64 + 581bf2c commit 3c90806
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 12 deletions.
2 changes: 1 addition & 1 deletion plugins/bc-blog/src/View/Helper/BlogHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ public function getCategoryList($categories, $depth = 3, $count = false, $option
* @return void
* @checked
* @noTodo
* @unitTest ラッパーメソッドのためユニットテストはスキップする
* @unitTest
*/
public function prevLink(BlogPost $post, string $title = '', array $htmlAttributes = [])
{
Expand Down
51 changes: 40 additions & 11 deletions plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,23 +609,52 @@ public static function getCategoryListDataProvider()
*/
public function testPrevLink($blogContentId, $id, $posts_date, $expected)
{
$this->markTestIncomplete('こちらのテストはまだ未確認です');
$this->expectOutputString($expected);
$post = ['BlogPost' => [
//データ生成
ContentFactory::make(['plugin' => 'BcBlog', 'type' => 'BlogContent', 'alias_id' => 1])
->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' => $blogContentId,
'id' => $id,
'posts_date' => $posts_date
]];
$this->Blog->prevLink($post);
'title' => 'title 1',
'posted' => $posts_date
])->persist();
BlogPostFactory::make([
'id' => 2,
'no' => 2,
'blog_content_id' => $blogContentId,
'title' => 'title 2',
'posted' => $posts_date
])->persist();
BlogPostFactory::make([
'id' => 3,
'no' => 3,
'blog_content_id' => 30,
'title' => 'title 3',
'posted' => $posts_date
])->persist();

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

$this->expectOutputString($expected);
$this->Blog->prevLink(BlogPostFactory::get($id));
}

public static function prevLinkDataProvider()
{
return [
[1, 4, '9000-08-10 18:58:07', '<a href="/news/archives/4" class="prev-link">≪ 4記事目</a>'],
[1, 3, '1000-08-10 18:58:07', ''],
[2, 2, '9000-08-10 18:58:07', '<a href="/" class="prev-link">≪ 8記事目</a>'], // 存在しないブログコンテンツ
[2, 1, '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 3c90806

Please sign in to comment.