From 324cd83fdfae183b1742b6d0ae811b0326e17899 Mon Sep 17 00:00:00 2001 From: thangnnmd <150879641+thangnnmd@users.noreply.github.com> Date: Tue, 17 Sep 2024 07:44:38 +0700 Subject: [PATCH] Add unitTest_MailHelper_descriptionExists (#3809) Co-authored-by: thangnn --- .../TestCase/View/Helper/MailHelperTest.php | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php index ec49fa33f5..1a83d9c728 100644 --- a/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php +++ b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php @@ -13,6 +13,7 @@ use BaserCore\TestSuite\BcTestCase; use BcMail\Model\Entity\MailContent; use BcMail\View\Helper\MailHelper; +use Cake\ORM\Entity; use Cake\View\View; /** @@ -63,13 +64,33 @@ public function testGetDescription() /** * 説明文の存在確認 + * @param $description + * @param $expected + * @dataProvider descriptionExistsProvider */ - public function testDescriptionExists() + public function testDescriptionExists($description, $expected) { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); - $this->Mail->setMailContent(1); - $result = $this->Mail->descriptionExists(); - $this->assertTrue($result, "メールの説明文が指定されていません。"); + //setUp + $mailContent = new Entity([ + 'description' => $description + ]); + $this->MailHelper->currentMailContent = $mailContent; + + $result = $this->MailHelper->descriptionExists(); + + $this->assertEquals($expected, $result); + } + + public static function descriptionExistsProvider() + { + return [ + ['This is a test description', true], + ['', false], + [null, false], + ['0', false], + [' ', true], + ['

This is a HTML description

', true], + ]; } /**