Zend_Service_Amazon_Ec2_Region = new Zend_Service_Amazon_Ec2_Region('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_Region::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 testDescribeSingleRegion() { $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-1\r\n" . " us-east-1.ec2.amazonaws.com\r\n" . " \r\n" . " \r\n" . ""; $this->adapter->setResponse($rawHttpResponse); $response = $this->Zend_Service_Amazon_Ec2_Region->describe('us-east-1'); $arrRegion = array( array( 'regionName' => 'us-east-1', 'regionUrl' => 'us-east-1.ec2.amazonaws.com' ) ); $this->assertSame($arrRegion, $response); } public function testDescribeMultipleRegions() { $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-1\r\n" . " us-east-1.ec2.amazonaws.com\r\n" . " \r\n" . " \r\n" . " us-west-1\r\n" . " us-west-1.ec2.amazonaws.com\r\n" . " \r\n" . " \r\n" . ""; $this->adapter->setResponse($rawHttpResponse); $response = $this->Zend_Service_Amazon_Ec2_Region->describe(array('us-east-1','us-west-1')); $arrRegion = array( array( 'regionName' => 'us-east-1', 'regionUrl' => 'us-east-1.ec2.amazonaws.com' ), array( 'regionName' => 'us-west-1', 'regionUrl' => 'us-west-1.ec2.amazonaws.com' ) ); $this->assertSame($arrRegion, $response); } }