PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/Flush.inc

https://github.com/lord-otori/php-ext-couchbase
PHP | 77 lines | 40 code | 12 blank | 25 comment | 3 complexity | 752664cec83d17d7d2cfcac9d435403f MD5 | raw file
Possible License(s): Apache-2.0, JSON
  1. <?php
  2. require_once 'Common.inc';
  3. /* This class is intended to replace 006.phpt from the older testing scheme. */
  4. class Flush extends CouchbaseTestCommon {
  5. /**
  6. * Common core test setup for get operations (oo)
  7. */
  8. function _test_setup_common_oo() {
  9. $oo = $this->oo;
  10. $key = $this->mk_key();
  11. $val = uniqid('couchbase-value-');
  12. $cas = $oo->set($key, $val);
  13. return array($oo, $key, $val, $cas);
  14. }
  15. /**
  16. * Common core test setup for get operations (non-oo)
  17. */
  18. function _test_setup_common() {
  19. $h = $this->handle;
  20. $key = $this->mk_key();
  21. $val = uniqid('couchbase-value-');
  22. $cas = couchbase_set($h, $key, $val);
  23. return array($h, $key, $val, $cas);
  24. }
  25. /**
  26. * @test flush (oo)
  27. *
  28. * @pre
  29. * setup run
  30. *
  31. * @post
  32. * key is not set
  33. */
  34. function testFlushOO() {
  35. list($oo, $key, $val, $cas) = $this->_test_setup_common_oo();
  36. try {
  37. $oo->flush();
  38. $this->assertNull($oo->get($key));
  39. } catch (CouchbaseAuthenticationException $exp) {
  40. $this->markTestSkipped("Flush command is currently inaccessible (need auth)");
  41. } catch (CouchbaseServerException $exp) {
  42. if (preg_match("/Flush is disabled for the bucket/", $exp->getMessage())) {
  43. $this->markTestSkipped("Flush command is currently inaccessible (not enabled)");
  44. } else {
  45. die("Failed to flush bucket: " . $exp->getMessage() . "\n");
  46. }
  47. }
  48. }
  49. /**
  50. * @test flush
  51. *
  52. * @pre
  53. * setup run
  54. *
  55. * @post
  56. * key is not set
  57. */
  58. function testFlush() {
  59. $this->markTestSkipped("Flush command is currently inaccessible");
  60. list($h, $key, $val, $cas) = $this->_test_setup_common();
  61. couchbase_flush($h);
  62. $this->assertNull(couchbase_get($h, $key));
  63. }
  64. }
  65. ?>