From 38aadabc9bf3892ee5d056d73c9059e15db05970 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 24 Apr 2012 14:00:44 -0400 Subject: [PATCH] Test formatting cleanup --- tests/core/core.php | 4 + tests/core/db_qb_test.php | 122 +++++++++++++++++------ tests/core/db_test.php | 22 ++-- tests/core/settings.php | 34 +++++-- tests/databases/firebird/firebird-qb.php | 4 +- tests/databases/firebird/firebird.php | 72 +++++++++---- tests/databases/mysql/mysql-qb.php | 5 +- tests/databases/mysql/mysql.php | 53 +++++++--- tests/databases/pgsql/pgsql-qb.php | 6 +- tests/databases/pgsql/pgsql.php | 54 +++++++--- tests/databases/sqlite/sqlite-qb.php | 2 +- tests/databases/sqlite/sqlite.php | 62 +++++++++--- tests/db_files/FB_TEST_DB.FDB | Bin 802816 -> 802816 bytes 13 files changed, 320 insertions(+), 120 deletions(-) diff --git a/tests/core/core.php b/tests/core/core.php index af31b1d..2815c8f 100644 --- a/tests/core/core.php +++ b/tests/core/core.php @@ -29,6 +29,8 @@ class CoreTest extends UnitTestCase { parent::__construct(); } + // -------------------------------------------------------------------------- + /** * TestPHPVersion function. * @@ -40,6 +42,8 @@ class CoreTest extends UnitTestCase { $this->assertTrue(version_compare(PHP_VERSION, "5.2", "ge")); } + // -------------------------------------------------------------------------- + /** * TestHasPDO function. * diff --git a/tests/core/db_qb_test.php b/tests/core/db_qb_test.php index f7f1940..d4b9de8 100644 --- a/tests/core/db_qb_test.php +++ b/tests/core/db_qb_test.php @@ -18,9 +18,11 @@ */ abstract class QBTest extends UnitTestCase { + // -------------------------------------------------------------------------- // ! Get Tests - - function TestGet() + // -------------------------------------------------------------------------- + + public function TestGet() { if (empty($this->db)) return; @@ -28,8 +30,10 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + + // -------------------------------------------------------------------------- - function TestGetLimit() + public function TestGetLimit() { if (empty($this->db)) return; @@ -37,8 +41,10 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + + // -------------------------------------------------------------------------- - function TestGetLimitSkip() + public function TestGetLimitSkip() { if (empty($this->db)) return; @@ -47,7 +53,9 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } - function TestGetWhere() + // -------------------------------------------------------------------------- + + public function TestGetWhere() { if (empty($this->db)) return; @@ -56,7 +64,9 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } - function TestHaving() + // -------------------------------------------------------------------------- + + public function TestHaving() { if (empty($this->db)) return; @@ -70,7 +80,9 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } - function TestOrHaving() + // -------------------------------------------------------------------------- + + public function TestOrHaving() { if (empty($this->db)) return; @@ -84,16 +96,20 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } - function TestGetViews() + // -------------------------------------------------------------------------- + + public function TestGetViews() { if (empty($this->db)) return; $this->assertTrue(is_array($this->db->get_views())); } + // -------------------------------------------------------------------------- // ! Select Tests + // -------------------------------------------------------------------------- - function TestSelectWhereGet() + public function TestSelectWhereGet() { if (empty($this->db)) return; @@ -104,8 +120,10 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + + // -------------------------------------------------------------------------- - function TestSelectWhereGet2() + public function TestSelectWhereGet2() { if (empty($this->db)) return; @@ -116,7 +134,9 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } - function TestSelectMax() + // -------------------------------------------------------------------------- + + public function TestSelectMax() { if (empty($this->db)) return; @@ -126,7 +146,9 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } - function TestSelectMin() + // -------------------------------------------------------------------------- + + public function TestSelectMin() { if (empty($this->db)) return; @@ -136,7 +158,9 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } - function TestSelectAvg() + // -------------------------------------------------------------------------- + + public function TestSelectAvg() { if (empty($this->db)) return; @@ -146,7 +170,9 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } - function TestSelectSum() + // -------------------------------------------------------------------------- + + public function TestSelectSum() { if (empty($this->db)) return; @@ -156,7 +182,9 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } - function TestSelectDistinct() + // -------------------------------------------------------------------------- + + public function TestSelectDistinct() { if (empty($this->db)) return; @@ -166,8 +194,10 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + + // -------------------------------------------------------------------------- - function TestSelectGet() + public function TestSelectGet() { if (empty($this->db)) return; @@ -176,8 +206,10 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + + // -------------------------------------------------------------------------- - function TestSelectFromGet() + public function TestSelectFromGet() { if (empty($this->db)) return; @@ -188,8 +220,10 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + + // -------------------------------------------------------------------------- - function TestSelectFromLimitGet() + public function TestSelectFromLimitGet() { if (empty($this->db)) return; @@ -202,9 +236,11 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + // -------------------------------------------------------------------------- // ! Query modifier tests + // -------------------------------------------------------------------------- - function TestOrderBy() + public function TestOrderBy() { if (empty($this->db)) return; @@ -219,8 +255,10 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + + // -------------------------------------------------------------------------- - function TestOrderByRandom() + public function TestOrderByRandom() { if (empty($this->db)) return; @@ -234,8 +272,10 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + + // -------------------------------------------------------------------------- - function TestGroupBy() + public function TestGroupBy() { if (empty($this->db)) return; @@ -253,8 +293,10 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + + // -------------------------------------------------------------------------- - function TestOrWhere() + public function TestOrWhere() { if (empty($this->db)) return; @@ -267,8 +309,10 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + + // -------------------------------------------------------------------------- - function TestLike() + public function TestLike() { if (empty($this->db)) return; @@ -278,8 +322,10 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + + // -------------------------------------------------------------------------- - function TestJoin() + public function TestJoin() { if (empty($this->db)) return; @@ -290,9 +336,11 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + // -------------------------------------------------------------------------- // ! DB update tests + // -------------------------------------------------------------------------- - function TestInsert() + public function TestInsert() { if (empty($this->db)) return; @@ -303,8 +351,10 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + + // -------------------------------------------------------------------------- - function TestUpdate() + public function TestUpdate() { if (empty($this->db)) return; @@ -316,8 +366,10 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + + // -------------------------------------------------------------------------- - function TestDelete() + public function TestDelete() { if (empty($this->db)) return; @@ -326,9 +378,11 @@ abstract class QBTest extends UnitTestCase { $this->assertIsA($query, 'PDOStatement'); } + // -------------------------------------------------------------------------- // ! Non-data read queries + // -------------------------------------------------------------------------- - function TestCountAll() + public function TestCountAll() { if (empty($this->db)) return; $query = $this->db->count_all('create_test'); @@ -336,7 +390,9 @@ abstract class QBTest extends UnitTestCase { $this->assertTrue(is_numeric($query)); } - function TestCountAllResults() + // -------------------------------------------------------------------------- + + public function TestCountAllResults() { if (empty($this->db)) return; $query = $this->db->count_all_results('create_test'); @@ -344,7 +400,9 @@ abstract class QBTest extends UnitTestCase { $this->assertTrue(is_numeric($query)); } - function TestCountAllResults2() + // -------------------------------------------------------------------------- + + public function TestCountAllResults2() { if (empty($this->db)) return; @@ -358,7 +416,9 @@ abstract class QBTest extends UnitTestCase { $this->assertTrue(is_numeric($query)); } - function TestNumRows() + // -------------------------------------------------------------------------- + + public function TestNumRows() { $query = $this->db->get('create_test'); diff --git a/tests/core/db_test.php b/tests/core/db_test.php index c2506b8..6aa12b3 100644 --- a/tests/core/db_test.php +++ b/tests/core/db_test.php @@ -18,22 +18,28 @@ */ abstract class DBTest extends UnitTestCase { - abstract function TestConnection(); + abstract public function TestConnection(); + + // -------------------------------------------------------------------------- - function tearDown() + public function tearDown() { $this->db = NULL; } + + // -------------------------------------------------------------------------- - function TestGetTables() + public function TestGetTables() { if (empty($this->db)) return; $tables = $this->db->get_tables(); $this->assertTrue(is_array($tables)); } + + // -------------------------------------------------------------------------- - function TestGetSystemTables() + public function TestGetSystemTables() { if (empty($this->db)) return; @@ -41,8 +47,10 @@ abstract class DBTest extends UnitTestCase { $this->assertTrue(is_array($tables)); } + + // -------------------------------------------------------------------------- - function TestCreateTransaction() + public function TestCreateTransaction() { if (empty($this->db)) return; @@ -50,7 +58,9 @@ abstract class DBTest extends UnitTestCase { $this->assertTrue($res); } - function TestBackupData() + // -------------------------------------------------------------------------- + + public function TestBackupData() { $this->assertTrue(is_string($this->db->util->backup_data())); } diff --git a/tests/core/settings.php b/tests/core/settings.php index 9f0c6a0..4e60e62 100644 --- a/tests/core/settings.php +++ b/tests/core/settings.php @@ -17,7 +17,7 @@ */ class SettingsTest extends UnitTestCase { - function __construct() + public function __construct() { parent::__construct(); $this->settings =& Settings::get_instance(); @@ -25,46 +25,62 @@ class SettingsTest extends UnitTestCase { // Make sure to delete 'foo' if it exists $this->settings->remove_db('foo'); } + + // -------------------------------------------------------------------------- - function TestExists() + public function TestExists() { $this->assertIsA($this->settings, 'Settings'); } - function TestGetEmptyDBs() + // -------------------------------------------------------------------------- + + public function TestGetEmptyDBs() { $this->assertTrue(is_object($this->settings->get_dbs())); } - function TestGetNull() + // -------------------------------------------------------------------------- + + public function TestGetNull() { $this->assertFalse(isset($this->settings->foo)); } - function TestSet() + // -------------------------------------------------------------------------- + + public function TestSet() { $bar = $this->settings->foo = 'bar'; $this->assertEqual('bar', $bar); } - function TestGet() + // -------------------------------------------------------------------------- + + public function TestGet() { $this->assertEqual('bar', $this->settings->foo); } - function TestSetDBProperty() + // -------------------------------------------------------------------------- + + public function TestSetDBProperty() { $res = $this->settings->__set('dbs', 2); $this->assertFalse($res); } - function TestGetEmptyDB() + // -------------------------------------------------------------------------- + + public function TestGetEmptyDB() { $this->assertFalse($this->settings->get_db('foo')); } - function TestAddDB() + // -------------------------------------------------------------------------- + + public function TestAddDB() { $this->settings->add_db('foo', array()); diff --git a/tests/databases/firebird/firebird-qb.php b/tests/databases/firebird/firebird-qb.php index 21225bc..a823623 100644 --- a/tests/databases/firebird/firebird-qb.php +++ b/tests/databases/firebird/firebird-qb.php @@ -18,7 +18,7 @@ */ class FirebirdQBTest extends QBTest { - function __construct() + public function __construct() { parent::__construct(); @@ -35,6 +35,4 @@ class FirebirdQBTest extends QBTest { // echo '
Firebird Queries
'; } - - } \ No newline at end of file diff --git a/tests/databases/firebird/firebird.php b/tests/databases/firebird/firebird.php index cb33f94..ee293ed 100644 --- a/tests/databases/firebird/firebird.php +++ b/tests/databases/firebird/firebird.php @@ -20,7 +20,7 @@ */ class FirebirdTest extends DBTest { - function setUp() + public function setUp() { $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(); } - function tearDown() + // -------------------------------------------------------------------------- + + public function tearDown() { unset($this->db); unset($this->tables); } + + // -------------------------------------------------------------------------- - function TestConnection() + public function TestConnection() { $this->assertIsA($this->db, 'Firebird'); } - function TestGetTables() + // -------------------------------------------------------------------------- + + public function TestGetTables() { $tables = $this->tables; $this->assertTrue(is_array($tables)); } - function TestGetSystemTables() + // -------------------------------------------------------------------------- + + public function TestGetSystemTables() { $only_system = TRUE; @@ -64,13 +72,17 @@ class FirebirdTest extends DBTest { $this->assertTrue($only_system); } - function TestCreateTransaction() + // -------------------------------------------------------------------------- + + public function TestCreateTransaction() { $res = $this->db->beginTransaction(); $this->assertTrue($res); } + + // -------------------------------------------------------------------------- - /*function TestCreateTable() + /*public function TestCreateTable() { //Attempt to create the table $sql = $this->db->sql->create_table('create_join', array( @@ -93,16 +105,18 @@ class FirebirdTest extends DBTest { $this->assertTrue($table_exists); }*/ + // -------------------------------------------------------------------------- - - function TestTruncate() + public function TestTruncate() { $this->db->truncate('create_test'); $this->assertTrue($this->db->affected_rows() > 0); } - function TestCommitTransaction() + // -------------------------------------------------------------------------- + + public function TestCommitTransaction() { $res = $this->db->beginTransaction(); @@ -113,7 +127,9 @@ class FirebirdTest extends DBTest { $this->assertTrue($res); } - function TestRollbackTransaction() + // -------------------------------------------------------------------------- + + public function TestRollbackTransaction() { $res = $this->db->beginTransaction(); @@ -124,9 +140,9 @@ class FirebirdTest extends DBTest { $this->assertTrue($res); } + // -------------------------------------------------------------------------- - - function TestPreparedStatements() + public function TestPreparedStatements() { $sql = <<assertFalse($this->db->prepare_query('', array())); } + + // -------------------------------------------------------------------------- - /*function TestDeleteTable() + /*public function TestDeleteTable() { //Attempt to delete the table $sql = $this->db->sql->delete_table('create_test'); @@ -169,22 +191,30 @@ SQL; $this->assertFalse($table_exists); }*/ - function TestGetSequences() + // -------------------------------------------------------------------------- + + public function TestGetSequences() { $this->assertTrue(is_array($this->db->get_sequences())); } - function TestGetProcedures() + // -------------------------------------------------------------------------- + + public function TestGetProcedures() { $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())); } diff --git a/tests/databases/mysql/mysql-qb.php b/tests/databases/mysql/mysql-qb.php index 60b5fb4..b014649 100644 --- a/tests/databases/mysql/mysql-qb.php +++ b/tests/databases/mysql/mysql-qb.php @@ -15,7 +15,7 @@ class MySQLQBTest extends QBTest { - function __construct() + public function __construct() { parent::__construct(); @@ -45,8 +45,9 @@ class MySQLQBTest extends QBTest { } } + // -------------------------------------------------------------------------- - function TestExists() + public function TestExists() { $this->assertTrue(in_array('mysql', pdo_drivers())); } diff --git a/tests/databases/mysql/mysql.php b/tests/databases/mysql/mysql.php index 5e8d210..1562bc5 100644 --- a/tests/databases/mysql/mysql.php +++ b/tests/databases/mysql/mysql.php @@ -20,7 +20,7 @@ */ class MySQLTest extends DBTest { - function setUp() + public function setUp() { // Attempt to connect, if there is a test config file if (is_file(BASE_DIR . "test_config.json")) @@ -35,20 +35,26 @@ class MySQLTest extends DBTest { $this->db = new MySQL('host=127.0.0.1;port=3306;dbname=test', 'root'); } } + + // -------------------------------------------------------------------------- - function TestExists() + public function TestExists() { $this->assertTrue(in_array('mysql', pdo_drivers())); } + + // -------------------------------------------------------------------------- - function TestConnection() + public function TestConnection() { if (empty($this->db)) return; $this->assertIsA($this->db, 'MySQL'); } + + // -------------------------------------------------------------------------- - function TestCreateTable() + public function TestCreateTable() { 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_join'); @@ -95,7 +103,9 @@ class MySQLTest extends DBTest { $cj_query = $this->db->query('SELECT * FROM create_join'); } - function TestPreparedStatements() + // -------------------------------------------------------------------------- + + public function TestPreparedStatements() { if (empty($this->db)) return; @@ -108,8 +118,10 @@ SQL; $statement->execute(); } + + // -------------------------------------------------------------------------- - function TestPrepareExecute() + public function TestPrepareExecute() { if (empty($this->db)) return; @@ -122,8 +134,10 @@ SQL; )); } + + // -------------------------------------------------------------------------- - function TestCommitTransaction() + public function TestCommitTransaction() { if (empty($this->db)) return; @@ -135,8 +149,10 @@ SQL; $res = $this->db->commit(); $this->assertTrue($res); } + + // -------------------------------------------------------------------------- - function TestRollbackTransaction() + public function TestRollbackTransaction() { if (empty($this->db)) return; @@ -149,24 +165,31 @@ SQL; $this->assertTrue($res); } - function TestGetSchemas() + // -------------------------------------------------------------------------- + + public function TestGetSchemas() { $this->assertFalse($this->db->get_schemas()); } - function TestGetsProcedures() + // -------------------------------------------------------------------------- + + public function TestGetsProcedures() { $this->assertTrue(is_array($this->db->get_procedures())); } - function TestGetTriggers() + // -------------------------------------------------------------------------- + + public function TestGetTriggers() { $this->assertTrue(is_array($this->db->get_triggers())); } - function TestGetSequences() + // -------------------------------------------------------------------------- + + public function TestGetSequences() { $this->assertFalse($this->db->get_sequences()); } -} - +} \ No newline at end of file diff --git a/tests/databases/pgsql/pgsql-qb.php b/tests/databases/pgsql/pgsql-qb.php index 58ac034..e763b08 100644 --- a/tests/databases/pgsql/pgsql-qb.php +++ b/tests/databases/pgsql/pgsql-qb.php @@ -14,7 +14,7 @@ class PgSQLQBTest extends QBTest { - function __construct() + public function __construct() { parent::__construct(); @@ -44,8 +44,10 @@ class PgSQLQBTest extends QBTest { $this->db = new Query_Builder($params); } } + + // -------------------------------------------------------------------------- - function TestExists() + public function TestExists() { $this->assertTrue(in_array('pgsql', pdo_drivers())); } diff --git a/tests/databases/pgsql/pgsql.php b/tests/databases/pgsql/pgsql.php index 5cd529b..80e6a61 100644 --- a/tests/databases/pgsql/pgsql.php +++ b/tests/databases/pgsql/pgsql.php @@ -19,12 +19,14 @@ */ class PgTest extends DBTest { - function __construct() + public function __construct() { parent::__construct(); } + + // -------------------------------------------------------------------------- - function setUp() + public function setUp() { // Attempt to connect, if there is a test config file if (is_file(BASE_DIR . "test_config.json")) @@ -39,20 +41,26 @@ class PgTest extends DBTest { $this->db = new PgSQL('host=127.0.0.1;port=5432;dbname=test', 'postgres'); } } + + // -------------------------------------------------------------------------- - function TestExists() + public function TestExists() { $this->assertTrue(in_array('pgsql', pdo_drivers())); } + + // -------------------------------------------------------------------------- - function TestConnection() + public function TestConnection() { if (empty($this->db)) return; $this->assertIsA($this->db, 'PgSQL'); } + + // -------------------------------------------------------------------------- - function TestCreateTable() + public function TestCreateTable() { 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_join'); @@ -111,7 +121,9 @@ class PgTest extends DBTest { $cj_query = $this->db->query('SELECT * FROM create_join'); } - function TestPreparedStatements() + // -------------------------------------------------------------------------- + + public function TestPreparedStatements() { if (empty($this->db)) return; @@ -124,8 +136,10 @@ SQL; $statement->execute(); } + + // -------------------------------------------------------------------------- - function TestPrepareExecute() + public function TestPrepareExecute() { if (empty($this->db)) return; @@ -138,8 +152,10 @@ SQL; )); } + + // -------------------------------------------------------------------------- - function TestCommitTransaction() + public function TestCommitTransaction() { if (empty($this->db)) return; @@ -151,8 +167,10 @@ SQL; $res = $this->db->commit(); $this->assertTrue($res); } + + // -------------------------------------------------------------------------- - function TestRollbackTransaction() + public function TestRollbackTransaction() { if (empty($this->db)) return; @@ -165,22 +183,30 @@ SQL; $this->assertTrue($res); } - function TestGetSchemas() + // -------------------------------------------------------------------------- + + public function TestGetSchemas() { $this->assertTrue(is_array($this->db->get_schemas())); } - function TestGetSequences() + // -------------------------------------------------------------------------- + + public function TestGetSequences() { $this->assertTrue(is_array($this->db->get_sequences())); } - function TestGetsProcedures() + // -------------------------------------------------------------------------- + + public function TestGetsProcedures() { $this->assertTrue(is_array($this->db->get_procedures())); } - function TestGetTriggers() + // -------------------------------------------------------------------------- + + public function TestGetTriggers() { $this->assertTrue(is_array($this->db->get_triggers())); } diff --git a/tests/databases/sqlite/sqlite-qb.php b/tests/databases/sqlite/sqlite-qb.php index ad62c12..1ea5e55 100644 --- a/tests/databases/sqlite/sqlite-qb.php +++ b/tests/databases/sqlite/sqlite-qb.php @@ -17,7 +17,7 @@ */ class SQLiteQBTest extends QBTest { - function __construct() + public function __construct() { parent::__construct(); diff --git a/tests/databases/sqlite/sqlite.php b/tests/databases/sqlite/sqlite.php index 78e766c..cd976a8 100644 --- a/tests/databases/sqlite/sqlite.php +++ b/tests/databases/sqlite/sqlite.php @@ -19,47 +19,61 @@ */ class SQLiteTest extends UnitTestCase { - function __construct() + public function __construct() { parent::__construct(); } + + // -------------------------------------------------------------------------- - function setUp() + public function setUp() { $path = TEST_DIR.DS.'db_files'.DS.'test_sqlite.db'; $this->db = new SQLite($path); } + + // -------------------------------------------------------------------------- - function tearDown() + public function tearDown() { unset($this->db); } + + // -------------------------------------------------------------------------- - function TestConnection() + public function TestConnection() { $this->assertIsA($this->db, 'SQLite'); } + + // -------------------------------------------------------------------------- - function TestGetTables() + public function TestGetTables() { $tables = $this->db->get_tables(); $this->assertTrue(is_array($tables)); } + + // -------------------------------------------------------------------------- - function TestGetSystemTables() + public function TestGetSystemTables() { $tables = $this->db->get_system_tables(); $this->assertTrue(is_array($tables)); } + + // -------------------------------------------------------------------------- - function TestCreateTransaction() + public function TestCreateTransaction() { $res = $this->db->beginTransaction(); $this->assertTrue($res); } + + // -------------------------------------------------------------------------- - function TestCreateTable() + public function TestCreateTable() { //Attempt to create the table $sql = $this->db->util->create_table('create_test', @@ -92,14 +106,18 @@ class SQLiteTest extends UnitTestCase { $this->assertTrue(in_array('create_test', $dbs)); } + + // -------------------------------------------------------------------------- - function TestTruncate() + public function TestTruncate() { $this->db->truncate('create_test'); $this->assertIsA($this->db->affected_rows(), 'int'); } + + // -------------------------------------------------------------------------- - function TestPreparedStatements() + public function TestPreparedStatements() { $sql = <<execute(); } + + // -------------------------------------------------------------------------- - function TestPrepareExecute() + public function TestPrepareExecute() { $sql = <<db->beginTransaction(); @@ -133,8 +155,10 @@ SQL; $res = $this->db->commit(); $this->assertTrue($res); } + + // -------------------------------------------------------------------------- - function TestRollbackTransaction() + public function TestRollbackTransaction() { $res = $this->db->beginTransaction(); @@ -144,9 +168,11 @@ SQL; $res = $this->db->rollback(); $this->assertTrue($res); } + + // -------------------------------------------------------------------------- // This is really time intensive ! Run only when needed - /*function TestDeleteTable() + /*public function TestDeleteTable() { //Make sure the table exists to delete $dbs = $this->db->get_tables(); @@ -160,13 +186,17 @@ SQL; $dbs = $this->db->get_tables(); $this->assertFalse(in_array('create_test', $dbs)); }*/ + + // -------------------------------------------------------------------------- - function TestGetDBs() + public function TestGetDBs() { $this->assertFalse($this->db->get_dbs()); } + + // -------------------------------------------------------------------------- - function TestGetSchemas() + public function TestGetSchemas() { $this->assertFalse($this->db->get_schemas()); } diff --git a/tests/db_files/FB_TEST_DB.FDB b/tests/db_files/FB_TEST_DB.FDB index 40708a8e17fe9d39feb2f706a6354ce87a3cd11f..496af9b8b2fea3e3a40e9c966c3c3bed78337bdf 100644 GIT binary patch delta 1426 zcmZ9MO=#3m5Xa|bKa%WF_SJRUO0k?XXl=U~%zV8vd9qZS>lF*q>iV9RvjuI<7_;tm~On~UJnwbR7c%w`npU3m^_ooXhm_U!fHa;Dv1Lp;>dp=}3OBB=so@YEec|RVXVBC18yD2hF3yW%>gspA z(B*in&&>MF)kLp0qF-}z`Wn7qLp|F^*C3eLBkj-o=xHEnS3TTAPt>*aj1X}LIAS4E zkiZ;g1S!iTgX%~I)qDm7x&!L#kTM|P>b(fk;>VTvNyT%hxU~|P<5VE!I294S$l5G! zek(6ckVzA;^`1cxIp6-zc|8?67>hG==b2gDOYY|~cJ|oH@=1fSE0CjOaJ=`UF|&1X<}C($Z&R z%Q+Ok@62pDbDWAu=a0KiQ=H8k0ZA{ZzeB9)X}|Xk-6M@`XcG~&M3WwU0HSuZ2PoCK y5GM*fdgkLV?9n$tPei?R2)9o07l1QRn_)7^NiCMz3UP{OyGVM`EW2+G@X9~BAR`C> delta 2182 zcmb_dPiPcp6o23BPIhJ*XUF{L?f_^ zNsXT1S`^pmB=2{*&P4rmBN{C7%1MMCWc^!pM*i&MRUX_OP8sQ_dyD~Nzg^_oLG!$$ z;84PIXqdx8Iz4l#@rl5nF7o7Dr<}4Do^6j=PR?UmnJKy5kuuqK)-PR>vgu~m}#_aG{jf-ba&mg3)&DHv) zdxCb$Dd%MM-n~ME%nUBMKv&j4G{bl};1(`2VC0`b131v(6#S(uCb77r7aIc36ZL7`4Cp6AIS=3SA z*Tvk-^E%<9y;pBMS@C5&eip!a4*g|W@*zu>RrLle%r$sJbn+o68HpQ&= zFPZqh7VK}Ue0ZBLjXd&W7!W$?b@D6M|MBHf3GBp|dc%yttSLTDch-0+=y-t~bpp{^ e+KJZM?yKbI_+XHa{}AIppXT+RrunTu_~dKJCtw`_