diff options
author | Andreas Gohr <andi@splitbrain.org> | 2014-04-16 18:31:49 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2014-04-16 18:31:49 +0200 |
commit | 8dfccb7a0f7dc83d9a52e1489713643ccf8a4234 (patch) | |
tree | 4a6064f91dd856fc36681a3611919724c3f0a6eb | |
parent | 4f6c1b595c2ba361d1fb101ec4e8775e890de84b (diff) | |
parent | 64d063f11abb3946bad9d076a56b0fc51ccff127 (diff) | |
download | rpg-8dfccb7a0f7dc83d9a52e1489713643ccf8a4234.tar.gz rpg-8dfccb7a0f7dc83d9a52e1489713643ccf8a4234.tar.bz2 |
Merge pull request #656 from glensc/skip-bzgz
tar: test. skip instead of error if bz2 or zlib extension is missing
-rw-r--r-- | _test/tests/inc/tar.test.php | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index 417f1a853..15453b16d 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -1,6 +1,38 @@ <?php class Tar_TestCase extends DokuWikiTest { + /** + * file extensions that several tests use + */ + protected $extensions = array('tar'); + + public function setUp() { + parent::setUp(); + if (extension_loaded('zlib')) { + $this->extensions[] = 'tgz'; + } + if (extension_loaded('bz2')) { + $this->extensions[] = 'tbz'; + } + } + + /* + * dependency for tests needing zlib extension to pass + */ + public function test_ext_zlib() { + if (!extension_loaded('zlib')) { + $this->markTestSkipped('skipping all zlib tests. Need zlib extension'); + } + } + + /* + * dependency for tests needing zlib extension to pass + */ + public function test_ext_bz2() { + if (!extension_loaded('bz2')) { + $this->markTestSkipped('skipping all bzip2 tests. Need bz2 extension'); + } + } /** * simple test that checks that the given filenames and contents can be grepped from @@ -58,8 +90,6 @@ class Tar_TestCase extends DokuWikiTest { $tar->addData('another/testdata3.txt', 'testcontent3'); $tar->close(); -copy ($tmp, '/tmp/test.tar'); - $this->assertTrue(filesize($tmp) > 30); //arbitrary non-zero number $data = file_get_contents($tmp); @@ -89,7 +119,7 @@ copy ($tmp, '/tmp/test.tar'); public function test_tarcontent() { $dir = dirname(__FILE__).'/tar'; - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -112,7 +142,7 @@ copy ($tmp, '/tmp/test.tar'); $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -138,7 +168,7 @@ copy ($tmp, '/tmp/test.tar'); $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -164,7 +194,7 @@ copy ($tmp, '/tmp/test.tar'); $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -190,7 +220,7 @@ copy ($tmp, '/tmp/test.tar'); $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -215,7 +245,7 @@ copy ($tmp, '/tmp/test.tar'); $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach($this->extensions as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -249,6 +279,9 @@ copy ($tmp, '/tmp/test.tar'); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz2')); } + /** + * @depends test_ext_zlib + */ public function test_longpathextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); @@ -338,6 +371,7 @@ copy ($tmp, '/tmp/test.tar'); /** * Extract a tarbomomb + * @depends test_ext_zlib */ public function test_tarbomb() { $dir = dirname(__FILE__).'/tar'; |