Skip to content

Commit

Permalink
Merge pull request #3967 from thangnnmd/unitTest_MailFieldsTable_dupl…
Browse files Browse the repository at this point in the history
…icateMailField

MailFieldsTable::duplicateMailField
  • Loading branch information
HungDV2022 authored Nov 7, 2024
2 parents b2b14a0 + dd41bef commit 71f5d67
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions plugins/bc-mail/src/Model/Table/MailFieldsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ public function getControlSource($field = null)
* @return boolean
* @checked
* @noTodo
* @unitTest
*/
public function duplicateMailField(string $value, array $context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@
use BaserCore\TestSuite\BcTestCase;
use BcMail\Model\Table\MailFieldsTable;
use BcMail\Test\Factory\MailFieldsFactory;
use BcMail\Test\Scenario\MailContentsScenario;
use BcMail\Test\Scenario\MailFieldsScenario;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;

/**
* @property MailFieldsTable $MailFieldsTable
*/
class MailFieldsTableTest extends BcTestCase
{

use ScenarioAwareTrait;

/**
* Set Up
*
Expand Down Expand Up @@ -167,7 +172,22 @@ public function testGetControlSource()
*/
public function testDuplicateMailField()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
$this->loadFixtureScenario(MailFieldsScenario::class);
$this->loadFixtureScenario(MailContentsScenario::class);

$context = [
'field' => 'field_name',
'data' => ['mail_content_id' => 1, 'id' => 2],
'newRecord' => true
];
//case false
$result = $this->MailFieldsTable->duplicateMailField('name_1', $context);
$this->assertFalse($result);

//case true
$result = $this->MailFieldsTable->duplicateMailField('name_test', $context);
$this->assertTrue($result);

}

/**
Expand Down

0 comments on commit 71f5d67

Please sign in to comment.