Skip to content

Commit

Permalink
Merge pull request #4066 from thangnnmd/unitTest_MailformHelper_getGr…
Browse files Browse the repository at this point in the history
…oupValidErrors

MailformHelper::getGroupValidErrors
  • Loading branch information
HungDV2022 authored Dec 11, 2024
2 parents d5139a0 + b2e4cba commit 91d8157
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/bc-mail/src/View/Helper/MailformHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,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)
{
Expand Down
23 changes: 23 additions & 0 deletions plugins/bc-mail/tests/TestCase/View/Helper/MailformHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@
use BaserCore\TestSuite\BcTestCase;
use BcMail\Model\Entity\MailField;
use BcMail\Test\Factory\MailMessagesFactory;
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
Expand Down Expand Up @@ -97,4 +105,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);
}
}

0 comments on commit 91d8157

Please sign in to comment.