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


PHP Zend_Http_Client_Adapter_Test类代码示例

本文整理汇总了PHP中Zend_Http_Client_Adapter_Test的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Client_Adapter_Test类的具体用法?PHP Zend_Http_Client_Adapter_Test怎么用?PHP Zend_Http_Client_Adapter_Test使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Zend_Http_Client_Adapter_Test类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: shouldUnshortenAGivenShortenedUrl

 /**
  * @test
  */
 public function shouldUnshortenAGivenShortenedUrl()
 {
     $adapter = new Zend_Http_Client_Adapter_Test();
     $client = new Zend_Http_Client('http://adapter.org', array('adapter' => $adapter));
     $adapter->setResponse("HTTP/1.1 302 Found" . "\r\n" . "Location: http://zendframework.com" . "\r\n");
     $this->_service = new Recordshelf_Service_Isgd($client);
     $this->assertEquals('http://zendframework.com', $this->_service->unshorten('http://is.gd/1T35Q'));
 }
开发者ID:raphaelstolt,项目名称:isgd-api-client,代码行数:11,代码来源:IsgdTest.php

示例2: testGetAdapterWithConfig

 public function testGetAdapterWithConfig()
 {
     $httptest = new Zend_Http_Client_Adapter_Test();
     // Nirvanix adapter
     $nirvanixConfig = new Zend_Config_Ini(realpath(dirname(__FILE__) . '/_files/config/nirvanix.ini'));
     $nirvanixConfig = $nirvanixConfig->toArray();
     $nirvanixConfig[Zend_Cloud_StorageService_Adapter_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 = new Zend_Http_Response(200, array('Date' => 0), $body);
     $httptest->setResponse($resp);
     $nirvanixAdapter = Zend_Cloud_StorageService_Factory::getAdapter($nirvanixConfig);
     $this->assertEquals('Zend_Cloud_StorageService_Adapter_Nirvanix', get_class($nirvanixAdapter));
     // S3 adapter
     $s3Config = new Zend_Config_Ini(realpath(dirname(__FILE__) . '/_files/config/s3.ini'));
     $s3Adapter = Zend_Cloud_StorageService_Factory::getAdapter($s3Config);
     $this->assertEquals('Zend_Cloud_StorageService_Adapter_S3', get_class($s3Adapter));
     // file system adapter
     $fileSystemConfig = new Zend_Config_Ini(realpath(dirname(__FILE__) . '/_files/config/filesystem.ini'));
     $fileSystemAdapter = Zend_Cloud_StorageService_Factory::getAdapter($fileSystemConfig);
     $this->assertEquals('Zend_Cloud_StorageService_Adapter_FileSystem', get_class($fileSystemAdapter));
     // Azure adapter
     $azureConfig = new Zend_Config_Ini(realpath(dirname(__FILE__) . '/_files/config/windowsazure.ini'));
     $azureConfig = $azureConfig->toArray();
     $azureContainer = $azureConfig[Zend_Cloud_StorageService_Adapter_WindowsAzure::CONTAINER];
     $azureConfig[Zend_Cloud_StorageService_Adapter_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 = new Zend_Http_Response(200, array('x-ms-request-id' => 0), $body);
     $httptest->setResponse($resp);
     $azureAdapter = Zend_Cloud_StorageService_Factory::getAdapter($azureConfig);
     $this->assertEquals('Zend_Cloud_StorageService_Adapter_WindowsAzure', get_class($azureAdapter));
 }
开发者ID:sasezaki,项目名称:mirror-zf1-tests,代码行数:53,代码来源:FactoryTest.php

示例3: setUp

 /**
  * Set up the test case
  *
  * @return void
  */
 public function setUp()
 {
     $this->rackspace = new Zend_Service_Rackspace_Files('foo', 'bar');
     $this->httpClientAdapterTest = new Zend_Http_Client_Adapter_Test();
     $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()));
 }
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:18,代码来源:OfflineTest.php

