logseq2gemtext/tests/ArticleRenderTest.php

44 lines
1.1 KiB
PHP
Raw Permalink Normal View History

<?php
declare(strict_types=1);
namespace LogseqGem\Tests;
use PHPUnit\Framework\TestCase;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;
use LogseqGem\ArticleRender;
class ArticleRenderTest extends TestCase {
private vfsStreamDirectory $root;
public function setUp(): void {
$this->root = vfsStream::setup();
}
public function testRender() {
$render = new ArticleRender(
"cool title",
"my gemtext",
['date' => '2021-01-01']
);
$output = $render->render(__DIR__ . "/../templates/article.tpl");
$this->assertStringContainsString("# cool title\n\n", $output);
$this->assertStringContainsString("\n\nmy gemtext\n\n", $output);
$this->assertStringContainsString("\n\n=> /gemlog.gmi", $output);
}
public function testMissingDate() {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('no date property');
$render = new ArticleRender(
"cool title",
"my gemtext",
);
}
}