You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PurifierLinkifyTest.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. class HTMLPurifier_Injector_PurifierLinkifyTest extends HTMLPurifier_InjectorHarness
  3. {
  4. public function setup()
  5. {
  6. parent::setup();
  7. $this->config->set('AutoFormat.PurifierLinkify', true);
  8. $this->config->set('AutoFormat.PurifierLinkify.DocURL', '#%s');
  9. }
  10. public function testNoTriggerCharacer()
  11. {
  12. $this->assertResult('Foobar');
  13. }
  14. public function testTriggerCharacterInIrrelevantContext()
  15. {
  16. $this->assertResult('20% off!');
  17. }
  18. public function testPreserveNamespace()
  19. {
  20. $this->assertResult('%Core namespace (not recognized)');
  21. }
  22. public function testLinkifyBasic()
  23. {
  24. $this->assertResult(
  25. '%Namespace.Directive',
  26. '<a href="#Namespace.Directive">%Namespace.Directive</a>'
  27. );
  28. }
  29. public function testLinkifyWithAdjacentTextNodes()
  30. {
  31. $this->assertResult(
  32. 'This %Namespace.Directive thing',
  33. 'This <a href="#Namespace.Directive">%Namespace.Directive</a> thing'
  34. );
  35. }
  36. public function testLinkifyInBlock()
  37. {
  38. $this->assertResult(
  39. '<div>This %Namespace.Directive thing</div>',
  40. '<div>This <a href="#Namespace.Directive">%Namespace.Directive</a> thing</div>'
  41. );
  42. }
  43. public function testPreserveInATag()
  44. {
  45. $this->assertResult(
  46. '<a>%Namespace.Directive</a>'
  47. );
  48. }
  49. public function testNeeded()
  50. {
  51. $this->config->set('HTML.Allowed', 'b');
  52. $this->expectError('Cannot enable PurifierLinkify injector because a is not allowed');
  53. $this->assertResult('%Namespace.Directive');
  54. }
  55. }
  56. // vim: et sw=4 sts=4