Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit f393670

Browse files
committed
Add functional test for getting attachments
1 parent f9e2bec commit f393670

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/Doctrine/Tests/CouchDB/Functional/CouchDBClientTest.php

+30
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,36 @@ public function testPostDocument()
178178
$this->assertEquals(array("_id" => $id, "_rev" => $rev, "foo" => "bar"), $response->body);
179179
}
180180

181+
public function testGetAttachments()
182+
{
183+
$client = $this->couchClient;
184+
185+
$mimeType = 'image/png';
186+
$base64Image = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX/TQBcNTh/AAAAAXRSTlPM0jRW/QAAAApJREFUe' .
187+
'JxjYgAAAAYAAzY3fKgAAAAASUVORK5CYII='; // 1px^2 PNG image
188+
189+
$fileName1 = 'file1.png';
190+
$fileName2 = 'file2.png';
191+
192+
$attachments = array(
193+
$fileName1 => array(
194+
'content_type' => $mimeType,
195+
'data' => $base64Image,
196+
),
197+
$fileName2 => array(
198+
'content_type' => $mimeType,
199+
'data' => $base64Image,
200+
),
201+
);
202+
203+
list($id, $rev) = $client->postDocument(array("foo" => "bar", "_attachments" => $attachments));
204+
205+
$response = $client->findDocument($id);
206+
$this->assertEquals($rev, $response->body['_rev']);
207+
$this->assertEquals(count($response->body['_attachments']), count($attachments));
208+
$this->assertEquals(base64_encode($this->couchClient->getAttachment($id, $fileName1)), $base64Image);
209+
}
210+
181211
public function testPutDocument()
182212
{
183213
$id = "foo-bar-baz";

0 commit comments

Comments
 (0)