addResponse() public method

Adds a response to the stack of responses.
public addResponse ( string | resourse $body, string $code = 200, string $uri = '', array $headers = [] ) : Horde_Http_Response_Mock
$body string | resourse The response body content.
$code string The response code.
$uri string The request uri.
$headers array Response headers. This can be one string representing the whole header or an array of strings with one string per header line.
return Horde_Http_Response_Mock The response.
Example #1
0
 public function testAddResponseHeader()
 {
     $mock = new Horde_Http_Request_Mock();
     $mock->addResponse('Test', 404, 'http://example.org', array('test: TEST'));
     $client = new Horde_Http_Client(array('request' => $mock));
     $this->assertEquals('TEST', $client->get()->getHeader('test'));
 }
Example #2
0
 /**
  * @expectedException Horde_Push_Exception
  */
 public function testBadResponse()
 {
     $push = new Horde_Push();
     $request = new Horde_Http_Request_Mock();
     $request->addResponse('Auth=X');
     $request->addResponse('', 201);
     $client = new Horde_Http_Client(array('request' => $request));
     $result = $push->addRecipient(new Horde_Push_Recipient_Blogger($client, array('url' => 'http://blogger.com', 'username' => 'test', 'password' => 'pass')))->setSummary('BLOG')->push();
 }