+ [misc] Add unit tests for docModel::setLastViewed() method

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-15 15:06:15 +08:00
co-authored by Claude
parent 4f3c873bad
commit 9fd2e43096
2 changed files with 44 additions and 0 deletions
@@ -2208,4 +2208,19 @@ class docTest
return $result;
}
/**
* Test setLastViewed method.
*
* @param array $value
* @access public
* @return mixed
*/
public function setLastViewedTest(array $value): mixed
{
$this->objectModel->setLastViewed($value);
if(dao::isError()) return dao::getError();
return true;
}
}
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env php
<?php
/**
title=测试 docModel::setLastViewed();
timeout=0
cid=0
- 执行docTest模块的setLastViewedTest方法,参数是array @1
- 执行docTest模块的setLastViewedTest方法,参数是array @1
- 执行docTest模块的setLastViewedTest方法,参数是array @1
- 执行docTest模块的setLastViewedTest方法,参数是array @1
- 执行docTest模块的setLastViewedTest方法,参数是array @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/doc.unittest.class.php';
su('admin');
$docTest = new docTest();
r($docTest->setLastViewedTest(array('lastViewedSpace' => '1', 'lastViewedSpaceHome' => '2', 'lastViewedLib' => '3'))) && p() && e('1');
r($docTest->setLastViewedTest(array('lastViewedSpace' => '4', 'otherKey' => 'ignore'))) && p() && e('1');
r($docTest->setLastViewedTest(array())) && p() && e('1');
r($docTest->setLastViewedTest(array('invalidKey' => 'value', 'lastViewedLib' => '5'))) && p() && e('1');
r($docTest->setLastViewedTest(array('lastViewedSpace' => 'special<>&"value', 'lastViewedSpaceHome' => '6'))) && p() && e('1');