2012-02-02 19:04:10 -05:00
|
|
|
<?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();
|
2012-02-07 08:45:56 -05:00
|
|
|
|
2012-02-07 20:31:36 -05:00
|
|
|
$this->db = new SQLite(dirname(__FILE__)."/../test_dbs/test_sqlite.db");
|
2012-02-02 19:04:10 -05:00
|
|
|
}
|
2012-02-07 08:18:38 -05:00
|
|
|
|
|
|
|
function TestConnection()
|
|
|
|
{
|
2012-02-07 08:45:56 -05:00
|
|
|
$this->assertIsA($this->db, 'SQLite');
|
2012-02-07 08:18:38 -05:00
|
|
|
}
|
2012-02-07 20:31:36 -05:00
|
|
|
|
|
|
|
function TestGetTables()
|
|
|
|
{
|
|
|
|
$tables = $this->db->get_tables();
|
2012-02-08 09:01:51 -05:00
|
|
|
$this->assertTrue(isset($tables['test']));
|
|
|
|
}
|
|
|
|
|
|
|
|
function TestCreateTable()
|
|
|
|
{
|
|
|
|
//Attempt to create the table
|
|
|
|
$sql = $this->db->manip->create_table('create_test', array('id' => 'INTEGER PRIMARY KEY'));
|
|
|
|
$this->db->query($sql);
|
|
|
|
|
|
|
|
//Check
|
|
|
|
$dbs = $this->db->get_tables();
|
|
|
|
$this->assertEqual($dbs['create_test'], 'CREATE TABLE create_test (id INTEGER PRIMARY KEY)');
|
|
|
|
}
|
|
|
|
|
|
|
|
function TestDeleteTable()
|
|
|
|
{
|
|
|
|
//Make sure the table exists to delete
|
|
|
|
$dbs = $this->db->get_tables();
|
|
|
|
$this->assertTrue(isset($dbs['create_test']));
|
|
|
|
|
|
|
|
//Attempt to delete the table
|
|
|
|
$sql = $this->db->manip->delete_table('create_test');
|
|
|
|
$this->db->query($sql);
|
|
|
|
|
|
|
|
//Check
|
|
|
|
$dbs = $this->db->get_tables();
|
|
|
|
$this->assertTrue(empty($dbs['create_test']));
|
2012-02-07 20:31:36 -05:00
|
|
|
}
|
2012-02-02 19:04:10 -05:00
|
|
|
}
|