posix_getpgid_variation.phpt 3.7 KB

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