Skip to content

Commit

Permalink
Update environment variables for tests
Browse files Browse the repository at this point in the history
Change-Id: I3b6ff92edd3190973bdf197b5d91fb38aeece527
Reviewed-on: http://review.couchbase.org/77545
Tested-by: Build Bot <[email protected]>
Reviewed-by: Sergey Avseyev <[email protected]>
  • Loading branch information
avsej committed May 1, 2017
1 parent ad67826 commit 2a15e9b
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 20 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Couchbase PHP Client [![Build Status](http://sdkbuilds.sc.couchbase.com/buildStatus/icon?job=builds-php)](http://sdkbuilds.sc.couchbase.com/job/builds-php)
# Couchbase PHP Client [![Build Status](http://sdkbuilds.sc.couchbase.com/buildStatus/icon?job=builds-php)](http://sdkbuilds.sc.couchbase.com/job/builds-php)

This library allows you to connect to a Couchbase cluster from PHP.
It is a native PHP extension and uses the very fast libcouchbase library to
Expand Down Expand Up @@ -97,8 +97,8 @@ The source code is available at
To execute our test suite, simply install and execute phpunit against your
checked out source code. Tests assume that you have Couchbase Server with
default bucket running on localhost (otherwise use environment variable
`CPDSN`, `CPBUCKET`, `CPUSER`, `CPPASS`. E.g. `CPDSN=couchbase://192.168.1.42/
CPBUCKET=travel-sample`).
`CB_DSN`, `CB_ADMIN_USER`, `CB_ADMIN_PASSWORD`, `CB_BUCKET`, `CB_USER`,
`CB_PASSWORD`. E.g. `CB_DSN=couchbase://192.168.1.42/ CB_BUCKET=travel-sample`).

```bash
curl -L https://phar.phpunit.de/phpunit.phar > ~/bin/phpunit
Expand Down
2 changes: 1 addition & 1 deletion integration/CrossBucketN1qlQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class SearchTest extends PHPUnit_Framework_TestCase {
public function __construct() {
$testDsn = getenv('CPDSN');
$testDsn = getenv('CB_DSN');
if ($testDsn === FALSE) {
$testDsn = 'couchbase://localhost/';
}
Expand Down
6 changes: 5 additions & 1 deletion integration/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
*/
class SearchTest extends PHPUnit_Framework_TestCase {
public function __construct() {
$this->testDsn = getenv('CPDSN');
$this->testDsn = getenv('CB_DSN');
if ($this->testDsn === FALSE) {
$this->testDsn = 'couchbase://localhost/';
}
$this->authenticator = \Couchbase\ClassicAuthenticator();
$this->authenticator->bucket('beer-sample', getenv('CB_USER_PASSWORD'));
}

protected function setUp() {
$this->cluster = new \Couchbase\Cluster($this->testDsn);
$this->cluster->authenticate($this->authenticator);
$this->bucket = $this->cluster->openBucket('beer-sample');
}

Expand Down Expand Up @@ -56,6 +59,7 @@ function testSearchWithNoHits() {

function testSearchWithConsistency() {
$cluster = new \Couchbase\Cluster($this->testDsn . '?fetch_mutation_tokens=true');
$this->cluster->authenticate($this->authenticator);
$bucket = $cluster->openBucket('beer-sample');

$id = uniqid('testSearchWithConsistency');
Expand Down
1 change: 1 addition & 0 deletions tests/BucketManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class BucketManagerTest extends CouchbaseTestCase {
*/
function testConnect() {
$h = new \Couchbase\Cluster($this->testDsn);
$h->authenticate($this->testAuthenticator);
$m = $h->openBucket($this->testBucket)->manager();
return $m;
}
Expand Down
9 changes: 6 additions & 3 deletions tests/BucketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ function testBadBucket() {
*/
function testConnect() {
$h = new \Couchbase\Cluster($this->testDsn);
$b = $h->openBucket();
$h->authenticate($this->testAuthenticator);
$b = $h->openBucket($this->testBucket);
$this->setTimeouts($b);
return $b;
}
Expand Down Expand Up @@ -318,7 +319,8 @@ function testRecursiveTranscode() {
global $recursive_transcoder_key3;

$h = new \Couchbase\Cluster($this->testDsn);
$b = $h->openBucket();
$h->authenticate($this->testAuthenticator);
$b = $h->openBucket($this->testBucket);
$this->setTimeouts($b);

$key1 = $this->makeKey('basicUpsertKey1');
Expand Down Expand Up @@ -362,7 +364,8 @@ function testRecursiveTranscode() {
*/
function testOptionVals() {
$h = new \Couchbase\Cluster($this->testDsn . "?console_log_level=42");
$b = $h->openBucket();
$h->authenticate($this->testAuthenticator);
$b = $h->openBucket($this->testBucket);

$checkVal = 243;

Expand Down
6 changes: 3 additions & 3 deletions tests/ClusterManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class ClusterManagerTest extends CouchbaseTestCase {
*/
function testConnect() {
$h = new \Couchbase\Cluster($this->testDsn);
$this->assertNotNull($this->testUser);
$this->assertNotNull($this->testPass);
$m = $h->manager($this->testUser, $this->testPass);
$this->assertNotNull($this->testAdminUser);
$this->assertNotNull($this->testAdminPassword);
$m = $h->manager($this->testAdminUser, $this->testAdminPassword);
return $m;
}

Expand Down
31 changes: 23 additions & 8 deletions tests/CouchbaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,44 @@
class CouchbaseTestCase extends \PHPUnit_Framework_TestCase {
public $testDsn;
public $testBucket;
public $testAdminUser;
public $testAdminPassword;
public $testUser;
public $testPass;
public $testPassword;
public $testAuthenticator;

public function __construct() {
$this->testDsn = getenv('CPDSN');
$this->testDsn = getenv('CB_DSN');
if ($this->testDsn === FALSE) {
$this->testDsn = 'couchbase://localhost/default';
}

$this->testBucket = getenv('CPBUCKET');
$this->testBucket = getenv('CB_BUCKET');
if ($this->testBucket === FALSE) {
$this->testBucket = 'default';
}

$this->testUser = getenv('CPUSER');
$this->testAdminUser = getenv('CB_ADMIN_USER');
if ($this->testAdminUser === FALSE) {
$this->testAdminUser = 'Administrator';
}

$this->testAdminPassword = getenv('CB_ADMIN_PASSWORD');
if ($this->testAdminPassword === FALSE) {
$this->testAdminPassword = 'password';
}

$this->testUser = getenv('CB_USER');
if ($this->testUser === FALSE) {
$this->testUser = 'Administrator';
$this->testUser = 'default';
}

$this->testPass = getenv('CPPASS');
if ($this->testPass === FALSE) {
$this->testPass = 'password';
$this->testPassword = getenv('CB_PASSWORD');
if ($this->testPassword === FALSE) {
$this->testPassword = '';
}
$this->testAuthenticator = new \Couchbase\ClassicAuthenticator();
$this->testAuthenticator->bucket($this->testBucket, $this->testPassword);
}

function setTimeouts($bucket) {
Expand Down
1 change: 1 addition & 0 deletions tests/DatastructuresTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class DatastructuresTest extends CouchbaseTestCase {

protected function setUp() {
$this->cluster = new \Couchbase\Cluster($this->testDsn);
$this->cluster->authenticate($this->testAuthenticator);
$this->bucket = $this->cluster->openBucket($this->testBucket);
$this->setTimeouts($this->bucket);
}
Expand Down
2 changes: 2 additions & 0 deletions tests/N1qlQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class N1qlQueryTest extends CouchbaseTestCase {

protected function setUp() {
$this->cluster = new \Couchbase\Cluster($this->testDsn);
$this->cluster->authenticate($this->testAuthenticator);
$this->bucket = $this->cluster->openBucket($this->testBucket);
$this->setTimeouts($this->bucket);
}
Expand Down Expand Up @@ -65,6 +66,7 @@ function testParameters() {
function testAtPlus() {
$bucketName = $this->testBucket;
$cluster = new \Couchbase\Cluster($this->testDsn . '?fetch_mutation_tokens=true');
$cluster->authenticate($this->testAuthenticator);
$bucket = $cluster->openBucket($bucketName);
$this->setTimeouts($bucket);

Expand Down
2 changes: 1 addition & 1 deletion tests/ViewQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
class ViewQueryTest extends CouchbaseTestCase {
protected function setUp() {
$this->cluster = new \Couchbase\Cluster($this->testDsn);
$this->cluster->authenticate($this->testAuthenticator);
$this->bucket = $this->cluster->openBucket($this->testBucket);
$this->manager = $this->bucket->manager();
$this->setTimeouts($this->bucket);

}

function testConsistency() {
Expand Down

0 comments on commit 2a15e9b

Please sign in to comment.