Test formatting cleanup

This commit is contained in:
Timothy Warren 2012-04-24 14:00:44 -04:00
parent 1849e2d6a8
commit 38aadabc9b
13 changed files with 320 additions and 120 deletions

View File

@ -29,6 +29,8 @@ class CoreTest extends UnitTestCase {
parent::__construct(); parent::__construct();
} }
// --------------------------------------------------------------------------
/** /**
* TestPHPVersion function. * TestPHPVersion function.
* *
@ -40,6 +42,8 @@ class CoreTest extends UnitTestCase {
$this->assertTrue(version_compare(PHP_VERSION, "5.2", "ge")); $this->assertTrue(version_compare(PHP_VERSION, "5.2", "ge"));
} }
// --------------------------------------------------------------------------
/** /**
* TestHasPDO function. * TestHasPDO function.
* *

View File

@ -18,9 +18,11 @@
*/ */
abstract class QBTest extends UnitTestCase { abstract class QBTest extends UnitTestCase {
// --------------------------------------------------------------------------
// ! Get Tests // ! Get Tests
// --------------------------------------------------------------------------
function TestGet() public function TestGet()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -29,7 +31,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestGetLimit() // --------------------------------------------------------------------------
public function TestGetLimit()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -38,7 +42,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestGetLimitSkip() // --------------------------------------------------------------------------
public function TestGetLimitSkip()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -47,7 +53,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestGetWhere() // --------------------------------------------------------------------------
public function TestGetWhere()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -56,7 +64,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestHaving() // --------------------------------------------------------------------------
public function TestHaving()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -70,7 +80,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestOrHaving() // --------------------------------------------------------------------------
public function TestOrHaving()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -84,16 +96,20 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestGetViews() // --------------------------------------------------------------------------
public function TestGetViews()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
$this->assertTrue(is_array($this->db->get_views())); $this->assertTrue(is_array($this->db->get_views()));
} }
// --------------------------------------------------------------------------
// ! Select Tests // ! Select Tests
// --------------------------------------------------------------------------
function TestSelectWhereGet() public function TestSelectWhereGet()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -105,7 +121,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestSelectWhereGet2() // --------------------------------------------------------------------------
public function TestSelectWhereGet2()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -116,7 +134,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestSelectMax() // --------------------------------------------------------------------------
public function TestSelectMax()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -126,7 +146,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestSelectMin() // --------------------------------------------------------------------------
public function TestSelectMin()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -136,7 +158,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestSelectAvg() // --------------------------------------------------------------------------
public function TestSelectAvg()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -146,7 +170,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestSelectSum() // --------------------------------------------------------------------------
public function TestSelectSum()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -156,7 +182,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestSelectDistinct() // --------------------------------------------------------------------------
public function TestSelectDistinct()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -167,7 +195,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestSelectGet() // --------------------------------------------------------------------------
public function TestSelectGet()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -177,7 +207,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestSelectFromGet() // --------------------------------------------------------------------------
public function TestSelectFromGet()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -189,7 +221,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestSelectFromLimitGet() // --------------------------------------------------------------------------
public function TestSelectFromLimitGet()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -202,9 +236,11 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
// --------------------------------------------------------------------------
// ! Query modifier tests // ! Query modifier tests
// --------------------------------------------------------------------------
function TestOrderBy() public function TestOrderBy()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -220,7 +256,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestOrderByRandom() // --------------------------------------------------------------------------
public function TestOrderByRandom()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -235,7 +273,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestGroupBy() // --------------------------------------------------------------------------
public function TestGroupBy()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -254,7 +294,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestOrWhere() // --------------------------------------------------------------------------
public function TestOrWhere()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -268,7 +310,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestLike() // --------------------------------------------------------------------------
public function TestLike()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -279,7 +323,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestJoin() // --------------------------------------------------------------------------
public function TestJoin()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -290,9 +336,11 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
// --------------------------------------------------------------------------
// ! DB update tests // ! DB update tests
// --------------------------------------------------------------------------
function TestInsert() public function TestInsert()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -304,7 +352,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestUpdate() // --------------------------------------------------------------------------
public function TestUpdate()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -317,7 +367,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
function TestDelete() // --------------------------------------------------------------------------
public function TestDelete()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -326,9 +378,11 @@ abstract class QBTest extends UnitTestCase {
$this->assertIsA($query, 'PDOStatement'); $this->assertIsA($query, 'PDOStatement');
} }
// --------------------------------------------------------------------------
// ! Non-data read queries // ! Non-data read queries
// --------------------------------------------------------------------------
function TestCountAll() public function TestCountAll()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
$query = $this->db->count_all('create_test'); $query = $this->db->count_all('create_test');
@ -336,7 +390,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertTrue(is_numeric($query)); $this->assertTrue(is_numeric($query));
} }
function TestCountAllResults() // --------------------------------------------------------------------------
public function TestCountAllResults()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
$query = $this->db->count_all_results('create_test'); $query = $this->db->count_all_results('create_test');
@ -344,7 +400,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertTrue(is_numeric($query)); $this->assertTrue(is_numeric($query));
} }
function TestCountAllResults2() // --------------------------------------------------------------------------
public function TestCountAllResults2()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -358,7 +416,9 @@ abstract class QBTest extends UnitTestCase {
$this->assertTrue(is_numeric($query)); $this->assertTrue(is_numeric($query));
} }
function TestNumRows() // --------------------------------------------------------------------------
public function TestNumRows()
{ {
$query = $this->db->get('create_test'); $query = $this->db->get('create_test');

View File

@ -18,14 +18,18 @@
*/ */
abstract class DBTest extends UnitTestCase { abstract class DBTest extends UnitTestCase {
abstract function TestConnection(); abstract public function TestConnection();
function tearDown() // --------------------------------------------------------------------------
public function tearDown()
{ {
$this->db = NULL; $this->db = NULL;
} }
function TestGetTables() // --------------------------------------------------------------------------
public function TestGetTables()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -33,7 +37,9 @@ abstract class DBTest extends UnitTestCase {
$this->assertTrue(is_array($tables)); $this->assertTrue(is_array($tables));
} }
function TestGetSystemTables() // --------------------------------------------------------------------------
public function TestGetSystemTables()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -42,7 +48,9 @@ abstract class DBTest extends UnitTestCase {
$this->assertTrue(is_array($tables)); $this->assertTrue(is_array($tables));
} }
function TestCreateTransaction() // --------------------------------------------------------------------------
public function TestCreateTransaction()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -50,7 +58,9 @@ abstract class DBTest extends UnitTestCase {
$this->assertTrue($res); $this->assertTrue($res);
} }
function TestBackupData() // --------------------------------------------------------------------------
public function TestBackupData()
{ {
$this->assertTrue(is_string($this->db->util->backup_data())); $this->assertTrue(is_string($this->db->util->backup_data()));
} }

View File

@ -17,7 +17,7 @@
*/ */
class SettingsTest extends UnitTestCase { class SettingsTest extends UnitTestCase {
function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
$this->settings =& Settings::get_instance(); $this->settings =& Settings::get_instance();
@ -26,45 +26,61 @@ class SettingsTest extends UnitTestCase {
$this->settings->remove_db('foo'); $this->settings->remove_db('foo');
} }
function TestExists() // --------------------------------------------------------------------------
public function TestExists()
{ {
$this->assertIsA($this->settings, 'Settings'); $this->assertIsA($this->settings, 'Settings');
} }
function TestGetEmptyDBs() // --------------------------------------------------------------------------
public function TestGetEmptyDBs()
{ {
$this->assertTrue(is_object($this->settings->get_dbs())); $this->assertTrue(is_object($this->settings->get_dbs()));
} }
function TestGetNull() // --------------------------------------------------------------------------
public function TestGetNull()
{ {
$this->assertFalse(isset($this->settings->foo)); $this->assertFalse(isset($this->settings->foo));
} }
function TestSet() // --------------------------------------------------------------------------
public function TestSet()
{ {
$bar = $this->settings->foo = 'bar'; $bar = $this->settings->foo = 'bar';
$this->assertEqual('bar', $bar); $this->assertEqual('bar', $bar);
} }
function TestGet() // --------------------------------------------------------------------------
public function TestGet()
{ {
$this->assertEqual('bar', $this->settings->foo); $this->assertEqual('bar', $this->settings->foo);
} }
function TestSetDBProperty() // --------------------------------------------------------------------------
public function TestSetDBProperty()
{ {
$res = $this->settings->__set('dbs', 2); $res = $this->settings->__set('dbs', 2);
$this->assertFalse($res); $this->assertFalse($res);
} }
function TestGetEmptyDB() // --------------------------------------------------------------------------
public function TestGetEmptyDB()
{ {
$this->assertFalse($this->settings->get_db('foo')); $this->assertFalse($this->settings->get_db('foo'));
} }
function TestAddDB() // --------------------------------------------------------------------------
public function TestAddDB()
{ {
$this->settings->add_db('foo', array()); $this->settings->add_db('foo', array());

View File

@ -18,7 +18,7 @@
*/ */
class FirebirdQBTest extends QBTest { class FirebirdQBTest extends QBTest {
function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
@ -35,6 +35,4 @@ class FirebirdQBTest extends QBTest {
// echo '<hr /> Firebird Queries <hr />'; // echo '<hr /> Firebird Queries <hr />';
} }
} }

View File

@ -20,7 +20,7 @@
*/ */
class FirebirdTest extends DBTest { class FirebirdTest extends DBTest {
function setUp() public function setUp()
{ {
$dbpath = TEST_DIR.DS.'db_files'.DS.'FB_TEST_DB.FDB'; $dbpath = TEST_DIR.DS.'db_files'.DS.'FB_TEST_DB.FDB';
@ -29,24 +29,32 @@ class FirebirdTest extends DBTest {
$this->tables = $this->db->get_tables(); $this->tables = $this->db->get_tables();
} }
function tearDown() // --------------------------------------------------------------------------
public function tearDown()
{ {
unset($this->db); unset($this->db);
unset($this->tables); unset($this->tables);
} }
function TestConnection() // --------------------------------------------------------------------------
public function TestConnection()
{ {
$this->assertIsA($this->db, 'Firebird'); $this->assertIsA($this->db, 'Firebird');
} }
function TestGetTables() // --------------------------------------------------------------------------
public function TestGetTables()
{ {
$tables = $this->tables; $tables = $this->tables;
$this->assertTrue(is_array($tables)); $this->assertTrue(is_array($tables));
} }
function TestGetSystemTables() // --------------------------------------------------------------------------
public function TestGetSystemTables()
{ {
$only_system = TRUE; $only_system = TRUE;
@ -64,13 +72,17 @@ class FirebirdTest extends DBTest {
$this->assertTrue($only_system); $this->assertTrue($only_system);
} }
function TestCreateTransaction() // --------------------------------------------------------------------------
public function TestCreateTransaction()
{ {
$res = $this->db->beginTransaction(); $res = $this->db->beginTransaction();
$this->assertTrue($res); $this->assertTrue($res);
} }
/*function TestCreateTable() // --------------------------------------------------------------------------
/*public function TestCreateTable()
{ {
//Attempt to create the table //Attempt to create the table
$sql = $this->db->sql->create_table('create_join', array( $sql = $this->db->sql->create_table('create_join', array(
@ -93,16 +105,18 @@ class FirebirdTest extends DBTest {
$this->assertTrue($table_exists); $this->assertTrue($table_exists);
}*/ }*/
// --------------------------------------------------------------------------
public function TestTruncate()
function TestTruncate()
{ {
$this->db->truncate('create_test'); $this->db->truncate('create_test');
$this->assertTrue($this->db->affected_rows() > 0); $this->assertTrue($this->db->affected_rows() > 0);
} }
function TestCommitTransaction() // --------------------------------------------------------------------------
public function TestCommitTransaction()
{ {
$res = $this->db->beginTransaction(); $res = $this->db->beginTransaction();
@ -113,7 +127,9 @@ class FirebirdTest extends DBTest {
$this->assertTrue($res); $this->assertTrue($res);
} }
function TestRollbackTransaction() // --------------------------------------------------------------------------
public function TestRollbackTransaction()
{ {
$res = $this->db->beginTransaction(); $res = $this->db->beginTransaction();
@ -124,9 +140,9 @@ class FirebirdTest extends DBTest {
$this->assertTrue($res); $this->assertTrue($res);
} }
// --------------------------------------------------------------------------
public function TestPreparedStatements()
function TestPreparedStatements()
{ {
$sql = <<<SQL $sql = <<<SQL
INSERT INTO "create_test" ("id", "key", "val") INSERT INTO "create_test" ("id", "key", "val")
@ -137,7 +153,9 @@ SQL;
} }
function TestPrepareExecute() // --------------------------------------------------------------------------
public function TestPrepareExecute()
{ {
$sql = <<<SQL $sql = <<<SQL
INSERT INTO "create_test" ("id", "key", "val") INSERT INTO "create_test" ("id", "key", "val")
@ -149,12 +167,16 @@ SQL;
} }
function TestPrepareQuery() // --------------------------------------------------------------------------
public function TestPrepareQuery()
{ {
$this->assertFalse($this->db->prepare_query('', array())); $this->assertFalse($this->db->prepare_query('', array()));
} }
/*function TestDeleteTable() // --------------------------------------------------------------------------
/*public function TestDeleteTable()
{ {
//Attempt to delete the table //Attempt to delete the table
$sql = $this->db->sql->delete_table('create_test'); $sql = $this->db->sql->delete_table('create_test');
@ -169,22 +191,30 @@ SQL;
$this->assertFalse($table_exists); $this->assertFalse($table_exists);
}*/ }*/
function TestGetSequences() // --------------------------------------------------------------------------
public function TestGetSequences()
{ {
$this->assertTrue(is_array($this->db->get_sequences())); $this->assertTrue(is_array($this->db->get_sequences()));
} }
function TestGetProcedures() // --------------------------------------------------------------------------
public function TestGetProcedures()
{ {
$this->assertTrue(is_array($this->db->get_procedures())); $this->assertTrue(is_array($this->db->get_procedures()));
} }
function TestGetFunctions() // --------------------------------------------------------------------------
public function TestGetpublic functions()
{ {
$this->assertTrue(is_array($this->db->get_functions())); $this->assertTrue(is_array($this->db->get_public functions()));
} }
function TestGetTriggers() // --------------------------------------------------------------------------
public function TestGetTriggers()
{ {
$this->assertTrue(is_array($this->db->get_triggers())); $this->assertTrue(is_array($this->db->get_triggers()));
} }

View File

@ -15,7 +15,7 @@
class MySQLQBTest extends QBTest { class MySQLQBTest extends QBTest {
function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
@ -45,8 +45,9 @@ class MySQLQBTest extends QBTest {
} }
} }
// --------------------------------------------------------------------------
function TestExists() public function TestExists()
{ {
$this->assertTrue(in_array('mysql', pdo_drivers())); $this->assertTrue(in_array('mysql', pdo_drivers()));
} }

View File

@ -20,7 +20,7 @@
*/ */
class MySQLTest extends DBTest { class MySQLTest extends DBTest {
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(BASE_DIR . "test_config.json")) if (is_file(BASE_DIR . "test_config.json"))
@ -36,19 +36,25 @@ class MySQLTest extends DBTest {
} }
} }
function TestExists() // --------------------------------------------------------------------------
public function TestExists()
{ {
$this->assertTrue(in_array('mysql', pdo_drivers())); $this->assertTrue(in_array('mysql', pdo_drivers()));
} }
function TestConnection() // --------------------------------------------------------------------------
public function TestConnection()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
$this->assertIsA($this->db, 'MySQL'); $this->assertIsA($this->db, 'MySQL');
} }
function TestCreateTable() // --------------------------------------------------------------------------
public function TestCreateTable()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -86,7 +92,9 @@ class MySQLTest extends DBTest {
} }
function TestTruncate() // --------------------------------------------------------------------------
public function TestTruncate()
{ {
$this->db->truncate('create_test'); $this->db->truncate('create_test');
$this->db->truncate('create_join'); $this->db->truncate('create_join');
@ -95,7 +103,9 @@ class MySQLTest extends DBTest {
$cj_query = $this->db->query('SELECT * FROM create_join'); $cj_query = $this->db->query('SELECT * FROM create_join');
} }
function TestPreparedStatements() // --------------------------------------------------------------------------
public function TestPreparedStatements()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -109,7 +119,9 @@ SQL;
} }
function TestPrepareExecute() // --------------------------------------------------------------------------
public function TestPrepareExecute()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -123,7 +135,9 @@ SQL;
} }
function TestCommitTransaction() // --------------------------------------------------------------------------
public function TestCommitTransaction()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -136,7 +150,9 @@ SQL;
$this->assertTrue($res); $this->assertTrue($res);
} }
function TestRollbackTransaction() // --------------------------------------------------------------------------
public function TestRollbackTransaction()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -149,24 +165,31 @@ SQL;
$this->assertTrue($res); $this->assertTrue($res);
} }
function TestGetSchemas() // --------------------------------------------------------------------------
public function TestGetSchemas()
{ {
$this->assertFalse($this->db->get_schemas()); $this->assertFalse($this->db->get_schemas());
} }
function TestGetsProcedures() // --------------------------------------------------------------------------
public function TestGetsProcedures()
{ {
$this->assertTrue(is_array($this->db->get_procedures())); $this->assertTrue(is_array($this->db->get_procedures()));
} }
function TestGetTriggers() // --------------------------------------------------------------------------
public function TestGetTriggers()
{ {
$this->assertTrue(is_array($this->db->get_triggers())); $this->assertTrue(is_array($this->db->get_triggers()));
} }
function TestGetSequences() // --------------------------------------------------------------------------
public function TestGetSequences()
{ {
$this->assertFalse($this->db->get_sequences()); $this->assertFalse($this->db->get_sequences());
} }
} }

