@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | $rowSrc = $articles->find('li') |
| 49 | 49 | ->remove() |
| 50 | 50 | ->eq(0); |
| 51 | -foreach( $rows as $r ) { |
|
| 51 | +foreach ($rows as $r) { |
|
| 52 | 52 | $row = $rowSrc->_clone(); |
| 53 | - foreach( $r as $field => $value ) { |
|
| 53 | + foreach ($r as $field => $value) { |
|
| 54 | 54 | $row->find(".{$field}") |
| 55 | 55 | ->html($value); |
| 56 | 56 | // die($row->htmlOuter()); |
@@ -75,10 +75,10 @@ discard block |
||
| 75 | 75 | $e = null; |
| 76 | 76 | try { |
| 77 | 77 | $children->before('<li>test</li>'); |
| 78 | -} catch(Exception $e) { |
|
| 78 | +} catch (Exception $e) { |
|
| 79 | 79 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
| 80 | 80 | } |
| 81 | -if (! $e) { |
|
| 81 | +if (!$e) { |
|
| 82 | 82 | print "Test '{$testName}' PASSED :)"; |
| 83 | 83 | } |
| 84 | 84 | print "\n"; |
@@ -61,10 +61,11 @@ discard block |
||
| 61 | 61 | //print htmlspecialchars("<pre>{$result}</pre>").'<br />'; |
| 62 | 62 | $similarity = 0.0; |
| 63 | 63 | similar_text($testResult, $result, $similarity); |
| 64 | -if ($similarity > 90) |
|
| 64 | +if ($similarity > 90) { |
|
| 65 | 65 | print "Test '{$testName}' passed :)"; |
| 66 | -else |
|
| 66 | +} else { |
|
| 67 | 67 | print "Test '{$testName}' <strong>FAILED</strong> ($similarity) !!!"; |
| 68 | +} |
|
| 68 | 69 | print "\n"; |
| 69 | 70 | |
| 70 | 71 | |
@@ -88,9 +89,9 @@ discard block |
||
| 88 | 89 | $doc = PhpQuery::newDocument('<div><p/></div>'); |
| 89 | 90 | $string = "La Thermo-sonde de cuisson vous permet de cuire à la perfection au four comme au bain-marie. Température: entre <b>0°C et 210°C</b>."; |
| 90 | 91 | $doc->find('p')->html($string); |
| 91 | -if (pq('p')->length == 1) |
|
| 92 | +if (pq('p')->length == 1) { |
|
| 92 | 93 | print "Test '{$testName}' PASSED :)"; |
| 93 | -else { |
|
| 94 | +} else { |
|
| 94 | 95 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
| 95 | 96 | print $doc->htmlOuter('htmlentities'); |
| 96 | 97 | } |
@@ -133,9 +134,9 @@ discard block |
||
| 133 | 134 | $doc = PhpQuery::newDocument('<div><p/></div>'); |
| 134 | 135 | $string = "La Thermo-sonde de cuisson vous permet de cuire à la perfection au four comme au bain-marie"; |
| 135 | 136 | $doc->find('p')->html($string); |
| 136 | -if (trim(pq('p:first')->html()) == $string) |
|
| 137 | +if (trim(pq('p:first')->html()) == $string) { |
|
| 137 | 138 | print "Test '{$testName}' PASSED :)"; |
| 138 | -else { |
|
| 139 | +} else { |
|
| 139 | 140 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
| 140 | 141 | print $doc->htmlOuter('htmlentities'); |
| 141 | 142 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | $result = PhpQuery::newDocumentFile('test.html'); |
| 11 | 11 | $result = $result->find('p') |
| 12 | 12 | ->filter('.body:gt(1)'); |
| 13 | -if ( $result->whois() == $testResult ) |
|
| 13 | +if ($result->whois() == $testResult) |
|
| 14 | 14 | print "Test '{$testName}' PASSED :)"; |
| 15 | 15 | else |
| 16 | 16 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $result = PhpQuery::newDocument($result->htmlOuter())->find('html') |
| 50 | 50 | ->attr('test'); |
| 51 | 51 | //similar_text($result->htmlOuter(), $validResult, $similarity); |
| 52 | -if ( $result == $validResult ) |
|
| 52 | +if ($result == $validResult) |
|
| 53 | 53 | print "Test '{$testName}' PASSED :)"; |
| 54 | 54 | else { |
| 55 | 55 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
@@ -10,10 +10,11 @@ discard block |
||
| 10 | 10 | $result = PhpQuery::newDocumentFile('test.html'); |
| 11 | 11 | $result = $result->find('p') |
| 12 | 12 | ->filter('.body:gt(1)'); |
| 13 | -if ( $result->whois() == $testResult ) |
|
| 13 | +if ( $result->whois() == $testResult ) { |
|
| 14 | 14 | print "Test '{$testName}' PASSED :)"; |
| 15 | -else |
|
| 15 | +} else { |
|
| 16 | 16 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
| 17 | +} |
|
| 17 | 18 | print_r($result->whois()); |
| 18 | 19 | print "\n"; |
| 19 | 20 | |
@@ -30,10 +31,11 @@ discard block |
||
| 30 | 31 | ; |
| 31 | 32 | $double = $testDOM->find('p') |
| 32 | 33 | ->filter('.body, .title'); |
| 33 | -if ($single->length == count($double)) |
|
| 34 | +if ($single->length == count($double)) { |
|
| 34 | 35 | print "Test '{$testName}' PASSED :)"; |
| 35 | -else |
|
| 36 | +} else { |
|
| 36 | 37 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
| 38 | +} |
|
| 37 | 39 | print "\n"; |
| 38 | 40 | print_r($single->whois()); |
| 39 | 41 | print "\n"; |
@@ -49,9 +51,9 @@ discard block |
||
| 49 | 51 | $result = PhpQuery::newDocument($result->htmlOuter())->find('html') |
| 50 | 52 | ->attr('test'); |
| 51 | 53 | //similar_text($result->htmlOuter(), $validResult, $similarity); |
| 52 | -if ( $result == $validResult ) |
|
| 54 | +if ( $result == $validResult ) { |
|
| 53 | 55 | print "Test '{$testName}' PASSED :)"; |
| 54 | -else { |
|
| 56 | +} else { |
|
| 55 | 57 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
| 56 | 58 | print "<pre>"; |
| 57 | 59 | print $result; |
@@ -8,10 +8,11 @@ discard block |
||
| 8 | 8 | ->find('li:first') |
| 9 | 9 | ->find('p:first') |
| 10 | 10 | ->html('żźć'); |
| 11 | -if (trim($result->html()) == 'żźć') |
|
| 11 | +if (trim($result->html()) == 'żźć') { |
|
| 12 | 12 | print "Test '{$testName}' passed :)<br />\n"; |
| 13 | -else |
|
| 13 | +} else { |
|
| 14 | 14 | print "Test '{$testName}' <strong>FAILED</strong> !!!<br />\n"; |
| 15 | +} |
|
| 15 | 16 | print "\n"; |
| 16 | 17 | |
| 17 | 18 | $testName = 'Text node HTML entite append'; |
@@ -20,9 +21,9 @@ discard block |
||
| 20 | 21 | ->find('p:first') |
| 21 | 22 | ->_empty() |
| 22 | 23 | ->append('é'); |
| 23 | -if (trim($result->html()) == 'é') |
|
| 24 | +if (trim($result->html()) == 'é') { |
|
| 24 | 25 | print "Test '{$testName}' passed :)<br />\n"; |
| 25 | -else { |
|
| 26 | +} else { |
|
| 26 | 27 | print "Test '{$testName}' <strong>FAILED</strong> !!!<br />\n"; |
| 27 | 28 | print $result->html(); |
| 28 | 29 | } |
@@ -34,9 +35,9 @@ discard block |
||
| 34 | 35 | ->find('p:first') |
| 35 | 36 | ->empty() |
| 36 | 37 | ->append('<span>é</span>'); |
| 37 | -if (trim($result->html()) == '<span>é</span>') |
|
| 38 | +if (trim($result->html()) == '<span>é</span>') { |
|
| 38 | 39 | print "Test '{$testName}' passed :)<br />\n"; |
| 39 | -else { |
|
| 40 | +} else { |
|
| 40 | 41 | print "Test '{$testName}' <strong>FAILED</strong> !!!<br />\n"; |
| 41 | 42 | print $result->html(); |
| 42 | 43 | } |
@@ -53,9 +54,9 @@ discard block |
||
| 53 | 54 | ); |
| 54 | 55 | $result = $result->find('div:first li:first'); |
| 55 | 56 | $expected = 'test1-é-test1test2-é-test2'; |
| 56 | -if (trim(str_replace("\n", '', $result->html())) == $expected) |
|
| 57 | +if (trim(str_replace("\n", '', $result->html())) == $expected) { |
|
| 57 | 58 | print "Test '{$testName}' passed :)<br />\n"; |
| 58 | -else { |
|
| 59 | +} else { |
|
| 59 | 60 | print "Test '{$testName}' <strong>FAILED</strong> !!!<br />\n"; |
| 60 | 61 | print "'".trim($result->html())."'"; |
| 61 | 62 | } |
@@ -65,9 +66,9 @@ discard block |
||
| 65 | 66 | $result = PhpQuery::newDocumentFile('test.html') |
| 66 | 67 | ->find('li:first') |
| 67 | 68 | ->attr('test', 'foo é żźć bar'); |
| 68 | -if (trim($result->attr('test')) == 'foo é żźć bar') |
|
| 69 | +if (trim($result->attr('test')) == 'foo é żźć bar') { |
|
| 69 | 70 | print "Test '{$testName}' passed :)<br />\n"; |
| 70 | -else { |
|
| 71 | +} else { |
|
| 71 | 72 | print "Test '{$testName}' <strong>FAILED</strong> !!!<br />\n"; |
| 72 | 73 | print $result->attr('test'); |
| 73 | 74 | } |
@@ -9,9 +9,9 @@ |
||
| 9 | 9 | print $doc->find('li:first')->html('foo <p>bar</p> foo <b><i>foo</i</b>')->html(); |
| 10 | 10 | die(); |
| 11 | 11 | $testResult = 10; |
| 12 | -if ($doc->script('example', 'p')->length == $testResult) |
|
| 12 | +if ($doc->script('example', 'p')->length == $testResult) { |
|
| 13 | 13 | print "Test '$testName' PASSED :)"; |
| 14 | -else { |
|
| 14 | +} else { |
|
| 15 | 15 | print "Test '$testName' <strong>FAILED</strong> !!! "; |
| 16 | 16 | print "<pre>"; |
| 17 | 17 | var_dump($doc->whois()); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require(__DIR__ . '/../src/PhpQuery.php'); |
|
| 2 | +require(__DIR__.'/../src/PhpQuery.php'); |
|
| 3 | 3 | |
| 4 | 4 | // INITIALIZE IT |
| 5 | 5 | // PhpQuery::newDocumentHTML($markup); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | // ITERATE IT |
| 37 | 37 | // all direct LIs from $ul |
| 38 | -foreach($ul['> li'] as $li) { |
|
| 38 | +foreach ($ul['> li'] as $li) { |
|
| 39 | 39 | // iteration returns PLAIN dom nodes, NOT PhpQuery objects |
| 40 | 40 | $tagName = $li->tagName; |
| 41 | 41 | $childNodes = $li->childNodes; |