ApacheRequestTest.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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\Tests\Component\HttpFoundation;
  11. use Symfony\Component\HttpFoundation\ApacheRequest;
  12. class ApacheRequestTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testGetBaseUrlDoesNotForceScriptName()
  15. {
  16. $request = new ApacheRequest();
  17. $request->server->replace(array(
  18. 'REQUEST_URI' => '/foo/bar',
  19. 'SCRIPT_NAME' => '/index.php',
  20. ));
  21. $this->assertEquals('', $request->getBaseUrl(), '->getBaseUrl() does not add the script name');
  22. }
  23. public function testGetBaseUrlIncludesScriptName()
  24. {
  25. $request = new ApacheRequest();
  26. $request->server->replace(array(
  27. 'REQUEST_URI' => '/index.php/foo/bar',
  28. 'SCRIPT_NAME' => '/index.php',
  29. ));
  30. $this->assertEquals('/index.php', $request->getBaseUrl(), '->getBaseUrl() includes the script name');
  31. }
  32. }