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