File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 1+ # Maintainers
2+
3+ This file details information that will be useful for the project maintainers.
4+
5+ ## Release Process
6+
7+ Put the desired version number into the ` VERSION ` constant in ` src/PHPCouchDB/Server.php ` . Then tag the master branch of the repo with the matching tag e.g. "v0.1.2" and push to GitHub.
Original file line number Diff line number Diff line change 66
77namespace PHPCouchDB ;
88
9+ const VERSION = "0.1.0 " ;
10+
911/**
1012 * Server class deals with operations on the server level, rather than specific
1113 * to a particular database
@@ -38,7 +40,10 @@ public function __construct(array $options)
3840 if (isset ($ options ['client ' ]) && $ options ['client ' ] instanceof \GuzzleHttp \ClientInterface) {
3941 $ client = $ options ['client ' ];
4042 } elseif (isset ($ options ['url ' ])) {
41- $ client = new \GuzzleHttp \Client (["base_uri " => $ options ['url ' ]]);
43+ // set a descriptive user agent
44+ $ user_agent = \GuzzleHttp \default_user_agent ();
45+ $ client = new \GuzzleHttp \Client (["base_uri " => $ options ['url ' ],
46+ "headers " => ["User-Agent " => "PHPCouchDB/ " . VERSION . " " . $ user_agent ]]);
4247 } else {
4348 throw new Exception \ServerException (
4449 'Failed to parse $options, array should contain either a url or a client '
Original file line number Diff line number Diff line change @@ -31,6 +31,22 @@ public function testCreateWithClient() {
3131 $ this ->assertAttributeInstanceOf ('\GuzzleHttp\ClientInterface ' , 'client ' , $ server );
3232 }
3333
34+ public function testCreateWithUrl () {
35+ $ mock = new MockHandler ([ ]);
36+
37+ $ handler = HandlerStack::create ($ mock );
38+
39+ // userland code starts
40+ $ server = new \PHPCouchDB \Server (["url " => "http://localhost:5984 " ]);
41+
42+ $ this ->assertObjectHasAttribute ('client ' , $ server );
43+ $ this ->assertAttributeInstanceOf ('\GuzzleHttp\ClientInterface ' , 'client ' , $ server );
44+
45+ $ config = $ server ->getClient ()->getConfig ();
46+ $ this ->assertArrayHasKey ('User-Agent ' , $ config ['headers ' ]);
47+ $ this ->assertStringStartsWith ('PHPCouchDB ' , $ config ['headers ' ]['User-Agent ' ]);
48+ }
49+
3450 public function testGetVersion () {
3551 $ mock = new MockHandler ([ $ this ->db_response ]);
3652
You can’t perform that action at this time.
0 commit comments