Zend_Service_Amazon_Ec2_Instance_Reserved = new Zend_Service_Amazon_Ec2_Instance_Reserved('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_Instance_Reserved::setHttpClient($client);
}
/**
* Cleans up the environment after running a test.
*/
protected function tearDown()
{
unset($this->adapter);
$this->Zend_Service_Amazon_Ec2_Instance_Reserved = null;
parent::tearDown();
}
/**
* Tests Zend_Service_Amazon_Ec2_Instance_Reserved->describeInstances()
*/
public function testDescribeInstances()
{
$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"
." 4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8\r\n"
." m1.small\r\n"
." us-east-1a\r\n"
." 12\r\n"
." 0.00\r\n"
." 0.00\r\n"
." 19\r\n"
." m1.small offering in us-east-1a\r\n"
." Active\r\n"
."
\r\n"
." \r\n"
."";
$this->adapter->setResponse($rawHttpResponse);
$return = $this->Zend_Service_Amazon_Ec2_Instance_Reserved->describeInstances('4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8');
$arrReturn = array(
array(
"reservedInstancesId" => "4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8",
"instanceType" => "m1.small",
"availabilityZone" => "us-east-1a",
"duration" => "12",
"fixedPrice" => "0.00",
"usagePrice" => "0.00",
"productDescription" => "m1.small offering in us-east-1a",
"instanceCount" => "19",
"state" => "Active"
)
);
$this->assertSame($arrReturn, $return);
}
/**
* Tests Zend_Service_Amazon_Ec2_Instance_Reserved->describeOfferings()
*/
public function testDescribeOfferings()
{
$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"
." 4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8\r\n"
." m1.small\r\n"
." us-east-1a\r\n"
." 12\r\n"
." 0.00\r\n"
." 0.00\r\n"
." m1.small offering in us-east-1a\r\n"
."
\r\n"
." \r\n"
."";
$this->adapter->setResponse($rawHttpResponse);
$return = $this->Zend_Service_Amazon_Ec2_Instance_Reserved->describeOfferings();
$arrReturn = array(
array(
"reservedInstancesOfferingId" => "4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8",
"instanceType" => "m1.small",
"availabilityZone" => "us-east-1a",
"duration" => "12",
"fixedPrice" => "0.00",
"usagePrice" => "0.00",
"productDescription" => "m1.small offering in us-east-1a",
)
);
$this->assertSame($arrReturn, $return);
}
/**
* Tests Zend_Service_Amazon_Ec2_Instance_Reserved->purchaseOffering()
*/
public function testPurchaseOffering()
{
$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"
." 4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8\r\n"
."";
$this->adapter->setResponse($rawHttpResponse);
$return = $this->Zend_Service_Amazon_Ec2_Instance_Reserved->purchaseOffering('4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8');
$this->assertSame('4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8', $return);
}
}