Beispiel #1
0
 /**
  * Get list of all databases on a host
  *
  * @param  string  $host
  * @param  integer $port
  * @return array
  */
 public static function getAllDbs($host = 'localhost', $port = self::COUCH_PORT)
 {
     $url = self::makeUrl($host, $port, '_all_dbs');
     $response = Sopha_Http_Request::get($url);
     if (!$response->isSuccess()) {
         require_once 'Sopha/Db/Exception.php';
         throw new Sopha_Db_Exception("Unexpected response from server: {$response->getStatus()}", $response->getStatus());
     }
     return $response->getDocument();
 }
Beispiel #2
0
 /**
  * Lazy-load the Attachment data if it was not already loaded
  */
 protected function _lazyLoadData()
 {
     require_once 'Sopha/Http/Request.php';
     $request = new Sopha_Http_Request($this->docUrl . '/' . $this->name);
     $response = $request->send();
     switch ($response->getStatus()) {
         case 200:
             $this->data = $response->getBody();
             $this->type = $response->getHeader('content-type');
             $this->size = $response->getHeader('content-length');
             break;
         case 404:
             require_once 'Sopha/Document/Exception.php';
             throw new Sopha_Document_Exception("Attachment '{$this->name}' does not exist", $response->getStatus());
             break;
         default:
             require_once 'Sopha/Db/Exception.php';
             throw new Sopha_Db_Exception("Unexpected response from server: " . "{$response->getStatus()} {$response->getMessage()}", $response->getStatus());
             break;
     }
 }
Beispiel #3
0
 /**
  * Tests Sopha_Http_Request::put()
  */
 public function testPut()
 {
     // TODO Auto-generated Sopha_Http_RequestTest::testPut()
     $this->markTestIncomplete("put test not implemented");
     Sopha_Http_Request::put();
 }
Beispiel #4
0
 /**
  * Test that we can properly delete a 
  */
 public function testDeleteDb()
 {
     if (!$this->_url) {
         $this->markTestSkipped("Test requires a CouchDb server set up - see TestConfiguration.php");
     }
     list($host, $port, $dbname) = $this->_getUrlParts();
     $dbname = trim($dbname, '/');
     $res = Sopha_Db::deleteDb($dbname, $host, $port);
     $this->assertTrue($res);
     // Make sure the DB no longer exists
     $response = Sopha_Http_Request::get($this->_url);
     $this->assertEquals(404, $response->getStatus());
 }