Example #1
0
 public function testMultiBigFile()
 {
     $MultiRequest = new MultiRequest();
     $MultiRequest->addUrl(self::$_urlBigFile, 'testMultiBigFile');
     $MultiRequest->addUrl(self::$_urlBigFile300, 'testMultiBigFile300');
     $MultiRequest->setCaching(true);
     $MultiRequest->setTimeout(10);
     SimpleBenchMark::start('t_download');
     SimpleBenchMark::start('i_download');
     while (true) {
         try {
             $MultiRequest->download();
         } catch (CurlError $e) {
             if ($e->getCode() == CurlError::E_M_TIMEOUT_REACHED) {
                 continue;
             }
         }
         break;
     }
     $MultiRequest->setCaching(false);
     foreach ($MultiRequest->getRequestList() as $Request) {
         /** @var Request $Request */
         $filePath = $Request->getDownloadFilePath(true);
         $stateFilePath = $Request->getDownloadStateFilePath(true);
         $this->assertFileExists($filePath);
         $this->assertFileExists($stateFilePath);
         $Request->_readStateFile($urlFromState, $contentTypeFromState, $charsetFromState, $fileSizeFromState, $expectedSizeFromState);
         $this->assertEquals($fileSizeFromState, $expectedSizeFromState);
         $this->assertEquals($Request->getUrl(), $urlFromState);
         $this->assertEquals($Request->getContentType(), $contentTypeFromState);
         $this->assertEquals(intval(filesize($Request->getDownloadFilePath(true))), $fileSizeFromState);
         $Request->__destruct();
         $this->assertFileNotExists($filePath);
         $this->assertFileNotExists($stateFilePath);
     }
 }