add glob_err test
authorMichael Wallner <mike@php.net>
Mon, 17 Oct 2016 08:38:39 +0000 (10:38 +0200)
committerMichael Wallner <mike@php.net>
Tue, 18 Oct 2016 08:31:05 +0000 (10:31 +0200)
tests/glob/glob004.phpt [new file with mode: 0644]

diff --git a/tests/glob/glob004.phpt b/tests/glob/glob004.phpt
new file mode 100644 (file)
index 0000000..eec1912
--- /dev/null
@@ -0,0 +1,72 @@
+--TEST--
+glob err
+--INI--
+psi.directory={PWD}/../../psi.d:{PWD}
+--SKIPIF--
+<?php
+extension_loaded("psi") or die("skip - need ext/psi");
+is_dir("/etc/sudoers.d") and !is_readable("/etc/sudoers.d") or die("skip - only for Linux with unreadable sudoers.d");
+?>
+--FILE--
+===TEST===
+<?php
+var_dump(psi\GLOB_ABORTED == psi\glob("/etc/sudoers.d/*", psi\GLOB_ERR, $glob, function($epath, $eerrno) {
+       printf("%s: %s\n", psi\strerror($eerrno), $epath);
+}));
+var_dump($glob);
+
+var_dump(psi\GLOB_ABORTED == psi\glob("/etc/sudoers.d/*", 0, $glob, function($epath, $eerrno) {
+       printf("%s: %s\n", psi\strerror($eerrno), $epath);
+       return 1;
+}));
+var_dump($glob);
+
+var_dump(psi\GLOB_ABORTED == psi\glob("/etc/sudoers.d/*", 0, $glob, function($epath, $eerrno) {
+       printf("%s: %s\n", psi\strerror($eerrno), $epath);
+       return 0;
+}));
+var_dump($glob);
+?>
+===DONE===
+--EXPECTF--
+===TEST===
+Permission denied: /etc/sudoers.d
+bool(true)
+array(4) {
+  ["gl_pathc"]=>
+  int(0)
+  ["gl_offs"]=>
+  int(0)
+  ["gl_flags"]=>
+  int(%d)
+  ["gl_pathv"]=>
+  array(0) {
+  }
+}
+Permission denied: /etc/sudoers.d
+bool(true)
+array(4) {
+  ["gl_pathc"]=>
+  int(0)
+  ["gl_offs"]=>
+  int(0)
+  ["gl_flags"]=>
+  int(%d)
+  ["gl_pathv"]=>
+  array(0) {
+  }
+}
+Permission denied: /etc/sudoers.d
+bool(false)
+array(4) {
+  ["gl_pathc"]=>
+  int(0)
+  ["gl_offs"]=>
+  int(0)
+  ["gl_flags"]=>
+  int(%d)
+  ["gl_pathv"]=>
+  array(0) {
+  }
+}
+===DONE===