+ [misc] Add unit tests for testcaseZen::setBrowseSession() method

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-18 13:12:08 +08:00
co-authored by Claude
parent 9a0608643b
commit b40cac6f81
2 changed files with 59 additions and 0 deletions
+30
View File
@@ -29,4 +29,34 @@ class testcaseZenTest
foreach($postData as $key => $value) $_POST[$key] = $value;
return callZenMethod('testcase', 'buildDataForImportFromLib', [$productID, $branch, $libID]);
}
/**
* Test setBrowseSession method.
*
* @param int $productID
* @param string|bool $branch
* @param int $moduleID
* @param string $browseType
* @param string $orderBy
* @access public
* @return array
*/
public function setBrowseSessionTest(int $productID, string|bool $branch, int $moduleID, string $browseType = '', string $orderBy = ''): array
{
global $tester;
// 调用setBrowseSession方法
callZenMethod('testcase', 'setBrowseSession', [$productID, $branch, $moduleID, $browseType, $orderBy]);
// 返回设置的会话数据进行验证
return array(
'productID' => $tester->session->productID,
'branch' => $tester->session->branch,
'moduleID' => $tester->session->moduleID,
'browseType' => $tester->session->browseType,
'orderBy' => $tester->session->orderBy,
'caseBrowseType' => $tester->session->caseBrowseType,
'testcaseOrderBy' => $tester->session->testcaseOrderBy
);
}
}
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env php
<?php
/**
title=测试 testcaseZen::setBrowseSession();
timeout=0
cid=0
- 步骤1:正常设置会话参数属性productID @1
- 步骤2:设置browseType为bymodule属性browseType @bymodule
- 步骤3:设置空的browseType属性moduleID @30
- 步骤4:设置branch为false属性caseBrowseType @wait
- 步骤5:设置所有参数为边界值属性orderBy @pri_asc
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/testcasezen.unittest.class.php';
su('admin');
$testcaseZenTest = new testcaseZenTest();
r($testcaseZenTest->setBrowseSessionTest(1, 'branch1', 10, 'all', 'id_desc')) && p('productID') && e('1'); // 步骤1:正常设置会话参数
r($testcaseZenTest->setBrowseSessionTest(2, 'branch2', 20, 'bymodule', 'name_asc')) && p('browseType') && e('bymodule'); // 步骤2:设置browseType为bymodule
r($testcaseZenTest->setBrowseSessionTest(3, 'branch3', 30, '', 'status_desc')) && p('moduleID') && e('30'); // 步骤3:设置空的browseType
r($testcaseZenTest->setBrowseSessionTest(4, false, 40, 'wait', '')) && p('caseBrowseType') && e('wait'); // 步骤4:设置branch为false
r($testcaseZenTest->setBrowseSessionTest(0, '', 0, 'closed', 'pri_asc')) && p('orderBy') && e('pri_asc'); // 步骤5:设置所有参数为边界值