xref: /PHP-7.1/ext/phar/tests/tar/links2.phpt (revision 16b4d8e0)
1--TEST--
2Phar: tar with hard link to nowhere
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--FILE--
6<?php
7$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
8$pname = 'phar://' . $fname;
9
10include dirname(__FILE__) . '/files/corrupt_tarmaker.php.inc';
11$a = new corrupt_tarmaker($fname, 'none');
12$a->init();
13$a->addFile('hardlink', 'internal/file.txt', array(
14                    'mode' => 0xA000 + 0644,
15                    'uid' => 0,
16                    'gid' => 0,
17                    'size' => 0,
18                    'mtime' => time(),
19                ));
20$a->close();
21
22try {
23	$p = new PharData($fname);
24} catch (Exception $e) {
25	echo $e->getMessage() . "\n";
26}
27?>
28===DONE===
29--CLEAN--
30<?php
31unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
32?>
33--EXPECTF--
34phar error: "%slinks2.tar" is a corrupted tar file - hard link to non-existent file "internal/file.txt"
35===DONE===
36