Added some unit tests

This commit is contained in:
Timothy Warren 2012-02-02 19:04:10 -05:00
parent c85f791de5
commit 9808bdcbac
8 changed files with 255 additions and 2 deletions

View File

@ -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
View 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);
}
}

View 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
View 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
View 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
View 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();
}
}

View 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();
}
}

View File

@ -16,4 +16,24 @@
* Unit test bootstrap - Using php simpletest
*/
define('BASE_DIR', '../src');
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"));