Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Napoli <matthieu@mnapoli.fr>2014-10-03 00:57:43 +0400
committerMatthieu Napoli <matthieu@mnapoli.fr>2014-10-03 00:57:43 +0400
commitf29c9380249d95fe004d6f2652dfdb318aea0784 (patch)
treef2af227dac62daa885f173077984917a79cc36ef /tests/PHPUnit/Core
parent699f9cd8bd84ee53c8b4e65e948052dbd8858d10 (diff)
Extracted the decompressing classes into a standalone Decompress component
Diffstat (limited to 'tests/PHPUnit/Core')
-rwxr-xr-xtests/PHPUnit/Core/Unzip/empty.zip0
-rw-r--r--tests/PHPUnit/Core/Unzip/relative.zipbin128 -> 0 bytes
-rwxr-xr-xtests/PHPUnit/Core/Unzip/test.gzbin41 -> 0 bytes
-rwxr-xr-xtests/PHPUnit/Core/Unzip/test.tar.gzbin202 -> 0 bytes
-rw-r--r--tests/PHPUnit/Core/Unzip/zaabs.zipbin132 -> 0 bytes
-rw-r--r--tests/PHPUnit/Core/Unzip/zaatt.zipbin128 -> 0 bytes
-rw-r--r--tests/PHPUnit/Core/UnzipTest.php217
7 files changed, 0 insertions, 217 deletions
diff --git a/tests/PHPUnit/Core/Unzip/empty.zip b/tests/PHPUnit/Core/Unzip/empty.zip
deleted file mode 100755
index e69de29bb2..0000000000
--- a/tests/PHPUnit/Core/Unzip/empty.zip
+++ /dev/null
diff --git a/tests/PHPUnit/Core/Unzip/relative.zip b/tests/PHPUnit/Core/Unzip/relative.zip
deleted file mode 100644
index 2388859d52..0000000000
--- a/tests/PHPUnit/Core/Unzip/relative.zip
+++ /dev/null
Binary files differ
diff --git a/tests/PHPUnit/Core/Unzip/test.gz b/tests/PHPUnit/Core/Unzip/test.gz
deleted file mode 100755
index 113cbed07f..0000000000
--- a/tests/PHPUnit/Core/Unzip/test.gz
+++ /dev/null
Binary files differ
diff --git a/tests/PHPUnit/Core/Unzip/test.tar.gz b/tests/PHPUnit/Core/Unzip/test.tar.gz
deleted file mode 100755
index b9cc91965d..0000000000
--- a/tests/PHPUnit/Core/Unzip/test.tar.gz
+++ /dev/null
Binary files differ
diff --git a/tests/PHPUnit/Core/Unzip/zaabs.zip b/tests/PHPUnit/Core/Unzip/zaabs.zip
deleted file mode 100644
index c5517f940d..0000000000
--- a/tests/PHPUnit/Core/Unzip/zaabs.zip
+++ /dev/null
Binary files differ
diff --git a/tests/PHPUnit/Core/Unzip/zaatt.zip b/tests/PHPUnit/Core/Unzip/zaatt.zip
deleted file mode 100644
index 91e0c4864a..0000000000
--- a/tests/PHPUnit/Core/Unzip/zaatt.zip
+++ /dev/null
Binary files differ
diff --git a/tests/PHPUnit/Core/UnzipTest.php b/tests/PHPUnit/Core/UnzipTest.php
deleted file mode 100644
index 12f754c8b7..0000000000
--- a/tests/PHPUnit/Core/UnzipTest.php
+++ /dev/null
@@ -1,217 +0,0 @@
-<?php
-/**
- * Piwik - free/libre analytics platform
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- */
-use Piwik\Unzip\Gzip;
-use Piwik\Unzip;
-use Piwik\Unzip\PclZip;
-use Piwik\Unzip\Tar;
-use Piwik\Unzip\ZipArchive;
-
-class UnzipTest extends PHPUnit_Framework_TestCase
-{
- /**
- * @group Core
- */
- public function testRelativePath()
- {
- clearstatcache();
- $extractDir = PIWIK_USER_PATH . '/tmp/latest/';
- $test = 'relative';
- $filename = dirname(__FILE__) . '/Unzip/' . $test . '.zip';
-
- if (class_exists('ZipArchive', false)) {
- $unzip = 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 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 = 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 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');
- }
-
- /**
- * @group Core
- */
- public function testRelativePathAttack()
- {
- clearstatcache();
- $extractDir = PIWIK_USER_PATH . '/tmp/latest/';
- $test = 'zaatt';
- $filename = dirname(__FILE__) . '/Unzip/' . $test . '.zip';
-
- if (class_exists('ZipArchive', false)) {
- $unzip = new ZipArchive($filename);
- $res = $unzip->extract($extractDir);
- $this->assertEquals(0, $res);
- $this->assertFileNotExists($extractDir . $test . '.txt');
- $this->assertFileNotExists($extractDir . '../' . $test . '.txt');
- $this->assertFileNotExists(dirname(__FILE__) . '/' . $test . '.txt');
- $this->assertFileNotExists(dirname(__FILE__) . '/../' . $test . '.txt');
- $this->assertFileNotExists(dirname(__FILE__) . '/../../' . $test . '.txt');
- }
-
- $unzip = new PclZip($filename);
- $res = $unzip->extract($extractDir);
- $this->assertEquals(0, $res);
- $this->assertFileNotExists($extractDir . $test . '.txt');
- $this->assertFileNotExists($extractDir . '../' . $test . '.txt');
- $this->assertFileNotExists(dirname(__FILE__) . '/' . $test . '.txt');
- $this->assertFileNotExists(dirname(__FILE__) . '/../' . $test . '.txt');
- $this->assertFileNotExists(dirname(__FILE__) . '/../../' . $test . '.txt');
- }
-
- /**
- * @group Core
- */
- public function testAbsolutePathAttack()
- {
- clearstatcache();
- $extractDir = PIWIK_USER_PATH . '/tmp/latest/';
- $test = 'zaabs';
- $filename = dirname(__FILE__) . '/Unzip/' . $test . '.zip';
-
- if (class_exists('ZipArchive', false)) {
- $unzip = new ZipArchive($filename);
- $res = $unzip->extract($extractDir);
- $this->assertEquals(0, $res);
- $this->assertFileNotExists($extractDir . $test . '.txt');
- $this->assertFileNotExists(dirname(__FILE__) . '/' . $test . '.txt');
- }
-
- $unzip = new PclZip($filename);
- $res = $unzip->extract($extractDir);
- $this->assertEquals(0, $res);
- $this->assertFileNotExists($extractDir . $test . '.txt');
- $this->assertFileNotExists(dirname(__FILE__) . '/' . $test . '.txt');
- }
-
- /**
- * @group Core
- */
- public function testUnzipErrorInfo()
- {
- clearstatcache();
- $filename = dirname(__FILE__) . '/Unzip/zaabs.zip';
-
- $unzip = new ZipArchive($filename);
- $this->assertContains('No error', $unzip->errorInfo());
- }
-
- /**
- * @group Core
- */
- public function testUnzipEmptyFile()
- {
- clearstatcache();
- $filename = dirname(__FILE__) . '/Unzip/empty.zip';
- $extractDir = PIWIK_USER_PATH . '/tmp/latest/';
-
- $unzip = new ZipArchive($filename);
- $res = $unzip->extract($extractDir);
- $this->assertEquals(0, $res);
- }
-
- /**
- * @group Core
- */
- public function testUnzipNotExistingFile()
- {
- clearstatcache();
- $filename = dirname(__FILE__) . '/Unzip/NotExisting.zip';
-
- try {
- new ZipArchive($filename);
- } catch (Exception $e) {
- return;
- }
- $this->fail('Exception not raised');
- }
-
- /**
- * @group Core
- */
- public function testUnzipInvalidFile2()
- {
- clearstatcache();
- $extractDir = PIWIK_USER_PATH . '/tmp/latest/';
- $filename = dirname(__FILE__) . '/Unzip/NotExisting.zip';
-
- $unzip = new PclZip($filename);
- $res = $unzip->extract($extractDir);
- $this->assertEquals(0, $res);
-
- $this->assertContains('PCLZIP_ERR_MISSING_FILE', $unzip->errorInfo());
- }
-
- /**
- * @group Core
- */
- public function testGzipFile()
- {
- $extractDir = PIWIK_USER_PATH . '/tmp/latest/';
- $extractFile = $extractDir . 'testgz.txt';
- $filename = dirname(__FILE__) . '/Unzip/test.gz';
-
- $unzip = new Gzip($filename);
- $res = $unzip->extract($extractFile);
- $this->assertTrue($res);
-
- $this->assertFileContentsEquals('TESTSTRING', $extractFile);
- }
-
- /**
- * @group Core
- */
- public function testTarGzFile()
- {
- $extractDir = PIWIK_USER_PATH . '/tmp/latest/';
- $filename = dirname(__FILE__) . '/Unzip/test.tar.gz';
-
- $unzip = new Tar($filename, 'gz');
- $res = $unzip->extract($extractDir);
- $this->assertTrue($res);
-
- $this->assertFileContentsEquals('TESTDATA', $extractDir . 'tarout1.txt');
- $this->assertFileContentsEquals('MORETESTDATA', $extractDir . 'tardir/tarout2.txt');
- }
-
- private function assertFileContentsEquals($expectedContent, $path)
- {
- $this->assertTrue(file_exists($path));
-
- $fd = fopen($path, 'rb');
- $actualContent = fread($fd, filesize($path));
- fclose($fd);
-
- $this->assertEquals($expectedContent, $actualContent);
- }
-}