* [perf story #75388] Adjust unit test.

This commit is contained in:
wangyidong
2025-06-18 10:48:44 +08:00
parent 7acca6947c
commit daad32fc65
3 changed files with 16 additions and 7 deletions
@@ -1,7 +1,7 @@
<?php
class actionTest
{
private $objectModel;
public $objectModel;
public function __construct()
{
@@ -796,9 +796,9 @@ class actionTest
* Test get first action.
*
* @access public
* @return array|object
* @return array|object|false
*/
public function getFirstActionTest(): array|object
public function getFirstActionTest(): array|object|false
{
$object = $this->objectModel->getFirstAction();
+8 -1
View File
@@ -5,6 +5,7 @@ include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/action.unittest.class.php';
zenData('action')->gen('10');
zenData('actionrecent')->gen('0');
zenData('user')->gen(10);
su('admin');
@@ -19,9 +20,15 @@ cid=1
- 属性id @1
- 属性objectID @1
- 属性objectType @product
- 属性action @common
- 属性extra @1
- 没有动态数据 @0
*/
$action = new actionTest();
r($action->getFirstActionTest()) && p('id,objectID,objectType') && e('1,1,product'); // 测试获取对象类型 story 对象ID 1 的动态信息
r($action->getFirstActionTest()) && p('id,objectID,objectType,action,extra') && e('1,1,product,common,1'); // 测试获取对象类型 story 对象ID 1 的动态信息
$action->objectModel->dao->delete()->from(TABLE_ACTION)->exec();
r($action->getFirstActionTest()) && p() && e('0'); // 没有动态数据
+5 -3
View File
@@ -6,6 +6,7 @@ include dirname(__FILE__, 4) . '/file/test/lib/file.unittest.class.php';
su('admin');
zenData('action')->gen(2);
zenData('actionrecent')->gen(0);
zenData('file')->gen(1);
/**
@@ -19,6 +20,7 @@ cid=1
- 测试文件是否更新成功, 文件的objectType和objectID被更新为comment和2
- 属性objectType @comment
- 属性objectID @2
- 属性name @文件标题1
*/
@@ -29,6 +31,6 @@ $uidList = array('', uniqid());
$action = new actionTest();
$file = new fileTest();
r($action->updateCommentTest($actionIDList[0], $commentList[0], $uidList[0])) && p('comment') && e('备注1'); // 测试更新action 1的备注, 备注被成功更新为备注1
r($action->updateCommentTest($actionIDList[1], $commentList[1], $uidList[1])) && p('comment') && e('备注2'); // 测试更新action 2的备注, 备注被成功更新为备注2
r($file->getByIdTest(1)) && p('objectType;objectID') && e('comment;2'); //测试文件是否更新成功, 文件的objectType和objectID被更新为comment和2
r($action->updateCommentTest($actionIDList[0], $commentList[0], $uidList[0])) && p('comment') && e('备注1'); // 测试更新action 1的备注, 备注被成功更新为备注1
r($action->updateCommentTest($actionIDList[1], $commentList[1], $uidList[1])) && p('comment') && e('备注2'); // 测试更新action 2的备注, 备注被成功更新为备注2
r($file->getByIdTest(1)) && p('objectType;objectID;name') && e('comment;2;文件标题1'); //测试文件是否更新成功, 文件的objectType和objectID被更新为comment和2