From 912a39d453d56339431e4d3a004372f58343f62a Mon Sep 17 00:00:00 2001 From: thangnn Date: Thu, 14 Nov 2024 13:59:55 +0700 Subject: [PATCH] Add unitTest_BlogCommentMailer_sendCommentToAdmin --- .../bc-blog/src/Mailer/BlogCommentMailer.php | 1 + .../TestCase/Mailer/BlogCommentMailerTest.php | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 plugins/bc-blog/tests/TestCase/Mailer/BlogCommentMailerTest.php diff --git a/plugins/bc-blog/src/Mailer/BlogCommentMailer.php b/plugins/bc-blog/src/Mailer/BlogCommentMailer.php index 2776ed186c..d03bb0d333 100755 --- a/plugins/bc-blog/src/Mailer/BlogCommentMailer.php +++ b/plugins/bc-blog/src/Mailer/BlogCommentMailer.php @@ -29,6 +29,7 @@ class BlogCommentMailer extends BcMailer * @param array $data * @checked * @noTodo + * @UnitTest */ public function sendCommentToAdmin(string $senderName, array $data) { diff --git a/plugins/bc-blog/tests/TestCase/Mailer/BlogCommentMailerTest.php b/plugins/bc-blog/tests/TestCase/Mailer/BlogCommentMailerTest.php new file mode 100644 index 0000000000..49a64fa2ae --- /dev/null +++ b/plugins/bc-blog/tests/TestCase/Mailer/BlogCommentMailerTest.php @@ -0,0 +1,32 @@ + 'email', 'value' => 'basertest@example.com'])->persist(); + $this->BlogCommentMailer = new BlogCommentMailer(); + } + + public function tearDown(): void + { + parent::tearDown(); + } + + /** + * test sendCommentToAdmin + */ + public function testSendCommentToAdmin() + { + $this->BlogCommentMailer->sendCommentToAdmin('test', ['test' => 'test']); + $this->assertEquals('BcBlog.blog_comment_admin', $this->BlogCommentMailer->viewBuilder()->getTemplate()); + $this->assertEquals(['test' => 'test'], $this->BlogCommentMailer->viewBuilder()->getVars()); + } +}