From 3c97cb367b1c97df99fc110c3f370cd2e55c3dc6 Mon Sep 17 00:00:00 2001 From: thangnn Date: Thu, 5 Dec 2024 14:00:47 +0700 Subject: [PATCH] Add unitTest_MailformHelper_getGroupValidErrors --- .../src/View/Helper/MailformHelper.php | 1 + .../View/Helper/MailformHelperTest.php | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/plugins/bc-mail/src/View/Helper/MailformHelper.php b/plugins/bc-mail/src/View/Helper/MailformHelper.php index f5dba87e79..9242797fc6 100755 --- a/plugins/bc-mail/src/View/Helper/MailformHelper.php +++ b/plugins/bc-mail/src/View/Helper/MailformHelper.php @@ -305,6 +305,7 @@ public function authCaptcha(string $fieldName, array $options = []) * @return array * @checked * @noTodo + * @unitTest */ public function getGroupValidErrors(ResultSetInterface $mailFields, string $groupValid, array $options = [], bool $distinct = true) { diff --git a/plugins/bc-mail/tests/TestCase/View/Helper/MailformHelperTest.php b/plugins/bc-mail/tests/TestCase/View/Helper/MailformHelperTest.php index 27dd75067d..03f248f25e 100644 --- a/plugins/bc-mail/tests/TestCase/View/Helper/MailformHelperTest.php +++ b/plugins/bc-mail/tests/TestCase/View/Helper/MailformHelperTest.php @@ -12,12 +12,20 @@ use BaserCore\TestSuite\BcTestCase; use BcMail\Model\Entity\MailField; +use BcMail\Service\MailFieldsServiceInterface; use BcMail\View\Helper\MailformHelper; +use BcMail\Test\Scenario\MailContentsScenario; +use BcMail\Test\Scenario\MailFieldsScenario; use Cake\ORM\ResultSet; use Cake\View\View; +use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; class MailformHelperTest extends BcTestCase { + /** + * ScenarioAwareTrait + */ + use ScenarioAwareTrait; /** * set up @@ -92,4 +100,19 @@ public static function isGroupLastFieldProvider() [[['group_field' => 'group1'], ['group_field' => 'group2']], 0, true], ]; } + + /** + * test getGroupValidErrors + */ + public function testGetGroupValidErrors() + { + // prepare + $this->loadFixtureScenario(MailContentsScenario::class); + $this->loadFixtureScenario(MailFieldsScenario::class); + $MailFieldsService = $this->getService(MailFieldsServiceInterface::class); + // get mail field list + $mailFields = $MailFieldsService->getIndex(1)->all(); + $rs = $this->MailformHelper->getGroupValidErrors($mailFields, 'field_name'); + $this->assertEquals([], $rs); + } }