diff --git a/module/block/test/lib/block.unittest.class.php b/module/block/test/lib/block.unittest.class.php index 82d2403a59..cb8739f4a9 100644 --- a/module/block/test/lib/block.unittest.class.php +++ b/module/block/test/lib/block.unittest.class.php @@ -4186,4 +4186,61 @@ class blockTest return $result; } + + /** + * Test printDocMyCollectionBlock method. + * + * @access public + * @return object + */ + public function printDocMyCollectionBlockTest() + { + global $app; + $app->loadClass('pager', true); + $pager = new pager(0, 6, 1); + + $docModel = $this->objectModel->loadModel('doc'); + + $result = new stdClass(); + $result->success = true; + $result->error = ''; + + try { + $docList = $docModel->getDocsByBrowseType('collectedbyme', 0, 0, 'editedDate_desc', $pager); + $libList = array(); + + if (!empty($docList)) { + foreach($docList as $doc) { + if(isset($doc->editedDate)) { + $doc->editedDate = substr($doc->editedDate, 0, 10); + $doc->editInterval = helper::getDateInterval($doc->editedDate); + } + if(isset($doc->lib)) { + $libList[] = $doc->lib; + } + } + } + + $result->docList = $docList ? $docList : array(); + $result->docCount = is_array($docList) ? count($docList) : 0; + $result->libList = $libList; + + } catch (Exception $e) { + $result->success = false; + $result->error = $e->getMessage(); + $result->docList = array(); + $result->docCount = 0; + $result->libList = array(); + } + + if(dao::isError()) { + $result->success = false; + $result->error = dao::getError(); + $result->docList = array(); + $result->docCount = 0; + $result->libList = array(); + } + + return $result; + } } diff --git a/module/block/test/zen/printdocmycollectionblock.php b/module/block/test/zen/printdocmycollectionblock.php new file mode 100755 index 0000000000..68e4e80578 --- /dev/null +++ b/module/block/test/zen/printdocmycollectionblock.php @@ -0,0 +1,54 @@ +#!/usr/bin/env php +id->range('1-10'); +$docTable->title->range('我关注的文档{10}'); +$docTable->status->range('normal{8},deleted{2}'); +$docTable->lib->range('1-5'); +$docTable->editedDate->range('2024-01-01 10:00:00,2024-01-02 11:00:00,2024-01-03 12:00:00'); +$docTable->deleted->range('0{8},1{2}'); +$docTable->gen(10); + +$doclibTable = zenData('doclib'); +$doclibTable->id->range('1-5'); +$doclibTable->name->range('文档库{5}'); +$doclibTable->deleted->range('0{5}'); +$doclibTable->gen(5); + +$docactionTable = zenData('docaction'); +$docactionTable->id->range('1-8'); +$docactionTable->doc->range('1-8'); +$docactionTable->action->range('collect{8}'); +$docactionTable->actor->range('admin{5},user1{3}'); +$docactionTable->date->range('2024-01-01 09:00:00,2024-01-02 09:00:00,2024-01-03 09:00:00'); +$docactionTable->gen(8); + +su('admin'); + +$blockTest = new blockTest(); + +r($blockTest->printDocMyCollectionBlockTest()) && p('success') && e('1'); +r($blockTest->printDocMyCollectionBlockTest()) && p('docCount') && e('5,<='); +r($blockTest->printDocMyCollectionBlockTest()) && p('docCount') && e('0,>='); +r($blockTest->printDocMyCollectionBlockTest()) && p('docList') && e('array'); +r($blockTest->printDocMyCollectionBlockTest()) && p('libList') && e('array'); \ No newline at end of file diff --git a/module/block/test/zen/yaml/doc_printdocmycollectionblock.yaml b/module/block/test/zen/yaml/doc_printdocmycollectionblock.yaml new file mode 100644 index 0000000000..b9e28c64d7 --- /dev/null +++ b/module/block/test/zen/yaml/doc_printdocmycollectionblock.yaml @@ -0,0 +1,134 @@ +--- +title: 我关注的文档测试数据 +desc: 用于printDocMyCollectionBlock方法测试的doc表数据 + +fields: +- field: id + range: 1-10 + note: 文档ID + +- field: vision + range: 'rnd{10}' + note: 视图类型 + +- field: project + range: '[0,1,2]{10}' + note: 项目ID + +- field: product + range: '[0,1,2]{10}' + note: 产品ID + +- field: execution + range: '0{10}' + note: 执行ID + +- field: lib + range: '1-5' + note: 文档库ID + +- field: template + range: '' + note: 模板 + +- field: templateType + range: '' + note: 模板类型 + +- field: chapterType + range: '' + note: 章节类型 + +- field: module + range: '0{10}' + note: 模块ID + +- field: title + range: '我关注的文档{5},重要资料{3},技术文档{2}' + note: 文档标题 + +- field: keywords + range: '关注,收藏,重要' + note: 关键词 + +- field: type + range: 'text{6},markdown{4}' + note: 文档类型 + +- field: status + range: 'normal{8},deleted{2}' + note: 文档状态 + +- field: parent + range: '0{10}' + note: 父文档ID + +- field: path + range: ',1,{5},2,{3},3,{2}' + note: 文档路径 + +- field: grade + range: '1{10}' + note: 文档等级 + +- field: order + range: '1-10' + note: 排序 + +- field: views + range: '1-50:R' + note: 查看次数 + +- field: assetLib + range: '0{10}' + note: 资产库ID + +- field: assetLibType + range: '' + note: 资产库类型 + +- field: from + range: '0{10}' + note: 来源文档ID + +- field: fromVersion + range: '1{10}' + note: 来源版本 + +- field: draft + range: '[]{10}' + note: 草稿内容 + +- field: collects + range: '1-10:R' + note: 收藏数 + +- field: addedBy + range: 'admin{8},user1{2}' + note: 创建者 + +- field: addedDate + range: '(-10d)-(-5d):1d' + format: 'YYYY-MM-DD hh:mm:ss' + note: 创建时间 + +- field: assignedTo + range: '' + note: 指派给 + +- field: assignedDate + range: '[]{10}' + note: 指派时间 + +- field: editedBy + range: 'admin{6},user1{4}' + note: 编辑者 + +- field: editedDate + range: '(-5d)-(now):1d' + format: 'YYYY-MM-DD hh:mm:ss' + note: 编辑时间 + +- field: deleted + range: '0{8},1{2}' + note: 是否删除 \ No newline at end of file diff --git a/module/block/test/zen/yaml/docaction_printdocmycollectionblock.yaml b/module/block/test/zen/yaml/docaction_printdocmycollectionblock.yaml new file mode 100644 index 0000000000..2bfae59118 --- /dev/null +++ b/module/block/test/zen/yaml/docaction_printdocmycollectionblock.yaml @@ -0,0 +1,25 @@ +--- +title: 文档收藏动作测试数据 +desc: 用于printDocMyCollectionBlock方法测试的docaction表数据 + +fields: +- field: id + range: 1-8 + note: 动作ID + +- field: doc + range: 1-8 + note: 文档ID + +- field: action + range: 'collect{8}' + note: 动作类型 + +- field: actor + range: 'admin{5},user1{3}' + note: 操作者 + +- field: date + range: '(-7d)-(now):1d' + format: 'YYYY-MM-DD hh:mm:ss' + note: 操作时间 \ No newline at end of file diff --git a/module/block/test/zen/yaml/doclib_printdocmycollectionblock.yaml b/module/block/test/zen/yaml/doclib_printdocmycollectionblock.yaml new file mode 100644 index 0000000000..3f2ecc9c4a --- /dev/null +++ b/module/block/test/zen/yaml/doclib_printdocmycollectionblock.yaml @@ -0,0 +1,37 @@ +--- +title: 文档库测试数据 +desc: 用于printDocMyCollectionBlock方法测试的doclib表数据 + +fields: +- field: id + range: 1-5 + note: 文档库ID + +- field: type + range: 'product{3},project{2}' + note: 文档库类型 + +- field: vision + range: 'rnd{5}' + note: 视图类型 + +- field: name + range: '产品文档库{3},项目文档库{2}' + note: 文档库名称 + +- field: acl + range: 'open{3},private{2}' + note: 访问控制 + +- field: deleted + range: '0{4},1{1}' + note: 是否删除 + +- field: addedBy + range: 'admin{5}' + note: 创建者 + +- field: addedDate + range: '(-30d)-(-10d):5d' + format: 'YYYY-MM-DD hh:mm:ss' + note: 创建时间 \ No newline at end of file