12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
- <?php
- require_once('../phpQuery/phpQuery.php');
- $testName = 'Text node append';
- $result = phpQuery::newDocumentFile('test.html')
- ->find('li:first')
- ->find('p:first')
- ->html('żźć');
- if (trim($result->html()) == 'żźć')
- print "Test '{$testName}' passed :)<br />\n";
- else
- print "Test '{$testName}' <strong>FAILED</strong> !!!<br />\n";
- print "\n";
- $testName = 'Text node HTML entite append';
- $result = phpQuery::newDocumentFile('test.html')
- ->find('li:first')
- ->find('p:first')
- ->_empty()
- ->append('é');
- if (trim($result->html()) == 'é')
- print "Test '{$testName}' passed :)<br />\n";
- else {
- print "Test '{$testName}' <strong>FAILED</strong> !!!<br />\n";
- print $result->html();
- }
- print "\n";
- $testName = 'DOMElement node HTML entite append';
- $result = phpQuery::newDocumentFile('test.html')
- ->find('li:first')
- ->find('p:first')
- ->empty()
- ->append('<span>é</span>');
- if (trim($result->html()) == '<span>é</span>')
- print "Test '{$testName}' passed :)<br />\n";
- else {
- print "Test '{$testName}' <strong>FAILED</strong> !!!<br />\n";
- print $result->html();
- }
- print "\n";
- $testName = 'Append and move';
- $result = phpQuery::newDocumentFile('test.html');
- $li = $result->find('li:first');
- $result->find('div')->_empty();
- $li->html('test1-é-test1')
- ->append('test2-é-test2')
- ->appendTo(
- $result->find('div:first')
- );
- $result = $result->find('div:first li:first');
- $expected = 'test1-é-test1test2-é-test2';
- if (trim(str_replace("\n", '', $result->html())) == $expected)
- print "Test '{$testName}' passed :)<br />\n";
- else {
- print "Test '{$testName}' <strong>FAILED</strong> !!!<br />\n";
- print "'".trim($result->html())."'";
- }
- print "\n";
- $testName = 'Attr charset';
- $result = phpQuery::newDocumentFile('test.html')
- ->find('li:first')
- ->attr('test', 'foo é żźć bar');
- if (trim($result->attr('test')) == 'foo é żźć bar')
- print "Test '{$testName}' passed :)<br />\n";
- else {
- print "Test '{$testName}' <strong>FAILED</strong> !!!<br />\n";
- print $result->attr('test');
- }
- print "\n";
|