/** * Fix repo for MongoDB. */ public function getRepository() { $driver = Database::registry()->getDriver('default'); if ($driver instanceof MongoDriver && !$this->_repository) { $this->setRepository(new Collection(['connection' => $this->connection, 'table' => $this->table, 'prefix' => $this->prefix, 'primaryKey' => '_id', 'displayField' => $this->displayField, 'entity' => get_class($this)])); } return parent::getRepository(); }
protected function setUp() { parent::setUp(); $db = Config::get('db'); $db['user'] = '******'; $db['pass'] = '******'; Database::registry()->addDriver('default', new PgsqlDriver($db)); }
/** * Setup the DB once, not before every test. */ public static function setUpBeforeClass() { Database::registry()->addDriver('default', new MongoDriver(Config::get('db'))); // Remove singletons User::flushInstances(); Book::flushInstances(); Series::flushInstances(); Profile::flushInstances(); }
/** * Extremely useful for validating the correct queries and the number of queries being ran. */ public function logQueries() { print_r(array_map('strval', Database::registry()->getDriver('default')->getLoggedQueries())); }
protected function setUp() { parent::setUp(); Database::registry()->addDriver('default', new SqliteDriver(Config::get('db'))); }
/** * Return the database class. * If none has been defined, register one. * * @return \Titon\Db\Database */ public function getDatabase() { if (!$this->_database) { $this->setDatabase(Database::registry()); } return $this->_database; }