2007-06-24 22:22:00 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_Injector_PurifierLinkifyTest extends HTMLPurifier_InjectorHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-24 22:22:00 +00:00
|
|
|
function setup() {
|
|
|
|
parent::setup();
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('AutoFormat.PurifierLinkify', true);
|
2009-05-13 20:14:20 +00:00
|
|
|
$this->config->set('AutoFormat.PurifierLinkify.DocURL', '#%s');
|
2007-06-24 22:22:00 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-08 05:38:52 +00:00
|
|
|
function testNoTriggerCharacer() {
|
2007-06-24 22:22:00 +00:00
|
|
|
$this->assertResult('Foobar');
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-08 05:38:52 +00:00
|
|
|
function testTriggerCharacterInIrrelevantContext() {
|
2007-06-24 22:22:00 +00:00
|
|
|
$this->assertResult('20% off!');
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-08 05:38:52 +00:00
|
|
|
function testPreserveNamespace() {
|
2007-06-24 22:22:00 +00:00
|
|
|
$this->assertResult('%Core namespace (not recognized)');
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-08 05:38:52 +00:00
|
|
|
function testLinkifyBasic() {
|
2007-06-24 22:22:00 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'%Namespace.Directive',
|
|
|
|
'<a href="#Namespace.Directive">%Namespace.Directive</a>'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-08 05:38:52 +00:00
|
|
|
function testLinkifyWithAdjacentTextNodes() {
|
2007-06-24 22:22:00 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'This %Namespace.Directive thing',
|
|
|
|
'This <a href="#Namespace.Directive">%Namespace.Directive</a> thing'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-08 05:38:52 +00:00
|
|
|
function testLinkifyInBlock() {
|
2007-06-24 22:22:00 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<div>This %Namespace.Directive thing</div>',
|
|
|
|
'<div>This <a href="#Namespace.Directive">%Namespace.Directive</a> thing</div>'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-08-08 05:38:52 +00:00
|
|
|
function testPreserveInATag() {
|
2007-06-24 22:22:00 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<a>%Namespace.Directive</a>'
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-28 13:06:15 +00:00
|
|
|
function testNeeded() {
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('HTML.Allowed', 'b');
|
2007-06-28 13:06:15 +00:00
|
|
|
$this->expectError('Cannot enable PurifierLinkify injector because a is not allowed');
|
2007-08-08 05:38:52 +00:00
|
|
|
$this->assertResult('%Namespace.Directive');
|
2007-06-28 13:06:15 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-06-24 22:22:00 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|