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.

addarguments.test.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?PHP
  2. if (!defined('INCLUDE')) { ?>
  3. <html>
  4. <head>
  5. <title>Poidsy unit test - URL Builder</title>
  6. <style type="text/css">
  7. table { border-collapse: collapse; width: 100%; }
  8. td, th { border: 1px solid #000; padding: 10px; }
  9. td.error { text-align: center; color: #fff; background-color: #c00; }
  10. td.succ { text-align: center; color: #fff; background-color: #0c0; }
  11. </style>
  12. </head>
  13. <body>
  14. <table>
  15. <tr><th>Input</th><th>Expected</th><th>Actual</th><th>Result</th></tr>
  16. <?PHP
  17. }
  18. require_once('../urlbuilder.inc.php');
  19. function doArgTest($data, $key) {
  20. list($base, $args, $output) = $data;
  21. $aoutput = URLBuilder::addArguments($base, $args);
  22. $result = $aoutput == $output;
  23. echo '<tr><td>', htmlentities($base), ', '; print_r($args); echo '</td>';
  24. echo '<td>', htmlentities($output), '</td>';
  25. echo '<td>', htmlentities($aoutput), '</td>';
  26. echo '<td class="', $result ? 'succ' : 'error', '">';
  27. echo $result ? 'Passed' : 'Failed';
  28. echo '</td>';
  29. echo '</tr>';
  30. }
  31. $tests = array(
  32. array('http://test/?foo=bar', array('baz' => 'qux'), 'http://test/?foo=bar&baz=qux'),
  33. array('http://test/?', array('baz' => 'qux'), 'http://test/?baz=qux'),
  34. array('http://test/?foo', array('baz' => 'qux'), 'http://test/?foo&baz=qux'),
  35. array('http://test/', array('a' => 'b', 'c'=>'d'), 'http://test/?a=b&c=d'),
  36. );
  37. array_walk($tests, 'doArgTest');
  38. ?>