Example #1
0
 /**
  * @test
  * @author Christopher Hlubek <*****@*****.**>
  */
 public function getDocumentInformationWorks()
 {
     $response = $this->client->createDocument(array('name' => 'Bar'));
     $id = $response->getId();
     $information = $this->client->getDocumentInformation($id);
     $this->assertEquals($response->getRevision(), $information->getRevision());
 }
 /**
  * Get the CouchDB revision of an object
  *
  * @param object $object An object
  * @return string The current revision if it was set, NULL otherwise
  * @author Christopher Hlubek <*****@*****.**>
  */
 protected function getRevisionByObject($object)
 {
     $metadata = $this->collectMetadata($object);
     if (is_array($metadata) && isset($metadata['CouchDB_Revision'])) {
         return $metadata['CouchDB_Revision'];
     }
     try {
         $identifier = $this->persistenceSession->getIdentifierByObject($object);
         $rawResponse = $this->client->getDocumentInformation($identifier);
         return $rawResponse->getRevision();
     } catch (Client\NotFoundException $notFoundException) {
         return NULL;
     }
 }