コード例 #1
0
$t->is(count($page_rec), 0, '年月指定');
// renderContent()
$t->diag('renderContent()');
$markdown = <<<EOF
test
====
foo bar
EOF;
$t->is(PageTable::renderContent($markdown, 'markdown'), "<h1 id=\"" . md5('test') . "\">test</h1>\n\n<p>foo bar</p>\n", 'markdownレンダリング');
$t->is(PageTable::renderContent("<h1>test</h1>\n\n<p>foo bar</p>\n", 'html'), "<h1>test</h1>\n\n<p>foo bar</p>\n", 'HTMLレンダリング');
// getRenderer()
$t->diag('getRenderer()');
$t->ok(PageTable::getRenderer('markdown') instanceof MarkdownRenderer, 'レンダラーの取得(Markdown)');
$t->ok(PageTable::getRenderer('markdown') instanceof MarkdownRenderer, 'レンダラーの取得(Markdown) 複数回実行(キャッシュのテスト)');
$t->ok(PageTable::getRenderer('html') instanceof HtmlRenderer, 'レンダラーの取得(HTML)');
$t->ok(PageTable::getRenderer('') instanceof MarkdownRenderer, 'レンダラーの取得(デフォルト=Markdown)');
// checkType()
$t->diag('checkType()');
$t->is(PageTable::checkType('test.markdown'), 'markdown', 'タイプ:マークダウン');
$t->is(PageTable::checkType('test.md'), 'markdown', 'タイプ:マークダウン');
$t->is(PageTable::checkType('test.mkd'), 'markdown', 'タイプ:マークダウン');
$t->is(PageTable::checkType('test.mdown'), 'markdown', 'タイプ:マークダウン');
$t->is(PageTable::checkType('test.mkdn'), 'markdown', 'タイプ:マークダウン');
$t->is(PageTable::checkType('test.html'), 'html', 'タイプ:HTML');
$t->is(PageTable::checkType('test'), 'markdown', 'タイプ:空の場合はマークダウン');
$t->is(PageTable::checkType('test.txt'), false, '未対応タイプ');
$t->is(PageTable::checkType('test.xml'), false, '未対応タイプ');
$t->is(PageTable::checkType('test.gif'), false, '未対応タイプ');
$t->is(PageTable::checkType('test.jpg'), false, '未対応タイプ');
$t->is(PageTable::checkType('test.png'), false, '未対応タイプ');
$t->is(PageTable::checkType('test.js'), false, '未対応タイプ');