dba_db4_018.phpt 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. --TEST--
  2. DBA DB4 with persistent connections
  3. --EXTENSIONS--
  4. dba
  5. --SKIPIF--
  6. <?php
  7. $handler = "db4";
  8. require_once(__DIR__ .'/skipif.inc');
  9. die("info $HND handler used");
  10. ?>
  11. --FILE--
  12. <?php
  13. $handler = "db4";
  14. require_once(__DIR__ .'/test.inc');
  15. echo "database handler: $handler\n";
  16. echo "Test 1\n";
  17. $db_file1 = dba_popen($db_filename, 'n', 'flatfile');
  18. dba_insert("key1", "This is a test insert 1", $db_file1);
  19. echo dba_fetch("key1", $db_file1), "\n";
  20. echo "Test 2\n";
  21. $db_file2 = dba_popen($db_filename, 'n', 'flatfile');
  22. if ($db_file1 === $db_file2) {
  23. echo "resources are the same\n";
  24. } else {
  25. echo "resources are different\n";
  26. }
  27. echo "Test 3 - fetch both rows from second resource\n";
  28. dba_insert("key2", "This is a test insert 2", $db_file2);
  29. echo dba_fetch("key1", $db_file2), "\n";
  30. echo dba_fetch("key2", $db_file2), "\n";
  31. echo "Test 4 - fetch both rows from first resource\n";
  32. echo dba_fetch("key1", $db_file1), "\n";
  33. echo dba_fetch("key2", $db_file1), "\n";
  34. echo "Test 5 - close 2nd resource\n";
  35. dba_close($db_file2);
  36. var_dump($db_file1);
  37. var_dump($db_file2);
  38. echo "Test 6 - query after closing 2nd resource\n";
  39. echo dba_fetch("key1", $db_file1), "\n";
  40. echo dba_fetch("key2", $db_file1), "\n";
  41. ?>
  42. --CLEAN--
  43. <?php
  44. require(__DIR__ .'/clean.inc');
  45. ?>
  46. --XFAIL--
  47. Test 6 crashes with dba pointer of NULL, bug http://bugs.php.net/bug.php?id=51278
  48. --EXPECTF--
  49. database handler: db4
  50. Test 1
  51. This is a test insert 1
  52. Test 2
  53. resources are different
  54. Test 3 - fetch both rows from second resource
  55. This is a test insert 1
  56. This is a test insert 2
  57. Test 4 - fetch both rows from first resource
  58. This is a test insert 1
  59. This is a test insert 2
  60. Test 5 - close 2nd resource
  61. resource(%d) of type (dba persistent)
  62. resource(%d) of type (Unknown)
  63. Test 6 - query after closing 2nd resource
  64. This is a test insert 1
  65. This is a test insert 2