1--TEST--
2Test posix_getpgid() function : variation
3--SKIPIF--
4<?php
5PHP_INT_SIZE == 4 or die("skip - 32-bit only");
6if((!extension_loaded("posix")) || (!function_exists("posix_getpgid"))) {
7	 print "skip - POSIX extension not loaded or posix_getpgid() does not exist";
8}
9?>
10--FILE--
11<?php
12/* Prototype  : proto int posix_getpgid(void)
13 * Description: Get the process group id of the specified process (This is not a POSIX function, but a SVR4ism, so we compile conditionally)
14 * Source code: ext/posix/posix.c
15 * Alias to functions:
16 */
17
18echo "*** Testing posix_getpgid() : usage variations ***\n";
19
20// Initialise function arguments not being substituted (if any)
21
22//get an unset variable
23$unset_var = 10;
24unset ($unset_var);
25
26//array of values to iterate over
27$values = array(
28
29      // float data
30      10.5,
31      -10.5,
32      10.1234567e10,
33      10.7654321E-10,
34      .5,
35
36      // array data
37      array(),
38      array(0),
39      array(1),
40      array(1, 2),
41      array('color' => 'red', 'item' => 'pen'),
42
43      // null data
44      NULL,
45      null,
46
47      // boolean data
48      true,
49      false,
50      TRUE,
51      FALSE,
52
53      // empty data
54      "",
55      '',
56
57      // string data
58      "string",
59      'string',
60
61      // undefined data
62      $undefined_var,
63
64      // unset data
65      $unset_var,
66
67      // object data
68      new stdclass(),
69);
70
71// loop through each element of the array for gid
72
73foreach($values as $value) {
74      echo "\nArg value $value \n";
75      $result = posix_getpgid($value);
76      if (is_int($result) || $result === false) {
77          echo "valid output\n";
78      } else {
79          var_dump($result);
80      }
81};
82
83echo "Done";
84?>
85--EXPECTF--
86*** Testing posix_getpgid() : usage variations ***
87
88Notice: Undefined variable: undefined_var in %s on line %d
89
90Notice: Undefined variable: unset_var in %s on line %d
91
92Arg value 10.5
93valid output
94
95Arg value -10.5
96valid output
97
98Arg value 101234567000
99
100Warning: posix_getpgid() expects parameter 1 to be int, float given in %s on line %d
101valid output
102
103Arg value 1.07654321E-9
104valid output
105
106Arg value 0.5
107valid output
108
109Notice: Array to string conversion in %sposix_getpgid_variation.php on line %d
110
111Arg value Array
112
113Warning: posix_getpgid() expects parameter 1 to be int, array given in %s on line %d
114valid output
115
116Notice: Array to string conversion in %sposix_getpgid_variation.php on line %d
117
118Arg value Array
119
120Warning: posix_getpgid() expects parameter 1 to be int, array given in %s on line %d
121valid output
122
123Notice: Array to string conversion in %sposix_getpgid_variation.php on line %d
124
125Arg value Array
126
127Warning: posix_getpgid() expects parameter 1 to be int, array given in %s on line %d
128valid output
129
130Notice: Array to string conversion in %sposix_getpgid_variation.php on line %d
131
132Arg value Array
133
134Warning: posix_getpgid() expects parameter 1 to be int, array given in %s on line %d
135valid output
136
137Notice: Array to string conversion in %sposix_getpgid_variation.php on line %d
138
139Arg value Array
140
141Warning: posix_getpgid() expects parameter 1 to be int, array given in %s on line %d
142valid output
143
144Arg value
145valid output
146
147Arg value
148valid output
149
150Arg value 1
151valid output
152
153Arg value
154valid output
155
156Arg value 1
157valid output
158
159Arg value
160valid output
161
162Arg value
163
164Warning: posix_getpgid() expects parameter 1 to be int, string given in %s on line %d
165valid output
166
167Arg value
168
169Warning: posix_getpgid() expects parameter 1 to be int, string given in %s on line %d
170valid output
171
172Arg value string
173
174Warning: posix_getpgid() expects parameter 1 to be int, string given in %s on line %d
175valid output
176
177Arg value string
178
179Warning: posix_getpgid() expects parameter 1 to be int, string given in %s on line %d
180valid output
181
182Arg value
183valid output
184
185Arg value
186valid output
187
188Recoverable fatal error: Object of class stdClass could not be converted to string in %s on line %d
189