| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- <?php
- /**
- * 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
- * @package Zend_Service_Amazon
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id$
- */
- require_once 'Zend/Service/Amazon/Ec2/Instance/Reserved.php';
- require_once 'Zend/Http/Client.php';
- require_once 'Zend/Http/Client/Adapter/Test.php';
- /**
- * Zend_Service_Amazon_Ec2_Instance_Reserved test case.
- * @todo Should this class be named Zend_Service_Amazon_Ec2_Instance_ReservedTest?
- *
- * @category Zend
- * @package Zend_Service_Amazon
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @group Zend_Service
- * @group Zend_Service_Amazon
- * @group Zend_Service_Amazon_Ec2
- */
- class InstanceReservedTest extends PHPUnit_Framework_TestCase
- {
- /**
- * @var Zend_Service_Amazon_Ec2_Instance_Reserved
- */
- private $Zend_Service_Amazon_Ec2_Instance_Reserved;
- /**
- * Prepares the environment before running a test.
- */
- protected function setUp()
- {
- parent::setUp();
- $this->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"
- ."<DescribeReservedInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
- ." <reservedInstancesSet>\r\n"
- ." <item>\r\n"
- ." <reservedInstancesId>4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8</reservedInstancesId>\r\n"
- ." <instanceType>m1.small</instanceType>\r\n"
- ." <availabilityZone>us-east-1a</availabilityZone>\r\n"
- ." <duration>12</duration>\r\n"
- ." <usagePrice>0.00</usagePrice>\r\n"
- ." <fixedPrice>0.00</fixedPrice>\r\n"
- ." <instanceCount>19</instanceCount>\r\n"
- ." <productDescription>m1.small offering in us-east-1a</productDescription>\r\n"
- ." <state>Active</state>\r\n"
- ." </item>\r\n"
- ." </reservedInstancesSet>\r\n"
- ."</DescribeReservedInstancesResponse>";
- $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"
- ."<DescribeReservedInstancesOfferingsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
- ." <reservedInstancesOfferingsSet>\r\n"
- ." <item>\r\n"
- ." <reservedInstancesOfferingId>4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8</reservedInstancesOfferingId>\r\n"
- ." <instanceType>m1.small</instanceType>\r\n"
- ." <availabilityZone>us-east-1a</availabilityZone>\r\n"
- ." <duration>12</duration>\r\n"
- ." <usagePrice>0.00</usagePrice>\r\n"
- ." <fixedPrice>0.00</fixedPrice>\r\n"
- ." <productDescription>m1.small offering in us-east-1a</productDescription>\r\n"
- ." </item>\r\n"
- ." </reservedInstancesOfferingsSet>\r\n"
- ."</DescribeReservedInstancesOfferingsResponse>";
- $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"
- ."<PurchaseReservedInstancesOfferingResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n"
- ." <reservedInstancesId>4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8</reservedInstancesId>\r\n"
- ."</PurchaseReservedInstancesOfferingResponse>";
- $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);
- }
- }
|