TokenTest.php 1000 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. class HTMLPurifier_TokenTest extends HTMLPurifier_Harness
  3. {
  4. protected function assertTokenConstruction($name, $attr,
  5. $expect_name = null, $expect_attr = null
  6. ) {
  7. if ($expect_name === null) $expect_name = $name;
  8. if ($expect_attr === null) $expect_attr = $attr;
  9. $token = new HTMLPurifier_Token_Start($name, $attr);
  10. $this->assertIdentical($expect_name, $token->name);
  11. $this->assertIdentical($expect_attr, $token->attr);
  12. }
  13. function testConstruct() {
  14. // standard case
  15. $this->assertTokenConstruction('a', array('href' => 'about:blank'));
  16. // lowercase the tag's name
  17. $this->assertTokenConstruction('A', array('href' => 'about:blank'),
  18. 'a');
  19. // lowercase attributes
  20. $this->assertTokenConstruction('a', array('HREF' => 'about:blank'),
  21. 'a', array('href' => 'about:blank'));
  22. }
  23. }
  24. // vim: et sw=4 sts=4