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.

LinkifyTest.php 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness
  3. {
  4. public function setup()
  5. {
  6. parent::setup();
  7. $this->config->set('AutoFormat.Linkify', true);
  8. }
  9. public function testLinkifyURLInRootNode()
  10. {
  11. $this->assertResult(
  12. 'http://example.com',
  13. '<a href="http://example.com">http://example.com</a>'
  14. );
  15. }
  16. public function testLinkifyURLInInlineNode()
  17. {
  18. $this->assertResult(
  19. '<b>http://example.com</b>',
  20. '<b><a href="http://example.com">http://example.com</a></b>'
  21. );
  22. }
  23. public function testBasicUsageCase()
  24. {
  25. $this->assertResult(
  26. 'This URL http://example.com is what you need',
  27. 'This URL <a href="http://example.com">http://example.com</a> is what you need'
  28. );
  29. }
  30. public function testIgnoreURLInATag()
  31. {
  32. $this->assertResult(
  33. '<a>http://example.com/</a>'
  34. );
  35. }
  36. public function testNeeded()
  37. {
  38. $this->config->set('HTML.Allowed', 'b');
  39. $this->expectError('Cannot enable Linkify injector because a is not allowed');
  40. $this->assertResult('http://example.com/');
  41. }
  42. public function testExcludes()
  43. {
  44. $this->assertResult('<a><span>http://example.com</span></a>');
  45. }
  46. }
  47. // vim: et sw=4 sts=4