示例#1
0
 public function testWait()
 {
     $tmpfile = tmpfile();
     $reqp = $this->prophesize('Hirak\\Prestissimo\\CopyRequest');
     $reqp->getCurlOptions()->willReturn(array(CURLOPT_URL => 'file://uso800.txt', CURLOPT_FILE => $tmpfile));
     $reqp->getMaskedURL()->willReturn('file://uso800.txt');
     $reqp->makeSuccess()->willReturn(null);
     $requests = array($reqp->reveal());
     $multi = new CurlMulti();
     $multi->setRequests($requests);
     do {
         $multi->setupEventLoop();
         $multi->wait();
         $result = $multi->getFinishedResults();
         $this->assertEquals(0, $result['successCnt']);
         $this->assertEquals(1, $result['failureCnt']);
     } while ($multi->remain());
     rewind($tmpfile);
     $content = stream_get_contents($tmpfile);
     $this->assertEmpty($content);
 }