From c5157b9d4c370bf0989b70b9ebd72b91e244befb Mon Sep 17 00:00:00 2001 From: tianshujie Date: Fri, 31 Mar 2023 14:11:24 +0800 Subject: [PATCH] * Add test case for doc module. --- module/doc/model.php | 6 +-- module/doc/view/doclist.html.php | 2 +- module/doc/view/tablecontents.html.php | 2 +- test/model/doc/printcreatebtn.php | 61 ++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 test/model/doc/printcreatebtn.php diff --git a/module/doc/model.php b/module/doc/model.php index 83f1e8e9d2..73a0989aa2 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -2944,12 +2944,11 @@ class docModel extends model * @param type $type project|product|custom * @param int $objectID * @param int $moduleID - * @param int $apiLibID * @param string $from list * @access public * @return string */ - public function printCreateBtn($lib, $type, $objectID, $moduleID, $apiLibID = 0, $from = '') + public function printCreateBtn($lib, $type, $objectID, $moduleID, $from = '') { if(!common::hasPriv('doc', 'create')) return null; @@ -2974,8 +2973,7 @@ class docModel extends model $printDivider = false; if($typeKey == 'template') $printDivider = true; - if($this->config->edition != 'max' and $typeKey == 'api') $printDivider = true; - if($this->config->edition != 'max' and !$apiLibID and $typeKey == 'html') $printDivider = true; + if($this->config->edition != 'max' and $typeKey == 'html') $printDivider = true; if($printDivider) $html .= '
  • '; } diff --git a/module/doc/view/doclist.html.php b/module/doc/view/doclist.html.php index 0fd35d8f35..16586e9ab4 100644 --- a/module/doc/view/doclist.html.php +++ b/module/doc/view/doclist.html.php @@ -33,7 +33,7 @@ body {margin-bottom: 25px;} doc->printCreateBtn($lib, $type, $objectID, $moduleID, $apiLibID, 'list'); + echo $this->doc->printCreateBtn($lib, $type, $objectID, $moduleID, 'list'); } ?>

    diff --git a/module/doc/view/tablecontents.html.php b/module/doc/view/tablecontents.html.php index 51a943c8ad..cc2e0d415f 100644 --- a/module/doc/view/tablecontents.html.php +++ b/module/doc/view/tablecontents.html.php @@ -45,7 +45,7 @@ } elseif($libID and common::hasPriv('doc', 'create')) { - echo $this->doc->printCreateBtn($lib, $type, $objectID, $moduleID, $apiLibID); + echo $this->doc->printCreateBtn($lib, $type, $objectID, $moduleID); } ?> diff --git a/test/model/doc/printcreatebtn.php b/test/model/doc/printcreatebtn.php new file mode 100644 index 0000000000..cb2697dd53 --- /dev/null +++ b/test/model/doc/printcreatebtn.php @@ -0,0 +1,61 @@ +#!/usr/bin/env php +id->range('1'); +$product->name->range('产品1'); +$product->gen(1); + +$project = zdTable('project'); +$project->id->range('1-2'); +$project->name->range('项目1,执行1'); +$project->type->range('project,sprint'); +$project->acl->range('open'); +$project->gen(2); + +$doclib = zdTable('doclib'); +$doclib->id->range('1-5'); +$doclib->name->range('产品库1,产品接口库1,项目库1,执行库1,自定义库1'); +$doclib->type->range('product,api,project,execution,custom'); +$doclib->vision->range('rnd'); +$doclib->product->range('1{2},0{3}'); +$doclib->project->range('0{2},1{2},0'); +$doclib->execution->range('0{3},2,0'); +$doclib->gen(5); + +$module = zdTable('module'); +$module->id->range('1-10'); +$module->name->range('第一章,第二章,第一章第一节,第一章第二节,第三章'); +$module->parent->range('0{2},1{2},0{3},6{2},0{2}'); +$module->root->range('1{5},2{5}'); +$module->type->range('doc{5},api{5}'); +$module->gen(10); + +su('admin'); + +/** + +title=测试 docModel->printCreateBtn(); +cid=1 +pid=1 + +测试产品库下的创建按钮 >> 创建文档 +测试项目库下的创建按钮 >> 创建文档 +测试执行库下的创建按钮 >> Word +测试自定义库下的创建按钮 >> PPT + +*/ + +global $tester; +$tester->loadModel('doc'); +$libList['product'] = $tester->doc->getLibById(1); +$libList['project'] = $tester->doc->getLibById(3); +$libList['execution'] = $tester->doc->getLibById(4); +$libList['custom'] = $tester->doc->getLibById(5); + +r(strip_tags($tester->doc->printCreateBtn($libList['product'], 'product', 1, 1))) && p() && e('创建文档'); // 测试产品库下的创建按钮 +r(strip_tags($tester->doc->printCreateBtn($libList['project'], 'project', 1, 0))) && p() && e('创建文档'); // 测试项目库下的创建按钮 +r(strip_tags($tester->doc->printCreateBtn($libList['execution'], 'execution', 2, 0))) && p() && e('Word'); // 测试执行库下的创建按钮 +r(strip_tags($tester->doc->printCreateBtn($libList['custom'], 'custom', 0, 0))) && p() && e('PPT'); // 测试自定义库下的创建按钮