Files
luxtools-plugin/_test/ChronologicalDateAutoLinkerTest.php
2026-02-16 13:39:26 +01:00

43 lines
1.2 KiB
PHP

<?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');
}
}
}