Added some unit tests
This commit is contained in:
parent
c85f791de5
commit
9808bdcbac
@ -111,7 +111,7 @@ abstract class DB_PDO extends PDO {
|
||||
/**
|
||||
* Abstract functions to override in child classes
|
||||
*/
|
||||
abstract function get_dbs(){}
|
||||
abstract function get_dbs();
|
||||
|
||||
}
|
||||
// End of db_pdo.php
|
69
tests/core.php
Normal file
69
tests/core.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* OpenSQLManager
|
||||
*
|
||||
* Free Database manager for Open Source Databases
|
||||
*
|
||||
* @author Timothy J. Warren
|
||||
* @copyright Copyright (c) 2012
|
||||
* @link https://github.com/aviat4ion/OpenSQLManager
|
||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
/**
|
||||
* CoreTest class - Compatibility and core functionality tests
|
||||
*
|
||||
* @extends UnitTestCase
|
||||
*/
|
||||
class CoreTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* TestPHPVersion function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function TestPHPVersion()
|
||||
{
|
||||
$this->assertTrue(version_compare(PHP_VERSION, "5.2", "ge"));
|
||||
}
|
||||
|
||||
/**
|
||||
* TestHasPDO function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function TestHasPDO()
|
||||
{
|
||||
// PDO class exists
|
||||
$this->assertTrue(class_exists('PDO'));
|
||||
|
||||
|
||||
// Make sure at least one of the supported drivers is enabled
|
||||
$supported = array(
|
||||
'mysql',
|
||||
'pgsql',
|
||||
'odbc',
|
||||
'sqlite',
|
||||
);
|
||||
|
||||
$drivers = pdo_drivers();
|
||||
|
||||
$num_supported = count(array_intersect($drivers, $supported));
|
||||
|
||||
$this->assertTrue($num_supported > 0);
|
||||
}
|
||||
}
|
32
tests/databases/firebird.php
Normal file
32
tests/databases/firebird.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* OpenSQLManager
|
||||
*
|
||||
* Free Database manager for Open Source Databases
|
||||
*
|
||||
* @author Timothy J. Warren
|
||||
* @copyright Copyright (c) 2012
|
||||
* @link https://github.com/aviat4ion/OpenSQLManager
|
||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* FirebirdTest class.
|
||||
*
|
||||
* @extends UnitTestCase
|
||||
*/
|
||||
class FirebirdTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
36
tests/databases/mysql.php
Normal file
36
tests/databases/mysql.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* OpenSQLManager
|
||||
*
|
||||
* Free Database manager for Open Source Databases
|
||||
*
|
||||
* @author Timothy J. Warren
|
||||
* @copyright Copyright (c) 2012
|
||||
* @link https://github.com/aviat4ion/OpenSQLManager
|
||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* MySQLTest class.
|
||||
*
|
||||
* @extends UnitTestCase
|
||||
*/
|
||||
class MySQLTest extends UnitTestCase {
|
||||
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
//$this->db = new MySQL();
|
||||
}
|
||||
}
|
||||
|
32
tests/databases/odbc.php
Normal file
32
tests/databases/odbc.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* OpenSQLManager
|
||||
*
|
||||
* Free Database manager for Open Source Databases
|
||||
*
|
||||
* @author Timothy J. Warren
|
||||
* @copyright Copyright (c) 2012
|
||||
* @link https://github.com/aviat4ion/OpenSQLManager
|
||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* ODBCTest class.
|
||||
*
|
||||
* @extends UnitTestCase
|
||||
*/
|
||||
class ODBCTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
32
tests/databases/pgsql.php
Normal file
32
tests/databases/pgsql.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* OpenSQLManager
|
||||
*
|
||||
* Free Database manager for Open Source Databases
|
||||
*
|
||||
* @author Timothy J. Warren
|
||||
* @copyright Copyright (c) 2012
|
||||
* @link https://github.com/aviat4ion/OpenSQLManager
|
||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* PgTest class.
|
||||
*
|
||||
* @extends UnitTestCase
|
||||
*/
|
||||
class PgTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
32
tests/databases/sqlite.php
Normal file
32
tests/databases/sqlite.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* OpenSQLManager
|
||||
*
|
||||
* Free Database manager for Open Source Databases
|
||||
*
|
||||
* @author Timothy J. Warren
|
||||
* @copyright Copyright (c) 2012
|
||||
* @link https://github.com/aviat4ion/OpenSQLManager
|
||||
* @license http://philsturgeon.co.uk/code/dbad-license
|
||||
*/
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* SQLiteTest class.
|
||||
*
|
||||
* @extends UnitTestCase
|
||||
*/
|
||||
class SQLiteTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
@ -17,3 +17,23 @@
|
||||
*/
|
||||
|
||||
define('BASE_DIR', '../src');
|
||||
|
||||
// Include simpletest
|
||||
// it has to be set in your php path, or put in the tests folder
|
||||
require_once('simpletest/autorun.php');
|
||||
|
||||
|
||||
// Bulk loading wrapper workaround for PHP < 5.4
|
||||
function do_include($path)
|
||||
{
|
||||
require_once($path);
|
||||
}
|
||||
|
||||
// Include core tests
|
||||
require_once("core.php");
|
||||
|
||||
// Include db classes
|
||||
array_map('do_include', glob("../src/databases/*.php"));
|
||||
|
||||
// Include db tests
|
||||
array_map('do_include', glob("./databases/*.php"));
|
Loading…
Reference in New Issue
Block a user