Add the Chronological
This commit is contained in:
42
_test/ChronologicalDateAutoLinkerTest.php
Normal file
42
_test/ChronologicalDateAutoLinkerTest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace dokuwiki\plugin\luxtools\test;
|
||||
|
||||
use dokuwiki\plugin\luxtools\ChronologicalDateAutoLinker;
|
||||
use DokuWikiTest;
|
||||
|
||||
require_once(__DIR__ . '/../autoload.php');
|
||||
|
||||
/**
|
||||
* Tests for extracted chronological auto-linker.
|
||||
*
|
||||
* @group plugin_luxtools
|
||||
* @group plugins
|
||||
*/
|
||||
class ChronologicalDateAutoLinkerTest extends DokuWikiTest
|
||||
{
|
||||
public function testLinksPlainTextDate(): void
|
||||
{
|
||||
$html = '<p>Meeting on 2024-10-24</p>';
|
||||
$out = ChronologicalDateAutoLinker::linkHtml($html);
|
||||
|
||||
$decoded = urldecode($out);
|
||||
if (strpos($decoded, 'chronological:2024:10:24') === false) {
|
||||
throw new \Exception('Expected canonical link target not found');
|
||||
}
|
||||
}
|
||||
|
||||
public function testSkipsCodeContent(): void
|
||||
{
|
||||
$html = '<p>Outside 2024-10-25</p><code>Inside 2024-10-24</code>';
|
||||
$out = ChronologicalDateAutoLinker::linkHtml($html);
|
||||
|
||||
$decoded = urldecode($out);
|
||||
if (strpos($decoded, 'chronological:2024:10:25') === false) {
|
||||
throw new \Exception('Expected outside date link not found');
|
||||
}
|
||||
if (strpos($decoded, 'chronological:2024:10:24') !== false) {
|
||||
throw new \Exception('Date inside code block should not be auto-linked');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user