1 | <?php |
||
28 | class CouchbaseTest extends CommonAdapterTest |
||
29 | { |
||
30 | public function setUp() |
||
31 | { |
||
32 | if (!getenv('TESTS_ZEND_CACHE_COUCHBASE_ENABLED')) { |
||
33 | $this->markTestSkipped('Enable TESTS_ZEND_CACHE_COUCHBASE_ENABLED to run this test'); |
||
34 | } |
||
35 | if (version_compare('2.0.0', phpversion('couchbase')) > 0) { |
||
36 | try { |
||
37 | new Couchbase(); |
||
38 | $this->fail("Expected exception Zend\Cache\Exception\ExtensionNotLoadedException"); |
||
39 | } catch (ExtensionNotLoadedException $e) { |
||
40 | $this->markTestSkipped("Missing ext/couchbase version >= 2.0.0"); |
||
41 | } |
||
42 | } |
||
43 | $this->_options = new CouchbaseOptions([ |
||
44 | 'resource_id' => __CLASS__ |
||
45 | ]); |
||
46 | if (getenv('TESTS_ZEND_CACHE_COUCHBASE_HOST') && getenv('TESTS_ZEND_CACHE_COUCHBASE_PORT')) { |
||
47 | $this->_options->getResourceManager()->setServer(__CLASS__, [ |
||
48 | [getenv('TESTS_ZEND_CACHE_COUCHBASE_HOST'), getenv('TESTS_ZEND_CACHE_COUCHBASE_PORT')] |
||
49 | ]); |
||
50 | } elseif (getenv('TESTS_ZEND_CACHE_COUCHBASE_HOST')) { |
||
51 | $this->_options->getResourceManager()->setServer(__CLASS__, [ |
||
52 | [getenv('TESTS_ZEND_CACHE_COUCHBASE_HOST')] |
||
53 | ]); |
||
54 | } |
||
55 | if (getenv('TESTS_ZEND_CACHE_COUCHBASE_USERNAME')) { |
||
56 | $this->_options->getResourceManager()->setUsername(__CLASS__, getenv('TESTS_ZEND_CACHE_COUCHBASE_USERNAME')); |
||
57 | } |
||
58 | if (getenv('TESTS_ZEND_CACHE_COUCHBASE_PASSWORD')) { |
||
59 | $this->_options->getResourceManager()->setPassword(__CLASS__, getenv('TESTS_ZEND_CACHE_COUCHBASE_PASSWORD')); |
||
60 | } |
||
61 | if (getenv('TESTS_ZEND_CACHE_COUCHBASE_BUCKET')) { |
||
62 | $this->_options->getResourceManager()->setBucket(__CLASS__, getenv('TESTS_ZEND_CACHE_COUCHBASE_BUCKET')); |
||
63 | } |
||
64 | $this->_storage = new Couchbase(); |
||
65 | $this->_storage->setOptions($this->_options); |
||
66 | $this->_storage->flush(); |
||
67 | parent::setUp(); |
||
68 | } |
||
69 | |||
70 | public function tearDown() |
||
71 | { |
||
72 | if ($this->_storage) { |
||
73 | $this->_storage->flush(); |
||
74 | } |
||
75 | parent::tearDown(); |
||
76 | } |
||
77 | } |
||
78 |