* Add test case for doc module.
This commit is contained in:
@@ -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 .= '<li class="divider"></li>';
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ body {margin-bottom: 25px;}
|
||||
<?php
|
||||
if($browseType != 'bySearch' and $libID and (common::hasPriv('doc', 'create') or (common::hasPriv('api', 'create') and !$apiLibID)))
|
||||
{
|
||||
echo $this->doc->printCreateBtn($lib, $type, $objectID, $moduleID, $apiLibID, 'list');
|
||||
echo $this->doc->printCreateBtn($lib, $type, $objectID, $moduleID, 'list');
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/doc.class.php';
|
||||
|
||||
$product = zdTable('product');
|
||||
$product->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'); // 测试自定义库下的创建按钮
|
||||
Reference in New Issue
Block a user