* [task#142982,doing,0.5h] Add the unit test of convertwiki2html.

This commit is contained in:
xieqiyu
2025-05-15 17:27:57 +08:00
committed by 刘刚
parent 4d6fbc02e6
commit b0e808334d
3 changed files with 81 additions and 0 deletions
@@ -846,4 +846,18 @@ class upgradeTest
$this->objectModel->upgradeWikiTemplates(array($wikiTemplateID));
return $this->objectModel->dao->select('*')->from(TABLE_DOCCONTENT)->where('doc')->eq($wikiTemplateID)->orderBy('id_desc')->fetch();
}
/**
* 将wiki下的章节和文章合并为一个html。
* Merge chapters and articles from the wiki into HTML.
*
* @param int $bookID
* @param int $nodeID
* @return string
*/
public function convertWiki2HtmlTest(int $bookID = 0, int $nodeID = 0): string
{
$html = $this->objectModel->convertWiki2Html($bookID, $nodeID);
return $html;
}
}
@@ -0,0 +1,51 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);
/**
title=测试 upgradeModel->convertWiki2Html();
timeout=0
cid=1
- 转换文档模板6 @<p>文档模板6</p>
- 转换文档模板7 @<p>文档模板7</p>
- 转换文档模板8 @<p>文档模板8</p>
- 转换文档模板9 @<p>文档模板9</p>
- 转换文档模板10 @<p>文档模板10</p>
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/upgrade.unittest.class.php';
zenData('user')->loadYaml('user')->gen(5);
su('admin');
$doc = zenData('doc');
$doc->id->range('1-10');
$doc->title->range('文档模板1,文档模板2,文档模板3,文档模板4,文档模板5,文档模板6,文档模板7,文档模板8,文档模板9,文档模板10');
$doc->module->range('');
$doc->lib->range('');
$doc->version->range('1');
$doc->type->range('book{5},html{5}');
$doc->templateType->range('1{5},``{5}');
$doc->chapterType->range('``{5},input{5}');
$doc->template->range('``{5},1,2,3,4,5');
$doc->parent->range('``{5},1{5}');
$doc->gen(10);
$docContent = zenData('doccontent');
$docContent->id->range('1-10');
$docContent->doc->range('1-10');
$docContent->type->range('html');
$docContent->title->range('文档模板1,文档模板2,文档模板3,文档模板4,文档模板5,文档模板6,文档模板7,文档模板8,文档模板9,文档模板10');
$docContent->version->range('1');
$docContent->gen(10);
$upgrade = new upgradeTest();
r($upgrade->convertWiki2HtmlTest(1, 6)) && p() && e('<p>文档模板6</p>'); // 转换文档模板6
r($upgrade->convertWiki2HtmlTest(1, 7)) && p() && e('<p>文档模板7</p>'); // 转换文档模板7
r($upgrade->convertWiki2HtmlTest(1, 8)) && p() && e('<p>文档模板8</p>'); // 转换文档模板8
r($upgrade->convertWiki2HtmlTest(1, 9)) && p() && e('<p>文档模板9</p>'); // 转换文档模板9
r($upgrade->convertWiki2HtmlTest(1, 10)) && p() && e('<p>文档模板10</p>'); // 转换文档模板10
@@ -8,6 +8,22 @@ title=测试 upgradeModel->upgradeWikiTemplates();
timeout=0
cid=1
- 更新文档模板1
- 属性version @2
- 属性type @doc
- 更新文档模板2
- 属性version @2
- 属性type @doc
- 更新文档模板3
- 属性version @2
- 属性type @doc
- 更新文档模板4
- 属性version @2
- 属性type @doc
- 更新文档模板5
- 属性version @2
- 属性type @doc
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';