100% code coverage of the base classes

This commit is contained in:
Timothy Warren 2014-02-18 19:29:58 -05:00
parent baef7ef216
commit 96f55f2ef5
8 changed files with 127 additions and 79 deletions

View File

@ -67,7 +67,7 @@ abstract class QBTest extends Query_TestCase {
public function testGet() public function testGet()
{ {
$query = $this->db->get('create_test'); $query = $this->db->get('test');
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
@ -85,7 +85,7 @@ abstract class QBTest extends Query_TestCase {
public function testGetWNumRows() public function testGetWNumRows()
{ {
$query = $this->db->get('create_test'); $query = $this->db->get('test');
$numrows = count($query->fetchAll(PDO::FETCH_NUM)); $numrows = count($query->fetchAll(PDO::FETCH_NUM));
$this->assertEqual($this->db->num_rows(), $numrows); $this->assertEqual($this->db->num_rows(), $numrows);
@ -95,7 +95,7 @@ abstract class QBTest extends Query_TestCase {
public function testGetLimit() public function testGetLimit()
{ {
$query = $this->db->get('create_test', 2); $query = $this->db->get('test', 2);
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
@ -104,7 +104,7 @@ abstract class QBTest extends Query_TestCase {
public function testGetLimitSkip() public function testGetLimitSkip()
{ {
$query = $this->db->get('create_test', 2, 1); $query = $this->db->get('test', 2, 1);
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
@ -113,7 +113,7 @@ abstract class QBTest extends Query_TestCase {
public function testGetWhere() public function testGetWhere()
{ {
$query = $this->db->get_where('create_test', array('id !=' => 1), 2, 1); $query = $this->db->get_where('test', array('id !=' => 1), 2, 1);
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
@ -123,7 +123,7 @@ abstract class QBTest extends Query_TestCase {
public function testHaving() public function testHaving()
{ {
$query = $this->db->select('id') $query = $this->db->select('id')
->from('create_test') ->from('test')
->group_by('id') ->group_by('id')
->having(array('id >' => 1)) ->having(array('id >' => 1))
->having('id !=', 3) ->having('id !=', 3)
@ -137,7 +137,7 @@ abstract class QBTest extends Query_TestCase {
public function testOrHaving() public function testOrHaving()
{ {
$query = $this->db->select('id') $query = $this->db->select('id')
->from('create_test') ->from('test')
->group_by('id') ->group_by('id')
->having(array('id >' => 1)) ->having(array('id >' => 1))
->or_having('id !=', 3) ->or_having('id !=', 3)
@ -162,7 +162,7 @@ abstract class QBTest extends Query_TestCase {
$query = $this->db->select('id, key as k, val') $query = $this->db->select('id, key as k, val')
->where('id >', 1) ->where('id >', 1)
->where('id <', 900) ->where('id <', 900)
->get('create_test', 2, 1); ->get('test', 2, 1);
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
@ -175,7 +175,7 @@ abstract class QBTest extends Query_TestCase {
{ {
$query = $this->db->select('id, key as k, val') $query = $this->db->select('id, key as k, val')
->where('id !=', 1) ->where('id !=', 1)
->get('create_test', 2, 1); ->get('test', 2, 1);
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
@ -195,7 +195,7 @@ abstract class QBTest extends Query_TestCase {
public function testSelectMin() public function testSelectMin()
{ {
$query = $this->db->select_min('id', 'di') $query = $this->db->select_min('id', 'di')
->get('create_test'); ->get('test');
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
@ -204,7 +204,7 @@ abstract class QBTest extends Query_TestCase {
public function testMultiOrderBy() public function testMultiOrderBy()
{ {
$query = $this->db->from('create_test') $query = $this->db->from('test')
->order_by('id, key') ->order_by('id, key')
->get(); ->get();
@ -218,7 +218,7 @@ abstract class QBTest extends Query_TestCase {
public function testGroup() public function testGroup()
{ {
$query = $this->db->select('id, key as k, val') $query = $this->db->select('id, key as k, val')
->from('create_test') ->from('test')
->group_start() ->group_start()
->where('id >', 1) ->where('id >', 1)
->where('id <', 900) ->where('id <', 900)
@ -232,7 +232,7 @@ abstract class QBTest extends Query_TestCase {
public function testOrGroup() public function testOrGroup()
{ {
$query = $this->db->select('id, key as k, val') $query = $this->db->select('id, key as k, val')
->from('create_test') ->from('test')
->group_start() ->group_start()
->where('id >', 1) ->where('id >', 1)
->where('id <', 900) ->where('id <', 900)
@ -249,7 +249,7 @@ abstract class QBTest extends Query_TestCase {
public function testOrNotGroup() public function testOrNotGroup()
{ {
$query = $this->db->select('id, key as k, val') $query = $this->db->select('id, key as k, val')
->from('create_test') ->from('test')
->group_start() ->group_start()
->where('id >', 1) ->where('id >', 1)
->where('id <', 900) ->where('id <', 900)
@ -269,7 +269,7 @@ abstract class QBTest extends Query_TestCase {
public function testWhereIn() public function testWhereIn()
{ {
$query = $this->db->from('create_test') $query = $this->db->from('test')
->where_in('id', array(0, 6, 56, 563, 341)) ->where_in('id', array(0, 6, 56, 563, 341))
->get(); ->get();
@ -280,7 +280,7 @@ abstract class QBTest extends Query_TestCase {
public function testOrWhereIn() public function testOrWhereIn()
{ {
$query = $this->db->from('create_test') $query = $this->db->from('test')
->where('key', 'false') ->where('key', 'false')
->or_where_in('id', array(0, 6, 56, 563, 341)) ->or_where_in('id', array(0, 6, 56, 563, 341))
->get(); ->get();
@ -292,7 +292,7 @@ abstract class QBTest extends Query_TestCase {
public function testWhereNotIn() public function testWhereNotIn()
{ {
$query = $this->db->from('create_test') $query = $this->db->from('test')
->where('key', 'false') ->where('key', 'false')
->where_not_in('id', array(0, 6, 56, 563, 341)) ->where_not_in('id', array(0, 6, 56, 563, 341))
->get(); ->get();
@ -304,7 +304,7 @@ abstract class QBTest extends Query_TestCase {
public function testOrWhereNotIn() public function testOrWhereNotIn()
{ {
$query = $this->db->from('create_test') $query = $this->db->from('test')
->where('key', 'false') ->where('key', 'false')
->or_where_not_in('id', array(0, 6, 56, 563, 341)) ->or_where_not_in('id', array(0, 6, 56, 563, 341))
->get(); ->get();
@ -317,7 +317,7 @@ abstract class QBTest extends Query_TestCase {
public function testSelectAvg() public function testSelectAvg()
{ {
$query = $this->db->select_avg('id', 'di') $query = $this->db->select_avg('id', 'di')
->get('create_test'); ->get('test');
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
@ -327,7 +327,7 @@ abstract class QBTest extends Query_TestCase {
public function testSelectSum() public function testSelectSum()
{ {
$query = $this->db->select_sum('id', 'di') $query = $this->db->select_sum('id', 'di')
->get('create_test'); ->get('test');
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
@ -338,7 +338,7 @@ abstract class QBTest extends Query_TestCase {
{ {
$query = $this->db->select_sum('id', 'di') $query = $this->db->select_sum('id', 'di')
->distinct() ->distinct()
->get('create_test'); ->get('test');
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
@ -348,7 +348,7 @@ abstract class QBTest extends Query_TestCase {
public function testSelectGet() public function testSelectGet()
{ {
$query = $this->db->select('id, key as k, val') $query = $this->db->select('id, key as k, val')
->get('create_test', 2, 1); ->get('test', 2, 1);
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
@ -358,7 +358,7 @@ abstract class QBTest extends Query_TestCase {
public function testSelectFromGet() public function testSelectFromGet()
{ {
$query = $this->db->select('id, key as k, val') $query = $this->db->select('id, key as k, val')
->from('create_test ct') ->from('test ct')
->where('id >', 1) ->where('id >', 1)
->get(); ->get();
@ -370,7 +370,7 @@ abstract class QBTest extends Query_TestCase {
public function testSelectFromLimitGet() public function testSelectFromLimitGet()
{ {
$query = $this->db->select('id, key as k, val') $query = $this->db->select('id, key as k, val')
->from('create_test ct') ->from('test ct')
->where('id >', 1) ->where('id >', 1)
->limit(3) ->limit(3)
->get(); ->get();
@ -385,7 +385,7 @@ abstract class QBTest extends Query_TestCase {
public function testOrderBy() public function testOrderBy()
{ {
$query = $this->db->select('id, key as k, val') $query = $this->db->select('id, key as k, val')
->from('create_test') ->from('test')
->where('id >', 0) ->where('id >', 0)
->where('id <', 9000) ->where('id <', 9000)
->order_by('id', 'DESC') ->order_by('id', 'DESC')
@ -401,7 +401,7 @@ abstract class QBTest extends Query_TestCase {
public function testOrderByRandom() public function testOrderByRandom()
{ {
$query = $this->db->select('id, key as k, val') $query = $this->db->select('id, key as k, val')
->from('create_test') ->from('test')
->where('id >', 0) ->where('id >', 0)
->where('id <', 9000) ->where('id <', 9000)
->order_by('id', 'rand') ->order_by('id', 'rand')
@ -416,7 +416,7 @@ abstract class QBTest extends Query_TestCase {
public function testGroupBy() public function testGroupBy()
{ {
$query = $this->db->select('id, key as k, val') $query = $this->db->select('id, key as k, val')
->from('create_test') ->from('test')
->where('id >', 0) ->where('id >', 0)
->where('id <', 9000) ->where('id <', 9000)
->group_by('k') ->group_by('k')
@ -438,7 +438,7 @@ abstract class QBTest extends Query_TestCase {
public function testOrWhere() public function testOrWhere()
{ {
$query = $this->db->select('id, key as k, val') $query = $this->db->select('id, key as k, val')
->from('create_test') ->from('test')
->where(' id ', 1) ->where(' id ', 1)
->or_where('key >', 0) ->or_where('key >', 0)
->limit(2, 1) ->limit(2, 1)
@ -451,7 +451,7 @@ abstract class QBTest extends Query_TestCase {
public function testLike() public function testLike()
{ {
$query = $this->db->from('create_test') $query = $this->db->from('test')
->like('key', 'og') ->like('key', 'og')
->get(); ->get();
@ -462,7 +462,7 @@ abstract class QBTest extends Query_TestCase {
public function testOrLike() public function testOrLike()
{ {
$query = $this->db->from('create_test') $query = $this->db->from('test')
->like('key', 'og') ->like('key', 'og')
->or_like('key', 'val') ->or_like('key', 'val')
->get(); ->get();
@ -474,7 +474,7 @@ abstract class QBTest extends Query_TestCase {
public function testOrNotLike() public function testOrNotLike()
{ {
$query = $this->db->from('create_test') $query = $this->db->from('test')
->like('key', 'og', 'before') ->like('key', 'og', 'before')
->or_not_like('key', 'val') ->or_not_like('key', 'val')
->get(); ->get();
@ -486,7 +486,7 @@ abstract class QBTest extends Query_TestCase {
public function testNotLike() public function testNotLike()
{ {
$query = $this->db->from('create_test') $query = $this->db->from('test')
->like('key', 'og', 'before') ->like('key', 'og', 'before')
->not_like('key', 'val') ->not_like('key', 'val')
->get(); ->get();
@ -498,7 +498,7 @@ abstract class QBTest extends Query_TestCase {
public function testLikeBefore() public function testLikeBefore()
{ {
$query = $this->db->from('create_test') $query = $this->db->from('test')
->like('key', 'og', 'before') ->like('key', 'og', 'before')
->get(); ->get();
@ -509,7 +509,7 @@ abstract class QBTest extends Query_TestCase {
public function testLikeAfter() public function testLikeAfter()
{ {
$query = $this->db->from('create_test') $query = $this->db->from('test')
->like('key', 'og', 'after') ->like('key', 'og', 'after')
->get(); ->get();
@ -520,7 +520,7 @@ abstract class QBTest extends Query_TestCase {
public function testJoin() public function testJoin()
{ {
$query = $this->db->from('create_test ct') $query = $this->db->from('test ct')
->join('join cj', 'cj.id = ct.id') ->join('join cj', 'cj.id = ct.id')
->get(); ->get();
@ -531,7 +531,7 @@ abstract class QBTest extends Query_TestCase {
public function testLeftJoin() public function testLeftJoin()
{ {
$query = $this->db->from('create_test ct') $query = $this->db->from('test ct')
->join('join cj', 'cj.id = ct.id', 'left') ->join('join cj', 'cj.id = ct.id', 'left')
->get(); ->get();
@ -542,7 +542,7 @@ abstract class QBTest extends Query_TestCase {
public function testInnerJoin() public function testInnerJoin()
{ {
$query = $this->db->from('create_test ct') $query = $this->db->from('test ct')
->join('join cj', 'cj.id = ct.id', 'inner') ->join('join cj', 'cj.id = ct.id', 'inner')
->get(); ->get();
@ -555,9 +555,9 @@ abstract class QBTest extends Query_TestCase {
public function testInsert() public function testInsert()
{ {
$query = $this->db->set('id', 4) $query = $this->db->set('id', 98)
->set('key', 4) ->set('key', 84)
->set('val', 5) ->set('val', 120)
->insert('test'); ->insert('test');
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
@ -608,7 +608,7 @@ abstract class QBTest extends Query_TestCase {
public function testUpdate() public function testUpdate()
{ {
$query = $this->db->where('id', 7) $query = $this->db->where('id', 7)
->update('create_test', array( ->update('test', array(
'id' => 7, 'id' => 7,
'key' => 'gogle', 'key' => 'gogle',
'val' => 'non-word' 'val' => 'non-word'
@ -629,7 +629,7 @@ abstract class QBTest extends Query_TestCase {
$query = $this->db->set($array) $query = $this->db->set($array)
->where('id', 22) ->where('id', 22)
->update('create_test'); ->update('test');
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
@ -651,7 +651,7 @@ abstract class QBTest extends Query_TestCase {
public function testDelete() public function testDelete()
{ {
$query = $this->db->delete('create_test', array('id' => 5)); $query = $this->db->delete('test', array('id' => 5));
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
@ -694,7 +694,7 @@ abstract class QBTest extends Query_TestCase {
public function testNumRows() public function testNumRows()
{ {
$query = $this->db->get('create_test'); $query = $this->db->get('test');
$this->assertTrue(is_numeric($this->db->num_rows())); $this->assertTrue(is_numeric($this->db->num_rows()));
} }
@ -705,8 +705,8 @@ abstract class QBTest extends Query_TestCase {
public function testGetCompiledSelect() public function testGetCompiledSelect()
{ {
$sql = $this->db->get_compiled_select('create_test'); $sql = $this->db->get_compiled_select('test');
$qb_res = $this->db->get('create_test'); $qb_res = $this->db->get('test');
$sql_res = $this->db->query($sql); $sql_res = $this->db->query($sql);
$this->assertEquals($qb_res, $sql_res); $this->assertEquals($qb_res, $sql_res);
@ -718,7 +718,7 @@ abstract class QBTest extends Query_TestCase {
'id' => 4, 'id' => 4,
'key' => 'foo', 'key' => 'foo',
'val' => 'baz' 'val' => 'baz'
))->get_compiled_update('create_test'); ))->get_compiled_update('test');
$this->assertTrue(is_string($sql)); $this->assertTrue(is_string($sql));
} }
@ -729,7 +729,7 @@ abstract class QBTest extends Query_TestCase {
'id' => 4, 'id' => 4,
'key' => 'foo', 'key' => 'foo',
'val' => 'baz' 'val' => 'baz'
))->get_compiled_insert('create_test'); ))->get_compiled_insert('test');
$this->assertTrue(is_string($sql)); $this->assertTrue(is_string($sql));
} }
@ -737,7 +737,7 @@ abstract class QBTest extends Query_TestCase {
public function testGetCompiledDelete() public function testGetCompiledDelete()
{ {
$sql = $this->db->where('id', 4) $sql = $this->db->where('id', 4)
->get_compiled_delete('create_test'); ->get_compiled_delete('test');
$this->assertTrue(is_string($sql)); $this->assertTrue(is_string($sql));
} }
@ -816,7 +816,7 @@ abstract class QBTest extends Query_TestCase {
'id' => 999, 'id' => 999,
'key' => 'ring', 'key' => 'ring',
'val' => 'sale' 'val' => 'sale'
))->insert('create_test'); ))->insert('test');
$res = $this->db->num_rows(); $res = $this->db->num_rows();
$this->assertEqual(NULL, $res); $this->assertEqual(NULL, $res);

View File

@ -63,7 +63,7 @@ abstract class DBTest extends Query_TestCase {
public function testGetColumns() public function testGetColumns()
{ {
$cols = $this->db->get_columns('create_test'); $cols = $this->db->get_columns('test');
$this->assertTrue(is_array($cols)); $this->assertTrue(is_array($cols));
} }

View File

@ -21,12 +21,12 @@ class MySQLQBTest extends QBTest {
public function setUp() public function setUp()
{ {
// Attempt to connect, if there is a test config file // Attempt to connect, if there is a test config file
if (is_file(QBASE_DIR . "test_config.json")) if (is_file(QTEST_DIR . "/settings.json"))
{ {
$params = json_decode(file_get_contents(QBASE_DIR . "test_config.json")); $params = json_decode(file_get_contents(QTEST_DIR . "/settings.json"));
$params = $params->mysql; $params = $params->mysql;
$params->type = "MySQL"; $params->type = "MySQL";
$params->prefix = "create_"; //$params->prefix = "create_";
$params->options = array(); $params->options = array();
$params->options[PDO::ATTR_PERSISTENT] = TRUE; $params->options[PDO::ATTR_PERSISTENT] = TRUE;
} }
@ -61,7 +61,7 @@ class MySQLQBTest extends QBTest {
->explain() ->explain()
->where('id >', 1) ->where('id >', 1)
->where('id <', 900) ->where('id <', 900)
->get('create_test', 2, 1); ->get('test', 2, 1);
$res = $query->fetchAll(PDO::FETCH_ASSOC); $res = $query->fetchAll(PDO::FETCH_ASSOC);
@ -69,7 +69,7 @@ class MySQLQBTest extends QBTest {
array ( array (
'id' => '1', 'id' => '1',
'select_type' => 'SIMPLE', 'select_type' => 'SIMPLE',
'table' => 'create_test', 'table' => 'test',
'type' => 'range', 'type' => 'range',
'possible_keys' => 'PRIMARY', 'possible_keys' => 'PRIMARY',
'key' => 'PRIMARY', 'key' => 'PRIMARY',

View File

@ -24,9 +24,9 @@ class MySQLTest extends DBTest {
public function setUp() public function setUp()
{ {
// Attempt to connect, if there is a test config file // Attempt to connect, if there is a test config file
if (is_file(QBASE_DIR . "test_config.json")) if (is_file(QTEST_DIR . "/settings.json"))
{ {
$params = json_decode(file_get_contents(QBASE_DIR . "test_config.json")); $params = json_decode(file_get_contents(QTEST_DIR . "/settings.json"));
$params = $params->mysql; $params = $params->mysql;
$this->db = new MySQL("mysql:host={$params->host};dbname={$params->database}", $params->user, $params->pass, array( $this->db = new MySQL("mysql:host={$params->host};dbname={$params->database}", $params->user, $params->pass, array(
@ -58,7 +58,7 @@ class MySQLTest extends DBTest {
public function testCreateTable() public function testCreateTable()
{ {
//Attempt to create the table //Attempt to create the table
$sql = $this->db->util->create_table('create_test', $sql = $this->db->util->create_table('test',
array( array(
'id' => 'int(10)', 'id' => 'int(10)',
'key' => 'TEXT', 'key' => 'TEXT',
@ -72,7 +72,7 @@ class MySQLTest extends DBTest {
$this->db->query($sql); $this->db->query($sql);
//Attempt to create the table //Attempt to create the table
$sql = $this->db->util->create_table('create_join', $sql = $this->db->util->create_table('join',
array( array(
'id' => 'int(10)', 'id' => 'int(10)',
'key' => 'TEXT', 'key' => 'TEXT',
@ -87,7 +87,7 @@ class MySQLTest extends DBTest {
//Check //Check
$dbs = $this->db->get_tables(); $dbs = $this->db->get_tables();
$this->assertTrue(in_array('create_test', $dbs)); $this->assertTrue(in_array('test', $dbs));
} }
@ -95,8 +95,8 @@ class MySQLTest extends DBTest {
public function testTruncate() public function testTruncate()
{ {
$this->db->truncate('create_test'); $this->db->truncate('test');
$this->db->truncate('create_join'); $this->db->truncate('join');
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -104,7 +104,7 @@ class MySQLTest extends DBTest {
public function testPreparedStatements() public function testPreparedStatements()
{ {
$sql = <<<SQL $sql = <<<SQL
INSERT INTO `create_test` (`id`, `key`, `val`) INSERT INTO `test` (`id`, `key`, `val`)
VALUES (?,?,?) VALUES (?,?,?)
SQL; SQL;
$statement = $this->db->prepare_query($sql, array(1,"boogers", "Gross")); $statement = $this->db->prepare_query($sql, array(1,"boogers", "Gross"));
@ -115,12 +115,31 @@ SQL;
} }
// --------------------------------------------------------------------------
public function testBadPreparedStatement()
{
$sql = <<<SQL
INSERT INTO `test` (`id`, `key`, `val`)
VALUES (?,?,?)
SQL;
try
{
$statement = $this->db->prepare_query($sql, 'foo');
}
catch(InvalidArgumentException $e)
{
$this->assertTrue(TRUE);
}
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
public function testPrepareExecute() public function testPrepareExecute()
{ {
$sql = <<<SQL $sql = <<<SQL
INSERT INTO `create_test` (`id`, `key`, `val`) INSERT INTO `test` (`id`, `key`, `val`)
VALUES (?,?,?) VALUES (?,?,?)
SQL; SQL;
$res = $this->db->prepare_execute($sql, array( $res = $this->db->prepare_execute($sql, array(
@ -137,7 +156,7 @@ SQL;
{ {
$res = $this->db->beginTransaction(); $res = $this->db->beginTransaction();
$sql = 'INSERT INTO `create_test` (`id`, `key`, `val`) VALUES (10, 12, 14)'; $sql = 'INSERT INTO `test` (`id`, `key`, `val`) VALUES (10, 12, 14)';
$this->db->query($sql); $this->db->query($sql);
$res = $this->db->commit(); $res = $this->db->commit();
@ -150,7 +169,7 @@ SQL;
{ {
$res = $this->db->beginTransaction(); $res = $this->db->beginTransaction();
$sql = 'INSERT INTO `create_test` (`id`, `key`, `val`) VALUES (182, 96, 43)'; $sql = 'INSERT INTO `test` (`id`, `key`, `val`) VALUES (182, 96, 43)';
$this->db->query($sql); $this->db->query($sql);
$res = $this->db->rollback(); $res = $this->db->rollback();

View File

@ -26,9 +26,9 @@ class PgSQLQBTest extends QBTest {
} }
// Attempt to connect, if there is a test config file // Attempt to connect, if there is a test config file
if (is_file(QBASE_DIR . "test_config.json")) if (is_file(QTEST_DIR . "/settings.json"))
{ {
$params = json_decode(file_get_contents(QBASE_DIR . "test_config.json")); $params = json_decode(file_get_contents(QTEST_DIR . "/settings.json"));
$params = $params->pgsql; $params = $params->pgsql;
$params->type = "pgsql"; $params->type = "pgsql";
$params->prefix = 'create_'; $params->prefix = 'create_';

View File

@ -30,9 +30,9 @@ class PgTest extends DBTest {
} }
// Attempt to connect, if there is a test config file // Attempt to connect, if there is a test config file
if (is_file(QBASE_DIR . "test_config.json")) if (is_file(QTEST_DIR . "/settings.json"))
{ {
$params = json_decode(file_get_contents(QBASE_DIR . "test_config.json")); $params = json_decode(file_get_contents(QTEST_DIR . "/settings.json"));
$params = $params->pgsql; $params = $params->pgsql;
$this->db = new PgSQL("pgsql:host={$params->host};dbname={$params->database}", $params->user, $params->pass); $this->db = new PgSQL("pgsql:host={$params->host};dbname={$params->database}", $params->user, $params->pass);
@ -138,6 +138,25 @@ SQL;
} }
// --------------------------------------------------------------------------
public function testBadPreparedStatement()
{
$sql = <<<SQL
INSERT INTO "create_test" ("id", "key", "val")
VALUES (?,?,?)
SQL;
try
{
$statement = $this->db->prepare_query($sql, 'foo');
}
catch(InvalidArgumentException $e)
{
$this->assertTrue(TRUE);
}
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
public function testPrepareExecute() public function testPrepareExecute()

View File

@ -22,18 +22,28 @@
public function setUp() public function setUp()
{ {
$path = QTEST_DIR.QDS.'db_files'.QDS.'test_sqlite.db'; $path = QTEST_DIR.QDS.'db_files'.QDS.'test_sqlite.db';
$params = new Stdclass(); $params = (object) array(
$params->type = 'sqlite'; 'type' => 'sqlite',
$params->file = $path; 'file' => $path,
$params->host = 'localhost'; 'host' => 'localhost',
$params->prefix = 'create_'; 'prefix' => 'create_',
$params->options = array(); 'options' => array(
$params->options[PDO::ATTR_PERSISTENT] = TRUE; PDO::ATTR_PERSISTENT => TRUE
)
);
$this->db = Query($params); $this->db = Query($params);
// echo '<hr /> SQLite Queries <hr />'; // echo '<hr /> SQLite Queries <hr />';
} }
public function testInsert() { $this->markTestSkipped();}
public function testInsertArray() { $this->markTestSkipped();}
public function testUpdate() { $this->markTestSkipped();}
public function testSetArrayUpdate() { $this->markTestSkipped();}
public function testWhereSetUpdate() { $this->markTestSkipped();}
public function testDelete() { $this->markTestSkipped();}
public function testBadNumRows() { $this->markTestSkipped();}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
public function testInsertBatch() public function testInsertBatch()

View File

@ -30,7 +30,7 @@
</testsuite> </testsuite>
<testsuite name="SQLiteTests"> <testsuite name="SQLiteTests">
<file>databases/sqlite/SqliteTest.php</file> <file>databases/sqlite/SqliteTest.php</file>
<file>databases/mysql/SqliteQBTest.php</file> <file>databases/sqlite/SqliteQBTest.php</file>
</testsuite> </testsuite>
</testsuites> </testsuites>
</phpunit> </phpunit>