getTempFileDir() public static method

public static getTempFileDir ( )
コード例 #1
0
 public function testDownloadByCurlCommand()
 {
     $downloader = new UrlDownloaderForTest($this->logger, new OptionResult());
     $downloader->setIsCurlCommandAvailable(true);
     $actualFilePath = tempnam(Config::getTempFileDir(), '');
     $downloader->download('http://httpbin.org/', $actualFilePath);
     $this->assertTrue($downloader->isCurlCommandAvailable());
     $this->assertFileExists($actualFilePath);
 }
コード例 #2
0
ファイル: DownloaderTest.php プロジェクト: phpbrew/phpbrew
 private function _test($downloader)
 {
     $instance = DownloadFactory::getInstance($this->logger, new OptionResult(), $downloader);
     if ($instance->hasSupport(false)) {
         $actualFilePath = tempnam(Config::getTempFileDir(), '');
         $instance->download('http://httpbin.org/', $actualFilePath);
         $this->assertFileExists($actualFilePath);
     } else {
         $this->markTestSkipped();
     }
 }
コード例 #3
0
ファイル: ExtractTask.php プロジェクト: WebDevJL/phpbrew
 /**
  * Unpacks the source tarball file.
  *
  * @param string $targetFilePath absolute file path
  */
 public function extract(Build $build, $targetFilePath, $extractDir = NULL)
 {
     $extractDirTemp = Config::getTempFileDir();
     if (!$extractDir) {
         $extractDir = dirname($targetFilePath);
     }
     $extractedDirTemp = $extractDirTemp . DIRECTORY_SEPARATOR . preg_replace('#\\.tar\\.(gz|bz2)$#', '', basename($targetFilePath));
     $extractedDir = $extractDir . DIRECTORY_SEPARATOR . $build->getName();
     if ($build->getState() >= Build::STATE_EXTRACT && file_exists($extractedDir . DIRECTORY_SEPARATOR . 'configure')) {
         $this->info("===> Distribution file was successfully extracted, skipping...");
         return $extractedDir;
     }
     // NOTICE: Always extract to prevent incomplete extraction
     $this->info("===> Extracting {$targetFilePath} to {$extractedDirTemp}");
     system("tar -C {$extractDirTemp} -xf {$targetFilePath}", $ret);
     if ($ret != 0) {
         throw new RuntimeException('Extract failed.');
     }
     clearstatcache(true);
     if (!is_dir($extractedDirTemp)) {
         // retry with github extracted dir path
         $extractedDirTemp = $extractDirTemp . DIRECTORY_SEPARATOR . 'php-src-' . preg_replace('#\\.tar\\.(gz|bz2)$#', '', basename($targetFilePath));
         if (!is_dir($extractedDirTemp)) {
             throw new RuntimeException("Unable to find {$extractedDirTemp}");
         }
     }
     if (is_dir($extractedDir)) {
         $this->info("===> Removing {$extractedDir}");
         system("rm -rf {$extractedDir}", $ret);
         if ($ret !== 0) {
             throw new RuntimeException("Unable to remove {$extractedDir}.");
         }
     }
     $this->info("===> Moving {$extractedDirTemp} to {$extractedDir}");
     if (!rename($extractedDirTemp, $extractedDir)) {
         throw new RuntimeException("Unable to move {$extractedDirTemp} to {$extractedDir}");
     }
     $build->setState(Build::STATE_EXTRACT);
     return $extractedDir;
     /*
      * XXX: unless we have a fast way to verify the extraction.
     if ($this->options->force || ! file_exists($extractedDir . DIRECTORY_SEPARATOR . 'configure')) {
         $this->info("===> Extracting $targetFilePath...");
         system("tar -C $dir -xjf $targetFilePath", $ret);
         if ($ret != 0) {
             die('Extract failed.');
         }
     } else {
         $this->info("Found existing $extractedDir, Skip extracting.");
     }
     */
 }
コード例 #4
0
 /**
  * $caller must be a subclass of PHPUnit_Framework_TestCase.
  * @param Object $caller the object which creates this object.
  * @param string $sourcePath the path of a source file.
  */
 public function __construct($caller, $sourcePath)
 {
     $this->caller = $caller;
     $this->sourcePath = $sourcePath;
     $this->temporaryDirectory = Config::getTempFileDir();
 }
コード例 #5
0
 public function __construct()
 {
     parent::__construct('5.3.29');
     $this->setSourceDirectory(Config::getTempFileDir() . '/' . uniqid());
 }