Skip to content

Commit 01f24dc

Browse files
committed
Update some tests that fell foul of the refactoring to connect when creating a server
1 parent 1ed1648 commit 01f24dc

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

tests/PHPCouchDB/ServerTest.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,20 @@
1212
class ServerTest extends \PHPUnit\Framework\TestCase
1313
{
1414
public function setUp() {
15-
// use some url and client variables
16-
$this->url = "http://localhost:5984";
17-
$this->client = new \GuzzleHttp\Client(["base_uri" => $this->url]);
18-
1915
// create the first request to check we can connect, can be added to
2016
// the mocks for any test that wants it
2117
$couchdb1 = '{"couchdb":"Welcome","uuid":"fce3d5aabfe189c988273c0ffa8d375b","version":"1.6.0","vendor":{"name":"Ubuntu","version":"15.10"}}';
2218
$this->db_response = new Response(200, [], $couchdb1);
2319
}
2420

25-
public function testCreateWithURL() {
26-
$server = new \PHPCouchDB\Server(["url" => $this->url]);
21+
public function testCreateWithClient() {
22+
$mock = new MockHandler([ $this->db_response ]);
2723

28-
$this->assertObjectHasAttribute('client', $server);
29-
$this->assertAttributeInstanceOf('\GuzzleHttp\ClientInterface', 'client', $server);
30-
}
24+
$handler = HandlerStack::create($mock);
25+
$client = new Client(['handler' => $handler]);
3126

32-
public function testCreateWithClient() {
33-
$server = new \PHPCouchDB\Server(["client" => $this->client]);
27+
// userland code starts
28+
$server = new \PHPCouchDB\Server(["client" => $client]);
3429

3530
$this->assertObjectHasAttribute('client', $server);
3631
$this->assertAttributeInstanceOf('\GuzzleHttp\ClientInterface', 'client', $server);

0 commit comments

Comments
 (0)