* Refator stakeholder::isClickable unit test.

This commit is contained in:
tianshujie
2023-12-22 14:07:26 +08:00
parent fded37514b
commit d312c92ee2
2 changed files with 45 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env php
<?php
/**
title=测试 stakeholderModel->isClickable();
cid=1
- 测试ID为0的干系人中期望按钮是否可点击 @1
- 测试ID为0的干系人中不存在干系人是否可点击 @0
- 测试ID为1的干系人中期望按钮是否可点击 @1
- 测试ID为1的干系人中不存在干系人是否可点击 @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/stakeholder.class.php';
zdTable('user')->gen(5);
zdTable('stakeholder')->gen(1);
$idList = array(0, 1);
$actions = array('expcet', 'notExists');
$stakeholderTester = new stakeholderTest();
r($stakeholderTester->isClickableTest($idList[0], $actions[0])) && p() && e('1'); // 测试ID为0的干系人中期望按钮是否可点击
r($stakeholderTester->isClickableTest($idList[0], $actions[1])) && p() && e('0'); // 测试ID为0的干系人中不存在干系人是否可点击
r($stakeholderTester->isClickableTest($idList[1], $actions[0])) && p() && e('1'); // 测试ID为1的干系人中期望按钮是否可点击
r($stakeholderTester->isClickableTest($idList[1], $actions[1])) && p() && e('0'); // 测试ID为1的干系人中不存在干系人是否可点击
@@ -410,4 +410,21 @@ class stakeholderTest
if(dao::isError()) return dao::getError();
return $issues;
}
/**
* 判断当前操作按钮是否可以点击。
* Judge the action is clickable.
*
* @param int $stakeholderID
* @param string $action
* @access public
* @return bool
*/
public function isClickableTest(int $stakeholderID, string $action): bool
{
$stakeholder = $this->objectModel->dao->select('*')->from(TABLE_STAKEHOLDER)->where('id')->eq($stakeholderID)->fetch();
if(!$stakeholder) $stakeholder = new stdclass();
return $this->objectModel->isClickable($stakeholder, $action);
}
}