No Description

ApacheRequestTest.php 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpFoundation\Tests;
  11. use Symfony\Component\HttpFoundation\ApacheRequest;
  12. class ApacheRequestTest extends \PHPUnit_Framework_TestCase
  13. {
  14. /**
  15. * @dataProvider provideServerVars
  16. */
  17. public function testUriMethods($server, $expectedRequestUri, $expectedBaseUrl, $expectedPathInfo)
  18. {
  19. $request = new ApacheRequest();
  20. $request->server->replace($server);
  21. $this->assertEquals($expectedRequestUri, $request->getRequestUri(), '->getRequestUri() is correct');
  22. $this->assertEquals($expectedBaseUrl, $request->getBaseUrl(), '->getBaseUrl() is correct');
  23. $this->assertEquals($expectedPathInfo, $request->getPathInfo(), '->getPathInfo() is correct');
  24. }
  25. public function provideServerVars()
  26. {
  27. return array(
  28. array(
  29. array(
  30. 'REQUEST_URI' => '/foo/app_dev.php/bar',
  31. 'SCRIPT_NAME' => '/foo/app_dev.php',
  32. 'PATH_INFO' => '/bar',
  33. ),
  34. '/foo/app_dev.php/bar',
  35. '/foo/app_dev.php',
  36. '/bar',
  37. ),
  38. array(
  39. array(
  40. 'REQUEST_URI' => '/foo/bar',
  41. 'SCRIPT_NAME' => '/foo/app_dev.php',
  42. ),
  43. '/foo/bar',
  44. '/foo',
  45. '/bar',
  46. ),
  47. array(
  48. array(
  49. 'REQUEST_URI' => '/app_dev.php/foo/bar',
  50. 'SCRIPT_NAME' => '/app_dev.php',
  51. 'PATH_INFO' => '/foo/bar',
  52. ),
  53. '/app_dev.php/foo/bar',
  54. '/app_dev.php',
  55. '/foo/bar',
  56. ),
  57. array(
  58. array(
  59. 'REQUEST_URI' => '/foo/bar',
  60. 'SCRIPT_NAME' => '/app_dev.php',
  61. ),
  62. '/foo/bar',
  63. '',
  64. '/foo/bar',
  65. ),
  66. array(
  67. array(
  68. 'REQUEST_URI' => '/app_dev.php',
  69. 'SCRIPT_NAME' => '/app_dev.php',
  70. ),
  71. '/app_dev.php',
  72. '/app_dev.php',
  73. '/',
  74. ),
  75. array(
  76. array(
  77. 'REQUEST_URI' => '/',
  78. 'SCRIPT_NAME' => '/app_dev.php',
  79. ),
  80. '/',
  81. '',
  82. '/',
  83. ),
  84. );
  85. }
  86. }