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.

trustrootnormaliser.test.php 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?PHP if (!defined('INCLUDE')) { ?><html>
  2. <head>
  3. <title>Poidsy unit test - trust root normaliser</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('../urlbuilder.inc.php');
  17. function doTrustRootTest($input, $output) {
  18. list($input1, $input2) = $input;
  19. $aoutput = URLBuilder::getTrustRoot($input1, $input2);
  20. $result = $aoutput == $output;
  21. echo '<tr><td>', htmlentities($input1 . ',' . $input2), '</td>';
  22. echo '<td>', htmlentities($output), '</td>';
  23. echo '<td>', htmlentities($aoutput), '</td>';
  24. echo '<td class="', $result ? 'succ' : 'error', '">';
  25. echo $result ? 'Passed' : 'Failed';
  26. echo '</td>';
  27. echo '</tr>';
  28. }
  29. $tests = array(
  30. 'http://test.fo1/' => array('http://test.fo1/','http://test.fo1/index.php'),
  31. 'http://test.fo2/' => array('http://test.fo2/bar/baz/','http://test.fo2/index.php'),
  32. 'http://test.fo3/' => array('http://test.fo3/','http://test.fo3/'),
  33. 'http://test.fo4/bar/' => array('http://test.fo4/bar/baz/','http://test.fo4/bar/q/i.php'),
  34. );
  35. array_walk($tests, 'doTrustRootTest');
  36. ?>