summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-11-03 18:30:52 +0100
committerAndreas Gohr <andi@splitbrain.org>2012-11-03 18:30:52 +0100
commit7252880f21c842017c334eb15c6a7a174f950798 (patch)
tree324a5749951a7325655ef9d1fdda0f48f8ee934b /_test
parentbee9f377bc547c99fe99b4e38199cb92cf668554 (diff)
downloadrpg-7252880f21c842017c334eb15c6a7a174f950798.tar.gz
rpg-7252880f21c842017c334eb15c6a7a174f950798.tar.bz2
added test cases for Tar::extract parameters
Diffstat (limited to '_test')
-rw-r--r--_test/tests/inc/tar.test.php103
1 files changed, 103 insertions, 0 deletions
diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php
index 706516d9e..4de9e668d 100644
--- a/_test/tests/inc/tar.test.php
+++ b/_test/tests/inc/tar.test.php
@@ -113,10 +113,113 @@ class Tar_TestCase extends DokuWikiTest {
TestUtils::rdelete($out);
}
+ }
+
+ /**
+ * Extract the prebuilt tar files with component stripping
+ */
+ public function test_compstripextract(){
+ $dir = dirname(__FILE__).'/tar';
+ $out = sys_get_temp_dir().'/dwtartest'.md5(time());
+
+ foreach(array('tar', 'tgz', 'tbz') as $ext){
+ $tar = new Tar();
+ $file = "$dir/test.$ext";
+
+ $tar->open($file);
+ $tar->extract($out,1);
+
+ clearstatcache();
+
+ $this->assertFileExists($out.'/testdata1.txt', "Extracted $file");
+ $this->assertEquals(13, filesize($out.'/testdata1.txt'), "Extracted $file");
+
+ $this->assertFileExists($out.'/foobar/testdata2.txt', "Extracted $file");
+ $this->assertEquals(13, filesize($out.'/foobar/testdata2.txt'), "Extracted $file");
+
+ TestUtils::rdelete($out);
+ }
+ }
+
+ /**
+ * Extract the prebuilt tar files with prefix stripping
+ */
+ public function test_prefixstripextract(){
+ $dir = dirname(__FILE__).'/tar';
+ $out = sys_get_temp_dir().'/dwtartest'.md5(time());
+ foreach(array('tar', 'tgz', 'tbz') as $ext){
+ $tar = new Tar();
+ $file = "$dir/test.$ext";
+
+ $tar->open($file);
+ $tar->extract($out,'tar/foobar/');
+
+ clearstatcache();
+
+ $this->assertFileExists($out.'/tar/testdata1.txt', "Extracted $file");
+ $this->assertEquals(13, filesize($out.'/tar/testdata1.txt'), "Extracted $file");
+
+ $this->assertFileExists($out.'/testdata2.txt', "Extracted $file");
+ $this->assertEquals(13, filesize($out.'/testdata2.txt'), "Extracted $file");
+
+ TestUtils::rdelete($out);
+ }
}
/**
+ * Extract the prebuilt tar files with include regex
+ */
+ public function test_includeextract(){
+ $dir = dirname(__FILE__).'/tar';
+ $out = sys_get_temp_dir().'/dwtartest'.md5(time());
+
+ foreach(array('tar', 'tgz', 'tbz') as $ext){
+ $tar = new Tar();
+ $file = "$dir/test.$ext";
+
+ $tar->open($file);
+ $tar->extract($out,'','','/\/foobar\//');
+
+ clearstatcache();
+
+ $this->assertFileNotExists($out.'/tar/testdata1.txt', "Extracted $file");
+
+
+ $this->assertFileExists($out.'/tar/foobar/testdata2.txt', "Extracted $file");
+ $this->assertEquals(13, filesize($out.'/tar/foobar/testdata2.txt'), "Extracted $file");
+
+ TestUtils::rdelete($out);
+ }
+ }
+
+ /**
+ * Extract the prebuilt tar files with exclude regex
+ */
+ public function test_excludeextract(){
+ $dir = dirname(__FILE__).'/tar';
+ $out = sys_get_temp_dir().'/dwtartest'.md5(time());
+
+ foreach(array('tar', 'tgz', 'tbz') as $ext){
+ $tar = new Tar();
+ $file = "$dir/test.$ext";
+
+ $tar->open($file);
+ $tar->extract($out,'','/\/foobar\//');
+
+ clearstatcache();
+
+ $this->assertFileExists($out.'/tar/testdata1.txt', "Extracted $file");
+ $this->assertEquals(13, filesize($out.'/tar/testdata1.txt'), "Extracted $file");
+
+ $this->assertFileNotExists($out.'/tar/foobar/testdata2.txt', "Extracted $file");
+
+ TestUtils::rdelete($out);
+ }
+ }
+
+
+ /**
* Check the extension to compression guesser
*/
public function test_filetype(){