Zend_Service_Amazon_Ec2_Availabilityzones = new Zend_Service_Amazon_Ec2_Availabilityzones('access_key', 'secret_access_key');
$adapter = new Zend_Http_Client_Adapter_Test();
$client = new Zend_Http_Client(null, array(
'adapter' => $adapter
));
$this->adapter = $adapter;
Zend_Service_Amazon_Ec2_Availabilityzones::setHttpClient($client);
}
/**
* Cleans up the environment after running a test.
*/
protected function tearDown()
{
unset($this->adapter);
$this->Zend_Service_Amazon_Ec2_Availabilityzones = null;
parent::tearDown();
}
public function testDescribeSingleAvailabilityZone()
{
$rawHttpResponse = "HTTP/1.1 200 OK\r\n"
. "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
. "Server: hi\r\n"
. "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
. "Status: 200 OK\r\n"
. "Content-type: application/xml; charset=utf-8\r\n"
. "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
. "Connection: close\r\n"
. "\r\n"
. "\r\n"
. " \r\n"
. " - \r\n"
. " us-east-1a\r\n"
. " available\r\n"
. "
\r\n"
. " \r\n"
. "";
$this->adapter->setResponse($rawHttpResponse);
$response = $this->Zend_Service_Amazon_Ec2_Availabilityzones->describe('us-east-1a');
$this->assertType('array', $response);
$this->assertEquals('us-east-1a', $response[0]['zoneName']);
$this->assertEquals('available', $response[0]['zoneState']);
}
public function testDescribeMultipleAvailabilityZones()
{
$rawHttpResponse = "HTTP/1.1 200 OK\r\n"
. "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
. "Server: hi\r\n"
. "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n"
. "Status: 200 OK\r\n"
. "Content-type: application/xml; charset=utf-8\r\n"
. "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
. "Connection: close\r\n"
. "\r\n"
. "\r\n"
. " \r\n"
. " - \r\n"
. " us-east-1a\r\n"
. " available\r\n"
. "
\r\n"
. " - \r\n"
. " us-east-1b\r\n"
. " available\r\n"
. "
\r\n"
. " - \r\n"
. " us-east-1c\r\n"
. " available\r\n"
. "
\r\n"
. " \r\n"
. "";
$this->adapter->setResponse($rawHttpResponse);
$response = $this->Zend_Service_Amazon_Ec2_Availabilityzones->describe();
$this->assertType('array', $response);
$arrExpected = array('us-east-1a', 'us-east-1b', 'us-east-1c');
foreach ($response as $k => $node) {
$this->assertEquals($arrExpected[$k], $node['zoneName']);
}
}
}