Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

103 lines
3.2KB

  1. <?php
  2. class HTMLPurifier_ElementDefTest extends HTMLPurifier_Harness
  3. {
  4. public function test_mergeIn()
  5. {
  6. $def1 = new HTMLPurifier_ElementDef();
  7. $def2 = new HTMLPurifier_ElementDef();
  8. $def3 = new HTMLPurifier_ElementDef();
  9. $old = 1;
  10. $new = 2;
  11. $overloaded_old = 3;
  12. $overloaded_new = 4;
  13. $removed = 5;
  14. $def1->standalone = true;
  15. $def1->attr = array(
  16. 0 => array('old-include'),
  17. 'old-attr' => $old,
  18. 'overloaded-attr' => $overloaded_old,
  19. 'removed-attr' => $removed,
  20. );
  21. /*
  22. $def1->attr_transform_pre =
  23. $def1->attr_transform_post = array(
  24. 'old-transform' => $old,
  25. 'overloaded-transform' => $overloaded_old,
  26. 'removed-transform' => $removed,
  27. );
  28. */
  29. $def1->attr_transform_pre[] = $old;
  30. $def1->attr_transform_post[] = $old;
  31. $def1->child = $overloaded_old;
  32. $def1->content_model = 'old';
  33. $def1->content_model_type = $overloaded_old;
  34. $def1->descendants_are_inline = false;
  35. $def1->excludes = array(
  36. 'old' => true,
  37. 'removed-old' => true
  38. );
  39. $def2->standalone = false;
  40. $def2->attr = array(
  41. 0 => array('new-include'),
  42. 'new-attr' => $new,
  43. 'overloaded-attr' => $overloaded_new,
  44. 'removed-attr' => false,
  45. );
  46. /*
  47. $def2->attr_transform_pre =
  48. $def2->attr_transform_post = array(
  49. 'new-transform' => $new,
  50. 'overloaded-transform' => $overloaded_new,
  51. 'removed-transform' => false,
  52. );
  53. */
  54. $def2->attr_transform_pre[] = $new;
  55. $def2->attr_transform_post[] = $new;
  56. $def2->child = $new;
  57. $def2->content_model = '#SUPER | new';
  58. $def2->content_model_type = $overloaded_new;
  59. $def2->descendants_are_inline = true;
  60. $def2->excludes = array(
  61. 'new' => true,
  62. 'removed-old' => false
  63. );
  64. $def1->mergeIn($def2);
  65. $def1->mergeIn($def3); // empty, has no effect
  66. $this->assertIdentical($def1->standalone, true);
  67. $this->assertIdentical($def1->attr, array(
  68. 0 => array('old-include', 'new-include'),
  69. 'old-attr' => $old,
  70. 'overloaded-attr' => $overloaded_new,
  71. 'new-attr' => $new,
  72. ));
  73. $this->assertIdentical($def1->attr_transform_pre, $def1->attr_transform_post);
  74. $this->assertIdentical($def1->attr_transform_pre, array($old, $new));
  75. /*
  76. $this->assertIdentical($def1->attr_transform_pre, array(
  77. 'old-transform' => $old,
  78. 'overloaded-transform' => $overloaded_new,
  79. 'new-transform' => $new,
  80. ));
  81. */
  82. $this->assertIdentical($def1->child, $new);
  83. $this->assertIdentical($def1->content_model, 'old | new');
  84. $this->assertIdentical($def1->content_model_type, $overloaded_new);
  85. $this->assertIdentical($def1->descendants_are_inline, true);
  86. $this->assertIdentical($def1->excludes, array(
  87. 'old' => true,
  88. 'new' => true
  89. ));
  90. }
  91. }
  92. // vim: et sw=4 sts=4