コード例 #1
0
ファイル: Package.php プロジェクト: mvanduijker/joomla-cli
 /**
  * Install a single package (archived file)
  *
  * @param $source
  * @return $this
  */
 protected function installPackageFile($source, $target)
 {
     if (!file_exists($source)) {
         throw new \RuntimeException('Source library folder does not exists!');
     }
     // first unpack to tmp dir, then install the directory
     $tmpFolder = $this->getTmpDir() . '/' . pathinfo($source, PATHINFO_FILENAME);
     $this->fs->mkdir($tmpFolder);
     $archive = new Archive();
     $archive->extract($source, $tmpFolder);
     // install the extension
     $installer = new Installer($tmpFolder);
     $installer->getAdapter()->install($target);
     // cleanup tmp folder
     $this->fs->remove($tmpFolder);
     return $this;
 }
コード例 #2
0
 /**
  * Tests extracting bzip2.
  *
  * @return  void
  *
  * @covers  Joomla\Archive\Archive::extract
  * @since   1.0
  */
 public function testExtractBzip2()
 {
     if (!is_dir($this->outputPath)) {
         $this->markTestSkipped("Couldn't create folder.");
         return;
     }
     if (!is_writable($this->outputPath) || !is_writable($this->fixture->options['tmp_path'])) {
         $this->markTestSkipped("Folder not writable.");
         return;
     }
     if (!ArchiveBzip2::isSupported()) {
         $this->markTestSkipped('Bzip2 files can not be extracted.');
         return;
     }
     $this->fixture->extract(__DIR__ . '/logo.bz2', $this->outputPath . '/logo-bz2.png');
     $this->assertTrue(is_file($this->outputPath . '/logo-bz2.png'));
     if (is_file($this->outputPath . '/logo-bz2.png')) {
         unlink($this->outputPath . '/logo-bz2.png');
     }
 }