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

testGetBlogTemplates #3067

Closed
Show file tree
Hide file tree
Changes from all 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
10 changes: 8 additions & 2 deletions plugins/bc-blog/src/View/Helper/BlogHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
use BaserCore\Annotation\NoTodo;
use BaserCore\Annotation\Checked;
use BaserCore\Annotation\UnitTest;
use Exception;

/**
* ブログヘルパー
Expand Down Expand Up @@ -900,11 +901,16 @@ public function hasNextLink($post)
* @return array ブログテンプレート一覧
* @checked
* @noTodo
* @unitTest
*/
public function getBlogTemplates($siteId = 0)
public function getBlogTemplates($siteId = 1)
{
$templatesPaths = BcUtil::getFrontTemplatePaths($siteId, 'BcBlog');
$_templates = [];
try {
$templatesPaths = BcUtil::getFrontTemplatePaths($siteId, 'BcBlog');
}catch (Exception $ex) {
return $_templates;
}
foreach($templatesPaths as $templatePath) {
$templatePath .= 'Blog' . DS;
$folder = new BcFolder($templatePath);
Expand Down
17 changes: 13 additions & 4 deletions plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -713,16 +713,24 @@ public static function nextLinkDataProvider()
*/
public function testGetBlogTemplates($theme, $expected)
{
$this->markTestIncomplete('こちらのテストはまだ未確認です');
SiteFactory::make(
[
'id' => 1,
'status' => true,
'name' => 'test',
'theme' => 'nada-icons'
]
)->persist();
$this->Blog->getView()->setRequest($this->getRequest()->withAttribute('currentSite', SiteFactory::get(1)));
$this->Blog->BcBaser->siteConfig['theme'] = $theme;
$result = $this->Blog->getBlogTemplates();
$this->assertEquals($result, $expected, 'ブログテンプレートを正しく取得できません');
$this->assertEquals($expected, $result);
}

public static function getBlogTemplatesDataProvider()
{
return [
['nada-icons', ['default' => 'default']]
['nada-icons', ['Blog' => 'Blog','default' => 'default']]
Copy link
Collaborator

Choose a reason for hiding this comment

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

@nghiem-mb 結果に、'Blog' => 'Blog' が入ってしまってはいけません。何が原因か調査してもらってもいいですか?

];
}

Expand Down Expand Up @@ -923,6 +931,7 @@ public function testGetCategories()
BlogPostFactory::make(['id' => 3, 'posted'=> '2015-01-28 12:57:59', 'blog_content_id'=> 1, 'blog_category_id'=> 3, 'user_id'=>1, 'status' => true])->persist();
BlogPostFactory::make(['id' => 4, 'posted'=> '2015-01-28 12:57:59', 'blog_content_id'=> 2, 'blog_category_id'=> 4, 'user_id'=>1, 'status' => true])->persist();
BlogPostFactory::make(['id' => 5, 'posted'=> '2015-01-28 12:57:59', 'blog_content_id'=> 1, 'blog_category_id'=> 5, 'user_id'=>1, 'status' => true])->persist();
BlogPostFactory::make(['id' => 6, 'posted'=> '2013-01-28 12:57:59', 'blog_content_id'=> 1, 'blog_category_id'=> 5, 'user_id'=>1, 'status' => true])->persist();
BlogCategoryFactory::make(['id' => 1, 'title' => 'title 1', 'name' => 'name-1', 'blog_content_id' => 1, 'lft' => 1, 'rght' => 2])->persist();
BlogCategoryFactory::make(['id' => 2, 'parent_id'=> 1, 'title' => 'title 2', 'name' => 'name-2', 'lft' => 1, 'rght' => 2, 'blog_content_id' => 1])->persist();
BlogCategoryFactory::make(['id' => 3, 'parent_id'=> 2, 'title' => 'title 3', 'name' => 'name-3', 'lft' => 1, 'rght' => 2, 'blog_content_id' => 1])->persist();
Expand Down Expand Up @@ -968,7 +977,7 @@ public function testGetCategories()

// option type year
$result = $this->Blog->getCategories(['blogContentId'=>1, 'type' => 'year']);
$this->assertEquals('name-5', $result['2015'][0]->name);
$this->assertEquals('name-5', $result['2013'][0]->name);

// option viewCount true
$result = $this->Blog->getCategories(['blogContentId'=>1, 'viewCount' => true]);
Expand Down
Loading