示例4: setUp

 /**
  * Setup for each test
  */
 public function setUp()
 {
     $this->infrastructure = Zend_Cloud_Infrastructure_Factory::getAdapter(array(Zend_Cloud_Infrastructure_Factory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend_Cloud_Infrastructure_Adapter_Ec2', Zend_Cloud_Infrastructure_Adapter_Ec2::AWS_ACCESS_KEY => 'foo', Zend_Cloud_Infrastructure_Adapter_Ec2::AWS_SECRET_KEY => 'bar', Zend_Cloud_Infrastructure_Adapter_Ec2::AWS_REGION => 'us-east-1'));
     $this->httpClientAdapterTest = new Zend_Http_Client_Adapter_Test();
     // load the HTTP response (from a file)
     $shortClassName = substr(__CLASS__, strlen('Zend_Cloud_Infrastructure_Adapter_'));
     $filename = dirname(__FILE__) . '/_files/' . $shortClassName . '_' . $this->getName() . '.response';
     if (file_exists($filename)) {
         $this->httpClientAdapterTest->setResponse($this->loadResponse($filename));
     }
     $adapter = $this->infrastructure->getAdapter();
     $client = new Zend_Http_Client(null, array('adapter' => $this->httpClientAdapterTest));
     call_user_func(array($adapter, 'setHttpClient'), $client);
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:17,代码来源:Ec2Test.php

示例5: setUp

 /**
  * Setup for each test
  */
 public function setUp()
 {
     $this->infrastructure = Zend_Cloud_Infrastructure_Factory::getAdapter(array(Zend_Cloud_Infrastructure_Factory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend_Cloud_Infrastructure_Adapter_Rackspace', Zend_Cloud_Infrastructure_Adapter_Rackspace::RACKSPACE_USER => 'foo', Zend_Cloud_Infrastructure_Adapter_Rackspace::RACKSPACE_KEY => 'bar', Zend_Cloud_Infrastructure_Adapter_Rackspace::RACKSPACE_REGION => 'USA'));
     $this->httpClientAdapterTest = new Zend_Http_Client_Adapter_Test();
     $this->infrastructure->getAdapter()->getHttpClient()->setAdapter($this->httpClientAdapterTest);
     // load the HTTP response (from a file)
     $shortClassName = 'RackspaceTest';
     $filename = dirname(__FILE__) . '/_files/' . $shortClassName . '_' . $this->getName() . '.response';
     if (file_exists($filename)) {
         // authentication (from file)
         $content = dirname(__FILE__) . '/_files/' . $shortClassName . '_testAuthenticate.response';
         $this->httpClientAdapterTest->setResponse($this->loadResponse($content));
         $this->assertTrue($this->infrastructure->getAdapter()->authenticate(), 'Authentication failed');
         $this->httpClientAdapterTest->setResponse($this->loadResponse($filename));
     }
 }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:19,代码来源:RackspaceTest.php

示例6: getInfo

 /**
  * Private method that queries REST service and returns SimpleXML response set
  *
  * @param  string $service name of Audioscrobbler service file we're accessing
  * @param  string $params  parameters that we send to the service if needded
  * @throws Zend_Http_Client_Exception
  * @throws Zend_Service_Exception
  * @return SimpleXMLElement result set
  */
 private function getInfo($service, $params = null)
 {
     $service = (string) $service;
     $params = (string) $params;
     if ($params === '') {
         $this->_client->setUri("http://ws.audioscrobbler.com{$service}");
     } else {
         $this->_client->setUri("http://ws.audioscrobbler.com{$service}?{$params}");
     }
     if ($this->_testing) {
         /**
          * @see Zend_Http_Client_Adapter_Test
          */
         require_once 'Zend/Http/Client/Adapter/Test.php';
         $adapter = new Zend_Http_Client_Adapter_Test();
         $this->_client->setConfig(array('adapter' => $adapter));
         $adapter->setResponse($this->_testingResponse);
     }
     $request = $this->_client->request();
     $response = $request->getBody();
     if ($response == 'No such path') {
         throw new Zend_Http_Client_Exception('Could not find: ' . $this->_client->getUri());
     } else {
         if ($response == 'No user exists with this name.') {
             throw new Zend_Http_Client_Exception('No user exists with this name');
         } else {
             if ($request->isError()) {
                 throw new Zend_Http_Client_Exception('The web service ' . $this->_client->getUri() . ' returned the following status code: ' . $response->getStatus());
             }
         }
     }
     set_error_handler(array($this, '_errorHandler'));
     if (!($simpleXmlElementResponse = simplexml_load_string($response))) {
         restore_error_handler();
         /**
          * @see Zend_Service_Exception
          */
         require_once 'Zend/Service/Exception.php';
         $exception = new Zend_Service_Exception('Response failed to load with SimpleXML');
         $exception->error = $this->_error;
         $exception->response = $response;
         throw $exception;
     }
     restore_error_handler();
     return $simpleXmlElementResponse;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:55,代码来源:Audioscrobbler.php

示例7: testTagSearchBasic

 /**
  * Basic testing to ensure that tagSearch() works as expected
  *
  * @return void
  */
 public function testTagSearchBasic()
 {
     $this->_flickr->getRestClient()->getHttpClient()->setAdapter($this->_httpClientAdapterTest);
     $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__));
     $options = array('per_page' => 10, 'page' => 1, 'tag_mode' => 'or', 'extras' => 'license, date_upload, date_taken, owner_name, icon_server');
     $resultSet = $this->_flickr->tagSearch('php', $options);
     $this->assertEquals(4285, $resultSet->totalResultsAvailable);
     $this->assertEquals(10, $resultSet->totalResults());
     $this->assertEquals(10, $resultSet->totalResultsReturned);
     $this->assertEquals(1, $resultSet->firstResultPosition);
     $this->assertEquals(0, $resultSet->key());
     try {
         $resultSet->seek(-1);
     } catch (OutOfBoundsException $e) {
         $this->assertContains('Illegal index', $e->getMessage());
     }
     $resultSet->seek(9);
     try {
         $resultSet->seek(10);
     } catch (OutOfBoundsException $e) {
         $this->assertContains('Illegal index', $e->getMessage());
     }
     $resultSet->rewind();
     $resultSetIds = array('428222530', '427883929', '427884403', '427887192', '427883923', '427884394', '427883930', '427884398', '427883924', '427884401');
     $this->assertTrue($resultSet->valid());
     foreach ($resultSetIds as $resultSetId) {
         $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__ . "-result_{$resultSetId}"));
         $result = $resultSet->current();
         $this->assertTrue($result instanceof Zend_Service_Flickr_Result);
         $resultSet->next();
     }
     $this->assertFalse($resultSet->valid());
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:38,代码来源:FlickrTest.php

示例8: testGravatarExistsWithCache

 /**
  * @covers Robo47_Service_Gravatar::gravatarExists
  * @covers Robo47_Service_Gravatar::_getCacheId
  * @dataProvider gravatarExistsProvider
  */
 public function testGravatarExistsWithCache()
 {
     $cache = Zend_Cache::factory('Core', new Robo47_Cache_Backend_Array(), array('automatic_cleaning_factor' => 0), array('automatic_cleaning_factor' => 0));
     $options = array('cachePrefix' => 'foo_', 'cache' => $cache);
     $service = new Robo47_Service_Gravatar($options);
     // do first request
     $this->_adapter->setResponse(new Zend_Http_Response(404, array()));
     $this->assertSame(false, $service->gravatarExists('foo@example.com'));
     $cacheEntry = $cache->load($service->getCacheId('foo@example.com'));
     $this->assertEquals('false', $cacheEntry, 'wrong value in cache');
     // assert cache is used and no request is made
     $this->_adapter->setResponse(new Zend_Http_Response(200, array()));
     $this->assertSame(false, $service->gravatarExists('foo@example.com'));
     $cacheEntry = $cache->load($service->getCacheId('foo@example.com'));
     $this->assertEquals('false', $cacheEntry, 'wrong value in cache');
     // ignore cache for checking
     $this->_adapter->setResponse(new Zend_Http_Response(200, array()));
     $this->assertSame(true, $service->gravatarExists('foo@example.com', false));
     $cacheEntry = $cache->load($service->getCacheId('foo@example.com'));
     $this->assertEquals('true', $cacheEntry, 'wrong value in cache');
     // use cache for checking
     $this->_adapter->setResponse(new Zend_Http_Response(404, array()));
     $this->assertSame(true, $service->gravatarExists('foo@example.com'));
     $cacheEntry = $cache->load($service->getCacheId('foo@example.com'));
     $this->assertEquals('true', $cacheEntry, 'wrong value in cache');
     // ignore cache again for checking
     $this->_adapter->setResponse(new Zend_Http_Response(404, array()));
     $this->assertSame(false, $service->gravatarExists('foo@example.com', false));
     $cacheEntry = $cache->load($service->getCacheId('foo@example.com'));
     $this->assertEquals('false', $cacheEntry, 'wrong value in cache');
 }
开发者ID:robo47,项目名称:robo47-components,代码行数:36,代码来源:GravatarTest.php

示例9: testAuthenticateError

 /**
  * Test the authentication error (401 Unauthorized - Bad username or password)
  *
  * @return void
  */
 public function testAuthenticateError()
 {
     $this->_files->getHttpClient()->setAdapter($this->_httpClientAdapterTest);
     $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__));
     $this->assertFalse($this->_files->authenticate());
     $this->assertFalse($this->_files->isSuccessful());
     $this->assertEquals($this->_files->getErrorCode(), '401');
     $this->assertEquals($this->_files->getErrorMsg(), 'Bad username or password');
 }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:14,代码来源:OfflineTest.php

示例10: _importInvalid

 /**
  * Import an invalid feed
  */
 protected function _importInvalid($filename)
 {
     $response = new Zend_Http_Response(200, array(), file_get_contents("{$this->_feedDir}/{$filename}"));
     $this->_adapter->setResponse($response);
     try {
         $feed = Zend_Feed::import('http://localhost');
     } catch (Exception $e) {
     }
     $this->assertTrue($e instanceof Zend_Feed_Exception, 'Expected Zend_Feed_Exception to be thrown');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:13,代码来源:ImportTest.php

示例11: write

 public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
 {
     $request = new Test_Zend_Gdata_MockHttpClient_Request();
     $request->method = $method;
     $request->uri = $uri;
     $request->http_ver = $http_ver;
     $request->headers = $headers;
     $request->body = $body;
     array_push($this->_requests, $request);
     return parent::write($method, $uri, $http_ver, $headers, $body);
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:11,代码来源:MockHttpClient.php

示例12: testUserSearchExceptionEmailInvalid

 /**
  * Ensures that userSearch() throws an exception when an invalid e-mail address is given
  *
  * @return void
  */
 public function testUserSearchExceptionEmailInvalid()
 {
     $this->_flickr->getRestClient()->getHttpClient()->setAdapter($this->_httpClientAdapterTest);
     $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__));
     try {
         $this->_flickr->userSearch('2e38a9d9425d7e2c9d0788455e9ccc61@example.com');
         $this->fail('Expected Zend_Service_Exception not thrown');
     } catch (Zend_Service_Exception $e) {
         $this->assertContains('User not found', $e->getMessage());
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:16,代码来源:OfflineTest.php

示例13: _importInvalid

 /**
  * Imports an invalid feed
  */
 protected function _importInvalid($filename)
 {
     $response = new Zend_Http_Response(200, array(), file_get_contents("{$this->_feedDir}/{$filename}"));
     $this->_adapter->setResponse($response);
     try {
         $feed = Zend_Feed::import('http://localhost');
         $this->fail('Expected Zend_Feed_Exception not thrown');
     } catch (Zend_Feed_Exception $e) {
         $this->assertType('Zend_Feed_Exception', $e);
     }
 }
开发者ID:travisj,项目名称:zf,代码行数:14,代码来源:ImportTest.php

示例14: 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__));
     try {
         $this->_flickr->groupPoolGetPhotos('2e38a9d9425d7e2c9d0788455e9ccc61');
         $this->fail('Expected Zend_Service_Exception not thrown');
     } catch (Zend_Service_Exception $e) {
         $this->assertContains('Group not found', $e->getMessage());
     }
 }
开发者ID:heiglandreas,项目名称:zf2,代码行数:16,代码来源:OfflineTest.php

示例15: testSettingNextResponseToAnInvalidIndex

 public function testSettingNextResponseToAnInvalidIndex()
 {
     $indexes = array(-1, 1);
     foreach ($indexes as $i) {
         try {
             $this->adapter->setResponseIndex($i);
             $this->fail();
         } catch (\Exception $e) {
             $this->assertInstanceOf('Zend\\Http\\Client\\Adapter\\Exception', $e);
             $this->assertRegexp('/out of range/i', $e->getMessage());
         }
     }
 }
开发者ID:alab1001101,项目名称:zf2,代码行数:13,代码来源:TestAdapterTest.php


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