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 6
6
7
7
namespace PHPCouchDB ;
8
8
9
+ const VERSION = "0.1.0 " ;
10
+
9
11
/**
10
12
* Server class deals with operations on the server level, rather than specific
11
13
* to a particular database
@@ -38,7 +40,10 @@ public function __construct(array $options)
38
40
if (isset ($ options ['client ' ]) && $ options ['client ' ] instanceof \GuzzleHttp \ClientInterface) {
39
41
$ client = $ options ['client ' ];
40
42
} 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 ]]);
42
47
} else {
43
48
throw new Exception \ServerException (
44
49
'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() {
31
31
$ this ->assertAttributeInstanceOf ('\GuzzleHttp\ClientInterface ' , 'client ' , $ server );
32
32
}
33
33
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
+
34
50
public function testGetVersion () {
35
51
$ mock = new MockHandler ([ $ this ->db_response ]);
36
52
You can’t perform that action at this time.
0 commit comments