summaryrefslogtreecommitdiff
path: root/ext/phar/tests/tar/bug71317-duplicate-filename.phpt
blob: b8004138bc6ce0db137ea0916424940264715c28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
--TEST--
Bug #71317: regression in opening tar based phar files
--SKIPIF--
<?php if (!extension_loaded('phar')) die('skip'); ?>
<?php if (!extension_loaded("zlib")) die("skip zlib not available"); ?>
--FILE--
<?php
include dirname(__FILE__) . '/files/tarmaker.php.inc';

$testDirectory = __DIR__ . '/files/test_bug71317';
$testTarFilename  = __DIR__ . '/files/test_bug71317.tar';

$tar = new tarmaker($testTarFilename, 'none');
$tar->init();
$tar->addFile('file1.txt', 'file1');
$tar->addFile('file2.txt', 'file2');
$tar->addFile('file3.txt', 'file3');
$tar->addFile('file4.txt', 'file4');
$tar->addFile('file5.txt', 'file5');
$tar->addFile('file2.txt', 'file2a');
$tar->close();

$fname = str_replace('\\', '/', $testTarFilename);
try {
	mkdir($testDirectory);
	$tar = new PharData($fname);
	$tar->extractTo($testDirectory);

	$fileContent = file_get_contents($testDirectory . '/file2.txt');
	$expectedContent = 'file2a';
	if ($fileContent !== $expectedContent) {
		throw new Exception(sprintf('Contents of file2.txt ("%s") is invalid, expected "%s"', $fileContent, $expectedContent));
	}
} catch(Exception $e) {
	echo $e->getMessage() . "\n";
}
?>
===DONE===
--CLEAN--
<?php
$testDirectory = __DIR__ . '/files/test_bug71317';
$testTarFilename  = __DIR__ . '/files/test_bug71317.tar';

unlink($testTarFilename);
array_map('unlink', glob($testDirectory . "/*.txt"));
rmdir($testDirectory);
?>
--EXPECT--
===DONE===