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.

62 lines
1.6KB

  1. <?php
  2. class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransformHarness
  3. {
  4. public function setUp()
  5. {
  6. parent::setUp();
  7. $this->obj = new HTMLPurifier_AttrTransform_ImgRequired();
  8. }
  9. public function testAddMissingAttr()
  10. {
  11. $this->config->set('Core.RemoveInvalidImg', false);
  12. $this->assertResult(
  13. array(),
  14. array('src' => '', 'alt' => 'Invalid image')
  15. );
  16. }
  17. public function testAlternateDefaults()
  18. {
  19. $this->config->set('Attr.DefaultInvalidImage', 'blank.png');
  20. $this->config->set('Attr.DefaultInvalidImageAlt', 'Pawned!');
  21. $this->config->set('Attr.DefaultImageAlt', 'not pawned');
  22. $this->config->set('Core.RemoveInvalidImg', false);
  23. $this->assertResult(
  24. array(),
  25. array('src' => 'blank.png', 'alt' => 'Pawned!')
  26. );
  27. }
  28. public function testGenerateAlt()
  29. {
  30. $this->assertResult(
  31. array('src' => '/path/to/foobar.png'),
  32. array('src' => '/path/to/foobar.png', 'alt' => 'foobar.png')
  33. );
  34. }
  35. public function testAddDefaultSrc()
  36. {
  37. $this->config->set('Core.RemoveInvalidImg', false);
  38. $this->assertResult(
  39. array('alt' => 'intrigue'),
  40. array('alt' => 'intrigue', 'src' => '')
  41. );
  42. }
  43. public function testAddDefaultAlt()
  44. {
  45. $this->config->set('Attr.DefaultImageAlt', 'default');
  46. $this->assertResult(
  47. array('src' => ''),
  48. array('src' => '', 'alt' => 'default')
  49. );
  50. }
  51. }
  52. // vim: et sw=4 sts=4