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