PutHandlerTest.php 3.1 KB

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