PageUrlTest.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * HttpUtils' tests
  4. */
  5. require_once 'application/HttpUtils.php';
  6. /**
  7. * Unitary tests for page_url()
  8. */
  9. class PageUrlTest extends PHPUnit_Framework_TestCase
  10. {
  11. /**
  12. * If on the main page, remove "index.php" from the URL resource
  13. */
  14. public function testRemoveIndex()
  15. {
  16. $this->assertEquals(
  17. 'http://host.tld/?p1=v1&p2=v2',
  18. page_url(
  19. array(
  20. 'HTTPS' => 'Off',
  21. 'SERVER_NAME' => 'host.tld',
  22. 'SERVER_PORT' => '80',
  23. 'SCRIPT_NAME' => '/index.php',
  24. 'QUERY_STRING' => 'p1=v1&p2=v2'
  25. )
  26. )
  27. );
  28. $this->assertEquals(
  29. 'http://host.tld/admin/?action=edit_tag',
  30. page_url(
  31. array(
  32. 'HTTPS' => 'Off',
  33. 'SERVER_NAME' => 'host.tld',
  34. 'SERVER_PORT' => '80',
  35. 'SCRIPT_NAME' => '/admin/index.php',
  36. 'QUERY_STRING' => 'action=edit_tag'
  37. )
  38. )
  39. );
  40. }
  41. /**
  42. * The resource is != "index.php"
  43. */
  44. public function testOtherResource()
  45. {
  46. $this->assertEquals(
  47. 'http://host.tld/page.php?p1=v1&p2=v2',
  48. page_url(
  49. array(
  50. 'HTTPS' => 'Off',
  51. 'SERVER_NAME' => 'host.tld',
  52. 'SERVER_PORT' => '80',
  53. 'SCRIPT_NAME' => '/page.php',
  54. 'QUERY_STRING' => 'p1=v1&p2=v2'
  55. )
  56. )
  57. );
  58. $this->assertEquals(
  59. 'http://host.tld/admin/page.php?action=edit_tag',
  60. page_url(
  61. array(
  62. 'HTTPS' => 'Off',
  63. 'SERVER_NAME' => 'host.tld',
  64. 'SERVER_PORT' => '80',
  65. 'SCRIPT_NAME' => '/admin/page.php',
  66. 'QUERY_STRING' => 'action=edit_tag'
  67. )
  68. )
  69. );
  70. }
  71. }