<?php // $Rev: 179 $ // ----------------------------------------------------------------------------- // setup error_reporting(E_ALL); require_once('../simple_html_dom.php'); $dom = new simple_html_dom; // ----------------------------------------------------------------------------- // test problem of last emelemt not found $str = <<<HTML <img src="src0"><p>foo</p><img src="src2"> HTML; function callback_1($e) { if ($e->tag==='img') $e->outertext = ''; } $dom->load($str); $dom->set_callback('callback_1'); assert($dom=='<p>foo</p>'); // ----------------------------------------------- // innertext test function callback_2($e) { if ($e->tag==='p') $e->innertext = 'bar'; } $dom->load($str); $dom->set_callback('callback_2'); assert($dom=='<img src="src0"><p>bar</p><img src="src2">'); // ----------------------------------------------- // attributes test function callback_3($e) { if ($e->tag==='img') $e->src = 'foo'; } $dom->load($str); $dom->set_callback('callback_3'); assert($dom=='<img src="foo"><p>foo</p><img src="foo">'); function callback_4($e) { if ($e->tag==='img') $e->id = 'foo'; } $dom->set_callback('callback_4'); assert($dom=='<img src="foo" id="foo"><p>foo</p><img src="foo" id="foo">'); // ----------------------------------------------- // attributes test2 //$dom = str_get_dom($str); $dom->load($str); $dom->remove_callback(); $dom->find('img', 0)->id = "foo"; assert($dom=='<img src="src0" id="foo"><p>foo</p><img src="src2">'); function callback_5($e) { if ($e->src==='src0') unset($e->id); } $dom->set_callback('callback_5'); assert($dom==$str); // ----------------------------------------------------------------------------- // tear down $dom->clear(); unset($dom); ?>
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
.svn | Folder | 2755 |
|
|
html | Folder | 2755 |
|
|
reader | Folder | 2755 |
|
|
all_test.php | File | 745 B | 0755 |
|
callback_testcase.php | File | 1.8 KB | 0755 |
|
dom_testcase.php | File | 11.4 KB | 0755 |
|
element_testcase.php | File | 8.21 KB | 0755 |
|
invalid_testcase.php | File | 18.25 KB | 0755 |
|
jquery-1.2.3.pack.js | File | 29.15 KB | 0755 |
|
mass_test.php | File | 2.98 KB | 0755 |
|
memory_test.php | File | 4.61 KB | 0755 |
|
misc_testcase.php | File | 1.81 KB | 0755 |
|
performance_test.php | File | 792 B | 0755 |
|
selector_testcase.php | File | 21.33 KB | 0755 |
|
slick_test.php | File | 892 B | 0755 |
|
slickspeed.htm | File | 113.89 KB | 0755 |
|
std_testcase.php | File | 6.67 KB | 0755 |
|
strip_testcase.php | File | 4.34 KB | 0755 |
|