OpenSQLManager/tests/databases/mysql.php

85 lines
1.6 KiB
PHP
Raw Normal View History

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
*/
// --------------------------------------------------------------------------
/**
* MySQLTest class.
*
* @extends UnitTestCase
*/
2012-03-19 14:30:52 -04:00
class MySQLTest extends DBTest {
2012-03-15 16:39:01 -04:00
function setUp()
{
// Attempt to connect, if there is a test config file
if (is_file("../test_config.json"))
{
$params = json_decode(file_get_contents("../test_config.json"));
$params = $params->mysql;
$this->db = new MySQL("host={$params->host};port={$params->port};dbname={$params->database}", $params->user, $params->pass);
}
}
function TestExists()
{
$this->assertTrue(in_array('mysql', pdo_drivers()));
}
2012-03-15 16:39:01 -04:00
function TestConnection()
{
if (empty($this->db)) return;
$this->assertIsA($this->db, 'MySQL');
}
function TestCreateTable()
{
if (empty($this->db)) return;
//Attempt to create the table
$sql = $this->db->sql->create_table('create_test',
array(
'id' => 'int(10)',
'key' => 'TEXT',
'val' => 'TEXT',
),
array(
'id' => 'PRIMARY KEY'
)
);
$this->db->query($sql);
//Attempt to create the table
$sql = $this->db->sql->create_table('create_join',
array(
'id' => 'int(10)',
'key' => 'TEXT',
'val' => 'TEXT',
),
array(
'id' => 'PRIMARY KEY'
)
);
$this->db->query($sql);
//Check
$dbs = $this->db->get_tables();
$this->assertTrue(in_array('create_test', $dbs));
}
2012-02-02 19:04:10 -05:00
}
2012-03-19 14:30:52 -04:00