1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* zf-couchbase2 |
4
|
|
|
* |
5
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
6
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
7
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
8
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
9
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
10
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
11
|
|
|
* SOFTWARE. |
12
|
|
|
* |
13
|
|
|
* @copyright 2015 MehrAlsNix (http://www.mehralsnix.de) |
14
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
15
|
|
|
* @link http://github.com/MehrAlsNix/zf-couchbase2 |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace MehrAlsNix\Test\ZF\Cache\Storage\Adapter; |
19
|
|
|
|
20
|
|
|
use MehrAlsNix\ZF\Cache\Storage\Adapter\Couchbase; |
21
|
|
|
use MehrAlsNix\ZF\Cache\Storage\Adapter\CouchbaseOptions; |
22
|
|
|
use Zend\Cache\Exception\ExtensionNotLoadedException; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Class CouchbaseTest |
26
|
|
|
* @package MehrAlsNix\Test\ZF\Cache\Storage\Adapter |
27
|
|
|
*/ |
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 testLibOptionsSet() |
71
|
|
|
{ |
72
|
|
|
$options = new CouchbaseOptions(); |
73
|
|
|
$options->setLibOptions([ |
74
|
|
|
'SERTYPE_IGBINARY' => false |
75
|
|
|
]); |
76
|
|
|
$this->assertEquals($options->getResourceManager()->getLibOptions( |
77
|
|
|
$options->getResourceId() |
78
|
|
|
), false); |
79
|
|
|
$couchbase = new Couchbase($options); |
80
|
|
|
$this->assertEquals($couchbase->getOptions()->getLibOptions(), [ |
81
|
|
|
\COUCHBASE_SERTYPE_IGBINARY => false |
82
|
|
|
]); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
public function tearDown() |
87
|
|
|
{ |
88
|
|
|
if ($this->_storage) { |
89
|
|
|
$this->_storage->flush(); |
|
|
|
|
90
|
|
|
} |
91
|
|
|
parent::tearDown(); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: