@@ -116,23 +116,9 @@ class Connection extends CouchbaseTestCommon
116
116
'bad-password ' ,
117
117
'does-not-exist ' );
118
118
119
- } catch (Exception $ e ) {
119
+ } catch (CouchbaseLibcouchbaseException $ e ) {
120
120
$ this ->assertRegExp ('/failed/i ' , $ e ->getMessage ());
121
121
}
122
-
123
- // now, make sure the object would support the given operations:
124
- $ this ->setErrorsRaiseException (false );
125
-
126
- $ oo = new Couchbase ('http://999.999.999.999:9999 ' ,
127
- 'bad-user ' ,
128
- 'bad-password ' ,
129
- 'does-not-exist ' );
130
-
131
- $ this ->assertGreaterThan (0 , $ oo ->getResultCode ());
132
- $ this ->assertNotNull ($ oo ->getResultMessage ());
133
- $ this ->assertNotEquals ("" , $ oo ->getResultMessage ());
134
-
135
- $ this ->setErrorsRaiseException (true );
136
122
}
137
123
138
124
function testConnectUri () {
@@ -170,7 +156,7 @@ class Connection extends CouchbaseTestCommon
170
156
array ($ url ),
171
157
"/failed/i " );
172
158
173
- $ this ->assertExceptionRegexp (function ($ u ) { return new Couchbase ($ u ); },
159
+ $ this ->assertExceptionRegexp (function ($ u ) { return new Couchbase ($ u ); },
174
160
array ($ url ),
175
161
"/failed/i " );
176
162
@@ -179,15 +165,18 @@ class Connection extends CouchbaseTestCommon
179
165
$ h = couchbase_connect ($ url );
180
166
$ this ->assertFalse ($ h );
181
167
182
- $ o = new Couchbase ($ url );
183
- $ this ->assertEquals (24 , $ o ->getResultCode ()); // 24 = 0x18 = LCB_CONNECT_ERROR
184
- $ this ->assertContains ('Connection ' , $ o ->getResultMessage ());
168
+ try {
169
+ $ o = new Couchbase ($ url );
170
+ $ this ->assertNull ("We should fail to connect " );
171
+ } catch (CouchbaseLibcouchbaseException $ e ) {
172
+ $ this ->assertRegexp ('/connect/i ' , $ e ->getMessage ());
173
+ }
185
174
186
175
# Try with a malformed uri
187
176
188
- try {
189
- $ cb = new Couchbase (array ("http:// " ));
190
- $ his ->assertNull ("We should detect bogus url " );
177
+ try {
178
+ $ cb = new Couchbase (array ("http:// " ));
179
+ $ this ->assertNull ("We should detect bogus url " );
191
180
} catch (CouchbaseException $ e ) {
192
181
$ this ->assertRegexp ('/malformed/i ' , $ e ->getMessage ());
193
182
}
@@ -201,11 +190,13 @@ class Connection extends CouchbaseTestCommon
201
190
$ h = couchbase_connect ($ hosts );
202
191
$ this ->assertFalse ($ h );
203
192
204
- $ o = new Couchbase ($ hosts );
205
- $ this ->assertEquals (24 , $ o ->getResultCode ()); // see note above re: 24
206
- $ this ->assertContains ('Connection ' , $ o ->getResultMessage ());
193
+ try {
194
+ $ o = new Couchbase ($ hosts );
195
+ $ this ->assertNull ("We should fail to connect " );
196
+ } catch (CouchbaseLibcouchbaseException $ e ) {
197
+ $ this ->assertRegexp ('/connect/i ' , $ e ->getMessage ());
198
+ }
207
199
}
208
-
209
200
}
210
201
211
202
/**
0 commit comments