Skip to content

Commit f420720

Browse files
committed
Tests for some helper getters, sneaky syntax fix
1 parent d2d2ec1 commit f420720

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/PHPCouchDB/Document.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function update()
8484
return $newrev;
8585
} catch (\GuzzleHTTP\Exception\ClientException $e) {
8686
// is it a conflict? Or something else?
87-
if($e->getResponse()->getStatusCode() == 409) {
87+
if ($e->getResponse()->getStatusCode() == 409) {
8888
throw new Exception\DocumentConflictException('Conflict. Outdated or missing revision information');
8989
} else {
9090
throw new Exception\DatabseException('The update failed', 0, $e);

src/PHPCouchDB/Exception/DocumentConflictException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
class DocumentConflictException extends \Exception
66
{
77
}
8-

tests/PHPCouchDB/DatabaseTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,30 @@ public function testGetDocById() {
123123
$this->assertInstanceOf('PHPCouchDB\Document', $fetched_doc);
124124
$this->assertObjectHasAttribute('id', $fetched_doc);
125125
}
126+
127+
public function testGetName() {
128+
$mock = new MockHandler([ $this->db_response, $this->use_response ]);
129+
130+
$handler = HandlerStack::create($mock);
131+
$client = new Client(['handler' => $handler]);
132+
133+
// userland code starts
134+
$server = new \PHPCouchDB\Server(["client" => $client]);
135+
$database = $server->useDB(["name" => "egdb"]);
136+
137+
$this->assertInternalType('string', $database->getName());
138+
}
139+
140+
public function testGetClient() {
141+
$mock = new MockHandler([ $this->db_response, $this->use_response ]);
142+
143+
$handler = HandlerStack::create($mock);
144+
$client = new Client(['handler' => $handler]);
145+
146+
// userland code starts
147+
$server = new \PHPCouchDB\Server(["client" => $client]);
148+
$database = $server->useDB(["name" => "egdb"]);
149+
150+
$this->assertInstanceOf('\GuzzleHttp\ClientInterface', $database->getClient());
151+
}
126152
}

0 commit comments

Comments
 (0)