From fcb7d15636824ce6e6b595c57f8d1d7b91798fbb Mon Sep 17 00:00:00 2001 From: thangnn Date: Mon, 22 Apr 2024 13:58:18 +0700 Subject: [PATCH 1/3] add unitTest_MailFieldsTable_sourceMailField --- .../src/Model/Table/MailFieldsTable.php | 1 + .../Model/Table/MailFieldsTableTest.php | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/bc-mail/src/Model/Table/MailFieldsTable.php b/plugins/bc-mail/src/Model/Table/MailFieldsTable.php index c729b8ff4b..1d5d5195d8 100755 --- a/plugins/bc-mail/src/Model/Table/MailFieldsTable.php +++ b/plugins/bc-mail/src/Model/Table/MailFieldsTable.php @@ -248,6 +248,7 @@ public function halfTextMailField(string $value) * @return bool * @checked * @noTodo + * @unitTest */ public function sourceMailField(string $value, array $context) { diff --git a/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php b/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php index e349283fc3..d3f77cbf54 100755 --- a/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php +++ b/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php @@ -181,12 +181,26 @@ public function testHalfTextMailField() /** * 選択リストの入力チェック + * @dataProvider sourceMailFieldDataProvider */ - public function testSourceMailField() + public function test_sourceMailField($value, $context, $expected) { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + $result = $this->MailFieldsTable->sourceMailField($value, $context); + $this->assertEquals($expected, $result); + } + + public static function sourceMailFieldDataProvider() + { + return [ + ['radio', ['data' => ['type' => 'radio']], 'radio'], + ['select', ['data' => ['type' => 'radio']], 'select'], + ['multi_check', ['data' => ['type' => 'radio']], 'multi_check'], + ['autozip', ['data' => ['type' => 'radio']], 'autozip'], + ['text', ['data' => ['type' => 'text']], true] + ]; } + /** * フィールドデータをコピーする * From aa8d76b423ec29e095d6acdb6ddb8a7b84f3a526 Mon Sep 17 00:00:00 2001 From: thangnn Date: Tue, 23 Apr 2024 09:37:15 +0700 Subject: [PATCH 2/3] modifed --- .../tests/TestCase/Model/Table/MailFieldsTableTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php b/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php index 3f170fb7c7..4676bb3bfa 100755 --- a/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php +++ b/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php @@ -201,9 +201,9 @@ public static function sourceMailFieldDataProvider() { return [ ['radio', ['data' => ['type' => 'radio']], 'radio'], - ['select', ['data' => ['type' => 'radio']], 'select'], - ['multi_check', ['data' => ['type' => 'radio']], 'multi_check'], - ['autozip', ['data' => ['type' => 'radio']], 'autozip'], + ['select', ['data' => ['type' => 'select']], 'select'], + ['multi_check', ['data' => ['type' => 'multi_check']], 'multi_check'], + ['autozip', ['data' => ['type' => 'autozip']], 'autozip'], ['text', ['data' => ['type' => 'text']], true] ]; } From e13748eb5514934c3f16548b29ac46467c1e234d Mon Sep 17 00:00:00 2001 From: thangnn Date: Thu, 25 Apr 2024 10:17:16 +0700 Subject: [PATCH 3/3] modified --- .../TestCase/Model/Table/MailFieldsTableTest.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php b/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php index 4676bb3bfa..1664de4fd7 100755 --- a/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php +++ b/plugins/bc-mail/tests/TestCase/Model/Table/MailFieldsTableTest.php @@ -200,10 +200,14 @@ public function test_sourceMailField($value, $context, $expected) public static function sourceMailFieldDataProvider() { return [ - ['radio', ['data' => ['type' => 'radio']], 'radio'], - ['select', ['data' => ['type' => 'select']], 'select'], - ['multi_check', ['data' => ['type' => 'multi_check']], 'multi_check'], - ['autozip', ['data' => ['type' => 'autozip']], 'autozip'], + ['radio', ['data' => ['type' => 'radio']], true], + ['', ['data' => ['type' => 'radio']], false], + ['select', ['data' => ['type' => 'select']], true], + ['', ['data' => ['type' => 'select']], false], + ['multi_check', ['data' => ['type' => 'multi_check']], true], + ['', ['data' => ['type' => 'multi_check']], false], + ['autozip', ['data' => ['type' => 'autozip']], true], + ['', ['data' => ['type' => 'autozip']], false], ['text', ['data' => ['type' => 'text']], true] ]; }