+ [misc] Add unit tests for docZen::assignVarsForUploadDocs() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -173,4 +173,43 @@ class docZenTest
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test assignVarsForUploadDocs method.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int $objectID
|
||||
* @param int $libID
|
||||
* @param int $moduleID
|
||||
* @param string $docType
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function assignVarsForUploadDocsTest(string $objectType = 'product', int $objectID = 0, int $libID = 0, int $moduleID = 0, string $docType = ''): object
|
||||
{
|
||||
ob_start();
|
||||
$view = callZenMethod('doc', 'assignVarsForUploadDocs', array($objectType, $objectID, $libID, $moduleID, $docType), 'view');
|
||||
ob_end_clean();
|
||||
|
||||
if(dao::isError()) return (object)dao::getError();
|
||||
|
||||
$result = new stdclass();
|
||||
$result->objectType = isset($view->objectType) ? $view->objectType : '';
|
||||
$result->spaceType = isset($view->spaceType) ? $view->spaceType : '';
|
||||
$result->type = isset($view->type) ? $view->type : '';
|
||||
$result->libID = isset($view->libID) ? (int)$view->libID : 0;
|
||||
$result->objectID = isset($view->objectID) ? (int)$view->objectID : 0;
|
||||
$result->moduleID = isset($view->moduleID) ? (int)$view->moduleID : 0;
|
||||
$result->docType = isset($view->docType) ? $view->docType : '';
|
||||
$result->title = isset($view->title) ? $view->title : '';
|
||||
$result->linkType = isset($view->linkType) ? $view->linkType : '';
|
||||
$result->hasLib = isset($view->lib) ? 1 : 0;
|
||||
$result->hasLibs = isset($view->libs) ? 1 : 0;
|
||||
$result->hasGroups = isset($view->groups) ? 1 : 0;
|
||||
$result->hasUsers = isset($view->users) ? 1 : 0;
|
||||
$result->hasSpaces = isset($view->spaces) ? 1 : 0;
|
||||
$result->hasOptionMenu = isset($view->optionMenu) ? 1 : 0;
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 docZen::assignVarsForUploadDocs();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 测试产品空间下上传文档
|
||||
- 属性objectType @product
|
||||
- 属性libID @1
|
||||
- 属性linkType @product
|
||||
- 属性hasOptionMenu @1
|
||||
- 测试项目空间下上传文档
|
||||
- 属性objectType @project
|
||||
- 属性libID @2
|
||||
- 属性linkType @project
|
||||
- 测试自定义空间下上传文档
|
||||
- 属性objectType @custom
|
||||
- 属性libID @7
|
||||
- 属性linkType @custom
|
||||
- 属性hasSpaces @1
|
||||
- 测试我的空间下上传文档
|
||||
- 属性objectType @mine
|
||||
- 属性libID @9
|
||||
- 属性linkType @mine
|
||||
- 属性hasSpaces @1
|
||||
- 测试执行空间下上传文档
|
||||
- 属性objectType @execution
|
||||
- 属性objectID @3
|
||||
- 测试不传入任何参数使用默认值
|
||||
- 属性objectType @product
|
||||
- 属性linkType @product
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/doczen.unittest.class.php';
|
||||
|
||||
zenData('doclib')->loadYaml('assignvarsforuploaddocs/doclib', false, 2)->gen(10);
|
||||
zenData('product')->loadYaml('assignvarsforuploaddocs/product', false, 2)->gen(5);
|
||||
zenData('project')->loadYaml('assignvarsforuploaddocs/project', false, 2)->gen(5);
|
||||
zenData('module')->loadYaml('assignvarsforuploaddocs/module', false, 2)->gen(5);
|
||||
zenData('doc')->loadYaml('assignvarsforuploaddocs/doc', false, 2)->gen(10);
|
||||
zenData('group')->gen(3);
|
||||
zenData('user')->gen(5);
|
||||
|
||||
su('admin');
|
||||
|
||||
$docTest = new docZenTest();
|
||||
|
||||
r($docTest->assignVarsForUploadDocsTest('product', 1, 1, 0, '')) && p('objectType,libID,linkType,hasOptionMenu') && e('product,1,product,1'); // 测试产品空间下上传文档
|
||||
r($docTest->assignVarsForUploadDocsTest('project', 2, 2, 0, '')) && p('objectType,libID,linkType') && e('project,2,project'); // 测试项目空间下上传文档
|
||||
r($docTest->assignVarsForUploadDocsTest('custom', 0, 7, 0, '')) && p('objectType,libID,linkType,hasSpaces') && e('custom,7,custom,1'); // 测试自定义空间下上传文档
|
||||
r($docTest->assignVarsForUploadDocsTest('mine', 0, 9, 0, '')) && p('objectType,libID,linkType,hasSpaces') && e('mine,9,mine,1'); // 测试我的空间下上传文档
|
||||
r($docTest->assignVarsForUploadDocsTest('execution', 3, 0, 0, '')) && p('objectType,objectID') && e('execution,3'); // 测试执行空间下上传文档
|
||||
r($docTest->assignVarsForUploadDocsTest('product', 0, 0, 0, '')) && p('objectType,linkType') && e('product,product'); // 测试不传入任何参数使用默认值
|
||||
@@ -0,0 +1,53 @@
|
||||
---
|
||||
title: 文档表
|
||||
desc: 用于测试 assignVarsForUploadDocs 方法的文档数据
|
||||
|
||||
fields:
|
||||
- field: id
|
||||
note: 文档ID
|
||||
range: 1-10
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: lib
|
||||
note: 所属库ID
|
||||
range: 1,1,2,2,3,4,5,5,7,9
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: title
|
||||
note: 文档标题
|
||||
range: 文档1,文档2,文档3,文档4,文档5,文档6,文档7,文档8,文档9,文档10
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: type
|
||||
note: 文档类型
|
||||
range: text,html,markdown
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: status
|
||||
note: 文档状态
|
||||
range: normal,draft
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: deleted
|
||||
note: 是否删除
|
||||
range: '0'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: addedBy
|
||||
note: 创建者
|
||||
range: admin
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: addedDate
|
||||
note: 创建时间
|
||||
range: (-1M)-(now):1D
|
||||
format: YYYY-MM-DD hh:mm:ss
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
title: 文档库表
|
||||
desc: 用于测试 assignVarsForUploadDocs 方法的文档库数据
|
||||
|
||||
fields:
|
||||
- field: id
|
||||
note: 库ID
|
||||
range: 1-10
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: type
|
||||
note: 库类型
|
||||
range: product{2},project{2},execution{2},custom{2},mine{2}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: product
|
||||
note: 产品ID
|
||||
range: 1,2,0,0,0,0,0,0,0,0
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: project
|
||||
note: 项目ID
|
||||
range: 0,0,1,2,0,0,0,0,0,0
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: execution
|
||||
note: 执行ID
|
||||
range: 0,0,0,0,1,2,0,0,0,0
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: name
|
||||
note: 库名称
|
||||
range: 产品文档库1,产品文档库2,项目文档库1,项目文档库2,执行文档库1,执行文档库2,自定义库1,自定义库2,我的文档库1,我的文档库2
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: acl
|
||||
note: 访问控制
|
||||
range: open{5},private{3},custom{2}
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: deleted
|
||||
note: 是否删除
|
||||
range: '0'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: addedBy
|
||||
note: 创建者
|
||||
range: admin
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: addedDate
|
||||
note: 创建时间
|
||||
range: (-1M)-(now):1D
|
||||
format: YYYY-MM-DD hh:mm:ss
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: 模块表
|
||||
desc: 用于测试 assignVarsForUploadDocs 方法的模块数据
|
||||
|
||||
fields:
|
||||
- field: id
|
||||
note: 模块ID
|
||||
range: 1-5
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: root
|
||||
note: 所属库ID
|
||||
range: 1,1,2,2,5
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: name
|
||||
note: 模块名称
|
||||
range: 模块1,模块2,模块3,模块4,模块5
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: type
|
||||
note: 模块类型
|
||||
range: doc
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: deleted
|
||||
note: 是否删除
|
||||
range: '0'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: 产品表
|
||||
desc: 用于测试 assignVarsForUploadDocs 方法的产品数据
|
||||
|
||||
fields:
|
||||
- field: id
|
||||
note: 产品ID
|
||||
range: 1-5
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: name
|
||||
note: 产品名称
|
||||
range: 产品1,产品2,产品3,产品4,产品5
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: type
|
||||
note: 产品类型
|
||||
range: normal
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: status
|
||||
note: 产品状态
|
||||
range: normal
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: deleted
|
||||
note: 是否删除
|
||||
range: '0'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: 项目表
|
||||
desc: 用于测试 assignVarsForUploadDocs 方法的项目数据
|
||||
|
||||
fields:
|
||||
- field: id
|
||||
note: 项目ID
|
||||
range: 1-5
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: name
|
||||
note: 项目名称
|
||||
range: 项目1,项目2,项目3,项目4,项目5
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: type
|
||||
note: 项目类型
|
||||
range: project
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: status
|
||||
note: 项目状态
|
||||
range: doing
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
|
||||
- field: deleted
|
||||
note: 是否删除
|
||||
range: '0'
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
Reference in New Issue
Block a user