xref: /PHP-5.6/ext/posix/tests/posix_getgrgid.phpt (revision 4a110443)
1--TEST--
2Test posix_getgrgid().
3--CREDITS--
4Till Klampaeckel, till@php.net
5TestFest Berlin 2009
6--SKIPIF--
7<?php
8if (!extension_loaded('posix')) {
9    die('SKIP The posix extension is not loaded.');
10}
11?>
12--FILE--
13<?php
14$grp = posix_getgrgid(0);
15if (!isset($grp['name'])) {
16    die('Array index "name" does not exist.');
17}
18if (!isset($grp['passwd'])) {
19    die('Array index "passwd" does not exist.');
20}
21if (!isset($grp['members'])) {
22    die('Array index "members" does not exist.');
23} elseif (!is_array($grp['members'])) {
24    die('Array index "members" must be an array.');
25} else {
26    if (count($grp['members']) > 0) {
27        foreach ($grp['members'] as $idx => $username) {
28            if (!is_int($idx)) {
29                die('Index in members Array is not an int.');
30            }
31            if (!is_string($username)) {
32                die('Username in members Array is not of type string.');
33            }
34        }
35    }
36}
37if (!isset($grp['gid'])) {
38    die('Array index "gid" does not exist.');
39}
40var_dump($grp['gid']);
41?>
42===DONE===
43--EXPECT--
44int(0)
45===DONE===
46