Apache404Test.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Controller
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. // Call Zend_Controller_Request_Apache404Test::main() if this source file is executed directly.
  23. if (!defined("PHPUnit_MAIN_METHOD")) {
  24. define("PHPUnit_MAIN_METHOD", "Zend_Controller_Request_Apache404Test::main");
  25. }
  26. require_once 'Zend/Controller/Request/Apache404.php';
  27. /**
  28. * Test class for Zend_Controller_Request_Apache404.
  29. * Generated by PHPUnit_Util_Skeleton on 2007-06-25 at 08:20:40.
  30. *
  31. * @category Zend
  32. * @package Zend_Controller
  33. * @subpackage UnitTests
  34. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. * @group Zend_Controller
  37. * @group Zend_Controller_Request
  38. */
  39. class Zend_Controller_Request_Apache404Test extends PHPUnit_Framework_TestCase
  40. {
  41. /**
  42. * Copy of $_SERVER
  43. * @var array
  44. */
  45. protected $_server;
  46. /**
  47. * Runs the test methods of this class.
  48. *
  49. * @access public
  50. * @static
  51. */
  52. public static function main()
  53. {
  54. $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Request_Apache404Test");
  55. $result = PHPUnit_TextUI_TestRunner::run($suite);
  56. }
  57. public function setUp()
  58. {
  59. $this->_server = $_SERVER;
  60. }
  61. public function tearDown()
  62. {
  63. $_SERVER = $this->_server;
  64. }
  65. public function testRedirectUrlSelectedOverRequestUri()
  66. {
  67. $_SERVER['REDIRECT_URL'] = '/foo/bar';
  68. $_SERVER['REQUEST_URI'] = '/baz/bat';
  69. $request = new Zend_Controller_Request_Apache404();
  70. $requestUri = $request->getRequestUri();
  71. $this->assertEquals('/foo/bar', $requestUri);
  72. }
  73. /**
  74. * @group ZF-3057
  75. * @group ZF-9776
  76. */
  77. public function testRedirectQueryStringShouldBeParsedIntoGetVars()
  78. {
  79. $_SERVER['REDIRECT_URL'] = '/foo/bar';
  80. $_SERVER['REDIRECT_QUERY_STRING'] = 'baz=bat&bat=delta';
  81. $_SERVER['REQUEST_URI'] = '/baz/bat';
  82. $request = new Zend_Controller_Request_Apache404();
  83. $requestUri = $request->getRequestUri();
  84. $this->assertEquals('/foo/bar', $requestUri);
  85. $this->assertSame(array('baz' => 'bat', 'bat' => 'delta'), $request->getQuery());
  86. }
  87. }
  88. // Call Zend_Controller_Request_Apache404Test::main() if this source file is executed directly.
  89. if (PHPUnit_MAIN_METHOD == "Zend_Controller_Request_Apache404Test::main") {
  90. Zend_Controller_Request_Apache404Test::main();
  91. }