审查视图

simplewind/vendor/electrolinux/phpquery/test-cases/test_replace.php 803 字节
xiaohu authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
<?php
require_once('../phpQuery/phpQuery.php');
phpQuery::$debug = true;

$testName = 'ReplaceWith';
phpQuery::newDocumentFile('test.html')
	->find('p:eq(1)')
		->replaceWith("<p class='newTitle'>
                        this is example title
                    </p>");
$result = pq('p:eq(1)');
if ( $result->hasClass('newTitle') )
	print "Test '{$testName}' PASSED :)";
else
	print "Test '{$testName}' <strong>FAILED</strong> !!! ";
$result->dump();
print "\n";



$testName = 'ReplaceAll';
$testResult = 3;
phpQuery::newDocumentFile('test.html');
pq('<div class="replacer">')
	->replaceAll('li:first p');
$result = pq('.replacer');
if ( $result->size() == $testResult )
	print "Test '{$testName}' PASSED :)";
else
	print "Test '{$testName}' <strong>FAILED</strong> !!! ";
$result->dump();
print "\n";