xref: /php-src/ext/phar/tests/tar/badchecksum.phpt (revision 74859783)
1--TEST--
2Phar: tar with bad checksum
3--EXTENSIONS--
4phar
5--FILE--
6<?php
7$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.tar';
8$pname = 'phar://' . $fname;
9
10include __DIR__ . '/files/corrupt_tarmaker.php.inc';
11$a = new corrupt_tarmaker($fname, 'none');
12$a->init();
13$a->addFile('hithere', 'contents', null, 'checksum');
14$a->close();
15
16try {
17    $p = new PharData($fname);
18} catch (Exception $e) {
19    echo $e->getMessage() . "\n";
20}
21
22?>
23--CLEAN--
24<?php
25unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.tar');
26?>
27--EXPECTF--
28phar error: "%sbadchecksum.tar" is a corrupted tar file (checksum mismatch of file "hithere")
29