xmd.lib.test.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <?php
  2. class TestXmd extends UnitTestCase{
  3. public $Xmddoc;
  4. public function TestXmddoc(){
  5. $this->UnitTestCase('XML Dom Library function tests');
  6. }
  7. public function setUp(){
  8. $this->Xmddoc = new xmddoc();
  9. }
  10. public function tearDown(){
  11. $this->Xmddoc= null;
  12. }
  13. public function testXmdGetElement(){
  14. $parent=0;
  15. array('?name' => $this->name[$parent],
  16. '?parent' => $this->parent[$parent]);
  17. $res = $this->Xmddoc->xmd_get_element($parent);
  18. if(!is_array($res))
  19. $this->assertTrue(is_null($res));
  20. else
  21. $this->assertTrue(is_array($res));
  22. //var_dump($res);
  23. }
  24. public function testXmdGetNsUri(){
  25. $parent = 0;
  26. $attName = '';
  27. $this->names[$this->ns[$parent]];
  28. $res = Xmddoc::xmd_get_ns_uri($parent = 0, $attName = '');
  29. if(is_array($res))
  30. $this->assertTrue(is_array($res));
  31. else
  32. $this->assertTrue(is_null($res));
  33. //var_dump($res);
  34. }
  35. public function testXmdRemoveElement(){
  36. $child='';
  37. $res = Xmddoc:: xmd_remove_element($child);
  38. $this->assertTrue(is_bool($res));
  39. $this->assertTrue($res === true || $res ===false);
  40. //var_dump($res);
  41. }
  42. public function testXmdRemoveNodes(){
  43. $children=2;
  44. $parent = 1;
  45. $res = Xmddoc::xmd_remove_nodes($children, $parent = 0);
  46. $this->assertTrue(is_bool($res));
  47. $this->assertTrue($res === true || $res === false);
  48. //var_dump($res);
  49. }
  50. /**
  51. *
  52. */
  53. public function testXmdUpdate(){
  54. $xmPath='';
  55. $text = '';
  56. $parent = 0;
  57. $res = $this->Xmddoc->xmd_update($xmPath, $text, $parent);
  58. $this->assertTrue(is_bool($res));
  59. $this->assertTrue($res === true || $res === false);
  60. //var_dump($res);
  61. }
  62. /**
  63. * this function have work with the method xmddoc
  64. */
  65. public function testXmdUpdateMany(){
  66. $xmPaths='';
  67. $subPath='';
  68. $text='';
  69. $parent='';
  70. $res = $this->Xmddoc->xmd_update_many($xmPaths, $subPath, $text, $parent);
  71. $this->assertTrue($res);
  72. //var_dump($res);
  73. }
  74. public function testXmdCopyForeignChild(){
  75. $fdoc='';
  76. $fchild='';
  77. $parent='';
  78. $res = $this->Xmddoc->xmd_copy_foreign_child($fdoc, $fchild, $parent);
  79. $this->assertTrue(is_null($res));
  80. //var_dump($res);
  81. }
  82. public function testXmdAddElement(){
  83. $name='asasasas';
  84. $parent = 0;
  85. $attribs = array();
  86. $res = $this->Xmddoc->xmd_add_element($name, $parent, $attribs);
  87. $this->assertTrue(is_numeric($res));
  88. $this->assertTrue($res === -1 || $res === 0);
  89. //var_dump($res);
  90. }
  91. public function testXmdSetAttribute(){
  92. $parent=0;
  93. $name='';
  94. $value=0;
  95. $checkurihaspfx = TRUE;
  96. $res = $this->Xmddoc->xmd_set_attribute($parent, $name, $value, $checkurihaspfx);
  97. $this->assertTrue(is_string($res));
  98. //var_dump($res);
  99. }
  100. public function testXmdAddText(){
  101. $text='asasasasasa';
  102. $parent = 1;
  103. $res = $this->Xmddoc->xmd_add_text($text, $parent = 0);
  104. $this->assertTrue(is_bool($res));
  105. $this->assertTrue($res === true || $res === false);
  106. //var_dump($res);
  107. }
  108. public function testXmdAddTextElement(){
  109. $name='';
  110. $text='';
  111. $parent = 0;
  112. $attribs = array();
  113. $res = $this->Xmddoc->xmd_add_text_element($name, $text, $parent = 0, $attribs = array());
  114. $this->assertTrue(is_bool($res) || is_numeric($res));
  115. //var_dump($res);
  116. }
  117. public function testXmdText(){
  118. $parent = 0;
  119. $res =$this->Xmddoc->xmd_text($parent = 0);
  120. $this->assertTrue(is_string($res));
  121. //var_dump($res);
  122. }
  123. public function testXmdXml(){
  124. $increase = ' ';
  125. $indent = '';
  126. $lbr = "\n";
  127. $parent = 0;
  128. $res = $this->Xmddoc->xmd_xml($increase, $indent, $lbr, $parent);
  129. $this->assertTrue(is_string($res));
  130. //var_dump($res);
  131. }
  132. public function testXmdValue($xmPath, $parent, $fix, $fun){
  133. $xmPath='';
  134. $parent = 0;
  135. $fix = array();
  136. $fun = '';
  137. $res = $this->Xmddoc->xmd_value($xmPath, $parent, $fix, $fun);
  138. $this->assertTrue(is_string($res));
  139. //var_dump($res);
  140. }
  141. public function testXmdHtmlValue(){
  142. $xmPath='';
  143. $parent = 0;
  144. $fun = 'htmlspecialchars';
  145. $res = $this->Xmddoc->xmd_html_value($xmPath, $parent , $fun );
  146. $this->assertTrue(is_string($res));
  147. //var_dump($res);
  148. }
  149. public function testXmdSelectSingleElement(){
  150. $xmPath='';
  151. $parent = 0;
  152. $res = $this->Xmddoc->xmd_select_single_element($xmPath, $parent);
  153. $this->assertTrue(is_numeric($res));
  154. $this->assertTrue($res);
  155. //var_dump($res);
  156. }
  157. public function testXmdSelectElementsWhere(){
  158. $xmPath='';
  159. $subPath = '.';
  160. $value = '';
  161. $parent = 0;
  162. $res = $this->Xmddoc->xmd_select_elements_where($xmPath, $subPath, $value, $parent);
  163. $this->assertTrue(is_array($res));
  164. //var_dump($res);
  165. }
  166. public function testXmdSelectElementsWhereNotempty(){
  167. $xmPath='';
  168. $subPath = '.';
  169. $parent = 0;
  170. $res = $this->Xmddoc->xmd_select_elements_where_notempty($xmPath,$subPath, $parent);
  171. $this->assertTrue(is_array($res));
  172. //var_dump($res);
  173. }
  174. public function testxmd_select_elements(){
  175. $xmPath='';
  176. $parent = 0;
  177. $res = $this->Xmddoc->xmd_select_elements($xmPath, $parent);
  178. $this->assertTrue(is_array($res));
  179. //var_dump($res);
  180. }
  181. public function testXmdSelectElements(){
  182. $xmPath='';
  183. $parent = 0;
  184. $res = $this->Xmddoc-> xmd_select_elements($xmPath, $parent);
  185. $this->assertTrue(is_array($res));
  186. //var_dump($res);
  187. }
  188. }
  189. ?>