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


PHP Client::setCurlMulti方法代码示例

本文整理汇总了PHP中Guzzle\Http\Client::setCurlMulti方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::setCurlMulti方法的具体用法?PHP Client::setCurlMulti怎么用?PHP Client::setCurlMulti使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Guzzle\Http\Client的用法示例。


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

示例1: testSavesResponsesInCache

 /**
  * @covers Guzzle\Http\Plugin\CachePlugin::onRequestSent
  * @covers Guzzle\Http\Plugin\CachePlugin::onRequestBeforeSend
  * @covers Guzzle\Http\Plugin\CachePlugin::saveCache
  * @covers Guzzle\Http\Plugin\CachePlugin::getCacheKey
  * @covers Guzzle\Http\Plugin\CachePlugin::canResponseSatisfyRequest
  */
 public function testSavesResponsesInCache()
 {
     // Send a 200 OK script to the testing server
     $this->getServer()->enqueue(array("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ndata", "HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ntest"));
     // Create a new Cache plugin
     $plugin = new CachePlugin($this->adapter);
     $client = new Client($this->getServer()->getUrl());
     $client->setCurlMulti(new \Guzzle\Http\Curl\CurlMulti());
     $client->getEventDispatcher()->addSubscriber($plugin);
     $request = $client->get();
     $request->send();
     // Calculate the cache key like the cache plugin does
     $key = $plugin->getCacheKey($request);
     // Make sure that the cache plugin set the request in cache
     $this->assertNotNull($this->adapter->fetch($key));
     // Clear out the requests stored on the server to make sure we didn't send a new request
     $this->getServer()->flush();
     // Test that the request is set manually
     // The test server has no more script data, so if it actually sends a
     // request it will fail the test.
     $this->assertEquals($key, $plugin->getCacheKey($request));
     $request->setState('new');
     $request->send();
     $this->assertEquals('data', $request->getResponse()->getBody(true));
     // Make sure a request wasn't sent
     $this->assertEquals(0, count($this->getServer()->getReceivedRequests(false)));
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:34,代码来源:CachePluginTest.php

示例2: testTransfersBatches

 public function testTransfersBatches()
 {
     $client = new Client('http://localhost:123');
     $request = $client->get();
     $multi = $this->getMock('Guzzle\\Http\\Curl\\CurlMultiInterface');
     $client->setCurlMulti($multi);
     $multi->expects($this->once())->method('add')->with($request);
     $multi->expects($this->once())->method('send');
     $batch = new BatchRequestTransfer(2);
     $batch->transfer(array($request));
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:11,代码来源:BatchRequestTransferTest.php

示例3: testTrimsDownMaxHandleCount

 public function testTrimsDownMaxHandleCount()
 {
     $this->getServer()->flush();
     $this->getServer()->enqueue(array("HTTP/1.1 307 OK\r\nLocation: /foo\r\nContent-Length: 0\r\n\r\n", "HTTP/1.1 307 OK\r\nLocation: /foo\r\nContent-Length: 0\r\n\r\n", "HTTP/1.1 307 OK\r\nLocation: /foo\r\nContent-Length: 0\r\n\r\n", "HTTP/1.1 307 OK\r\nLocation: /foo\r\nContent-Length: 0\r\n\r\n", "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"));
     $client = new Client($this->getServer()->getUrl());
     $client->setCurlMulti(new CurlMultiProxy(2));
     $request = $client->get();
     $request->send();
     $this->assertEquals(200, $request->getResponse()->getStatusCode());
     $handles = $this->readAttribute($client->getCurlMulti(), 'handles');
     $this->assertEquals(2, count($handles));
 }
开发者ID:ludichrislyts,项目名称:fieldWork,代码行数:12,代码来源:CurlMultiProxyTest.php

示例4: testTransfersBatches

 public function testTransfersBatches()
 {
     $client = new Client('http://127.0.0.1:123');
     $request = $client->get();
     // For some reason... PHP unit clones the request, which emits a request.clone event. This causes the
     // 'sorted' property of the event dispatcher to contain an array in the cloned request that is not present in
     // the original.
     $request->dispatch('request.clone');
     $multi = $this->getMock('Guzzle\\Http\\Curl\\CurlMultiInterface');
     $client->setCurlMulti($multi);
     $multi->expects($this->once())->method('add')->with($request);
     $multi->expects($this->once())->method('send');
     $batch = new BatchRequestTransfer(2);
     $batch->transfer(array($request));
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:15,代码来源:BatchRequestTransferTest.php

示例5: testCatchesExceptionsBeforeSendingCurlMulti

 /**
  * @covers Guzzle\Http\Curl\CurlMulti
  * @expectedException RuntimeException
  * @expectedExceptionMessage Testing!
  */
 public function testCatchesExceptionsBeforeSendingCurlMulti()
 {
     $client = new Client($this->getServer()->getUrl());
     $multi = new CurlMulti();
     $client->setCurlMulti($multi);
     $multi->getEventDispatcher()->addListener(CurlMulti::BEFORE_SEND, function () {
         throw new \RuntimeException('Testing!');
     });
     $client->get()->send();
 }
开发者ID:MicroSDHC,项目名称:justinribeiro.com-examples,代码行数:15,代码来源:CurlMultiTest.php

示例6: testCatchesExceptionsBeforeSendingSingleRequest

 public function testCatchesExceptionsBeforeSendingSingleRequest()
 {
     $client = new Client($this->getServer()->getUrl());
     $multi = new CurlMulti();
     $client->setCurlMulti($multi);
     $request = $client->get();
     $request->getEventDispatcher()->addListener('request.before_send', function () {
         throw new \RuntimeException('Testing!');
     });
     try {
         $request->send();
         $this->fail('Did not throw');
     } catch (\RuntimeException $e) {
         // Ensure it was removed
         $this->assertEquals(0, count($multi));
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:17,代码来源:CurlMultiTest.php

示例7: testAllowsCustomCurlMultiObjects

 public function testAllowsCustomCurlMultiObjects()
 {
     $mock = $this->getMock('Guzzle\\Http\\Curl\\CurlMulti', array('add', 'send'));
     $mock->expects($this->once())->method('add')->will($this->returnSelf());
     $mock->expects($this->once())->method('send')->will($this->returnSelf());
     $client = new Client();
     $client->setCurlMulti($mock);
     $request = $client->get();
     $request->setResponse(new Response(200), true);
     $client->send($request);
 }
开发者ID:carlesgutierrez,项目名称:libreobjet.org,代码行数:11,代码来源:ClientTest.php


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