View File

@ -14,7 +14,7 @@
class PgSQLQBTest extends QBTest { class PgSQLQBTest extends QBTest {
function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
@ -45,7 +45,9 @@ class PgSQLQBTest extends QBTest {
} }
} }
function TestExists() // --------------------------------------------------------------------------
public function TestExists()
{ {
$this->assertTrue(in_array('pgsql', pdo_drivers())); $this->assertTrue(in_array('pgsql', pdo_drivers()));
} }

View File

@ -19,12 +19,14 @@
*/ */
class PgTest extends DBTest { class PgTest extends DBTest {
function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
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(BASE_DIR . "test_config.json")) if (is_file(BASE_DIR . "test_config.json"))
@ -40,19 +42,25 @@ class PgTest extends DBTest {
} }
} }
function TestExists() // --------------------------------------------------------------------------
public function TestExists()
{ {
$this->assertTrue(in_array('pgsql', pdo_drivers())); $this->assertTrue(in_array('pgsql', pdo_drivers()));
} }
function TestConnection() // --------------------------------------------------------------------------
public function TestConnection()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
$this->assertIsA($this->db, 'PgSQL'); $this->assertIsA($this->db, 'PgSQL');
} }
function TestCreateTable() // --------------------------------------------------------------------------
public function TestCreateTable()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -102,7 +110,9 @@ class PgTest extends DBTest {
} }
function TestTruncate() // --------------------------------------------------------------------------
public function TestTruncate()
{ {
$this->db->truncate('create_test'); $this->db->truncate('create_test');
$this->db->truncate('create_join'); $this->db->truncate('create_join');
@ -111,7 +121,9 @@ class PgTest extends DBTest {
$cj_query = $this->db->query('SELECT * FROM create_join'); $cj_query = $this->db->query('SELECT * FROM create_join');
} }
function TestPreparedStatements() // --------------------------------------------------------------------------
public function TestPreparedStatements()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -125,7 +137,9 @@ SQL;
} }
function TestPrepareExecute() // --------------------------------------------------------------------------
public function TestPrepareExecute()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -139,7 +153,9 @@ SQL;
} }
function TestCommitTransaction() // --------------------------------------------------------------------------
public function TestCommitTransaction()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -152,7 +168,9 @@ SQL;
$this->assertTrue($res); $this->assertTrue($res);
} }
function TestRollbackTransaction() // --------------------------------------------------------------------------
public function TestRollbackTransaction()
{ {
if (empty($this->db)) return; if (empty($this->db)) return;
@ -165,22 +183,30 @@ SQL;
$this->assertTrue($res); $this->assertTrue($res);
} }
function TestGetSchemas() // --------------------------------------------------------------------------
public function TestGetSchemas()
{ {
$this->assertTrue(is_array($this->db->get_schemas())); $this->assertTrue(is_array($this->db->get_schemas()));
} }
function TestGetSequences() // --------------------------------------------------------------------------
public function TestGetSequences()
{ {
$this->assertTrue(is_array($this->db->get_sequences())); $this->assertTrue(is_array($this->db->get_sequences()));
} }
function TestGetsProcedures() // --------------------------------------------------------------------------
public function TestGetsProcedures()
{ {
$this->assertTrue(is_array($this->db->get_procedures())); $this->assertTrue(is_array($this->db->get_procedures()));
} }
function TestGetTriggers() // --------------------------------------------------------------------------
public function TestGetTriggers()
{ {
$this->assertTrue(is_array($this->db->get_triggers())); $this->assertTrue(is_array($this->db->get_triggers()));
} }

