当前位置: 首页>>代码示例>>PHP>>正文


PHP Adapter\Test类代码示例

本文整理汇总了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);
 }
开发者ID:robborocks,项目名称:ZendService_Amazon,代码行数:10,代码来源:InstanceReservedTest.php

示例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));
     *
     */
 }
开发者ID:robertodormepoco,项目名称:zf2,代码行数:59,代码来源:FactoryTest.php

示例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);
 }
开发者ID:robborocks,项目名称:ZendService_Amazon,代码行数:8,代码来源:RegionTest.php

示例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);
 }
开发者ID:robertodormepoco,项目名称:zf2,代码行数:11,代码来源:InstanceWindowsTest.php

示例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);
 }
开发者ID:guenterh,项目名称:vufind,代码行数:8,代码来源:CloudWatchTest.php

示例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;
 }
开发者ID:bbeckman,项目名称:NDL-VuFind2,代码行数:16,代码来源:WikipediaTest.php

示例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());
 }
开发者ID:pokap,项目名称:webarchive,代码行数:10,代码来源:ClientTest.php

示例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));
     }
 }
开发者ID:robertodormepoco,项目名称:zf2,代码行数:15,代码来源:OfflineTest.php

示例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);
 }
开发者ID:bix0r,项目名称:Stjornvisi,代码行数:14,代码来源:GoogleMapTest.php

示例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);
 }
开发者ID:grharry,项目名称:vufind,代码行数:19,代码来源:WorldCatUtilsTest.php

示例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']);
     }
 }
开发者ID:guenterh,项目名称:vufind,代码行数:11,代码来源:AvailabilityZonesTest.php

示例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);
 }
开发者ID:DavidHavl,项目名称:Ajasta,代码行数:14,代码来源:MaintenanceServiceTest.php

示例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);
 }
开发者ID:bix0r,项目名称:Stjornvisi,代码行数:15,代码来源:JaMapTest.php

示例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);
 }
开发者ID:pokap,项目名称:webarchive,代码行数:15,代码来源:MementoProviderTest.php

示例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);
 }
开发者ID:pokap,项目名称:webarchive,代码行数:17,代码来源:WayBackProviderTest.php


注:本文中的Zend\Http\Client\Adapter\Test类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。