* Add test case for dev module.

This commit is contained in:
tianshujie
2023-03-13 08:55:13 +08:00
parent f0cce961ee
commit d0ecdd9b65
3 changed files with 31 additions and 106 deletions
-104
View File
@@ -1,104 +0,0 @@
<?php
/**
* The log view file of repo module of ZenTaoPMS.
*
* @copyright Copyright 2009-2012 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com)
* @author Wang Yidong, Zhu Jinyong
* @package repo
* @version $Id: log.html.php $
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php js::set('repoID', $repoID);?>
<?php js::set('paramsBase', "repoID=$repoID&objectID=$objectID&entry=" . $this->repo->encodePath($entry) . "&revision=$revision&type=$type");?>
<div id='mainMenu' class='clearfix'>
<div class="btn-toolbar pull-left">
<?php echo html::backButton("<i class='icon icon-back icon-sm'></i> " . $lang->goback, '', 'btn btn-link');?>
<div class="divider"></div>
<div class="page-title">
<strong>
<?php
echo html::a($this->repo->createLink('log', "repoID=$repoID&objectID=$objectID"), $repo->name, '', "data-app='{$app->tab}'");
$paths= explode('/', $entry);
$fileName = array_pop($paths);
$postPath = '';
foreach($paths as $pathName)
{
$postPath .= $pathName . '/';
echo '/' . ' ' . html::a($this->repo->createLink('log', "repoID=$repoID&ojbectID=$objectID&entry=" . $this->repo->encodePath($postPath)), trim($pathName, '/'), '', "data-app='{$app->tab}'");
}
echo '/' . ' ' . $fileName;
?>
</strong>
</div>
</div>
</div>
<div id="mainContent">
<nav id="contentNav">
<ul class="nav nav-default">
<?php $encodeEntry = $this->repo->encodePath($entry);?>
<li><a><?php echo $lang->repo->log;?></a></li>
<li><?php echo html::a($this->repo->createLink('view', "repoID=$repoID&objectID=$objectID&entry=$encodeEntry&revision=$revision"), $lang->repo->view, '', "data-app='{$app->tab}'");?></li>
<?php if($info->kind == 'file'):?>
<li><?php echo html::a($this->repo->createLink('blame', "repoID=$repoID&objectID=$objectID&entry=$encodeEntry&revision=$revision"), $lang->repo->blame, '', "data-app='{$app->tab}'");?></li>
<li><?php echo html::a($this->repo->createLink('download', "repoID=$repoID&path=$encodeEntry&fromRevision=$revision"), $lang->repo->download, 'hiddenwin');?></li>
<?php endif;?>
</ul>
</nav>
<form id='logForm' class='main-table' data-ride='table' method='post'>
<table class='table table-fixed' id='logList'>
<thead>
<tr>
<th class='w-40px'></th>
<th class='w-110px'><?php echo $lang->repo->revision?></th>
<?php if($repo->SCM != 'Subversion'):?>
<th class='w-90px'><?php echo $lang->repo->commit?></th>
<?php endif;?>
<th class='w-150px'><?php echo $lang->repo->date?></th>
<th class='w-100px'><?php echo $lang->repo->committer?></th>
<th><?php echo $lang->repo->comment?></th>
</tr>
</thead>
<tbody>
<?php foreach($logs as $log):?>
<tr>
<td>
<div class='checkbox-primary'>
<input type='checkbox' name='revision[]' value="<?php echo $log->revision?>" />
<label></label>
</div>
</td>
<td class='versions'><?php echo html::a($this->repo->createLink('revision', "repoID=$repoID&objectID=$objectID&revision=" . $log->revision), substr($log->revision, 0, 10), '', "data-app='{$app->tab}'");?></td>
<?php if($repo->SCM != 'Subversion'):?>
<td><?php echo $log->commit?></td>
<?php endif;?>
<td><?php echo $log->time;?></td>
<td><?php echo $log->committer;?></td>
<td class='comment'><?php echo $log->comment;?></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<div class='table-footer'>
<?php if(common::hasPriv('repo', 'diff')) echo html::submitButton($lang->repo->diff, '', count($logs) < 2 ? 'disabled btn btn-primary' : 'btn btn-primary')?>
<?php if($repo->SCM == 'Gitlab'):?>
<?php
$prePage = $pager->pageID == 1 ? 1 : $pager->pageID - 1;
$nextPage = $pager->pageID == $pager->pageTotal ? $pager->pageID : $pager->pageID + 1;
$params = "repoID=$repoID&objectID=$objectID&entry=" . $this->repo->encodePath($entry) . "&revision=$revision&type=$type&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}";
$preLink = $this->repo->createLink('log', "$params&pageID=$prePage");
$nextLink = $this->repo->createLink('log', "$params&pageID=$nextPage");
//echo html::a($preLink, "<i class='icon icon-angle-left'></i>", "", "" . ($prePage == $pager->pageID ? ' disabled' : ''));
//echo html::a($nextLink, "<i class='icon icon-angle-right'></i>", "", "" . ($nextPage == $pager->pageID ? ' disabled' : ''));
$total = count($logs) < $pager->recPerPage ? $pager->recPerPage * $pager->pageID : $pager->recPerPage * ($pager->pageID + 1)
?>
<ul id="repoPageSize" class="pager" data-ride="pager" data-elements="size_menu,prev_icon,next_icon" data-rec-total="<?php echo $total;?>" data-rec-per-page="<?php echo $pager->recPerPage;?>" data-page="<?php echo $pager->pageID;?>" data-link-creator="<?php echo $this->repo->createLink('log', $params . '&pageID={page}');?>"></ul>
<?php else:?>
<?php $pager->show('right', 'pagerjs');?>
<?php endif;?>
</div>
</form>
</div>
<?php include '../../common/view/footer.html.php';?>
+2 -2
View File
@@ -39,8 +39,8 @@ $devTester = new devTest();
r($devTester->getCustomedLangTest('test')) && p() && e("0"); // 错误的类型返回数据
r($devTester->getCustomedLangTest('common')) && p('productCommon') && e("测试1"); // 正确的类型返回数据
r($devTester->getCustomedLangTest('second', $failModule)) && p() && e("0"); // 正确的类型,错误的模块返回数据
r($devTester->getCustomedLangTest('second', $realModule)) && p('index') && e("测试2"); // 正确的类型,正确的模块返回数据
r($devTester->getCustomedLangTest('second', $failModule)) && p() && e("0"); // 正确的类型,错误的模块返回数据
r($devTester->getCustomedLangTest('second', $realModule)) && p('menu_index') && e("测试2"); // 正确的类型,正确的模块返回数据
r($devTester->getCustomedLangTest('tag', $realModule, $failMethod)) && p() && e("0"); // 正确的类型,正确的模块,错误的方法返回数据
r($devTester->getCustomedLangTest('tag', $realModule, $realMethod)) && p('featureBar-todo_all') && e("测试3"); // 正确的类型,正确的模块,正确的方法返回数据
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/dev.class.php';
su('admin');
/**
title=测试 devModel::getTree();
cid=1
pid=1
测试传入空值的情况 >> 0
测试传入错误类型的情况 >> 0
测试获取type=module模块树,并检查高亮情况 >> my,1
测试获取type=table模块树,并检查高亮情况 >> my,1
*/
global $tester;
$tester->loadModel('dev');
$activeList = array('', 'index', 'zt_todo');
$typeList = array('', 'tree', 'module', 'table');
r($tester->dev->getTree($activeList[0], $typeList[0])) && p() && e('0'); // 测试传入空值的情况
r($tester->dev->getTree($activeList[0], $typeList[1])) && p() && e('0'); // 测试传入错误类型的情况
r($tester->dev->getTree($activeList[1], $typeList[2])) && p('0:key,active') && e('my,1'); // 测试获取type=module模块树,并检查高亮情况
r($tester->dev->getTree($activeList[2], $typeList[3])) && p('0:key,active') && e('my,1'); // 测试获取type=table模块树,并检查高亮情况