div.articles text node

paragraph after UL

EOF; $rows = array( array( 'title' => 'News 1 title', 'body' => 'News 1 body', ), array( 'title' => 'News 2 title', 'body' => 'News 2 body', ), array( 'title' => 'News 3', 'body' => 'News 3 body', ), ); phpQuery::newDocumentFile('test.html'); $articles = pq('.articles ul'); $rowSrc = $articles->find('li') ->remove() ->eq(0); foreach( $rows as $r ) { $row = $rowSrc->_clone(); foreach( $r as $field => $value ) { $row->find(".{$field}") ->html($value); // die($row->htmlOuter()); } $row->appendTo($articles); } $result = pq('.articles')->htmlOuter(); //print htmlspecialchars("
{$result}
").'
'; $similarity = 0.0; similar_text($testResult, $result, $similarity); if ($similarity > 90) print "Test '{$testName}' passed :)"; else print "Test '{$testName}' FAILED ($similarity) !!!"; print "\n"; $testName = 'Parent && children'; $result = phpQuery::newDocumentFile('test.html'); $parent = $result->find('ul:first'); $children = $parent->find('li:first'); $e = null; try { $children->before('
  • test
  • '); } catch(Exception $e) { print "Test '{$testName}' FAILED !!! "; } if (! $e) { print "Test '{$testName}' PASSED :)"; } print "\n"; $testName = 'HTML insertion'; $doc = phpQuery::newDocument('

    '); $string = "La Thermo-sonde de cuisson vous permet de cuire à la perfection au four comme au bain-marie. Température: entre 0°C et 210°C."; $doc->find('p')->html($string); if (pq('p')->length == 1) print "Test '{$testName}' PASSED :)"; else { print "Test '{$testName}' FAILED !!! "; print $doc->htmlOuter('htmlentities'); } print "\n"; $testName = 'HTML insertion 2'; $doc = phpQuery::newDocument('

    '); $string = "
    La Thermo-sonde de cuisson vous permet de cuire à la perfection au four comme au bain-marie. Température: entre 0°C et 210°C.
    "; $doc->find('p')->html($string); if (pq('div')->length == 2) { print "Test '{$testName}' PASSED :)"; } else { print "Test '{$testName}' FAILED !!! "; print $doc->htmlOuter('htmlentities'); } print "\n"; $testName = 'HTML insertion 3'; $doc = phpQuery::newDocument('

    '); $string = 'Hors paragraphe.

    Éditorial de l\'institution Saint-Pierre.

    Hors paragraphe.'; $doc->find('p')->html($string); if (pq('img')->length == 1) { print "Test '{$testName}' PASSED :)"; print $doc->htmlOuter(); } else { print "Test '{$testName}' FAILED !!! "; print $doc->htmlOuter('htmlentities'); } print "\n"; $testName = 'Text insertion'; $doc = phpQuery::newDocument('

    '); $string = "La Thermo-sonde de cuisson vous permet de cuire à la perfection au four comme au bain-marie"; $doc->find('p')->html($string); if (trim(pq('p:first')->html()) == $string) print "Test '{$testName}' PASSED :)"; else { print "Test '{$testName}' FAILED !!! "; print $doc->htmlOuter('htmlentities'); } print "\n"; ?>