2
0

Apache404Test.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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-2010 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 "PHPUnit/Framework/TestCase.php";
  27. require_once "PHPUnit/Framework/TestSuite.php";
  28. require_once 'Zend/Controller/Request/Apache404.php';
  29. /**
  30. * Test class for Zend_Controller_Request_Apache404.
  31. * Generated by PHPUnit_Util_Skeleton on 2007-06-25 at 08:20:40.
  32. *
  33. * @category Zend
  34. * @package Zend_Controller
  35. * @subpackage UnitTests
  36. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  37. * @license http://framework.zend.com/license/new-bsd New BSD License
  38. * @group Zend_Controller
  39. * @group Zend_Controller_Request
  40. */
  41. class Zend_Controller_Request_Apache404Test extends PHPUnit_Framework_TestCase
  42. {
  43. /**
  44. * Copy of $_SERVER
  45. * @var array
  46. */
  47. protected $_server;
  48. /**
  49. * Runs the test methods of this class.
  50. *
  51. * @access public
  52. * @static
  53. */
  54. public static function main()
  55. {
  56. require_once "PHPUnit/TextUI/TestRunner.php";
  57. $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Request_Apache404Test");
  58. $result = PHPUnit_TextUI_TestRunner::run($suite);
  59. }
  60. public function setUp()
  61. {
  62. $this->_server = $_SERVER;
  63. }
  64. public function tearDown()
  65. {
  66. $_SERVER = $this->_server;
  67. }
  68. public function testRedirectUrlSelectedOverRequestUri()
  69. {
  70. $_SERVER['REDIRECT_URL'] = '/foo/bar';
  71. $_SERVER['REQUEST_URI'] = '/baz/bat';
  72. $request = new Zend_Controller_Request_Apache404();
  73. $requestUri = $request->getRequestUri();
  74. $this->assertEquals('/foo/bar', $requestUri);
  75. }
  76. /**
  77. * @group ZF-3057
  78. */
  79. public function testRedirectQueryStringShouldBeParsedIntoGetVars()
  80. {
  81. $_SERVER['REDIRECT_URL'] = '/foo/bar';
  82. $_SERVER['REDIRECT_QUERYSTRING'] = 'baz=bat&bat=delta';
  83. $_SERVER['REQUEST_URI'] = '/baz/bat';
  84. $request = new Zend_Controller_Request_Apache404();
  85. $requestUri = $request->getRequestUri();
  86. $this->assertEquals('/foo/bar', $requestUri);
  87. $this->assertSame(array('baz' => 'bat', 'bat' => 'delta'), $request->getQuery());
  88. }
  89. }
  90. // Call Zend_Controller_Request_Apache404Test::main() if this source file is executed directly.
  91. if (PHPUnit_MAIN_METHOD == "Zend_Controller_Request_Apache404Test::main") {
  92. Zend_Controller_Request_Apache404Test::main();
  93. }