本文整理汇总了PHP中Zend\Http\Client\Adapter\Test类的典型用法代码示例。如果您正苦于以下问题:PHP Test类的具体用法?PHP Test怎么用?PHP Test使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Test类的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: 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));
*
*/
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: getClient
/**
* Load HTTP client w/ fixture
*
* @param string $fixture Fixture name
*
* @return HttpClient
*/
protected function getClient($fixture)
{
$file = realpath(__DIR__ . '/../../../../fixtures/wikipedia/' . $fixture);
$adapter = new TestAdapter();
$adapter->setResponse(file_get_contents($file));
$client = new HttpClient();
$client->setAdapter($adapter);
return $client;
}
示例7: testRetrieve
public function testRetrieve()
{
$mock = $this->getMock('WebArchive\\Provider\\ProviderInterface');
$mock->expects($this->once())->method('generateSnapshots')->will($this->returnValue(true));
$client = new Client(new Request(null), $mock);
$adapter = new TestAdapter();
$adapter->setResponse(new Response());
$client->getClient()->setAdapter($adapter);
$this->assertTrue($client->retrieve());
}
示例8: 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));
}
}
示例9: testHttpError
/**
* Result is not HTTP/1.1 200
*/
public function testHttpError()
{
$client = new Client();
$adapter = new Test();
$adapter->setResponse(file_get_contents(__DIR__ . '/../data/google-map-response/03.txt'));
$client->setAdapter($adapter);
$map = new GoogleMap($client);
$result = $map->request('My address');
$this->assertNull($result->lat);
$this->assertNull($result->lng);
}
示例10: getClient
/**
* Load WorldCatUtils client w/ fixture
*
* @param string $fixture Fixture name
* @param bool $silent Use silent mode?
*
* @return WorldCatUtils
*/
protected function getClient($fixture = null, $silent = true)
{
$client = new HttpClient();
if (null !== $fixture) {
$adapter = new TestAdapter();
$file = realpath(__DIR__ . '/../../../../fixtures/worldcat/' . $fixture);
$adapter->setResponse(file_get_contents($file));
$client->setAdapter($adapter);
}
return new WorldCatUtils('dummy', $client, $silent);
}
示例11: 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']);
}
}
示例12: testUpdateAddressFormatsUsesProgresAdapter
/**
* @covers ::updateAddressFormats
*/
public function testUpdateAddressFormatsUsesProgresAdapter()
{
$testAdapter = new HttpTestAdapter();
$testAdapter->setResponse([(new HttpResponse())->setContent('empty'), (new HttpResponse())->setContent('{"name": "ZZ"}')]);
$httpClient = new HttpClient();
$httpClient->setAdapter($testAdapter);
$progressAdapter = $this->getMock('Zend\\ProgressBar\\Adapter\\AbstractAdapter');
$progressAdapter->expects($this->any())->method('notify')->with($this->logicalOr($this->equalTo(0.0), $this->equalTo(1.0)), $this->equalTo(1.0));
$maintenanceService = new MaintenanceService($this->options, $httpClient);
$maintenanceService->updateAddressFormats($progressAdapter);
}
示例13: testNot200ResponseCode
/**
* Data is OK, but the response header
* is HTTP/1.1 404 Not Found
*/
public function testNot200ResponseCode()
{
$client = new Client();
$adapter = new Test();
$adapter->setResponse(file_get_contents(__DIR__ . '/../data/ja-response/03.txt'));
$client->setAdapter($adapter);
$map = new JaMap($client);
$result1 = $map->request("Hringbraut 107, 101 Reykjavík");
$this->assertNull($result1->lat);
$this->assertNull($result1->lng);
}
示例14: generateSnapshots
/**
* @return \WebArchive\SnapshotCollection
*/
private function generateSnapshots()
{
$uri = 'http://pokap.io/';
$provider = new MementoProvider();
$client = new Client($provider->createUrlRequest($uri));
$response = new Response();
$response->setContent(implode(gzfile(__DIR__ . '/fixtures/pokap.io-memento.gz')));
$adapter = new TestAdapter();
$adapter->setResponse($response);
$client->setAdapter($adapter);
return $provider->generateSnapshots($client->send(), $uri);
}
示例15: generateSnapshots
/**
* @param int $year
*
* @return \WebArchive\SnapshotCollection
*/
private function generateSnapshots($year)
{
$uri = 'http://archive.org/';
$provider = new WayBackProvider($year);
$client = new Client($provider->createUrlRequest($uri));
$response = new Response();
$response->setContent(implode(gzfile(__DIR__ . '/fixtures/archive.org-' . $year . '.html.gz')));
$adapter = new TestAdapter();
$adapter->setResponse($response);
$client->setAdapter($adapter);
return $provider->generateSnapshots($client->send(), $uri);
}