posix_getpgid_variation.phpt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. --TEST--
  2. Test posix_getpgid() function : variation
  3. --SKIPIF--
  4. <?php
  5. PHP_INT_SIZE == 4 or die("skip - 32-bit only");
  6. if((!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. echo "*** Testing posix_getpgid() : usage variations ***\n";
  18. // Initialise function arguments not being substituted (if any)
  19. //get an unset variable
  20. $unset_var = 10;
  21. unset ($unset_var);
  22. //array of values to iterate over
  23. $values = array(
  24. // float data
  25. 10.5,
  26. -10.5,
  27. 10.1234567e10,
  28. 10.7654321E-10,
  29. .5,
  30. // array data
  31. array(),
  32. array(0),
  33. array(1),
  34. array(1, 2),
  35. array('color' => 'red', 'item' => 'pen'),
  36. // null data
  37. NULL,
  38. null,
  39. // boolean data
  40. true,
  41. false,
  42. TRUE,
  43. FALSE,
  44. // empty data
  45. "",
  46. '',
  47. // string data
  48. "string",
  49. 'string',
  50. // undefined data
  51. $undefined_var,
  52. // unset data
  53. $unset_var,
  54. // object data
  55. new stdclass(),
  56. );
  57. // loop through each element of the array for gid
  58. foreach($values as $value) {
  59. echo "\nArg value $value \n";
  60. $result = posix_getpgid($value);
  61. if (is_int($result) || $result === false) {
  62. echo "valid output\n";
  63. } else {
  64. var_dump($result);
  65. }
  66. };
  67. echo "Done";
  68. ?>
  69. --EXPECTF--
  70. *** Testing posix_getpgid() : usage variations ***
  71. Notice: Undefined variable: undefined_var in %s on line %d
  72. Notice: Undefined variable: unset_var in %s on line %d
  73. Arg value 10.5
  74. valid output
  75. Arg value -10.5
  76. valid output
  77. Arg value 101234567000
  78. Warning: posix_getpgid() expects parameter 1 to be int, float given in %s on line %d
  79. valid output
  80. Arg value 1.07654321E-9
  81. valid output
  82. Arg value 0.5
  83. valid output
  84. Notice: Array to string conversion in %sposix_getpgid_variation.php on line %d
  85. Arg value Array
  86. Warning: posix_getpgid() expects parameter 1 to be int, array given in %s on line %d
  87. valid output
  88. Notice: Array to string conversion in %sposix_getpgid_variation.php on line %d
  89. Arg value Array
  90. Warning: posix_getpgid() expects parameter 1 to be int, array given in %s on line %d
  91. valid output
  92. Notice: Array to string conversion in %sposix_getpgid_variation.php on line %d
  93. Arg value Array
  94. Warning: posix_getpgid() expects parameter 1 to be int, array given in %s on line %d
  95. valid output
  96. Notice: Array to string conversion in %sposix_getpgid_variation.php on line %d
  97. Arg value Array
  98. Warning: posix_getpgid() expects parameter 1 to be int, array given in %s on line %d
  99. valid output
  100. Notice: Array to string conversion in %sposix_getpgid_variation.php on line %d
  101. Arg value Array
  102. Warning: posix_getpgid() expects parameter 1 to be int, array given in %s on line %d
  103. valid output
  104. Arg value
  105. valid output
  106. Arg value
  107. valid output
  108. Arg value 1
  109. valid output
  110. Arg value
  111. valid output
  112. Arg value 1
  113. valid output
  114. Arg value
  115. valid output
  116. Arg value
  117. Warning: posix_getpgid() expects parameter 1 to be int, string given in %s on line %d
  118. valid output
  119. Arg value
  120. Warning: posix_getpgid() expects parameter 1 to be int, string given in %s on line %d
  121. valid output
  122. Arg value string
  123. Warning: posix_getpgid() expects parameter 1 to be int, string given in %s on line %d
  124. valid output
  125. Arg value string
  126. Warning: posix_getpgid() expects parameter 1 to be int, string given in %s on line %d
  127. valid output
  128. Arg value
  129. valid output
  130. Arg value
  131. valid output
  132. Recoverable fatal error: Object of class stdClass could not be converted to string in %s on line %d