<?php

// uncomment this line if you want to run both MDB2 from a CVS checkout
#ini_set('include_path', '..'.PATH_SEPARATOR.ini_get('include_path'));

$testcases = array(
    'MDB2_api_testcase',
    'MDB2_usage_testcase',
    'MDB2_bugs_testcase',
    'MDB2_extended_testcase',
    'MDB2_datatype_testcase',
    'MDB2_manager_testcase',
    'MDB2_reverse_testcase',
    'MDB2_function_testcase',
    'MDB2_native_testcase',
    'MDB2_internals_testcase',
);

// use a user that has full permissions on a database named "driver_test"
$mysql = array(
    'dsn' => array(
        'phptype' => 'mysql',
        'username' => 'username',
        'password' => 'password',
        'hostspec' => 'hostname',
    ),
    'options' => array(
        'use_transactions' => true
    )
);

$pgsql = array(
    'dsn' => array(
        'phptype' => 'pgsql',
        'username' => 'username',
        'password' => 'password',
        'hostspec' => 'hostname',
    )
);

$oci8 = array(
    'dsn' => array(
        'phptype' => 'oci8',
        'username' => '',
        'password' => 'password',
        'hostspec' => 'hostname',
    ),
    'options' => array(
        'DBA_username' => 'username',
        'DBA_password' => 'password'
    )
);

$sqlite = array(
    'dsn' => array(
        'phptype' => 'sqlite',
        'username' => '',
        'password' => 'password',
        'hostspec' => 'hostname',
    ),
    'options' => array(
        'database_path' => '',
        'database_extension' => '',
    )
);

// must be a user with system administrator privileges
$mssql = array(
    'dsn' => array(
        'phptype' => 'mssql',
        'username' => 'username',
        'password' => 'password',
        'hostspec' => 'hostname',
    )
);

$fbsql = array(
    'dsn' => array(
        'phptype' => 'fbsql',
        'username' => 'username',
        'password' => 'password',
        'hostspec' => 'hostname',
    )
);


$ibase = array(
    'dsn' => array(
        'phptype' => 'ibase',
        'username' => 'username',
        'password' => 'password',
        'hostspec' => 'hostname',
    )
);

$dbarray = array();
#$dbarray[] = $mysql;
#$dbarray[] = $pgsql;
#$dbarray[] = $oci8;
#$dbarray[] = $sqlite;
#$dbarray[] = $mssql;
#$dbarray[] = $fbsql;
#$dbarray[] = $ibase;

// you may need to uncomment the line and modify the multiplier as you see fit
#set_time_limit(60*count($dbarray));

//if uncommented, the following will drop and recreate the test database when running the test
// the paths assumes that MDB2_Schema is checked out in the same parent directory as MDB2
/*
require_once('MDB2/Schema.php');
$schema_path = '../../MDB2_Schema/tests/';

function pe($e) {
    die($e->getMessage().' '.$e->getUserInfo());
}
PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, 'pe');
foreach ($dbarray as $dbtype) {
    // Work around oci8 problems with dropping the connected user
    $dsn = $dbtype['dsn'];
    if ($dbtype['dsn']['phptype'] == 'oci8') {
        $dsn['username'] = $dbtype['options']['DBA_username'];
        $dsn['password'] = $dbtype['options']['DBA_password'];
        $dsn['database'] = $dbtype['options']['DBA_username'];
    }
    $db =& MDB2::connect($dsn, $dbtype['options']);
    $db->loadModule('Manager');
    if (in_array('driver_test', $db->manager->listDatabases())) {
        $db->manager->dropDatabase('driver_test');
    }
    // Work around oci8 problems with dropping the connected user
    if ($dbtype['dsn']['phptype'] == 'oci8') {
        $db->query('CREATE USER '.$dbtype['dsn']['username'].' IDENTIFIED BY '.$dbtype['dsn']['password'].' DEFAULT TABLESPACE USERS QUOTA UNLIMITED ON USERS');
        $db->query('GRANT CREATE SESSION, CREATE TABLE, CREATE SEQUENCE, CREATE TRIGGER to '.$dbtype['dsn']['username']);
    }
    $schema =& MDB2_Schema::factory($dbtype['dsn'], $dbtype['options']);
    $schema->updateDatabase(
                            '../../MDB2_Schema/tests/driver_test.schema',
                            false,
                            array('create' => '1', 'name' => 'driver_test')
                            );
    $schema->updateDatabase(
                            '../../MDB2_Schema/tests/lob_test.schema',
                            false,
                            array('create' => '1', 'name' => 'driver_test')
                            );
}
PEAR::popErrorHandling();
*/

?>
