* Refactor setProjectSession method.
This commit is contained in:
@@ -271,13 +271,14 @@ class executionModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 给执行所属的项目ID设置session。
|
||||
* Set project into session.
|
||||
*
|
||||
* @param int $executionID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function setProjectSession($executionID)
|
||||
public function setProjectSession(int $executionID)
|
||||
{
|
||||
$execution = $this->getByID($executionID);
|
||||
if(!empty($execution)) $this->session->set('project', $execution->project, $this->app->tab);
|
||||
|
||||
@@ -111,13 +111,14 @@ class executionTest
|
||||
}
|
||||
|
||||
/**
|
||||
* 给执行所属的项目ID设置session。
|
||||
* Set project into session.
|
||||
*
|
||||
* @param int $executionID
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function setProjectSessionTest($executionID)
|
||||
public function setProjectSessionTest(int $executionID): int
|
||||
{
|
||||
unset($_SESSION['project']);
|
||||
$this->executionModel->setProjectSession($executionID);
|
||||
|
||||
@@ -21,15 +21,11 @@ $execution->gen(5);
|
||||
/**
|
||||
|
||||
title=测试 executionModel::setProjectSession();
|
||||
timeout=0
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
执行存在的情况 >> 2
|
||||
执行不存在的情况 >> 0
|
||||
|
||||
*/
|
||||
|
||||
$executionTester = new executionTest();
|
||||
|
||||
r($executionTester->setProjectSessionTest(3)) && p() && e('2'); // 执行存在的情况
|
||||
r($executionTester->setProjectSessionTest(10)) && p() && e('0'); // 执行不存在的情况
|
||||
|
||||
Reference in New Issue
Block a user