+ [misc] Add unit tests for docZen::assignApiVarForSpace() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -25,8 +25,52 @@ class docZenTest
|
||||
public function processReleaseListDataTest(array $releaseList, array $childReleases): array
|
||||
{
|
||||
$result = callZenMethod('doc', 'processReleaseListData', array($releaseList, $childReleases));
|
||||
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test assignApiVarForSpace method.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $browseType
|
||||
* @param string $libType
|
||||
* @param int $libID
|
||||
* @param array $libs
|
||||
* @param int $objectID
|
||||
* @param int $moduleID
|
||||
* @param int $queryID
|
||||
* @param string $orderBy
|
||||
* @param int $param
|
||||
* @param int $recTotal
|
||||
* @param int $recPerPage
|
||||
* @param int $pageID
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function assignApiVarForSpaceTest(string $type = 'product', string $browseType = 'all', string $libType = 'lib', int $libID = 0, array $libs = array(), int $objectID = 0, int $moduleID = 0, int $queryID = 0, string $orderBy = 'id_desc', int $param = 0, int $recTotal = 0, int $recPerPage = 20, int $pageID = 1): object
|
||||
{
|
||||
ob_start();
|
||||
$view = callZenMethod('doc', 'assignApiVarForSpace', array($type, $browseType, $libType, $libID, $libs, $objectID, $moduleID, $queryID, $orderBy, $param, $recTotal, $recPerPage, $pageID), 'view');
|
||||
ob_end_clean();
|
||||
|
||||
if(dao::isError()) return (object)dao::getError();
|
||||
|
||||
$result = new stdclass();
|
||||
$result->pager = isset($view->pager) ? get_class($view->pager) : '';
|
||||
$result->canExport = isset($view->canExport) ? (int)$view->canExport : 0;
|
||||
|
||||
if($libType == 'api')
|
||||
{
|
||||
$result->hasApiList = isset($view->apiList) ? 1 : 0;
|
||||
$result->hasLibs = isset($view->libs) ? 1 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result->hasDocs = isset($view->docs) ? 1 : 0;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 docZen::assignApiVarForSpace();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 执行docTest模块的assignApiVarForSpaceTest方法,参数是'product', 'all', 'lib', 1, array
|
||||
- 属性pager @pager
|
||||
- 属性hasDocs @1
|
||||
- 执行docTest模块的assignApiVarForSpaceTest方法,参数是'product', 'all', 'api', 1, array
|
||||
- 属性pager @pager
|
||||
- 属性hasApiList @1
|
||||
- 执行docTest模块的assignApiVarForSpaceTest方法,参数是'product', 'all', 'lib', 1, array 属性canExport @0
|
||||
- 执行docTest模块的assignApiVarForSpaceTest方法,参数是'project', 'all', 'lib', 1, array 属性canExport @0
|
||||
- 执行docTest模块的assignApiVarForSpaceTest方法,参数是'product', 'all', 'lib', 1, array 属性pager @pager
|
||||
- 执行docTest模块的assignApiVarForSpaceTest方法,参数是'product', 'all', 'lib', 1, array 属性pager @pager
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/doczen.unittest.class.php';
|
||||
|
||||
zendata('doclib')->gen(10);
|
||||
zendata('doc')->gen(20);
|
||||
zendata('api')->gen(15);
|
||||
|
||||
su('admin');
|
||||
|
||||
$docTest = new docZenTest();
|
||||
|
||||
r($docTest->assignApiVarForSpaceTest('product', 'all', 'lib', 1, array(1 => 'testlib'), 1, 0, 0, 'id_desc', 0, 20, 20, 1)) && p('pager,hasDocs') && e('pager,1');
|
||||
r($docTest->assignApiVarForSpaceTest('product', 'all', 'api', 1, array(1 => 'apilib'), 1, 0, 0, 'id_desc', 0, 15, 20, 1)) && p('pager,hasApiList') && e('pager,1');
|
||||
r($docTest->assignApiVarForSpaceTest('product', 'all', 'lib', 1, array(1 => 'testlib'), 1, 0, 0, 'id_desc', 0, 20, 20, 1)) && p('canExport') && e('0');
|
||||
r($docTest->assignApiVarForSpaceTest('project', 'all', 'lib', 1, array(1 => 'testlib'), 1, 0, 0, 'id_desc', 0, 20, 20, 1)) && p('canExport') && e('0');
|
||||
r($docTest->assignApiVarForSpaceTest('product', 'all', 'lib', 1, array(1 => 'testlib'), 1, 0, 0, 'id_desc', 0, 50, 20, 1)) && p('pager') && e('pager');
|
||||
r($docTest->assignApiVarForSpaceTest('product', 'all', 'lib', 1, array(1 => 'testlib'), 1, 0, 0, 'id_desc', 0, 100, 50, 2)) && p('pager') && e('pager');
|
||||
Reference in New Issue
Block a user