dba_cdb_001.phpt 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. --TEST--
  2. DBA CDB handler test
  3. --SKIPIF--
  4. <?php
  5. $handler = 'cdb';
  6. require_once(dirname(__FILE__) .'/skipif.inc');
  7. die('info CDB does not support replace or delete');
  8. ?>
  9. --FILE--
  10. <?php
  11. $handler = 'cdb';
  12. require_once(dirname(__FILE__) .'/test.inc');
  13. echo "Test 0\n";
  14. if (($db_file = dba_open($db_filename, 'n', $handler))!==FALSE) {
  15. var_dump(dba_insert("key1", "Content String 1", $db_file));
  16. var_dump(dba_replace("key1", "New Content String", $db_file));
  17. var_dump(dba_fetch("key1", $db_file));
  18. var_dump(dba_firstkey($db_file));
  19. var_dump(dba_delete("key1", $db_file));
  20. var_dump(dba_optimize($db_file));
  21. var_dump(dba_sync($db_file));
  22. dba_close($db_file);
  23. }
  24. else {
  25. echo "Failed to open DB\n";
  26. }
  27. unlink($db_filename);
  28. echo "Test 1\n";
  29. if (($db_file = dba_open($db_filename, 'c', $handler))!==FALSE) {
  30. dba_insert("key1", "Content String 1", $db_file);
  31. dba_close($db_file);
  32. }
  33. else {
  34. echo "Failed to open DB\n";
  35. }
  36. echo "Test 2\n";
  37. if (($db_file = dba_open($db_filename, 'r', $handler))!==FALSE) {
  38. dba_insert("key1", "Content String 1", $db_file);
  39. dba_close($db_file);
  40. }
  41. else {
  42. echo "Failed to open DB\n";
  43. }
  44. echo "Test 3\n";
  45. if (($db_file = dba_open($db_filename, 'w', $handler))!==FALSE) {
  46. echo dba_fetch("key1", $db_file), "\n";
  47. dba_close($db_file);
  48. }
  49. else {
  50. echo "Failed to open DB\n";
  51. }
  52. ?>
  53. ===DONE===
  54. --CLEAN--
  55. <?php
  56. require(dirname(__FILE__) .'/clean.inc');
  57. ?>
  58. --EXPECTF--
  59. Test 0
  60. bool(true)
  61. bool(false)
  62. bool(false)
  63. bool(false)
  64. bool(false)
  65. bool(true)
  66. bool(true)
  67. Test 1
  68. Warning: dba_open(%stest0.dbm,c): Driver initialization failed for handler: cdb: Update operations are not supported in %sdba_cdb_001.php on line %d
  69. Failed to open DB
  70. Test 2
  71. Warning: dba_insert(): You cannot perform a modification to a database without proper access in %sdba_cdb_001.php on line %d
  72. Test 3
  73. Warning: dba_open(%stest0.dbm,w): Driver initialization failed for handler: cdb: Update operations are not supported in %sdba_cdb_001.php on line %d
  74. Failed to open DB
  75. ===DONE===