|
12 | 12 | class ServerTest extends \PHPUnit\Framework\TestCase |
13 | 13 | { |
14 | 14 | 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 | | - |
19 | 15 | // create the first request to check we can connect, can be added to |
20 | 16 | // the mocks for any test that wants it |
21 | 17 | $couchdb1 = '{"couchdb":"Welcome","uuid":"fce3d5aabfe189c988273c0ffa8d375b","version":"1.6.0","vendor":{"name":"Ubuntu","version":"15.10"}}'; |
22 | 18 | $this->db_response = new Response(200, [], $couchdb1); |
23 | 19 | } |
24 | 20 |
|
25 | | - public function testCreateWithURL() { |
26 | | - $server = new \PHPCouchDB\Server(["url" => $this->url]); |
| 21 | + public function testCreateWithClient() { |
| 22 | + $mock = new MockHandler([ $this->db_response ]); |
27 | 23 |
|
28 | | - $this->assertObjectHasAttribute('client', $server); |
29 | | - $this->assertAttributeInstanceOf('\GuzzleHttp\ClientInterface', 'client', $server); |
30 | | - } |
| 24 | + $handler = HandlerStack::create($mock); |
| 25 | + $client = new Client(['handler' => $handler]); |
31 | 26 |
|
32 | | - public function testCreateWithClient() { |
33 | | - $server = new \PHPCouchDB\Server(["client" => $this->client]); |
| 27 | + // userland code starts |
| 28 | + $server = new \PHPCouchDB\Server(["client" => $client]); |
34 | 29 |
|
35 | 30 | $this->assertObjectHasAttribute('client', $server); |
36 | 31 | $this->assertAttributeInstanceOf('\GuzzleHttp\ClientInterface', 'client', $server); |
|
0 commit comments