diff --git a/plugins/bc-blog/src/View/Helper/BlogHelper.php b/plugins/bc-blog/src/View/Helper/BlogHelper.php index e5c3ed14cf..48306dcd87 100755 --- a/plugins/bc-blog/src/View/Helper/BlogHelper.php +++ b/plugins/bc-blog/src/View/Helper/BlogHelper.php @@ -1396,6 +1396,7 @@ public function getCategoryTitle(BlogPost $post) * @return string * @checked * @noTodo + * @unitTest */ public function getPostId(BlogPost $post) { diff --git a/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php b/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php index e3370ac2f1..8775c5bf4f 100755 --- a/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php +++ b/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php @@ -1874,4 +1874,28 @@ public function test_getCategoryTitle() $result = $this->Blog->getCategoryTitle($blogPost); $this->assertEmpty($result); } + + /** + * getPostId + */ + public function test_getPostId() + { + // テストデータを作る + $this->loadFixtureScenario(InitAppScenario::class); + $this->Blog->getView()->setRequest($this->getRequest()->withAttribute('currentSite', SiteFactory::get(1))); + $post = new BlogPost([ + 'id' => 1, + 'blog_content_id' => 1, + 'name' => 'release', + ]); + + //check exits id + $result = $this->Blog->getPostId($post); + $this->assertEquals(1, $result); + + //check not exits id + $post = new BlogPost([]); + $result = $this->Blog->getPostId($post); + $this->assertEmpty($result); + } }