summaryrefslogtreecommitdiff
path: root/_test/tests/inc/tar.test.php
diff options
context:
space:
mode:
authorKlap-in <klapinklapin@gmail.com>2013-07-14 13:35:06 +0200
committerKlap-in <klapinklapin@gmail.com>2013-07-14 13:35:06 +0200
commit33c3b3817b00aa9384760813643fac0e33daaaff (patch)
tree481c880b00a32ba5887834b52a17248bac8bfc7c /_test/tests/inc/tar.test.php
parent040f0e135c37c5b544f16277ff69205369df5f1f (diff)
parentfbd8067eeeb9f424981aad8b283e17f734c738c3 (diff)
downloadrpg-33c3b3817b00aa9384760813643fac0e33daaaff.tar.gz
rpg-33c3b3817b00aa9384760813643fac0e33daaaff.tar.bz2
merge master in branch
Diffstat (limited to '_test/tests/inc/tar.test.php')
-rw-r--r--_test/tests/inc/tar.test.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php
index e8805a75d..90bc2e49e 100644
--- a/_test/tests/inc/tar.test.php
+++ b/_test/tests/inc/tar.test.php
@@ -316,4 +316,48 @@ class Tar_TestCase extends DokuWikiTest {
TestUtils::rdelete($out);
}
+
+ /**
+ * A single zero file should be just a header block + the footer
+ */
+ public function test_zerofile(){
+ $dir = dirname(__FILE__).'/tar';
+ $tar = new Tar();
+ $tar->create();
+ $tar->addFile("$dir/zero.txt", 'zero.txt');
+ $file = $tar->getArchive(Tar::COMPRESS_NONE);
+
+ $this->assertEquals(512*3, strlen($file)); // 1 header block + 2 footer blocks
+ }
+
+ public function test_zerodata(){
+ $tar = new Tar();
+ $tar->create();
+ $tar->addData('zero.txt','');
+ $file = $tar->getArchive(Tar::COMPRESS_NONE);
+
+ $this->assertEquals(512*3, strlen($file)); // 1 header block + 2 footer blocks
+ }
+
+ /**
+ * A file of exactly one block should be just a header block + data block + the footer
+ */
+ public function test_blockfile(){
+ $dir = dirname(__FILE__).'/tar';
+ $tar = new Tar();
+ $tar->create();
+ $tar->addFile("$dir/block.txt", 'block.txt');
+ $file = $tar->getArchive(Tar::COMPRESS_NONE);
+
+ $this->assertEquals(512*4, strlen($file)); // 1 header block + data block + 2 footer blocks
+ }
+
+ public function test_blockdata(){
+ $tar = new Tar();
+ $tar->create();
+ $tar->addData('block.txt', str_pad('', 512, 'x'));
+ $file = $tar->getArchive(Tar::COMPRESS_NONE);
+
+ $this->assertEquals(512*4, strlen($file)); // 1 header block + data block + 2 footer blocks
+ }
} \ No newline at end of file