Beispiel #1
0
 public function testQueryOptions()
 {
     $connection = DB::connection(array('driver' => 'mysql', 'autoConnect' => false));
     $query = new Query('Stuff');
     $query->setConnection($connection);
     $options = $query->getOptions();
     $this->assertEquals(array('asObject' => true, 'lateProperties' => false, 'constructorArguments' => array(), 'fetchInto' => null, 'resultCollection' => null, 'insertIdField' => 'id'), $options);
 }
Beispiel #2
0
 /**
  * Gets a working DB connection
  *
  * @returns \Fuel\Database\Connection
  */
 public function getDbInstance()
 {
     if ($this->connection === null) {
         // Grab the DB config from codeception and create a DB instance we can use to talk to the database with
         $config = Configuration::config();
         $dbConfig = $config['modules']['config']['Db'];
         /** @type Connection $fuelDBConnection */
         $this->connection = \Fuel\Database\DB::connection(['dsn' => $dbConfig['dsn'], 'username' => $dbConfig['user'], 'password' => $dbConfig['password']]);
     }
     return $this->connection;
 }
Beispiel #3
0
 public function connectionProvider()
 {
     $connection = DB::connection(array('database' => 'fuelphp_database_tests', 'host' => 'localhost', 'username' => 'root', 'password' => '', 'persistent' => true));
     return array(array($connection));
 }
Beispiel #4
0
 public function connectionProvider()
 {
     return array(array(DB::connection(array('driver' => 'mysql', 'pdo' => M::mock('stdClass')))), array(DB::connection(array('driver' => 'pgsql', 'pdo' => M::mock('stdClass')))), array(DB::connection(array('driver' => 'mysql', 'pdo' => M::mock('sqlite')))), array(DB::connection(array('driver' => 'sqlsrv', 'pdo' => M::mock('sqlite')))));
 }
Beispiel #5
0
 /**
  * @expectedException \Fuel\Database\Exception
  */
 public function testInvalidConnection()
 {
     DB::connection(array('driver' => 'unknown'));
 }
Beispiel #6
0
 /**
  * @expectedException \Fuel\Database\Exception
  */
 public function testInvalidOrOn()
 {
     $connection = DB::connection(array('driver' => 'mysql', 'pdo' => M::mock('mysql')));
     $connection->select()->orOn('a', 'b');
 }