+ [misc] Add unit tests for productZen::getActionsForDynamic() method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-11-12 08:31:02 +08:00
co-authored by Claude
parent 2b2a5dd0be
commit 8368d6ea8d
3 changed files with 88 additions and 0 deletions
+21
View File
@@ -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]);
}
}
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/env php
<?php
/**
title=测试 productZen::getActionsForDynamic();
timeout=0
cid=0
- 测试步骤1:获取产品1所有用户的全部动态记录 @0
- 测试步骤2:获取产品1的admin用户动态记录 @0
- 测试步骤3:获取产品1特定日期的动态记录 @0
- 测试步骤4:获取产品1动态记录按ID降序排列 @0
- 测试步骤5:获取产品0(无效产品ID)的动态记录 @0
- 测试步骤6:获取产品1按账户类型(account)筛选的动态 @0
- 测试步骤7:获取产品1的动态记录向前翻页 @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/zen.class.php';
zenData('action')->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的动态记录向前翻页
@@ -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: ""