dba_cdb_001.phpt 2.0 KB

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