IndexUrlTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * HttpUtils' tests
  4. */
  5. require_once 'application/HttpUtils.php';
  6. /**
  7. * Unitary tests for index_url()
  8. */
  9. class IndexUrlTest 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/',
  18. index_url(
  19. array(
  20. 'HTTPS' => 'Off',
  21. 'SERVER_NAME' => 'host.tld',
  22. 'SERVER_PORT' => '80',
  23. 'SCRIPT_NAME' => '/index.php'
  24. )
  25. )
  26. );
  27. $this->assertEquals(
  28. 'http://host.tld/admin/',
  29. index_url(
  30. array(
  31. 'HTTPS' => 'Off',
  32. 'SERVER_NAME' => 'host.tld',
  33. 'SERVER_PORT' => '80',
  34. 'SCRIPT_NAME' => '/admin/index.php'
  35. )
  36. )
  37. );
  38. }
  39. /**
  40. * The resource is != "index.php"
  41. */
  42. public function testOtherResource()
  43. {
  44. $this->assertEquals(
  45. 'http://host.tld/page.php',
  46. page_url(
  47. array(
  48. 'HTTPS' => 'Off',
  49. 'SERVER_NAME' => 'host.tld',
  50. 'SERVER_PORT' => '80',
  51. 'SCRIPT_NAME' => '/page.php'
  52. )
  53. )
  54. );
  55. $this->assertEquals(
  56. 'http://host.tld/admin/page.php',
  57. page_url(
  58. array(
  59. 'HTTPS' => 'Off',
  60. 'SERVER_NAME' => 'host.tld',
  61. 'SERVER_PORT' => '80',
  62. 'SCRIPT_NAME' => '/admin/page.php'
  63. )
  64. )
  65. );
  66. }
  67. }