www.gusucode.com > Aycms自媒体建站系统PHP版 v1.0.1源码程序 > Aycms_v1.0.1/vendor/electrolinux/phpquery/test-cases/test_multidoc.php

    <?php
require_once('../phpQuery/phpQuery.php');
phpQuery::$debug = true;

$testName = 'Multi document append phpQuery object';
$testResult = array(
	'p.body',
);
$doc1 = phpQuery::newDocumentFile('test.html');
$doc2 = phpQuery::newDocumentFile('test.html');

foreach ($doc1->find('p') as $node)
   $doc2->find('body')->append(pq($node));
$testResult = $doc2->find('p');
if ( $testResult->size() == 2*$doc1->find('p')->size() )
	print "Test '{$testName}' PASSED :)";
else {
	print "Test '{$testName}' <strong>FAILED</strong> !!!<br />";
	$testResult->whois();
}

$testName = 'Multi document append DOMNode';
$testResult = array(
	'p.body',
);
$doc1 = phpQuery::newDocumentFile('test.html');
$doc2 = phpQuery::newDocumentFile('test.html');
foreach ($doc1->find('p') as $node)
   $doc2->find('body')->append($node);
$testResult = $doc2->find('p');
if ( $testResult->size() == 2*$doc1->find('p')->size() )
	print "Test '{$testName}' PASSED :)";
else {
	print "Test '{$testName}' <strong>FAILED</strong> !!!<br />";
	$testResult->whois();
}
?>