Exemplo n.º 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);
 }
Exemplo n.º 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;
 }
Exemplo n.º 3
0
 public function connectionProvider()
 {
     $connection = DB::connection(array('database' => 'fuelphp_database_tests', 'host' => 'localhost', 'username' => 'root', 'password' => '', 'persistent' => true));
     return array(array($connection));
 }
Exemplo n.º 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')))));
 }
Exemplo n.º 5
0
 /**
  * @expectedException \Fuel\Database\Exception
  */
 public function testInvalidConnection()
 {
     DB::connection(array('driver' => 'unknown'));
 }
Exemplo n.º 6
0
 /**
  * @expectedException \Fuel\Database\Exception
  */
 public function testInvalidOrOn()
 {
     $connection = DB::connection(array('driver' => 'mysql', 'pdo' => M::mock('mysql')));
     $connection->select()->orOn('a', 'b');
 }