PutHandlerTest.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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-2015 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_Plugin_PutHandlerTest::main() if this source file is executed directly.
  23. if (!defined("PHPUnit_MAIN_METHOD")) {
  24. define("PHPUnit_MAIN_METHOD", "Zend_Controller_Plugin_PutHandlerTest::main");
  25. }
  26. require_once 'Zend/Controller/Plugin/PutHandler.php';
  27. require_once 'Zend/Controller/Request/HttpTestCase.php';
  28. require_once 'Zend/Controller/Front.php';
  29. /**
  30. * Test class for Zend_Controller_Plugin_PutHandler.
  31. */
  32. /**
  33. * @category Zend
  34. * @package Zend_Controller
  35. * @subpackage UnitTests
  36. * @copyright Copyright (c) 2005-2015 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_Plugin
  40. */
  41. class Zend_Controller_Plugin_PutHandlerTest extends PHPUnit_Framework_TestCase
  42. {
  43. /**
  44. * Request object
  45. * @var Zend_Controller_Request_Http
  46. */
  47. public $request;
  48. /**
  49. * Error handler plugin
  50. * @var Zend_Controller_Plugin_PutHandler
  51. */
  52. public $plugin;
  53. /**
  54. * Runs the test methods of this class.
  55. *
  56. * @access public
  57. * @static
  58. */
  59. public static function main()
  60. {
  61. $suite = new PHPUnit_Framework_TestSuite("Zend_Controller_Plugin_PutHandlerTest");
  62. $result = PHPUnit_TextUI_TestRunner::run($suite);
  63. }
  64. /**
  65. * Sets up the fixture, for example, open a network connection.
  66. * This method is called before a test is executed.
  67. *
  68. * @access protected
  69. */
  70. protected function setUp()
  71. {
  72. Zend_Controller_Front::getInstance()->resetInstance();
  73. $this->request = new Zend_Controller_Request_HttpTestCase();
  74. $this->plugin = new Zend_Controller_Plugin_PutHandler();
  75. $this->plugin->setRequest($this->request);
  76. }
  77. public function test_marshall_PUT_body_as_params()
  78. {
  79. $this->request->setMethod('PUT');
  80. $this->request->setRawBody('param1=value1&param2=value2');
  81. $this->plugin->preDispatch($this->request);
  82. $this->assertEquals('value1', $this->request->getParam('param1'));
  83. $this->assertEquals('value2', $this->request->getParam('param2'));
  84. }
  85. }
  86. // Call Zend_Controller_Plugin_PutHandlerTest::main() if this source file is executed directly.
  87. if (PHPUnit_MAIN_METHOD == "Zend_Controller_Plugin_PutHandlerTest::main") {
  88. Zend_Controller_Plugin_PutHandlerTest::main();
  89. }