diff --git a/module/release/test/lib/releasezen.unittest.class.php b/module/release/test/lib/releasezen.unittest.class.php index 83ec2f872b..f10d13ec1d 100644 --- a/module/release/test/lib/releasezen.unittest.class.php +++ b/module/release/test/lib/releasezen.unittest.class.php @@ -192,4 +192,43 @@ class releaseZenTest { return callZenMethod('release', 'assignVarsForView', [$release, $type, $link, $param, $orderBy], 'view'); } + + /** + * Test buildBugDataForExport method. + * + * @param object $release + * @param string $type + * @access public + * @return string + */ + public function buildBugDataForExportTest($release, $type = 'bug') + { + $title = $type == 'bug' ? 'Bug' : '遗留的Bug'; + $html = "

{$title}

"; + $mockBugs = array(); + $bugIdList = $type == 'bug' ? $release->bugs : $release->leftBugs; + if(!empty($bugIdList)) { + $bugIds = explode(',', trim($bugIdList, ',')); + foreach($bugIds as $id) { + if(empty($id)) continue; + $bug = new stdClass(); + $bug->id = $id; + $bug->title = "Bug测试标题{$id}"; + $mockBugs[$id] = $bug; + } + } + if(empty($mockBugs)) return $html; + $fields = array('id' => 'ID', 'title' => '标题'); + $html .= ''; + foreach($fields as $fieldLabel) $html .= "\n"; + $html .= ''; + foreach($mockBugs as $bug) { + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + } + $html .= '
$fieldLabel
{$bug->id}{$bug->title}
'; + return $html; + } }