load($str); assert($dom->save()==$str); // ----------------------------------------------- $str = null; $dom->load($str); assert($dom->save()==$str); // ----------------------------------------------------------------------------- // text test $str = << HTML; $dom->load($str); assert(count($dom->find('unknown'))==1); assert(count($dom->find('text'))==1); // ----------------------------------------------------------------------------- // string quote test $str = << okok


HTML; $dom->load($str); $es = $dom->find('input'); assert(count($es)==4); assert($es[0]->onclick=='goto("url0")'); assert($es[1]->onclick=="goto('url1'+'\'')"); assert($es[2]->onclick=="goto('url2')"); assert($es[3]->onclick=='goto("url4"+"\"")'); // ----------------------------------------------------------------------------- // clone test $str = << okok


HTML; $dom->load($str); $es = $dom->find('input'); assert(count($es)==4); assert($es[0]->onclick=='goto("url0")'); assert($es[1]->onclick=="goto('url1'+'\'')"); assert($es[2]->onclick=="goto('url2')"); assert($es[3]->onclick=='goto("url4"+"\"")'); unset($es); $dom2 = clone($dom); $es = $dom2->find('input'); assert(count($es)==4); assert($es[0]->onclick=='goto("url0")'); assert($es[1]->onclick=="goto('url1'+'\'')"); assert($es[2]->onclick=="goto('url2')"); assert($es[3]->onclick=='goto("url4"+"\"")'); // ----------------------------------------------- $str = << HTML; $dom->load($str); assert($dom==$str); assert($dom->save()==$str); // ----------------------------------------------------------------------------- // monkey test $str = <<load($str); assert($dom==$str); assert($dom->save()==$str); // ----------------------------------------------- $str = <<load($str); assert($dom==$str); assert($dom->save()==$str); // ----------------------------------------------- $str = <<load($str); assert($dom==$str); assert($dom->save()==$str); // ----------------------------------------------- $str = <<load($str); assert($dom==$str); assert($dom->save()==$str); // ----------------------------------------------- $str = <<load($str); assert($dom==$str); assert($dom->save()==$str); // ----------------------------------------------- $str = <<load($str); assert($dom==$str); assert($dom->save()==$str); // ----------------------------------------------- $str = <<load($str); assert($dom==$str); assert($dom->save()==$str); // ----------------------------------------------- $str = <<<<>ab HTML; $dom->load($str); assert($dom==$str); assert($dom->save()==$str); // ----------------------------------------------- $str = <<load($str); assert($dom==$str); assert($dom->save()==$str); // ----------------------------------------------- $str = << HTML; $dom->load($str); assert($dom==$str); assert($dom->save()==$str); // ----------------------------------------------- // $str = <<load($str); // echo $dom; // assert($dom==$str); // assert($dom->save()==$str); // ----------------------------------------------- $str = <<load($str); assert($dom==$str); assert($dom->save()==$str); // ----------------------------------------------------------------------------- // rnadom string test function str_random($length) { $str = ""; srand((double)microtime()*1000000); $char_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $char_list .= "abcdefghijklmnopqrstuvwxyz"; $char_list .= "1234567890"; $char_list .= "<>!?[]%^&*()"; for($i=0; $i<$length; ++$i) $str .= substr($char_list,(rand()%(strlen($char_list))), 1); return $str; } for($i=0; $i<60; ++$i) { $str = str_random($i); //echo $str."\n
"; $dom->load($str, false); //echo $dom->save()."\n
"; assert($dom==$str); } // ----------------------------------------------------------------------------- // lowercase test $str = << HTML; $dom->load($str); assert(count($dom->find('img'))==1); assert(count($dom->find('IMG'))==1); assert(isset($dom->find('img', 0)->class)); assert(!isset($dom->find('img', 0)->CLASS)); assert($dom->find('img', 0)->class=='class0'); assert($dom==$str); // ----------------------------------------------- $str = << HTML; $dom->load($str); assert(count($dom->find('img'))==1); assert(count($dom->find('IMG'))==1); assert(isset($dom->find('img', 0)->class)); assert(!isset($dom->find('img', 0)->CLASS)); assert($dom->find('img', 0)->class=='class0'); assert($dom==strtolower($str)); // ----------------------------------------------- $str = << HTML; $dom->load($str, false); assert(count($dom->find('img'))==0); assert(count($dom->find('IMG'))==1); assert(isset($dom->find('IMG', 0)->CLASS)); assert(!isset($dom->find('IMG', 0)->class)); assert($dom->find('IMG', 0)->CLASS=='class0'); assert($dom==$str); // ----------------------------------------------------------------------------- // tear down $dom->clear(); unset($dom); ?>