MockHttpClient.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_Gdata
  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. require_once 'Zend/Http/Client/Adapter/Test.php';
  23. /**
  24. * @category Zend
  25. * @package Zend_Gdata
  26. * @subpackage UnitTests
  27. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. */
  30. class Test_Zend_Gdata_MockHttpClient_Request
  31. {
  32. public $methd;
  33. public $uri;
  34. public $http_ver;
  35. public $headers;
  36. public $body;
  37. }
  38. /**
  39. * @category Zend
  40. * @package Zend_Gdata
  41. * @subpackage UnitTests
  42. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  43. * @license http://framework.zend.com/license/new-bsd New BSD License
  44. */
  45. class Test_Zend_Gdata_MockHttpClient extends Zend_Http_Client_Adapter_Test
  46. {
  47. protected $_requests;
  48. public function __construct()
  49. {
  50. parent::__construct();
  51. $this->_requests = array();
  52. }
  53. public function popRequest()
  54. {
  55. if (count($this->_requests))
  56. return array_pop($this->_requests);
  57. else
  58. return NULL;
  59. }
  60. public function write($method,
  61. $uri,
  62. $http_ver = '1.1',
  63. $headers = array(),
  64. $body = '')
  65. {
  66. $request = new Test_Zend_Gdata_MockHttpClient_Request();
  67. $request->method = $method;
  68. $request->uri = $uri;
  69. $request->http_ver = $http_ver;
  70. $request->headers = $headers;
  71. $request->body = $body;
  72. array_push($this->_requests, $request);
  73. return parent::write($method, $uri, $http_ver, $headers, $body);
  74. }
  75. }