Esempio n. 1
0
 public function testGetAttachmentFaild()
 {
     $this->setExpectedException('Klinai\\Model\\Exception\\AttachmentIsNotExistsException');
     $docData = json_decode('{
        "_id": "fooBar",
        "_rev": "1-7182e53ce7cd148307e40521e9ede288",
        "foo" : "dummy",
        "boo" : "dummy",
        "_attachments": {
            "attachment1": {
                "content_type": "text/plain",
                "revpos": 11,
                "digest": "md5-ezhD8uRb10w4JpIqaH8R+A==",
                "length": 125664,
                "stub": true
            }
        }
     }', false);
     /* @var $doc \Klinai\Model\Document */
     $doc = new Document($docData, $this->mockClient, 'client_test1');
     $attachment = $doc->getAttachment('notExistsAttachment');
 }
Esempio n. 2
0
 public function deleteDocument($databaseName, &$doc)
 {
     if (!$doc instanceof Document && !$doc instanceof \stdClass && !is_array($doc)) {
         throw new RuntimeException("doc is not a instance of (Document or stdClass or Array)");
     }
     if (!$doc instanceof Document) {
         $doc = new Document($doc, $this, $databaseName);
     }
     $parameters = array('rev' => $doc->_rev);
     $uriOptions = array('database' => $databaseName, 'docId' => $doc->_id, 'parameters' => array_merge($parameters, $this->getRequestParameters()));
     $uri = $this->buildUri($uriOptions);
     $request = $this->getRequest();
     $request->setUri($uri);
     $request->setMethod($request::METHOD_DELETE);
     $response = $this->sendRequest();
     if (!is_string($response) && isset($response->error)) {
         throw $this->createExceptionInstance($response, $uriOptions, array('uri' => $uri));
     }
     $doc->setDeleted();
     return $response;
 }