From 8368d6ea8df7b0f1d4bdbdc0ffa4b74972a13feb Mon Sep 17 00:00:00 2001 From: liugang Date: Tue, 11 Nov 2025 00:40:36 +0800 Subject: [PATCH] + [misc] Add unit tests for productZen::getActionsForDynamic() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- module/product/test/lib/zen.class.php | 21 ++++++++ .../product/test/zen/getactionsfordynamic.php | 48 +++++++++++++++++++ .../getactionsfordynamic/actionproduct.yaml | 19 ++++++++ 3 files changed, 88 insertions(+) create mode 100755 module/product/test/zen/getactionsfordynamic.php create mode 100644 module/product/test/zen/yaml/getactionsfordynamic/actionproduct.yaml diff --git a/module/product/test/lib/zen.class.php b/module/product/test/lib/zen.class.php index d59708af63..47546a1e37 100644 --- a/module/product/test/lib/zen.class.php +++ b/module/product/test/lib/zen.class.php @@ -290,4 +290,25 @@ class productZenTest extends baseTest if(dao::isError()) return dao::getError(); return $actions; } + + /** + * Test getActionsForDynamic method. + * + * @param string $account + * @param string $orderBy + * @param int $productID + * @param string $type + * @param string $date + * @param string $direction + * @access public + * @return mixed + */ + public function getActionsForDynamicTest(string $account = '', string $orderBy = 'date_desc', int $productID = 0, string $type = 'all', string $date = '', string $direction = 'next') + { + $result = $this->invokeArgs('getActionsForDynamic', array($account, $orderBy, $productID, $type, $date, $direction)); + if(dao::isError()) return dao::getError(); + + /* Return count of actions. */ + return count($result[0]); + } } diff --git a/module/product/test/zen/getactionsfordynamic.php b/module/product/test/zen/getactionsfordynamic.php new file mode 100755 index 0000000000..e9eee1ce1a --- /dev/null +++ b/module/product/test/zen/getactionsfordynamic.php @@ -0,0 +1,48 @@ +#!/usr/bin/env php +loadYaml('action_year', false, 4)->gen(35); +zenData('actionrecent')->loadYaml('action_year', false, 4)->gen(35); + +$actionproduct = zenData('actionproduct'); +$actionproduct->action->range('1-35'); +$actionproduct->product->range('1{7},2{7},3{7},4{7},5{7}'); +$actionproduct->gen(35); + +zenData('doclib')->loadYaml('doclib', false, 3)->gen(15); +zenData('doc')->loadYaml('doc', false, 3)->gen(5); +zenData('product')->gen(5); +zenData('project')->loadYaml('execution', false, 2)->gen(12); +zenData('user')->loadYaml('user', false, 1)->gen(3); +zenData('userview')->loadYaml('userview', false, 1)->gen(2); + +su('admin'); + +$productTest = new productZenTest(); + +r($productTest->getActionsForDynamicTest('all', 'date_desc', 1, 'all', '', 'next')) && p() && e('0'); // 测试步骤1:获取产品1所有用户的全部动态记录 +r($productTest->getActionsForDynamicTest('admin', 'date_desc', 1, 'all', '', 'next')) && p() && e('0'); // 测试步骤2:获取产品1的admin用户动态记录 +r($productTest->getActionsForDynamicTest('all', 'date_desc', 1, 'all', date('Y-m-d'), 'next')) && p() && e('0'); // 测试步骤3:获取产品1特定日期的动态记录 +r($productTest->getActionsForDynamicTest('all', 'id_desc', 1, 'all', '', 'next')) && p() && e('0'); // 测试步骤4:获取产品1动态记录按ID降序排列 +r($productTest->getActionsForDynamicTest('all', 'date_desc', 0, 'all', '', 'next')) && p() && e('0'); // 测试步骤5:获取产品0(无效产品ID)的动态记录 +r($productTest->getActionsForDynamicTest('all', 'date_desc', 1, 'account', '', 'next')) && p() && e('0'); // 测试步骤6:获取产品1按账户类型(account)筛选的动态 +r($productTest->getActionsForDynamicTest('all', 'date_desc', 1, 'all', '', 'pre')) && p() && e('0'); // 测试步骤7:获取产品1的动态记录向前翻页 \ No newline at end of file diff --git a/module/product/test/zen/yaml/getactionsfordynamic/actionproduct.yaml b/module/product/test/zen/yaml/getactionsfordynamic/actionproduct.yaml new file mode 100644 index 0000000000..50956fc81c --- /dev/null +++ b/module/product/test/zen/yaml/getactionsfordynamic/actionproduct.yaml @@ -0,0 +1,19 @@ +title: table zt_actionproduct +desc: "系统日志-产品关联" +author: test +version: "1.0" +fields: + - field: action + note: "动作ID" + range: 1-100 + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: product + note: "产品ID" + range: 1-5 + prefix: "" + postfix: "" + loop: 0 + format: ""