@@ -21,7 +21,7 @@ |
||
| 21 | 21 | print var_dump($text); |
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | -require_once(__DIR__ . '/../../Dom/DOMDocumentWrapper.php'); |
|
| 24 | +require_once(__DIR__.'/../../Dom/DOMDocumentWrapper.php'); |
|
| 25 | 25 | PhpQuery::$debug = 2; |
| 26 | 26 | |
| 27 | 27 | /* ENCODINGS */ |
@@ -17,8 +17,9 @@ |
||
| 17 | 17 | static $documents = array(); |
| 18 | 18 | static $defaultCharset = 'utf-8'; |
| 19 | 19 | static function debug($text) { |
| 20 | - if (self::$debug) |
|
| 21 | - print var_dump($text); |
|
| 20 | + if (self::$debug) { |
|
| 21 | + print var_dump($text); |
|
| 22 | + } |
|
| 22 | 23 | } |
| 23 | 24 | } |
| 24 | 25 | require_once(__DIR__ . '/../../Dom/DOMDocumentWrapper.php'); |
@@ -27,14 +27,14 @@ |
||
| 27 | 27 | array('callbackClass', 'staticMethodCallback'), |
| 28 | 28 | array(new callbackClass, 'methodCallback') |
| 29 | 29 | ); |
| 30 | -foreach($tests as $test) { |
|
| 30 | +foreach ($tests as $test) { |
|
| 31 | 31 | $result = PhpQuery::newDocumentFile('test.html') |
| 32 | 32 | ->find('li') |
| 33 | 33 | ->each($test); |
| 34 | 34 | $testName = is_array($test) |
| 35 | 35 | ? $test[1] |
| 36 | 36 | : $test; |
| 37 | - if ( $result->whois() == $testResult ) |
|
| 37 | + if ($result->whois() == $testResult) |
|
| 38 | 38 | print "Test '$testName' PASSED :)"; |
| 39 | 39 | else { |
| 40 | 40 | print "Test '$testName' <strong>FAILED</strong> !!! "; |
@@ -34,9 +34,9 @@ |
||
| 34 | 34 | $testName = is_array($test) |
| 35 | 35 | ? $test[1] |
| 36 | 36 | : $test; |
| 37 | - if ( $result->whois() == $testResult ) |
|
| 38 | - print "Test '$testName' PASSED :)"; |
|
| 39 | - else { |
|
| 37 | + if ( $result->whois() == $testResult ) { |
|
| 38 | + print "Test '$testName' PASSED :)"; |
|
| 39 | + } else { |
|
| 40 | 40 | print "Test '$testName' <strong>FAILED</strong> !!! "; |
| 41 | 41 | print "<pre>"; |
| 42 | 42 | print_r($result->whois()); |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | $result = PhpQuery::newDocumentFile('test.html') |
| 10 | 10 | ->find('li') |
| 11 | 11 | ->slice(1, 2); |
| 12 | -if ( $result->whois() == $testResult ) |
|
| 12 | +if ($result->whois() == $testResult) |
|
| 13 | 13 | print "Test 'Slice1' PASSED :)"; |
| 14 | 14 | else { |
| 15 | 15 | print "Test 'Slice1' <strong>FAILED</strong> !!! "; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $result = PhpQuery::newDocumentFile('test.html') |
| 30 | 30 | ->find('li') |
| 31 | 31 | ->slice(1, -1); |
| 32 | -if ( $result->whois() == $testResult ) |
|
| 32 | +if ($result->whois() == $testResult) |
|
| 33 | 33 | print "Test 'Slice2' PASSED :)"; |
| 34 | 34 | else { |
| 35 | 35 | print "Test 'Slice2' <strong>FAILED</strong> !!! "; |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | ->php('longlongtest'); |
| 46 | 46 | $validResult = '<li><span class="field1"><php>longlongtest</php></span><span class="field1"><php>longlongtest</php></span></li>'; |
| 47 | 47 | similar_text($result->htmlOuter(), $validResult, $similarity); |
| 48 | -if ( $similarity > 80 ) |
|
| 48 | +if ($similarity > 80) |
|
| 49 | 49 | print "Test 'Multi-insert' PASSED :)"; |
| 50 | 50 | else { |
| 51 | 51 | print "Test 'Multi-insert' <strong>FAILED</strong> !!! "; |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $result = PhpQuery::newDocumentFile('test.html') |
| 61 | 61 | ->find('p') |
| 62 | 62 | ->index(pq('p.title:first')); |
| 63 | -if ( $result == $testResult ) |
|
| 63 | +if ($result == $testResult) |
|
| 64 | 64 | print "Test 'Index' PASSED :)"; |
| 65 | 65 | else { |
| 66 | 66 | print "Test 'Index' <strong>FAILED</strong> !!! "; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $p = PhpQuery::newDocumentFile('test.html') |
| 75 | 75 | ->toReference($document) |
| 76 | 76 | ->find('p:first'); |
| 77 | -foreach(array(0,1,2) as $i) { |
|
| 77 | +foreach (array(0, 1, 2) as $i) { |
|
| 78 | 78 | $p->clone() |
| 79 | 79 | ->addClass("clone-test") |
| 80 | 80 | ->addClass("class-$i") |
@@ -9,9 +9,9 @@ discard block |
||
| 9 | 9 | $result = PhpQuery::newDocumentFile('test.html') |
| 10 | 10 | ->find('li') |
| 11 | 11 | ->slice(1, 2); |
| 12 | -if ( $result->whois() == $testResult ) |
|
| 12 | +if ( $result->whois() == $testResult ) { |
|
| 13 | 13 | print "Test 'Slice1' PASSED :)"; |
| 14 | -else { |
|
| 14 | +} else { |
|
| 15 | 15 | print "Test 'Slice1' <strong>FAILED</strong> !!! "; |
| 16 | 16 | print "<pre>"; |
| 17 | 17 | print_r($result->whois()); |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | $result = PhpQuery::newDocumentFile('test.html') |
| 30 | 30 | ->find('li') |
| 31 | 31 | ->slice(1, -1); |
| 32 | -if ( $result->whois() == $testResult ) |
|
| 32 | +if ( $result->whois() == $testResult ) { |
|
| 33 | 33 | print "Test 'Slice2' PASSED :)"; |
| 34 | -else { |
|
| 34 | +} else { |
|
| 35 | 35 | print "Test 'Slice2' <strong>FAILED</strong> !!! "; |
| 36 | 36 | print "<pre>"; |
| 37 | 37 | print_r($result->whois()); |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | ->php('longlongtest'); |
| 46 | 46 | $validResult = '<li><span class="field1"><php>longlongtest</php></span><span class="field1"><php>longlongtest</php></span></li>'; |
| 47 | 47 | similar_text($result->htmlOuter(), $validResult, $similarity); |
| 48 | -if ( $similarity > 80 ) |
|
| 48 | +if ( $similarity > 80 ) { |
|
| 49 | 49 | print "Test 'Multi-insert' PASSED :)"; |
| 50 | -else { |
|
| 50 | +} else { |
|
| 51 | 51 | print "Test 'Multi-insert' <strong>FAILED</strong> !!! "; |
| 52 | 52 | print "<pre>"; |
| 53 | 53 | var_dump($result->htmlOuter()); |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | $result = PhpQuery::newDocumentFile('test.html') |
| 61 | 61 | ->find('p') |
| 62 | 62 | ->index(pq('p.title:first')); |
| 63 | -if ( $result == $testResult ) |
|
| 63 | +if ( $result == $testResult ) { |
|
| 64 | 64 | print "Test 'Index' PASSED :)"; |
| 65 | -else { |
|
| 65 | +} else { |
|
| 66 | 66 | print "Test 'Index' <strong>FAILED</strong> !!! "; |
| 67 | 67 | } |
| 68 | 68 | print "\n"; |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | ->addClass("class-$i") |
| 81 | 81 | ->insertBefore($p); |
| 82 | 82 | } |
| 83 | -if (pq('.clone-test')->size() == $testResult) |
|
| 83 | +if (pq('.clone-test')->size() == $testResult) { |
|
| 84 | 84 | print "Test '$testName' PASSED :)"; |
| 85 | -else { |
|
| 85 | +} else { |
|
| 86 | 86 | print "Test '$testName' <strong>FAILED</strong> !!! "; |
| 87 | 87 | } |
| 88 | 88 | print "\n"; |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | ->next() |
| 98 | 98 | ->prev() |
| 99 | 99 | ->is('#testID'); |
| 100 | -if ($result) |
|
| 100 | +if ($result) { |
|
| 101 | 101 | print "Test '$testName' PASSED :)"; |
| 102 | -else { |
|
| 102 | +} else { |
|
| 103 | 103 | print "Test '$testName' <strong>FAILED</strong> !!! "; |
| 104 | 104 | } |
| 105 | 105 | print "\n"; |
@@ -10,9 +10,9 @@ discard block |
||
| 10 | 10 | $testHtml = PhpQuery::newDocumentFile('test.html'); |
| 11 | 11 | $testHtml['li:first']->append('<span class="just-added">test</span>'); |
| 12 | 12 | $testName = 'Array Access get'; |
| 13 | -if (trim($testHtml['.just-added']->html()) == 'test') |
|
| 13 | +if (trim($testHtml['.just-added']->html()) == 'test') { |
|
| 14 | 14 | print "Test '$testName' PASSED :)"; |
| 15 | -else { |
|
| 15 | +} else { |
|
| 16 | 16 | print "Test '$testName' <strong>FAILED</strong> !!! "; |
| 17 | 17 | print "<pre>"; |
| 18 | 18 | print_r($testHtml['.just-added']->whois()); |
@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | $testHtml = PhpQuery::newDocumentFile('test.html'); |
| 26 | 26 | $testHtml['li:first'] = 'new inner html'; |
| 27 | 27 | $testName = 'Array Access set'; |
| 28 | -if (trim($testHtml['li:first']->html()) == 'new inner html') |
|
| 28 | +if (trim($testHtml['li:first']->html()) == 'new inner html') { |
|
| 29 | 29 | print "Test '$testName' PASSED :)"; |
| 30 | -else { |
|
| 30 | +} else { |
|
| 31 | 31 | print "Test '$testName' <strong>FAILED</strong> !!! "; |
| 32 | 32 | print "<pre>"; |
| 33 | 33 | print_r($testHtml['.just-added']->whois()); |
@@ -9,13 +9,13 @@ |
||
| 9 | 9 | whois($X->query($Query)); |
| 10 | 10 | function whois($nodeList) { |
| 11 | 11 | $return = array(); |
| 12 | - foreach( $nodeList as $node ) { |
|
| 12 | + foreach ($nodeList as $node) { |
|
| 13 | 13 | $return[] = ( |
| 14 | 14 | $node->tagName |
| 15 | 15 | .($node->getAttribute('id') |
| 16 | - ? '#'.$node->getAttribute('id'):'') |
|
| 16 | + ? '#'.$node->getAttribute('id') : '') |
|
| 17 | 17 | .($node->getAttribute('class') |
| 18 | - ? '.'.join('.', split(' ', $node->getAttribute('class'))):'') |
|
| 18 | + ? '.'.join('.', split(' ', $node->getAttribute('class'))) : '') |
|
| 19 | 19 | ); |
| 20 | 20 | } |
| 21 | 21 | print "<pre>"; |
@@ -11,9 +11,9 @@ |
||
| 11 | 11 | print $doc->find('p'); |
| 12 | 12 | $markup = "test<br />test<p>test p</p>"; |
| 13 | 13 | $doc['body > p:last']->append($markup); |
| 14 | -if ($doc['body > p:last p']->length == 1) |
|
| 14 | +if ($doc['body > p:last p']->length == 1) { |
|
| 15 | 15 | print "Test '{$testName}' PASSED :)"; |
| 16 | -else { |
|
| 16 | +} else { |
|
| 17 | 17 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
| 18 | 18 | print $doc->htmlOuter('htmlspecialchars'); |
| 19 | 19 | } |
@@ -8,8 +8,8 @@ discard block |
||
| 8 | 8 | ->slice(1, 3); |
| 9 | 9 | $p->wrap('<div class="wrapper">'); |
| 10 | 10 | $result = true; |
| 11 | -foreach($p as $node) { |
|
| 12 | - if (! pq($node)->parent()->is('.wrapper')) |
|
| 11 | +foreach ($p as $node) { |
|
| 12 | + if (!pq($node)->parent()->is('.wrapper')) |
|
| 13 | 13 | $result = false; |
| 14 | 14 | } |
| 15 | 15 | if ($result) |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | ->slice(1, 3) |
| 29 | 29 | ->wrapAll('<div class="wrapper">'); |
| 30 | 30 | $result = pq('.wrapper'); |
| 31 | -if ( $result->size() == $testResult ) |
|
| 31 | +if ($result->size() == $testResult) |
|
| 32 | 32 | print "Test '{$testName}' PASSED :)"; |
| 33 | 33 | else |
| 34 | 34 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | ->find('li:first') |
| 44 | 44 | ->wrapInner('<div class="wrapper">'); |
| 45 | 45 | $result = pq('.wrapper p'); |
| 46 | -if ( $result->size() == $testResult ) |
|
| 46 | +if ($result->size() == $testResult) |
|
| 47 | 47 | print "Test '{$testName}' PASSED :)"; |
| 48 | 48 | else |
| 49 | 49 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
@@ -9,13 +9,15 @@ discard block |
||
| 9 | 9 | $p->wrap('<div class="wrapper">'); |
| 10 | 10 | $result = true; |
| 11 | 11 | foreach($p as $node) { |
| 12 | - if (! pq($node)->parent()->is('.wrapper')) |
|
| 13 | - $result = false; |
|
| 14 | -} |
|
| 15 | -if ($result) |
|
| 12 | + if (! pq($node)->parent()->is('.wrapper')) { |
|
| 13 | + $result = false; |
|
| 14 | + } |
|
| 15 | + } |
|
| 16 | +if ($result) { |
|
| 16 | 17 | print "Test '{$testName}' PASSED :)"; |
| 17 | -else |
|
| 18 | +} else { |
|
| 18 | 19 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
| 20 | +} |
|
| 19 | 21 | $p->dump(); |
| 20 | 22 | print "\n"; |
| 21 | 23 | |
@@ -28,10 +30,11 @@ discard block |
||
| 28 | 30 | ->slice(1, 3) |
| 29 | 31 | ->wrapAll('<div class="wrapper">'); |
| 30 | 32 | $result = pq('.wrapper'); |
| 31 | -if ( $result->size() == $testResult ) |
|
| 33 | +if ( $result->size() == $testResult ) { |
|
| 32 | 34 | print "Test '{$testName}' PASSED :)"; |
| 33 | -else |
|
| 35 | +} else { |
|
| 34 | 36 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
| 37 | +} |
|
| 35 | 38 | $result->dump(); |
| 36 | 39 | print "\n"; |
| 37 | 40 | |
@@ -43,10 +46,11 @@ discard block |
||
| 43 | 46 | ->find('li:first') |
| 44 | 47 | ->wrapInner('<div class="wrapper">'); |
| 45 | 48 | $result = pq('.wrapper p'); |
| 46 | -if ( $result->size() == $testResult ) |
|
| 49 | +if ( $result->size() == $testResult ) { |
|
| 47 | 50 | print "Test '{$testName}' PASSED :)"; |
| 48 | -else |
|
| 51 | +} else { |
|
| 49 | 52 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
| 53 | +} |
|
| 50 | 54 | print $result->dump(); |
| 51 | 55 | print "\n"; |
| 52 | 56 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | foreach ($doc1->find('p') as $node) |
| 13 | 13 | $doc2->find('body')->append(pq($node)); |
| 14 | 14 | $testResult = $doc2->find('p'); |
| 15 | -if ( $testResult->size() == 2*$doc1->find('p')->size() ) |
|
| 15 | +if ($testResult->size() == 2*$doc1->find('p')->size()) |
|
| 16 | 16 | print "Test '{$testName}' PASSED :)"; |
| 17 | 17 | else { |
| 18 | 18 | print "Test '{$testName}' <strong>FAILED</strong> !!!<br />"; |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | foreach ($doc1->find('p') as $node) |
| 29 | 29 | $doc2->find('body')->append($node); |
| 30 | 30 | $testResult = $doc2->find('p'); |
| 31 | -if ( $testResult->size() == 2*$doc1->find('p')->size() ) |
|
| 31 | +if ($testResult->size() == 2*$doc1->find('p')->size()) |
|
| 32 | 32 | print "Test '{$testName}' PASSED :)"; |
| 33 | 33 | else { |
| 34 | 34 | print "Test '{$testName}' <strong>FAILED</strong> !!!<br />"; |
@@ -9,12 +9,13 @@ discard block |
||
| 9 | 9 | $doc1 = PhpQuery::newDocumentFile('test.html'); |
| 10 | 10 | $doc2 = PhpQuery::newDocumentFile('test.html'); |
| 11 | 11 | |
| 12 | -foreach ($doc1->find('p') as $node) |
|
| 12 | +foreach ($doc1->find('p') as $node) { |
|
| 13 | 13 | $doc2->find('body')->append(pq($node)); |
| 14 | +} |
|
| 14 | 15 | $testResult = $doc2->find('p'); |
| 15 | -if ( $testResult->size() == 2*$doc1->find('p')->size() ) |
|
| 16 | +if ( $testResult->size() == 2*$doc1->find('p')->size() ) { |
|
| 16 | 17 | print "Test '{$testName}' PASSED :)"; |
| 17 | -else { |
|
| 18 | +} else { |
|
| 18 | 19 | print "Test '{$testName}' <strong>FAILED</strong> !!!<br />"; |
| 19 | 20 | $testResult->whois(); |
| 20 | 21 | } |
@@ -25,12 +26,13 @@ discard block |
||
| 25 | 26 | ); |
| 26 | 27 | $doc1 = PhpQuery::newDocumentFile('test.html'); |
| 27 | 28 | $doc2 = PhpQuery::newDocumentFile('test.html'); |
| 28 | -foreach ($doc1->find('p') as $node) |
|
| 29 | +foreach ($doc1->find('p') as $node) { |
|
| 29 | 30 | $doc2->find('body')->append($node); |
| 31 | +} |
|
| 30 | 32 | $testResult = $doc2->find('p'); |
| 31 | -if ( $testResult->size() == 2*$doc1->find('p')->size() ) |
|
| 33 | +if ( $testResult->size() == 2*$doc1->find('p')->size() ) { |
|
| 32 | 34 | print "Test '{$testName}' PASSED :)"; |
| 33 | -else { |
|
| 35 | +} else { |
|
| 34 | 36 | print "Test '{$testName}' <strong>FAILED</strong> !!!<br />"; |
| 35 | 37 | $testResult->whois(); |
| 36 | 38 | } |
@@ -274,11 +274,11 @@ discard block |
||
| 274 | 274 | ); |
| 275 | 275 | |
| 276 | 276 | PhpQuery::newDocumentFile('test.html'); |
| 277 | -foreach( $tests as $k => $test ) { |
|
| 278 | - $tests[ $k ][2] = pq( $test[0] )->whois(); |
|
| 277 | +foreach ($tests as $k => $test) { |
|
| 278 | + $tests[$k][2] = pq($test[0])->whois(); |
|
| 279 | 279 | } |
| 280 | -foreach( $tests as $test ) { |
|
| 281 | - if ( $test[1] == $test[2] ) |
|
| 280 | +foreach ($tests as $test) { |
|
| 281 | + if ($test[1] == $test[2]) |
|
| 282 | 282 | print "Test '{$test[0]}' PASSED :)"; |
| 283 | 283 | else { |
| 284 | 284 | print "Test '{$test[0]}' <strong>FAILED</strong> !!!"; |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | pq('<select name="test[]"><option value=3>test</option></select>') |
| 294 | 294 | ->appendTo('body'); |
| 295 | 295 | $result = pq('select[name="test[]"]:has(option[value=3])'); |
| 296 | -if ( $result->size() == 1 ) |
|
| 296 | +if ($result->size() == 1) |
|
| 297 | 297 | print "Test '{$testName}' PASSED :)"; |
| 298 | 298 | else |
| 299 | 299 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
@@ -278,9 +278,9 @@ discard block |
||
| 278 | 278 | $tests[ $k ][2] = pq( $test[0] )->whois(); |
| 279 | 279 | } |
| 280 | 280 | foreach( $tests as $test ) { |
| 281 | - if ( $test[1] == $test[2] ) |
|
| 282 | - print "Test '{$test[0]}' PASSED :)"; |
|
| 283 | - else { |
|
| 281 | + if ( $test[1] == $test[2] ) { |
|
| 282 | + print "Test '{$test[0]}' PASSED :)"; |
|
| 283 | + } else { |
|
| 284 | 284 | print "Test '{$test[0]}' <strong>FAILED</strong> !!!"; |
| 285 | 285 | print_r($test[2]); |
| 286 | 286 | } |
@@ -293,10 +293,11 @@ discard block |
||
| 293 | 293 | pq('<select name="test[]"><option value=3>test</option></select>') |
| 294 | 294 | ->appendTo('body'); |
| 295 | 295 | $result = pq('select[name="test[]"]:has(option[value=3])'); |
| 296 | -if ( $result->size() == 1 ) |
|
| 296 | +if ( $result->size() == 1 ) { |
|
| 297 | 297 | print "Test '{$testName}' PASSED :)"; |
| 298 | -else |
|
| 298 | +} else { |
|
| 299 | 299 | print "Test '{$testName}' <strong>FAILED</strong> !!! "; |
| 300 | +} |
|
| 300 | 301 | $result->dump(); |
| 301 | 302 | print "\n"; |
| 302 | 303 | ?> |
| 303 | 304 | \ No newline at end of file |