xref: /PHP-5.5/ext/phar/tests/tar/tar_001.phpt (revision 16b4d8e0)
1--TEST--
2Phar: tar-based phar corrupted
3--SKIPIF--
4<?php if (!extension_loaded('phar')) die('skip'); ?>
5<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
6--FILE--
7<?php
8include dirname(__FILE__) . '/files/make_invalid_tar.php.inc';
9
10$tar = new corrupter(dirname(__FILE__) . '/tar_001.phar.tar', 'none');
11$tar->init();
12$tar->addFile('tar_001.phpt', __FILE__);
13$tar->close();
14
15$tar = fopen('phar://' . dirname(__FILE__) . '/tar_001.phar.tar/tar_001.phpt', 'rb');
16try {
17	$phar = new Phar(dirname(__FILE__) . '/tar_001.phar.tar');
18	echo "should not execute\n";
19} catch (Exception $e) {
20	echo $e->getMessage() . "\n";
21}
22?>
23===DONE===
24--CLEAN--
25<?php
26@unlink(dirname(__FILE__) . '/tar_001.phar.tar');
27?>
28--EXPECTF--
29Warning: fopen(phar://%star_001.phar.tar/tar_001.phpt): failed to open stream: phar error: "%star_001.phar.tar" is a corrupted tar file (truncated) in %star_001.php on line 9
30phar error: "%star_001.phar.tar" is a corrupted tar file (truncated)
31===DONE===
32