Skip to content

Commit 7b1936c

Browse files
committed
TarTestCase::testReadCurrentEntry() added
1 parent 5ff390c commit 7b1936c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/TarTestCase.php

+25
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,31 @@ public function testNumberEncodeDecode()
804804
$this->assertEquals($refValue, $decoded);
805805
}
806806

807+
public function testReadCurrentEntry()
808+
{
809+
$tar = new Tar();
810+
$tar->open(__DIR__ . '/tar/test.tar');
811+
$out = sys_get_temp_dir() . '/dwtartest' . md5(time());
812+
$tar->extract($out);
813+
814+
$tar = new Tar();
815+
$tar->open(__DIR__ . '/tar/test.tar');
816+
$pathsRead = array();
817+
foreach($tar->yieldContents() as $i) {
818+
$this->assertFileExists($out . '/' . $i->getPath());
819+
if ($i->getIsdir()) {
820+
$this->assertEquals('', $tar->readCurrentEntry());
821+
} else {
822+
$this->assertStringEqualsFile($out . '/' . $i->getPath(), $tar->readCurrentEntry());
823+
}
824+
$pathsRead[] = $i->getPath();
825+
}
826+
$pathsReadRef = array('tar', 'tar/testdata1.txt', 'tar/foobar', 'tar/foobar/testdata2.txt');
827+
$this->assertEquals($pathsReadRef, $pathsRead);
828+
829+
self::RDelete($out);
830+
}
831+
807832
/**
808833
* recursive rmdir()/unlink()
809834
*

0 commit comments

Comments
 (0)