Http/Client/Adapter/Test.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Http  
Subpackage
Client_Adapter  
Version
$Id: Test.php 24593 2012-01-05 20:35:02Z matthew $  

\Zend_Http_Client_Adapter_Test

Package: Zend\Http\Client\Adapter
A testing-purposes adapter.

Should be used to test all components that rely on Zend_Http_Client, without actually performing an HTTP request. You should instantiate this object manually, and then set it as the client's adapter. Then, you can set the expected response using the setResponse() method.

Implements
\Zend_Http_Client_Adapter_Interface
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Properties

>VPropertyprotectedboolean $_nextRequestWillFail = false
Wether or not the next request will fail with an exception
Default valuefalseDetails
Type
boolean
>VPropertyprotectedarray $config = array()
Parameters array
Default valuearray()Details
Type
array
>VPropertyprotectedinteger $responseIndex = 0
Current position in the response buffer
Default value0Details
Type
integer
>VPropertyprotectedarray $responses = array("HTTP/1.1 400 Bad Request\r\n\r\n")
Buffer of responses to be returned by the read() method.

Can be set using setResponse() and addResponse().

Default valuearray("HTTP/1.1 400 Bad Request\r\n\r\n")Details
Type
array

Methods

methodpublic__construct() : void

Adapter constructor, currently empty.

Config is set using setConfig()

methodpublicaddResponse(string $response) : void

Add another response to the response buffer.

Parameters
NameTypeDescription
$responsestring

Zend_Http_Response|$response

methodpublicclose() : void

Close the connection (dummy)

methodpublicconnect(string $host, int $port = 80, boolean $secure = false) : void

Connect to the remote server

Parameters
NameTypeDescription
$hoststring
$portint
$secureboolean
Throws
ExceptionDescription
\Zend_Http_Client_Adapter_Exception
methodpublicgetConfig() : array

Retrieve the array of all configuration options

Returns
TypeDescription
array
methodpublicread() : string

Return the response set in $this->setResponse()

Returns
TypeDescription
string
methodpublicsetConfig(\Zend_Config $config = array()) : void

Set the configuration array for the adapter

Parameters
NameTypeDescription
$config\Zend_Config

| array $config

methodpublicsetNextRequestWillFail(boolean $flag) : \Zend_Http_Client_Adapter_Test

Set the nextRequestWillFail flag

Parameters
NameTypeDescription
$flagboolean
Returns
TypeDescription
\Zend_Http_Client_Adapter_Test
methodpublicsetResponse(\Zend_Http_Response | array | string $response) : void

Set the HTTP response(s) to be returned by this adapter

Parameters
NameTypeDescription
$response\Zend_Http_Response | array | string
methodpublicsetResponseIndex(integer $index) : void

Sets the position of the response buffer.

Selects which response will be returned on the next call to read().

Parameters
NameTypeDescription
$indexinteger
methodpublicwrite(string $method, \Zend_Uri_Http $uri, string $http_ver = '1.1', array $headers = array(), string $body = '') : string

Send request to the remote server

Parameters
NameTypeDescription
$methodstring
$uri\Zend_Uri_Http
$http_verstring
$headersarray
$bodystring
Returns
TypeDescription
stringRequest as string
Documentation was generated by phpDocumentor 2.0.0a12.