Skip to content

Commit

Permalink
fixes Couchbase tests to not throw floating point exception 8
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Apr 22, 2015
1 parent 67afff5 commit 899cb94
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions test/lib/OAuth2/Storage/Bootstrap.php
Expand Up @@ -171,19 +171,29 @@ private function testMongoConnection(\MongoClient $mongo)
public function getCouchbase()
{
if (!$this->couchbase) {
$skipCouchbase = $this->getEnvVar('SKIP_COUCHBASE_TESTS');
if (!$skipCouchbase && class_exists('Couchbase')) {
$couchbase = new \Couchbase(array('localhost:8091'), '', '', 'auth', false);
if ($this->testCouchbaseConnection($couchbase)) {
$this->clearCouchbase($couchbase);
$this->createCouchbaseDB($couchbase);

$this->couchbase = new CouchbaseDB($couchbase);
if ($this->getEnvVar('SKIP_COUCHBASE_TESTS')) {
$this->couchbase = new NullStorage('Couchbase', 'Skipping Couchbase tests');
} elseif (!class_exists('Couchbase')) {
$this->couchbase = new NullStorage('Couchbase', 'Missing Couchbase php extension. Please install couchbase.so');
} else {
// round-about way to make sure couchbase is working
// this is required because it throws a "floating point exception" otherwise
$code = "new \Couchbase(array('localhost:8091'), '', '', 'auth', false);";
$exec = sprintf('php -r "%s"', $code);
$ret = exec($exec, $test, $var);
if ($ret != 0) {
$couchbase = new \Couchbase(array('localhost:8091'), '', '', 'auth', false);
if ($this->testCouchbaseConnection($couchbase)) {
$this->clearCouchbase($couchbase);
$this->createCouchbaseDB($couchbase);

$this->couchbase = new CouchbaseDB($couchbase);
} else {
$this->couchbase = new NullStorage('Couchbase', 'Unable to connect to Couchbase server on "localhost:8091"');
}
} else {
$this->couchbase = new NullStorage('Couchbase', 'Unable to connect to Couchbase server on "localhost:8091"');
$this->couchbase = new NullStorage('Couchbase', 'Error while trying to connect to Couchbase');
}
} else {
$this->couchbase = new NullStorage('Couchbase', 'Missing Couchbase php extension. Please install couchbase.so');
}
}

Expand Down

0 comments on commit 899cb94

Please sign in to comment.