From bdf0871ea5064b6d1f9979f3b035ded8bd31b3e0 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 11 Dec 2023 10:48:38 +0800 Subject: [PATCH] * Refactor doc::getToAndCcList unit test. --- module/doc/test/doc.class.php | 13 +++++++------ module/doc/test/model/gettoandcclist.php | 22 ++++++++++++---------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/module/doc/test/doc.class.php b/module/doc/test/doc.class.php index 6d05b943f2..3f375dad0b 100644 --- a/module/doc/test/doc.class.php +++ b/module/doc/test/doc.class.php @@ -429,20 +429,21 @@ class docTest } /** + * 获取收信人和抄送人列表。 * Get toList and ccList. * - * @param int $docID + * @param string $mailto * @access public * @return bool|array */ - public function getToAndCcListTest($docID) + public function getToAndCcListTest(string $mailto): bool|array { - $doc = $this->objectModel->getByID($docID); - $objects = $this->objectModel->getToAndCcList($doc); + $doc = new stdclass(); + $doc->mailto = $mailto; + $data = $this->objectModel->getToAndCcList($doc); if(dao::isError()) return dao::getError(); - - return $objects; + return $data; } public function selectTest($type, $objects, $objectID, $libs, $libID = 0) diff --git a/module/doc/test/model/gettoandcclist.php b/module/doc/test/model/gettoandcclist.php index 9d30020e00..bd659ee4d6 100755 --- a/module/doc/test/model/gettoandcclist.php +++ b/module/doc/test/model/gettoandcclist.php @@ -1,22 +1,24 @@ #!/usr/bin/env php getToAndCcList(); cid=1 -pid=1 - +- 测试抄送人为空时,获取的收信人列表 @0 +- 测试抄送人为admin时,获取的收信人列表 @admin +- 测试抄送人为admin,user1时,获取的抄送人列表属性1 @user1 */ -$docID = array('1', '2', '3'); +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/doc.class.php'; -$doc = new docTest(); +zdTable('user')->gen(5); -r($doc->getToAndCcListTest($docID[0])) && p('0;1') && e('admin;'); //查询文档type为text的数据 -r($doc->getToAndCcListTest($docID[1])) && p('0;1') && e('admin;'); //查询文档type为markdown的数据 -r($doc->getToAndCcListTest($docID[2])) && p('0;1') && e('admin;'); //查询文档type为url的数据 \ No newline at end of file +$mailtoList = array('', 'admin', 'admin,user1'); + +$docTester = new docTest(); +r($docTester->getToAndCcListTest($mailtoList[0])) && p() && e('0'); // 测试抄送人为空时,获取的收信人列表 +r($docTester->getToAndCcListTest($mailtoList[1])) && p('0') && e('admin'); // 测试抄送人为admin时,获取的收信人列表 +r($docTester->getToAndCcListTest($mailtoList[2])) && p('1') && e('user1'); // 测试抄送人为admin,user1时,获取的抄送人列表