From 8bb238ae407e73bc851e92be308ee660ec32155f Mon Sep 17 00:00:00 2001 From: liugang Date: Wed, 18 Jun 2025 14:58:01 +0800 Subject: [PATCH] * [misc] fix unittest error of the storyTao::getModules4ExecutionStories method. --- module/story/tao.php | 9 ++++++++- module/story/test/tao/getmodules4executionstories.php | 7 ++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/module/story/tao.php b/module/story/tao.php index 42af4ba3e8..94528fc360 100644 --- a/module/story/tao.php +++ b/module/story/tao.php @@ -484,10 +484,17 @@ class storyTao extends storyModel protected function getModules4ExecutionStories(string $type, string $param): array { $moduleID = (int)($type == 'bymodule' && $param !== '' ? $param : $this->cookie->storyModuleParam); - if(!$moduleID || strpos('allstory,unclosed,bymodule', $type) === false) return []; + if(empty($moduleID)) + { + if(!empty($type) && strpos('allstory,unclosed,bymodule', $type) !== false) return $this->dao->select('id')->from(TABLE_MODULE)->where('deleted')->eq('0')->andWhere('type')->eq('story')->fetchPairs(); + + return []; + } /* 从缓存中获取模块路径然后在 LIKE 查询中使用左匹配以利用索引提高性能。Find the path of the module from cache and use left match in like query to improve performance. */ $path = $this->mao->select('path')->from(TABLE_MODULE)->where('id')->eq($moduleID)->fetch('path'); + if(empty($path)) return []; + return $this->dao->select('id')->from(TABLE_MODULE)->where('deleted')->eq('0')->andWhere('path')->like("$path%")->fetchPairs(); } diff --git a/module/story/test/tao/getmodules4executionstories.php b/module/story/test/tao/getmodules4executionstories.php index 3c04b7c211..cffd65040f 100755 --- a/module/story/test/tao/getmodules4executionstories.php +++ b/module/story/test/tao/getmodules4executionstories.php @@ -4,12 +4,13 @@ /** title=测试 storyModel->getModules4ExecutionStories(); +timeout=0 cid=0 - 不传入数据。 @0 - 传入 type=byproduct,不传入 param 参数。 @0 - 传入 type=byproduct 和 param 参数。 @0 -- 传入 type=bymodule,不传入 param 参数。 @0 +- 传入 type=bymodule,不传入 param 参数。属性2 @2 - 传入 type=bymodule 和 param 参数。属性1 @1 - 设置COOKIE,传入 type=byproduct,不传入 param 参数。属性2 @2 - 设置COOKIE,传入 type=byproduct 和 param 参数。属性2 @2 @@ -28,11 +29,11 @@ $storyModel = $tester->loadModel('story'); r($storyModel->getModules4ExecutionStories('', '')) && p() && e('0'); //不传入数据。 r($storyModel->getModules4ExecutionStories('byproduct', '')) && p() && e('0'); //传入 type=byproduct,不传入 param 参数。 r($storyModel->getModules4ExecutionStories('byproduct', '1')) && p() && e('0'); //传入 type=byproduct 和 param 参数。 -r($storyModel->getModules4ExecutionStories('bymodule', '')) && p() && e('0'); //传入 type=bymodule,不传入 param 参数。 +r($storyModel->getModules4ExecutionStories('bymodule', '')) && p(2) && e('2'); //传入 type=bymodule,不传入 param 参数。 r($storyModel->getModules4ExecutionStories('bymodule', '1')) && p(1) && e('1'); //传入 type=bymodule 和 param 参数。 $_COOKIE['storyModuleParam'] = 2; r($storyModel->getModules4ExecutionStories('byproduct', '')) && p(2) && e('2'); //设置COOKIE,传入 type=byproduct,不传入 param 参数。 r($storyModel->getModules4ExecutionStories('byproduct', '1')) && p(2) && e('2'); //设置COOKIE,传入 type=byproduct 和 param 参数。 r($storyModel->getModules4ExecutionStories('bymodule', '')) && p(2) && e('2'); //设置COOKIE,传入 type,不传入 param 参数。 -r($storyModel->getModules4ExecutionStories('bymodule', '1')) && p(1) && e('1'); //设置COOKIE,传入 type=bymodule 和 param 参数。 +r($storyModel->getModules4ExecutionStories('bymodule', '1')) && p(1) && e('1'); //设置COOKIE,传入 type=bymodule 和 param 参数。 \ No newline at end of file