summaryrefslogtreecommitdiffstats
path: root/tests/014-stream.phpt
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2023-10-12 15:49:40 +0200
committerRemi Collet <remi@php.net>2023-10-12 15:49:40 +0200
commitcecd15012c843bc60ed0e667eef7447632e0ece6 (patch)
treee3b136725eda0fe6ddd4c1815538e10d2e1a7ed7 /tests/014-stream.phpt
parent8bf3b94ac38682b4e5f1553ce0a501873dbcb855 (diff)
implement stat
Diffstat (limited to 'tests/014-stream.phpt')
-rw-r--r--tests/014-stream.phpt20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/014-stream.phpt b/tests/014-stream.phpt
index 90192bf..6651a8c 100644
--- a/tests/014-stream.phpt
+++ b/tests/014-stream.phpt
@@ -7,10 +7,19 @@ if (version_compare(RPMVERSION, '4.13', 'lt')) print("skip librpm is older than
?>
--FILE--
<?php
+$d = "rpm://" . __DIR__ . "/bidon.rpm#/usr/share/doc/bidon";
$n = "rpm://" . __DIR__ . "/bidon.rpm#/usr/share/doc/bidon/README";
+echo "+ wrapper\n";
var_dump(in_array('rpm', stream_get_wrappers()));
+echo "+ stat\n";
+$s = stat($d); // S_ISDIR
+var_dump($s['size'], $s['mode'] , $s['mode'] & 0040000 ? "OK" : "KO");
+$s = stat($n); // S_ISREG
+var_dump($s['size'], $s['mode'] , $s['mode'] & 0100000 ? "OK" : "KO");
+
+echo "+ file\n";
var_dump($f = fopen($n, "r"));
$s = fstat($f);
var_dump($s['size'], $s['mode']);
@@ -20,13 +29,23 @@ var_dump(trim(fread($f, 100)));
var_dump(feof($f));
fclose($f);
+echo "+ stream\n";
var_dump(trim(file_get_contents($n)));
var_dump(file_get_contents(str_replace('README', 'TODO', $n)));
?>
Done
--EXPECTF--
++ wrapper
bool(true)
++ stat
+int(0)
+int(16877)
+string(2) "OK"
+int(29)
+int(33188)
+string(2) "OK"
++ file
resource(%d) of type (stream)
int(29)
int(33188)
@@ -34,6 +53,7 @@ string(10) "Mon Feb 12"
bool(false)
string(17) "13:27:47 CET 2018"
bool(true)
++ stream
string(28) "Mon Feb 12 13:27:47 CET 2018"
Warning: file_get_contents(%s/bidon.rpm#/usr/share/doc/bidon/TODO): Failed to open stream: operation failed in %s on line %d