* Change the call method of the execution::checkaccess unit test.
This commit is contained in:
@@ -3078,4 +3078,19 @@ class executionTest
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户是否可以访问当前执行。
|
||||
* Check whether access to the current execution is allowed or not.
|
||||
*
|
||||
* @param int $executionID
|
||||
* @param array $executions
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function checkAccessTest(int $executionID, array $executions)
|
||||
{
|
||||
if(!isset($executions[$executionID])) return (int)key($executions);
|
||||
return $this->executionModel->checkAccess($executionID, $executions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/execution.class.php';
|
||||
|
||||
zdTable('project')->config('execution')->gen(10);
|
||||
su('admin');
|
||||
@@ -13,12 +14,11 @@ cid=1
|
||||
|
||||
*/
|
||||
|
||||
global $tester;
|
||||
$tester->loadModel('execution');
|
||||
|
||||
$executions = array(101 => 101, 102 => 102, 106 => 106);
|
||||
$idList = array(0, 106, 110);
|
||||
r($tester->execution->checkAccess($idList[0], $executions)) && p() && e('101'); //不传入ID
|
||||
r($tester->execution->checkAccess($idList[1], $executions)) && p() && e('106'); //传入存在ID的值
|
||||
r($tester->execution->checkAccess($idList[0], $executions)) && p() && e('101'); //不传入ID,读取session信息
|
||||
r($tester->execution->checkAccess($idList[2], $executions)) && p() && e('101'); //传入正确的ID
|
||||
$idList = array(0, 106, 110);
|
||||
|
||||
$executionTester = new executionTest();
|
||||
r($executionTester->checkAccessTest($idList[0], $executions)) && p() && e('101'); //不传入ID
|
||||
r($executionTester->checkAccessTest($idList[1], $executions)) && p() && e('106'); //传入存在ID的值
|
||||
r($executionTester->checkAccessTest($idList[0], $executions)) && p() && e('101'); //不传入ID,读取session信息
|
||||
r($executionTester->checkAccessTest($idList[2], $executions)) && p() && e('101'); //传入不存在的ID
|
||||
|
||||
Reference in New Issue
Block a user