From ed6ff37bd285fd5206dae11832ea302aae044b36 Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 8 Sep 2025 01:22:55 +0800 Subject: [PATCH] + [misc] Add unit tests for convertModel::checkImportJira() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../test/lib/convert.unittest.class.php | 35 +++++++++++++++++++ module/convert/test/model/checkimportjira.php | 29 +++++++++++++++ 2 files changed, 64 insertions(+) create mode 100755 module/convert/test/model/checkimportjira.php diff --git a/module/convert/test/lib/convert.unittest.class.php b/module/convert/test/lib/convert.unittest.class.php index 328876fe08..5ffc5b751b 100644 --- a/module/convert/test/lib/convert.unittest.class.php +++ b/module/convert/test/lib/convert.unittest.class.php @@ -517,4 +517,39 @@ class convertTest return $result; } + + /** + * Test checkImportJira method. + * + * @param string $step + * @param array $postData + * @access public + * @return mixed + */ + public function checkImportJiraTest($step = '', $postData = array()) + { + // 备份原始POST数据 + $originalPost = $_POST; + + // 设置测试POST数据 + $_POST = $postData; + + try { + $result = $this->objectModel->checkImportJira($step); + if(dao::isError()) { + $errors = dao::getError(); + // 恢复原始POST数据 + $_POST = $originalPost; + return $errors; + } + + // 恢复原始POST数据 + $_POST = $originalPost; + return $result; + } catch (Exception $e) { + // 恢复原始POST数据 + $_POST = $originalPost; + return 'exception: ' . $e->getMessage(); + } + } } \ No newline at end of file diff --git a/module/convert/test/model/checkimportjira.php b/module/convert/test/model/checkimportjira.php new file mode 100755 index 0000000000..03b6932546 --- /dev/null +++ b/module/convert/test/model/checkimportjira.php @@ -0,0 +1,29 @@ +#!/usr/bin/env php +checkImportJiraTest('object', array('jiraObject' => array('1', '2'), 'zentaoObject' => array('1' => 'story', '2' => 'task')))) && p() && e('1'); +r($convertTest->checkImportJiraTest('object', array('jiraObject' => array('1', '2'), 'zentaoObject' => array('1' => 'story', '2' => '')))) && p('message') && e('『禅道对象』不能为空。'); +r($convertTest->checkImportJiraTest('object', array('jiraObject' => array(), 'zentaoObject' => array()))) && p() && e('1'); +r($convertTest->checkImportJiraTest('status', array('jiraObject' => array('1'), 'zentaoObject' => array('1' => 'story')))) && p() && e('1'); +r($convertTest->checkImportJiraTest('', array('jiraObject' => array('1'), 'zentaoObject' => array('1' => 'story')))) && p() && e('1'); \ No newline at end of file