dba015.phpt 1.9 KB

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