public function testGetAllDocs() { $docs = $this->_couchDb->getAllDocs(); $this->assertType('array', $docs); $this->assertEquals(1, $docs['total_rows']); $this->assertEquals(0, $docs['offset']); $this->assertEquals(array(array('id' => 'bin_doc', 'key' => 'bin_doc', 'value' => array('rev' => '4272993301'))), $docs['rows']); }
/** * Factory * * @param array|Zend_Config $config * @return Zym_Couch_Connection */ public static function factory($config = null, $isDefault = true) { if ($config instanceof Zend_Config) { $config = $config->toArray(); } if (!is_array($config)) { $config = array(); } $defaults = array('host', 'port'); foreach ($defaults as $key) { if (!isset($config[$key])) { $config[$key] = null; } } $connection = new Zym_Couch_Connection($config['host'], $config['port']); if ($isDefault) { Zym_Couch_Db::setDefaultConnection($connection); } return $connection; }
/** * Factory * * @param array|Zend_Config $config * @return Zym_Couch_Connection */ public static function factory($config, $isDefault = true) { if ($config instanceof Zend_Config) { $config = $config->toArray(); } if (!is_array($config)) { /** * @see Zym_Couch_Exception */ require_once 'Zym/Couch/Exception.php'; throw new Zym_Couch_Exception('Config must be an array or instance of Zend_Config.'); } $defaults = array('host' => 'localhost', 'port' => 5984); $config = array_merge($defaults, $config); foreach ($defaults as $key => $value) { if (empty($config[$key])) { /** * @see Zym_Couch_Exception */ require_once 'Zym/Couch/Exception.php'; throw new Zym_Couch_Exception('Config entry "' . $key . '" can\'t be empty.'); } } $connection = new Zym_Couch_Connection($config['host'], $config['port']); if ($isDefault) { Zym_Couch_Db::setDefaultConnection($connection); } return $connection; }
/** * Get a DB instance * * @param string $name * @return Zym_Couch_Db */ public function getDb($name) { $db = new Zym_Couch_Db($name); $db->setConnection($this); return $db; }
/** * Set a default DB connection * * @param Zym_Couch_Connection $connection */ public static function setDefaultConnection(Zym_Couch_Connection $connection) { self::$_defaultConnection = $connection; }