1
0
mirror of https://github.com/php/php-src.git synced 2026-04-29 19:23:22 +02:00
Files
archived-php-src/ext/zip/tests/oo_getstreamindex.phpt
T
Remi Collet e9b96ae5da Add ZipArchive::clearError, getStreamIndex and getStreamName methods
public function clearError(): void {}
    public function getStreamIndex(int $index, int $flags = 0) {}
    public function getStreamName(string $name, int $flags = 0) {}

ZipArchive::getStream is kept for BC

See https://github.com/pierrejoye/php_zip/issues/20
2021-10-11 15:39:35 +02:00

68 lines
1.2 KiB
PHP

--TEST--
ZipArchive::getStreamIndex / ZipArchive::getName
--EXTENSIONS--
zip
--FILE--
<?php
$name = __DIR__ . '/getstream.zip';
$zip = new ZipArchive;
$r = $zip->open($name, ZIPARCHIVE::CREATE);
$zip->addFromString('foo.txt', 'foo');
$zip->addFromString('bar.txt', 'bar');
$zip->close();
$r = $zip->open($name);
$zip->addFromString('bar.txt', 'baz', ZipArchive::FL_OVERWRITE);
echo "== Name\n";
$fp = $zip->getStreamName('foo.txt');
var_dump($zip->status);
var_dump(stream_get_contents($fp));
$zip->clearError();
fclose($fp);
echo "== Index\n";
$fp = $zip->getStreamIndex(0);
var_dump($zip->status);
var_dump(stream_get_contents($fp));
$zip->clearError();
fclose($fp);
echo "== Index, changed\n";
$fp = $zip->getStreamIndex(1);
var_dump($zip->status);
$zip->clearError();
echo "== Index, unchanged\n";
$fp = $zip->getStreamIndex(1, ZipArchive::FL_UNCHANGED);
var_dump($zip->status);
var_dump(stream_get_contents($fp));
$zip->clearError();
fclose($fp);
$zip->close();
?>
== Done
--CLEAN--
<?php
$name = __DIR__ . '/getstream.zip';
@unlink($name);
?>
--EXPECTF--
== Name
int(0)
string(3) "foo"
== Index
int(0)
string(3) "foo"
== Index, changed
int(15)
== Index, unchanged
int(0)
string(3) "bar"
== Done