diff --git a/plugins/bc-blog/src/Service/BlogCommentsService.php b/plugins/bc-blog/src/Service/BlogCommentsService.php index 0eabf39e3a..9eb244325a 100755 --- a/plugins/bc-blog/src/Service/BlogCommentsService.php +++ b/plugins/bc-blog/src/Service/BlogCommentsService.php @@ -153,7 +153,7 @@ public function getNew() * @param array $postData * @return EntityInterface * @checked - * @unitTest + * @unitTest */ public function add(int $blogContentId, int $blogPostId, array $postData) { @@ -213,6 +213,7 @@ public function getBlogContent($blogContentId) * @throws \Throwable * @checked * @noTodo + * @unitTest */ public function sendCommentToAdmin(EntityInterface $entity) { diff --git a/plugins/bc-blog/tests/TestCase/Service/BlogCommentsServiceTest.php b/plugins/bc-blog/tests/TestCase/Service/BlogCommentsServiceTest.php index 502a61d2d1..6a884e5185 100755 --- a/plugins/bc-blog/tests/TestCase/Service/BlogCommentsServiceTest.php +++ b/plugins/bc-blog/tests/TestCase/Service/BlogCommentsServiceTest.php @@ -11,6 +11,8 @@ namespace BcBlog\Test\TestCase\Service; +use BaserCore\Test\Factory\SiteConfigFactory; +use BaserCore\Test\Factory\SiteFactory; use BaserCore\TestSuite\BcTestCase; use BcBlog\Service\BlogCommentsService; use BcBlog\Test\Factory\BlogCommentFactory; @@ -299,4 +301,30 @@ public function testAdd() $this->BlogCommentsService->add(1, 1, []); } + /** + * test sendCommentToAdmin + */ + public function testSendCommentToAdmin() + { + //データー生成 + SiteConfigFactory::make(['name' => 'email', 'value' => 'basertest@example.com'])->persist(); + SiteFactory::make(['id' => 1])->persist(); + $this->loadFixtureScenario( + BlogContentScenario::class, + 1, // id + 1, // siteId + null, // parentId + 'news1', // name + '/news/' // url + ); + BlogPostFactory::make(['id' => 1, 'blog_content_id' => 1, 'status' => true])->persist(); + $blogComment = BlogCommentFactory::make([['blog_content_id' => 1, 'blog_post_id' => 1, 'no' => 1, 'status' => 1,]])->getEntity(); + + //正常テスト + $this->BlogCommentsService->sendCommentToAdmin($blogComment); + + //異常テスト + $this->expectException(\TypeError::class); + $this->BlogCommentsService->sendCommentToAdmin([]); + } }