PHP OpenID consumer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

parsehtml.test.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?PHP if (!defined('INCLUDE')) { ?><html>
  2. <head>
  3. <title>Poidsy unit test - HTML parser</title>
  4. <style type="text/css">
  5. table { border-collapse: collapse; width: 100%; }
  6. td, th { border: 1px solid #000; padding: 10px; }
  7. td.error { text-align: center; color: #fff; background-color: #c00; }
  8. td.succ { text-align: center; color: #fff; background-color: #0c0; }
  9. </style>
  10. </head>
  11. <body>
  12. <table>
  13. <tr><th>Input</th><th>Expected</th><th>Actual</th><th>Result</th></tr>
  14. <?PHP
  15. }
  16. require_once('../discoverer.inc.php');
  17. function doHtmlTest($output, $input) {
  18. $disc = new Discoverer(null);
  19. $disc->parseHtml(file_get_contents($input));
  20. $aoutput = $disc->getVersion() . ':' . $disc->getEndpointUrl() . ',' . $disc->getOpLocalId();
  21. $result = $aoutput == $output;
  22. echo '<tr><td><a href="', htmlentities($input), '">', htmlentities($input), '</a></td>';
  23. echo '<td>', htmlentities($output), '</td>';
  24. echo '<td>', htmlentities($aoutput), '</td>';
  25. echo '<td class="', $result ? 'succ' : 'error', '">';
  26. echo $result ? 'Passed' : 'Failed';
  27. echo '</td>';
  28. echo '</tr>';
  29. }
  30. $tests = array(
  31. 'samplehtml/test1.html' => '1:http://server.com/path,http://delegate.com/',
  32. 'samplehtml/test2.html' => '1:http://server.com/path,http://delegate.com/',
  33. 'samplehtml/test3.html' => '1:http://server/path?foo&bar,',
  34. 'samplehtml/v2-test1.html' => '2:http://server.com/path,http://delegate.com/',
  35. 'samplehtml/v2-test2.html' => '2:http://server.com/path,',
  36. 'samplehtml/v2-test3.html' => '2:http://server.com/path,',
  37. 'samplehtml/v2-test4.html' => '1:http://server.com/path,http://delegate.com/',
  38. );
  39. array_walk($tests, 'doHtmlTest');
  40. ?>