View File

@ -17,7 +17,7 @@
*/ */
class SQLiteQBTest extends QBTest { class SQLiteQBTest extends QBTest {
function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();

View File

@ -19,47 +19,61 @@
*/ */
class SQLiteTest extends UnitTestCase { class SQLiteTest extends UnitTestCase {
function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
function setUp() // --------------------------------------------------------------------------
public function setUp()
{ {
$path = TEST_DIR.DS.'db_files'.DS.'test_sqlite.db'; $path = TEST_DIR.DS.'db_files'.DS.'test_sqlite.db';
$this->db = new SQLite($path); $this->db = new SQLite($path);
} }
function tearDown() // --------------------------------------------------------------------------
public function tearDown()
{ {
unset($this->db); unset($this->db);
} }
function TestConnection() // --------------------------------------------------------------------------
public function TestConnection()
{ {
$this->assertIsA($this->db, 'SQLite'); $this->assertIsA($this->db, 'SQLite');
} }
function TestGetTables() // --------------------------------------------------------------------------
public function TestGetTables()
{ {
$tables = $this->db->get_tables(); $tables = $this->db->get_tables();
$this->assertTrue(is_array($tables)); $this->assertTrue(is_array($tables));
} }
function TestGetSystemTables() // --------------------------------------------------------------------------
public function TestGetSystemTables()
{ {
$tables = $this->db->get_system_tables(); $tables = $this->db->get_system_tables();
$this->assertTrue(is_array($tables)); $this->assertTrue(is_array($tables));
} }
function TestCreateTransaction() // --------------------------------------------------------------------------
public function TestCreateTransaction()
{ {
$res = $this->db->beginTransaction(); $res = $this->db->beginTransaction();
$this->assertTrue($res); $this->assertTrue($res);
} }
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('create_test',
@ -93,13 +107,17 @@ class SQLiteTest extends UnitTestCase {
$this->assertTrue(in_array('create_test', $dbs)); $this->assertTrue(in_array('create_test', $dbs));
} }
function TestTruncate() // --------------------------------------------------------------------------
public function TestTruncate()
{ {
$this->db->truncate('create_test'); $this->db->truncate('create_test');
$this->assertIsA($this->db->affected_rows(), 'int'); $this->assertIsA($this->db->affected_rows(), 'int');
} }
function TestPreparedStatements() // --------------------------------------------------------------------------
public function TestPreparedStatements()
{ {
$sql = <<<SQL $sql = <<<SQL
INSERT INTO "create_test" ("id", "key", "val") INSERT INTO "create_test" ("id", "key", "val")
@ -111,7 +129,9 @@ SQL;
} }
function TestPrepareExecute() // --------------------------------------------------------------------------
public function TestPrepareExecute()
{ {
$sql = <<<SQL $sql = <<<SQL
INSERT INTO "create_test" ("id", "key", "val") INSERT INTO "create_test" ("id", "key", "val")
@ -123,7 +143,9 @@ SQL;
} }
function TestCommitTransaction() // --------------------------------------------------------------------------
public function TestCommitTransaction()
{ {
$res = $this->db->beginTransaction(); $res = $this->db->beginTransaction();
@ -134,7 +156,9 @@ SQL;
$this->assertTrue($res); $this->assertTrue($res);
} }
function TestRollbackTransaction() // --------------------------------------------------------------------------
public function TestRollbackTransaction()
{ {
$res = $this->db->beginTransaction(); $res = $this->db->beginTransaction();
@ -145,8 +169,10 @@ SQL;
$this->assertTrue($res); $this->assertTrue($res);
} }
// --------------------------------------------------------------------------
// This is really time intensive ! Run only when needed // This is really time intensive ! Run only when needed
/*function TestDeleteTable() /*public function TestDeleteTable()
{ {
//Make sure the table exists to delete //Make sure the table exists to delete
$dbs = $this->db->get_tables(); $dbs = $this->db->get_tables();
@ -161,12 +187,16 @@ SQL;
$this->assertFalse(in_array('create_test', $dbs)); $this->assertFalse(in_array('create_test', $dbs));
}*/ }*/
function TestGetDBs() // --------------------------------------------------------------------------
public function TestGetDBs()
{ {
$this->assertFalse($this->db->get_dbs()); $this->assertFalse($this->db->get_dbs());
} }
function TestGetSchemas() // --------------------------------------------------------------------------
public function TestGetSchemas()
{ {
$this->assertFalse($this->db->get_schemas()); $this->assertFalse($this->db->get_schemas());
} }

Binary file not shown.