Inheritance: implements pharext\Task
Exemplo n.º 1
0
 function testPecl()
 {
     $cmd = new Task\StreamFetch("http://pecl.php.net/get/pecl_http", function ($pct) use(&$log) {
         $log[] = $pct;
     });
     $tmp = $cmd->run();
     $this->assertTrue(is_file($tmp), "is_file({$tmp})");
     $this->assertGreaterThan(1, count($log), "1 < count(\$log)");
     $this->assertContains(0, $log, "in_array(0, \$log)");
     $this->assertContains(1, $log, "in_array(1, \$log)");
     $cmd = new Task\Extract($tmp);
     $dir = $cmd->run();
     $this->assertTrue(is_dir($dir), "is_dir({$dir})");
     $this->assertTrue(is_file("{$dir}/package.xml"), "is_file({$dir}/package.xml");
     $cmd = new Task\PeclFixup($dir);
     $new = $cmd->run();
     $this->assertTrue(is_dir($new), "is_dir({$new})");
     $this->assertFalse(is_file("{$dir}/package.xml"), "is_file({$dir}/package.xml");
     $this->assertTrue(is_file("{$new}/package.xml"), "is_file({$new}/package.xml");
     (new Task\Cleanup($dir))->run();
     $this->assertFalse(is_dir($dir), "is_dir({$dir})");
     $this->assertFalse(is_dir($new), "is_dir({$new})");
 }
Exemplo n.º 2
0
 /**
  * Download remote source
  * @param string $source
  * @return string local source
  */
 private function download($source)
 {
     if ($this->args->git) {
         $task = new Task\GitClone($source, $this->args->branch);
     } else {
         /* print newline only once */
         $done = false;
         $task = new Task\StreamFetch($source, function ($bytes_pct) use(&$done) {
             if (!$done) {
                 $this->info(" %3d%% [%s>%s] \r", floor($bytes_pct * 100), str_repeat("=", round(50 * $bytes_pct)), str_repeat(" ", round(50 * (1 - $bytes_pct))));
                 if ($bytes_pct == 1) {
                     $done = true;
                     $this->info("\n");
                 }
             }
         });
     }
     $local = $task->run($this->verbosity());
     $this->cleanup[] = new Task\Cleanup($local);
     return $local;
 }