posix_getpwuid_variation.phpt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. --TEST--
  2. Test posix_getpwuid() function : usage variations - parameter types
  3. --SKIPIF--
  4. <?php
  5. PHP_INT_SIZE == 4 or die("skip - 32-bit only");
  6. if(!extension_loaded("posix")) print "skip - POSIX extension not loaded";
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Prototype : proto array posix_getpwuid(long uid)
  11. * Description: User database access (POSIX.1, 9.2.2)
  12. * Source code: ext/posix/posix.c
  13. * Alias to functions:
  14. */
  15. echo "*** Testing posix_getpwuid() : usage variations ***\n";
  16. // Initialise function arguments not being substituted (if any)
  17. //get an unset variable
  18. $unset_var = 10;
  19. unset ($unset_var);
  20. //array of values to iterate over
  21. $values = array(
  22. // float data
  23. 10.5,
  24. -10.5,
  25. 10.1234567e10,
  26. 10.7654321E-10,
  27. .5,
  28. // array data
  29. array(),
  30. array(0),
  31. array(1),
  32. array(1, 2),
  33. array('color' => 'red', 'item' => 'pen'),
  34. // null data
  35. NULL,
  36. null,
  37. // boolean data
  38. true,
  39. false,
  40. TRUE,
  41. FALSE,
  42. // empty data
  43. "",
  44. '',
  45. // string data
  46. "string",
  47. 'string',
  48. // undefined data
  49. $undefined_var,
  50. // unset data
  51. $unset_var,
  52. // object data
  53. new stdclass(),
  54. );
  55. // loop through each element of the array for uid
  56. foreach($values as $value) {
  57. echo "\nArg value $value \n";
  58. $result = posix_getpwuid($value);
  59. if ((is_array($result) && (count($result) == 7))
  60. ||
  61. ($result === false)) {
  62. echo "valid output\n";
  63. } else {
  64. var_dump($result);
  65. }
  66. };
  67. echo "Done";
  68. ?>
  69. --EXPECTF--
  70. *** Testing posix_getpwuid() : 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_getpwuid() 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_getpwuid_variation.php on line %d
  85. Arg value Array
  86. Warning: posix_getpwuid() expects parameter 1 to be int, array given in %s on line %d
  87. valid output
  88. Notice: Array to string conversion in %sposix_getpwuid_variation.php on line %d
  89. Arg value Array
  90. Warning: posix_getpwuid() expects parameter 1 to be int, array given in %s on line %d
  91. valid output
  92. Notice: Array to string conversion in %sposix_getpwuid_variation.php on line %d
  93. Arg value Array
  94. Warning: posix_getpwuid() expects parameter 1 to be int, array given in %s on line %d
  95. valid output
  96. Notice: Array to string conversion in %sposix_getpwuid_variation.php on line %d
  97. Arg value Array
  98. Warning: posix_getpwuid() expects parameter 1 to be int, array given in %s on line %d
  99. valid output
  100. Notice: Array to string conversion in %sposix_getpwuid_variation.php on line %d
  101. Arg value Array
  102. Warning: posix_getpwuid() 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_getpwuid() expects parameter 1 to be int, string given in %s on line %d
  118. valid output
  119. Arg value
  120. Warning: posix_getpwuid() expects parameter 1 to be int, string given in %s on line %d
  121. valid output
  122. Arg value string
  123. Warning: posix_getpwuid() expects parameter 1 to be int, string given in %s on line %d
  124. valid output
  125. Arg value string
  126. Warning: posix_getpwuid() 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