* Autotest program case.

This commit is contained in:
zhengrunyu
2022-01-18 10:22:42 +08:00
parent 172b4ade25
commit 8ebdc2a3b6
26 changed files with 702 additions and 4 deletions
+27 -4
View File
@@ -2,15 +2,38 @@
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
class Tester
{
public function __construct($user)
{
global $tester;
su('admin');
$this->program = $tester->loadModel('program');
}
public function getById($programID)
{
if(empty($this->program->getById($programID)))
{
return array('code' => 'fail', 'message' => 'Not Found');
}
else
{
return $this->program->getById($programID);
}
}
}
$t = new Tester('admin');
/**
title=测试 programModel::getById();
cid=1
pid=1
通过id字段获取存在的项目集 >> 测试项目集1
*/
$program = $tester->loadModel('program');
r($program->getById(1)) && p('name') && e('测试项目集1'); // 通过id字段获取存在的项目集
r($t->getById(1)) && p('name') && e('项目集1'); // 通过id字段获取id=1的项目集并验证它的name。
r($t->getById(1000)) && p('message') && e('Not Found'); // 通过id字段获取id=1000的项目集并验证它的name。