mysqli_class_mysqli_warning.phpt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. --TEST--
  2. Interface of the class mysqli_warning - TODO
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifemb.inc');
  7. require_once('skipifconnectfailure.inc');
  8. require_once('connect.inc');
  9. if (!$TEST_EXPERIMENTAL)
  10. die("skip - experimental (= unsupported) feature");
  11. ?>
  12. --FILE--
  13. <?php
  14. require('connect.inc');
  15. $warning = new mysqli_warning();
  16. $warning = new mysqli_warning(null);
  17. $warning = new mysqli_warning(null, null);
  18. $mysqli = new mysqli();
  19. $warning = new mysqli_warning($mysqli);
  20. $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
  21. $stmt = new mysqli_stmt($mysqli);
  22. $warning = new mysqli_warning($stmt);
  23. $stmt = $mysqli->stmt_init();
  24. $warning = new mysqli_warning($stmt);
  25. $obj = new stdClass();
  26. $warning = new mysqli_warning($obj);
  27. include("table.inc");
  28. $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
  29. $res = $mysqli->query('INSERT INTO test(id, label) VALUES (1, "zz")');
  30. $warning = mysqli_get_warnings($mysqli);
  31. printf("Parent class:\n");
  32. var_dump(get_parent_class($warning));
  33. printf("\nMethods:\n");
  34. $methods = get_class_methods($warning);
  35. $expected_methods = array(
  36. 'next' => true,
  37. );
  38. foreach ($methods as $k => $method) {
  39. if (isset($expected_methods[$method])) {
  40. unset($methods[$k]);
  41. unset($expected_methods[$method]);
  42. }
  43. }
  44. if (!empty($methods)) {
  45. printf("Dumping list of unexpected methods.\n");
  46. var_dump($methods);
  47. }
  48. if (!empty($expected_methods)) {
  49. printf("Dumping list of missing methods.\n");
  50. var_dump($expected_methods);
  51. }
  52. if (empty($methods) && empty($expected_methods))
  53. printf("ok\n");
  54. printf("\nClass variables:\n");
  55. $variables = get_class_vars(get_class($mysqli));
  56. sort($variables);
  57. foreach ($variables as $k => $var)
  58. printf("%s\n", $var);
  59. printf("\nObject variables:\n");
  60. $variables = get_object_vars($mysqli);
  61. foreach ($variables as $k => $var)
  62. printf("%s\n", $var);
  63. printf("\nMagic, magic properties:\n");
  64. assert('' === $warning->message);
  65. printf("warning->message = '%s'\n", $warning->message);
  66. assert('' === $warning->sqlstate);
  67. printf("warning->sqlstate= '%s'\n", $warning->sqlstate);
  68. assert(0 === $warning->errno);
  69. printf("warning->errno = '%s'\n", $warning->errno);
  70. printf("\nAccess to undefined properties:\n");
  71. printf("warning->unknown = '%s'\n", @$warning->unknown);
  72. print "done!";
  73. ?>
  74. --CLEAN--
  75. <?php
  76. require_once("clean_table.inc");
  77. ?>
  78. --EXPECTF--
  79. Warning: Wrong parameter count for mysqli_warning::mysqli_warning() in %s on line %d
  80. Warning: mysqli_warning::mysqli_warning() expects parameter 1 to be object, null given in %s on line %d
  81. Warning: Wrong parameter count for mysqli_warning::mysqli_warning() in %s on line %d
  82. Warning: mysqli_warning::mysqli_warning(): Couldn't fetch mysqli in %s on line %d
  83. Warning: mysqli_warning::mysqli_warning(): invalid object or resource mysqli_stmt
  84. in %s on line %d
  85. Warning: mysqli_warning::mysqli_warning(): invalid object or resource mysqli_stmt
  86. in %s on line %d
  87. Warning: mysqli_warning::mysqli_warning(): invalid class argument in /home/nixnutz/php6_mysqlnd/ext/mysqli/tests/mysqli_class_mysqli_warning.php on line 19
  88. Warning: mysqli_warning::mysqli_warning(): No warnings found in %s on line %d
  89. Parent class:
  90. bool(false)
  91. Methods:
  92. ok
  93. Class variables:
  94. Object variables:
  95. Magic, magic properties:
  96. warning->message = ''
  97. warning->sqlstate= ''
  98. warning->errno = ''
  99. Access to undefined properties:
  100. warning->unknown = ''
  101. done!