本文整理汇总了PHP中Zend\Http\Client\Adapter\Test::setResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP Test::setResponse方法的具体用法?PHP Test::setResponse怎么用?PHP Test::setResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Http\Client\Adapter\Test
的用法示例。
在下文中一共展示了Test::setResponse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPurchaseOffering
/**
* 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->httpClientTestAdapter->setResponse($rawHttpResponse);
$return = $this->instance->purchaseOffering('4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8');
$this->assertSame('4b2293b4-5813-4cc8-9ce3-1957fc1dcfc8', $return);
}
示例2: testZF8149
public function testZF8149()
{
$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" . "<GetMetricStatisticsResponse xmlns=\"http://monitoring.amazonaws.com/doc/2009-05-15/\">\r\n" . " <GetMetricStatisticsResult>\r\n" . " <Datapoints>\r\n" . " <member>\r\n" . " <Timestamp>2009-11-19T21:52:00Z</Timestamp>\r\n" . " <Unit>Percent</Unit>\r\n" . " <Samples>1.0</Samples>\r\n" . " <Average>0.09</Average>\r\n" . " </member>\r\n" . " <member>\r\n" . " <Timestamp>2009-11-19T21:55:00Z</Timestamp>\r\n" . " <Unit>Percent</Unit>\r\n" . " <Samples>1.0</Samples>\r\n" . " <Average>0.18</Average>\r\n" . " </member>\r\n" . " <member>\r\n" . " <Timestamp>2009-11-19T21:54:00Z</Timestamp>\r\n" . " <Unit>Percent</Unit>\r\n" . " <Samples>1.0</Samples>\r\n" . " <Average>0.09</Average>\r\n" . " </member>\r\n" . " <member>\r\n" . " <Timestamp>2009-11-19T21:51:00Z</Timestamp>\r\n" . " <Unit>Percent</Unit>\r\n" . " <Samples>1.0</Samples>\r\n" . " <Average>0.18</Average>\r\n" . " </member>\r\n" . " <member>\r\n" . " <Timestamp>2009-11-19T21:53:00Z</Timestamp>\r\n" . " <Unit>Percent</Unit>\r\n" . " <Samples>1.0</Samples>\r\n" . " <Average>0.09</Average>\r\n" . " </member>\r\n" . " </Datapoints>\r\n" . " <Label>CPUUtilization</Label>\r\n" . " </GetMetricStatisticsResult>\r\n" . " <ResponseMetadata>\r\n" . " <RequestId>6fb864fd-d557-11de-ac37-475775222f21</RequestId>\r\n" . " </ResponseMetadata>\r\n" . "</GetMetricStatisticsResponse>";
$this->httpClientTestAdapter->setResponse($rawHttpResponse);
$return = $this->cloudWatchInstance->getMetricStatistics(array('MeasureName' => 'CPUUtilization', 'Statistics' => array('Average'), 'Dimensions' => array('InstanceId' => 'i-93ba31fa'), 'StartTime' => '2009-11-19T21:51:57+00:00', 'EndTime' => '2009-11-19T21:56:57+00:00'));
$arrReturn = array('label' => 'CPUUtilization', 'datapoints' => array(0 => array('Timestamp' => '2009-11-19T21:52:00Z', 'Unit' => 'Percent', 'Samples' => '1.0', 'Average' => '0.09'), 1 => array('Timestamp' => '2009-11-19T21:55:00Z', 'Unit' => 'Percent', 'Samples' => '1.0', 'Average' => '0.18'), 2 => array('Timestamp' => '2009-11-19T21:54:00Z', 'Unit' => 'Percent', 'Samples' => '1.0', 'Average' => '0.09'), 3 => array('Timestamp' => '2009-11-19T21:51:00Z', 'Unit' => 'Percent', 'Samples' => '1.0', 'Average' => '0.18'), 4 => array('Timestamp' => '2009-11-19T21:53:00Z', 'Unit' => 'Percent', 'Samples' => '1.0', 'Average' => '0.09')));
$this->assertSame($arrReturn, $return);
}
示例3: testDescribeBundle
/**
* Tests Zend_Service_Amazon_Ec2_Instance_Windows->describeBundle()
*/
public function testDescribeBundle()
{
$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" . "<DescribeBundleTasksResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . " <bundleInstanceTasksSet>\r\n" . " <item>\r\n" . " <instanceId>i-12345678</instanceId>\r\n" . " <bundleId>bun-cla322b9</bundleId>\r\n" . " <state>bundling</state>\r\n" . " <startTime>2008-10-07T11:41:50.000Z</startTime>\r\n" . " <updateTime>2008-10-07T11:51:50.000Z</updateTime>\r\n" . " <progress>20%</progress>\r\n" . " <storage>\r\n" . " <S3>\r\n" . " <bucket>my-bucket</bucket>\r\n" . " <prefix>my-new-image</prefix>\r\n" . " </S3>\r\n" . " </storage>\r\n" . " </item>\r\n" . " </bundleInstanceTasksSet>\r\n" . "</DescribeBundleTasksResponse>";
$this->httpClientTestAdapter->setResponse($rawHttpResponse);
$return = $this->instance->describeBundle('bun-cla322b9');
$arrReturn = array(array("instanceId" => "i-12345678", "bundleId" => "bun-cla322b9", "state" => "bundling", "startTime" => "2008-10-07T11:41:50.000Z", "updateTime" => "2008-10-07T11:51:50.000Z", "progress" => "20%", "storage" => array("s3" => array("bucket" => "my-bucket", "prefix" => "my-new-image"))));
$this->assertSame($arrReturn, $return);
}
示例4: testDescribeMultipleRegions
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" . "<DescribeRegionsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . " <regionInfo>\r\n" . " <item>\r\n" . " <regionName>us-east-1</regionName>\r\n" . " <regionUrl>us-east-1.ec2.amazonaws.com</regionUrl>\r\n" . " </item>\r\n" . " <item>\r\n" . " <regionName>us-west-1</regionName>\r\n" . " <regionUrl>us-west-1.ec2.amazonaws.com</regionUrl>\r\n" . " </item>\r\n" . " </regionInfo>\r\n" . "</DescribeRegionsResponse>";
$this->httpClientTestAdapter->setResponse($rawHttpResponse);
$response = $this->regionInstance->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);
}
示例5: setUp
/**
* Sets up this test case
*
* @return void
*/
public function setUp()
{
$this->gogrid = new Server('foo', 'bar');
$this->httpClientAdapterTest = new \Zend\Http\Client\Adapter\Test();
$this->gogrid->getHttpClient()->setAdapter($this->httpClientAdapterTest);
$filename = __DIR__ . '/_files/' . $this->getName() . '.response';
if (file_exists($filename)) {
$this->httpClientAdapterTest->setResponse($this->loadResponse($filename));
}
}
示例6: testDescribeMultipleAvailabilityZones
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" . "<DescribeAvailabilityZonesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . " <availabilityZoneInfo>\r\n" . " <item>\r\n" . " <zoneName>us-east-1a</zoneName>\r\n" . " <zoneState>available</zoneState>\r\n" . " </item>\r\n" . " <item>\r\n" . " <zoneName>us-east-1b</zoneName>\r\n" . " <zoneState>available</zoneState>\r\n" . " </item>\r\n" . " <item>\r\n" . " <zoneName>us-east-1c</zoneName>\r\n" . " <zoneState>available</zoneState>\r\n" . " </item>\r\n" . " </availabilityZoneInfo>\r\n" . "</DescribeAvailabilityZonesResponse>";
$this->httpClientTestAdapter->setResponse($rawHttpResponse);
$response = $this->availabilityZones->describe();
$this->assertInternalType('array', $response);
$arrExpected = array('us-east-1a', 'us-east-1b', 'us-east-1c');
foreach ($response as $k => $node) {
$this->assertEquals($arrExpected[$k], $node['zoneName']);
}
}
示例7: setUp
/**
* Set up the test case
*
* @return void
*/
public function setUp()
{
$this->rackspace = new RackspaceFiles('foo', 'bar');
$this->httpClientAdapterTest = new HttpTest();
$this->rackspace->getHttpClient()->setAdapter($this->httpClientAdapterTest);
// authentication (from a file)
$this->httpClientAdapterTest->setResponse(self::loadResponse('../../_files/testAuthenticate'));
$this->assertTrue($this->rackspace->authenticate(), 'Authentication failed');
$this->metadata = array('foo' => 'bar', 'foo2' => 'bar2');
$this->metadata2 = array('hello' => 'world');
// load the HTTP response (from a file)
$this->httpClientAdapterTest->setResponse($this->loadResponse($this->getName()));
}
示例8: testJobList
/**
* testJobList
*
* @return void
*/
public function testJobList()
{
$this->_job->getHttpClient()->setAdapter($this->_httpClientAdapterTest);
$this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__));
$joblist = $this->_job->getList();
$this->assertEquals(count($joblist), 2);
$this->assertEquals($joblist->getStatus(), 'success');
$job = $joblist[0];
$this->assertEquals($job->getAttribute('id'), '583288');
$this->assertEquals($job->getAttribute('owner'), 'enrico@zend.com');
$command = $job->getAttribute('command');
$this->assertEquals($command['name'], 'DeleteVirtualServer');
$history = $job->getAttribute('history');
$this->assertEquals($history[0]['id'], '3303238');
$this->assertEquals(count($history), 4);
}
示例9: testRevokeSecurityGroupName
public function testRevokeSecurityGroupName()
{
$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" . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" . "<RevokeSecurityGroupIngressResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . " <return>true</return>\r\n" . "</RevokeSecurityGroupIngressResponse>\r\n";
$this->httpClientTestAdapter->setResponse($rawHttpResponse);
$return = $this->securitygroupsInstance->revokeGroup('MyGroup', 'groupname', '15333848');
$this->assertTrue($return);
}
示例10: testGroupPoolGetPhotosExceptionGroupIdInvalid
/**
* Ensures that groupPoolGetPhotos() throws an exception when an invalid group_id is given
*
* @return void
*/
public function testGroupPoolGetPhotosExceptionGroupIdInvalid()
{
$this->flickr->getRestClient()->getHttpClient()->setAdapter($this->httpClientAdapterTest);
$this->httpClientAdapterTest->setResponse($this->loadResponse(__FUNCTION__));
$this->setExpectedException('Zend\\Service\\Flickr\\Exception\\RuntimeException', 'Group not found');
$this->flickr->groupPoolGetPhotos('2e38a9d9425d7e2c9d0788455e9ccc61');
}
示例11: testResetAttribute
public function testResetAttribute()
{
$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" . "<ResetImageAttributeResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . " <return>true</return>\r\n" . "</ResetImageAttributeResponse>\r\n";
$this->httpClientTestAdapter->setResponse($rawHttpResponse);
$return = $this->ec2ImageInstance->resetAttribute('ami-61a54008', 'launchPermission');
$this->assertTrue($return);
}
示例12: testReleaseElasticIp
/**
* Tests Zend_Service_Amazon_Ec2_Elasticip->release()
*/
public function testReleaseElasticIp()
{
$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" . "<ReleaseAddressResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . " <return>true</return>\r\n" . "</ReleaseAddressResponse>";
$this->httpClientTestAdapter->setResponse($rawHttpResponse);
$return = $this->elasticip->release('67.202.55.255');
$this->assertTrue($return);
}
示例13: testGetAdapterWithConfig
public function testGetAdapterWithConfig()
{
$httptest = new HttpClientTest();
// Nirvanix adapter
$nirvanixConfig = ConfigFactory::fromFile(realpath(dirname(__FILE__) . '/_files/config/nirvanix.ini'), true);
$nirvanixConfig = $nirvanixConfig->toArray();
$nirvanixConfig[Nirvanix::HTTP_ADAPTER] = $httptest;
$doc = new \DOMDocument('1.0', 'utf-8');
$root = $doc->createElement('Response');
$responseCode = $doc->createElement('ResponseCode', 0);
$sessionTok = $doc->createElement('SessionToken', '54592180-7060-4D4B-BC74-2566F4B2F943');
$root->appendChild($responseCode);
$root->appendChild($sessionTok);
$doc->appendChild($root);
$body = $doc->saveXML();
$resp = HttpResponse::fromString("HTTP/1.1 200 OK\nContent-type: text/xml;charset=UTF-8\nDate: 0\n\n" . $body);
$httptest->setResponse($resp);
$nirvanixAdapter = Factory::getAdapter($nirvanixConfig);
$this->assertEquals('Zend\\Cloud\\StorageService\\Adapter\\Nirvanix', get_class($nirvanixAdapter));
// S3 adapter
$s3Config = ConfigFactory::fromFile(realpath(dirname(__FILE__) . '/_files/config/s3.ini'), true);
$s3Adapter = Factory::getAdapter($s3Config);
$this->assertEquals('Zend\\Cloud\\StorageService\\Adapter\\S3', get_class($s3Adapter));
// file system adapter
$fileSystemConfig = ConfigFactory::fromFile(realpath(dirname(__FILE__) . '/_files/config/filesystem.ini'), true);
$fileSystemAdapter = Factory::getAdapter($fileSystemConfig);
$this->assertEquals('Zend\\Cloud\\StorageService\\Adapter\\FileSystem', get_class($fileSystemAdapter));
// Azure adapter
/*
$azureConfig = ConfigFactory::fromFile(realpath(dirname(__FILE__) . '/_files/config/windowsazure.ini'), true);
$azureConfig = $azureConfig->toArray();
$azureContainer = $azureConfig[WindowsAzure::CONTAINER];
$azureConfig[WindowsAzure::HTTP_ADAPTER] = $httptest;
$q = "?";
$doc = new \DOMDocument('1.0', 'utf-8');
$root = $doc->createElement('EnumerationResults');
$acctName = $doc->createAttribute('AccountName');
$acctName->value = 'http://myaccount.blob.core.windows.net';
$root->appendChild($acctName);
$maxResults = $doc->createElement('MaxResults', 1);
$containers = $doc->createElement('Containers');
$container = $doc->createElement('Container');
$containerName = $doc->createElement('Name', $azureContainer);
$container->appendChild($containerName);
$containers->appendChild($container);
$root->appendChild($maxResults);
$root->appendChild($containers);
$doc->appendChild($root);
$body = $doc->saveXML();
$resp = HttpResponse::fromString("HTTP/1.1 200 OK\nContent-type: text/xml;charset=UTF-8\nx-ms-request-id: 0\n\n".$body);
$httptest->setResponse($resp);
$azureAdapter = Factory::getAdapter($azureConfig);
$this->assertEquals('Zend\Cloud\StorageService\Adapter\WindowsAzure', get_class($azureAdapter));
*
*/
}
示例14: testDeleteDoesNotFailOnValidKey
public function testDeleteDoesNotFailOnValidKey()
{
$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" . "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" . "<DeleteKeyPair xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . " <return>true</return>\r\n" . "</DeleteKeyPair>";
$this->httpClientTestAdapter->setResponse($rawHttpResponse);
$response = $this->keypairInstance->delete('example-key-name');
$this->assertInternalType('boolean', $response);
$this->assertTrue($response);
}
示例15: testUnmonitorInstance
public function testUnmonitorInstance()
{
$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" . "<UnmonitorInstancesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . " <instancesSet>" . " <item>" . " <instanceId>i-43a4412a</instanceId>" . " <monitoring>" . " <state>pending</state>" . " </monitoring>" . " </item>" . " </instancesSet>" . "</UnmonitorInstancesResponse>\r\n";
$this->httpClientTestAdapter->setResponse($rawHttpResponse);
$return = $this->instance->unmonitor('i-43a4412a');
$arrReturn = array(array('instanceid' => 'i-43a4412a', 'monitorstate' => 'pending'));
$this->assertSame($arrReturn, $return);
}