ApnsProxy.php 2.2 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_Mobile
  17. * @subpackage Push
  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. /** Zend_Mobile_Push_Apns **/
  23. require_once 'Zend/Mobile/Push/Apns.php';
  24. /**
  25. * Apns Test Proxy
  26. * This class is utilized for unit testing purposes
  27. *
  28. * @category Zend
  29. * @package Zend_Mobile
  30. * @subpackage Push
  31. */
  32. class Zend_Mobile_Push_Test_ApnsProxy extends Zend_Mobile_Push_Apns
  33. {
  34. /**
  35. * Read Response
  36. *
  37. * @var string
  38. */
  39. protected $_readResponse;
  40. /**
  41. * Write Response
  42. *
  43. * @var mixed
  44. */
  45. protected $_writeResponse;
  46. /**
  47. * Set the Response
  48. *
  49. * @param string $str
  50. */
  51. public function setReadResponse($str) {
  52. $this->_readResponse = $str;
  53. }
  54. /**
  55. * Set the write response
  56. *
  57. * @param mixed $resp
  58. * @return void
  59. */
  60. public function setWriteResponse($resp)
  61. {
  62. $this->_writeResponse = $resp;
  63. }
  64. /**
  65. * Connect
  66. *
  67. * @return true
  68. */
  69. protected function _connect($uri) {
  70. return true;
  71. }
  72. /**
  73. * Return Response
  74. *
  75. * @param string $length
  76. * @return string
  77. */
  78. protected function _read($length) {
  79. $ret = substr($this->_readResponse, 0, $length);
  80. $this->_readResponse = null;
  81. return $ret;
  82. }
  83. /**
  84. * Write and Return Length
  85. *
  86. * @param string $payload
  87. * @return int
  88. */
  89. protected function _write($payload) {
  90. $ret = $this->_writeResponse;
  91. $this->_writeResponse = null;
  92. return (null === $ret) ? strlen($payload) : $ret;
  93. }
  94. }