add ztf testcases.

This commit is contained in:
zhouxin
2022-01-24 05:50:56 +00:00
parent babfd88f2d
commit 1b021e1f24
2 changed files with 69 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
/**
title=测试productModel->getLatestProject();
cid=1
pid=1
*/
class Tester
{
public function __construct($user)
{
global $tester;
su($user);
$this->product = $tester->loadModel('product');
}
public function testGetLatestProject($productID)
{
$project = $this->product->getLatestProject($productID);
if($project == false) return '没有数据';
return $project;
}
}
$z = new Tester('admin');
r($z->testGetLatestProject(25)) && p('id') && e('315'); // 测试产品25关联的最后一个未关闭的项目,按begin字段排序
r($z->testGetLatestProject(38)) && p('id') && e('688'); // 测试产品38关联的最后一个未关闭的项目,按begin字段排序
r($z->testGetLatestProject(101)) && p() && e('没有数据'); // 传入不存在的产品
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
su('admin');
/**
title=测试productModel->isClickable();
cid=1
pid=1
*/
class Tester
{
public function __construct($user)
{
global $tester;
su($user);
$this->product = $tester->loadModel('product');
}
public function testIsClickable($productID, $status)
{
$product = $this->product->getById($productID);
$isClick = $this->product->isClickable($product, $status);
return $isClick == false ? 'false' : 'true';
}
}
$adminTester = new Tester('admin');
r($adminTester->testIsClickable(2, 'close')) && p() && e('true'); // status为normal,action为close
r($adminTester->testIsClickable(75, 'close')) && p() && e('false'); // status为close,action为close
r($adminTester->testIsClickable(2, 'start')) && p() && e('true'); // status为normal,action为start
r($adminTester->testIsClickable(75, 'start')) && p() && e('true'); // status为close,action为start