posix_getpwuid_variation.phpt 3.6 KB

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