Exemplo n.º 1
0
 /**
  * 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();
 }
Exemplo n.º 2
0
 protected function setUp()
 {
     parent::setUp();
     $db = Config::get('db');
     $db['user'] = '******';
     $db['pass'] = '******';
     Database::registry()->addDriver('default', new PgsqlDriver($db));
 }
Exemplo n.º 3
0
 /**
  * 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();
 }
Exemplo n.º 4
0
 /**
  * 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()));
 }
Exemplo n.º 5
0
 protected function setUp()
 {
     parent::setUp();
     Database::registry()->addDriver('default', new SqliteDriver(Config::get('db')));
 }
Exemplo n.º 6
0
 /**
  * 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;
 }