Exemplo n.º 1
0
 private function oneClick_Unpack()
 {
     $pathExtracted = PIWIK_USER_PATH . self::PATH_TO_EXTRACT_LATEST_VERSION;
     $this->pathRootExtractedPiwik = $pathExtracted . 'piwik';
     if (file_exists($this->pathRootExtractedPiwik)) {
         Piwik::unlinkRecursive($this->pathRootExtractedPiwik, true);
     }
     $archive = Piwik_Unzip::factory('PclZip', $this->pathPiwikZip);
     if (0 == ($archive_files = $archive->extract($pathExtracted))) {
         throw new Exception(Piwik_TranslateException('CoreUpdater_ExceptionArchiveIncompatible', $archive->errorInfo()));
     }
     if (0 == count($archive_files)) {
         throw new Exception(Piwik_TranslateException('CoreUpdater_ExceptionArchiveEmpty'));
     }
     unlink($this->pathPiwikZip);
 }
Exemplo n.º 2
0
 /**
  * @group Core
  * @group Unzip
  */
 public function testRelativePath()
 {
     clearstatcache();
     $extractDir = PIWIK_USER_PATH . '/tmp/latest/';
     $test = 'relative';
     $filename = dirname(__FILE__) . '/Unzip/' . $test . '.zip';
     if (class_exists('ZipArchive', false)) {
         $unzip = Piwik_Unzip::factory('ZipArchive', $filename);
         $res = $unzip->extract($extractDir);
         $this->assertEquals(1, count($res));
         $this->assertFileExists($extractDir . $test . '.txt');
         $this->assertFileNotExists(dirname(__FILE__) . '/' . $test . '.txt');
         $this->assertFileNotExists(dirname(__FILE__) . '/../../tests/' . $test . '.txt');
         unlink($extractDir . $test . '.txt');
         $unzip = new Piwik_Unzip_ZipArchive($filename);
         $res = $unzip->extract($extractDir);
         $this->assertEquals(1, count($res));
         $this->assertFileExists($extractDir . $test . '.txt');
         $this->assertFileNotExists(dirname(__FILE__) . '/' . $test . '.txt');
         $this->assertFileNotExists(dirname(__FILE__) . '/../../tests/' . $test . '.txt');
         unlink($extractDir . $test . '.txt');
     }
     $unzip = Piwik_Unzip::factory('PclZip', $filename);
     $res = $unzip->extract($extractDir);
     $this->assertEquals(1, count($res));
     $this->assertFileExists($extractDir . $test . '.txt');
     $this->assertFileNotExists(dirname(__FILE__) . '/' . $test . '.txt');
     $this->assertFileNotExists(dirname(__FILE__) . '/../../tests/' . $test . '.txt');
     unlink($extractDir . $test . '.txt');
     $unzip = new Piwik_Unzip_PclZip($filename);
     $res = $unzip->extract($extractDir);
     $this->assertEquals(1, count($res));
     $this->assertFileExists($extractDir . $test . '.txt');
     $this->assertFileNotExists(dirname(__FILE__) . '/' . $test . '.txt');
     $this->assertFileNotExists(dirname(__FILE__) . '/../../tests/' . $test . '.txt');
     unlink($extractDir . $test . '.txt');
 }