From d7d2caeda9529a8e2d70f8675be29bc4f15ce088 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Fri, 8 Sep 2023 17:25:47 +0800 Subject: [PATCH] + Add unit test for execution getFullNameList. --- module/execution/model.php | 24 +++---------------- .../execution/test/model/getfullnamelist.php | 23 ++++++++++++++++++ 2 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 module/execution/test/model/getfullnamelist.php diff --git a/module/execution/model.php b/module/execution/model.php index 4012f9bf43..daa498aaba 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -2075,31 +2075,13 @@ class executionModel extends model } /** - * Get full name by path. - * @param string $executionPath - * @access public - * @return string - */ - public function getFullNameByPath($executionPath) - { - $paths = explode(',', trim($executionPath, ',')); - $executions = $this->dao->select('id,name')->from(TABLE_EXECUTION)->where('id')->in($paths)->andWhere('type')->notin('program,project')->fetchPairs(); - $executionName = array(); - foreach($paths as $path) - { - if(isset($executions[$path])) $executionName[] = $executions[$path]; - } - - return implode('/', $executionName); - } - - /** - * Get full name of executions. + * 获取完整路径的执行名称。 + * Get full path name of execution. * @param array $executions * @access public * @return array */ - public function getFullNameList($executions) + public function getFullNameList(array $executions): array { $allExecutions = $this->dao->select('id,name,parent')->from(TABLE_EXECUTION) ->where('type')->notin(array('program', 'project')) diff --git a/module/execution/test/model/getfullnamelist.php b/module/execution/test/model/getfullnamelist.php new file mode 100644 index 0000000000..9e025610b5 --- /dev/null +++ b/module/execution/test/model/getfullnamelist.php @@ -0,0 +1,23 @@ +#!/usr/bin/env php +gen(5); +su('admin'); + +zdTable('project')->config('execution')->gen(30); + +/** + +title=测试 executionModel->getFullNameList(); +timeout=0 +cid=1 + +*/ + +global $tester; +$executionModel = $tester->loadModel('execution'); +$allExecutions = $executionModel->fetchExecutionList(); + +r($executionModel->getFullNameList(array())) && p() && e('0'); // 空执行的情况 +r($executionModel->getFullNameList($allExecutions)) && p('101') && e('迭代5'); // 正常情况 +r(count($executionModel->getFullNameList($allExecutions))) && p() && e(20); // 正常情况