cakephp2-php8/tests/libs/dbo_adodb_test.php.disabled

76 lines
No EOL
1.7 KiB
Text

<?php
uses ('test', 'dbo_adodb');
class DboAdodbTest extends TestCase {
var $abc;
// constructor of the test suite
function DboAdodbTest ($name) {
$this->TestCase($name);
}
// called before the test functions will be executed
// this function is defined in PHPUnit_TestCase and overwritten
// here
function setUp() {
$this->abc = new DBO_AdoDB (loadDatabaseConfig('test'));
$this->createTemporaryTable();
}
// called after the test functions are executed
// this function is defined in PHPUnit_TestCase and overwritten
// here
function tearDown() {
$this->dropTemporaryTable();
}
function createTemporaryTable () {
$create_sqls = array(
'mysql' => 'CREATE TABLE __test (id INT UNSIGNED PRIMARY KEY, body VARCHAR(255))',
'postgres' => 'CREATE TABLE __test (id serial NOT NULL, body CHARACTER VARYING(255))'
);
$sql = $create_sqls[$this->abc->config['driver']];
return $this->abc->query($sql);
}
function dropTemporaryTable () {
return $this->abc->query("DROP TABLE __test");
}
function testHasImplementation () {
$functions = array(
'connect',
'disconnect',
'execute',
'fetchRow',
'tables',
'fields',
'prepare',
'lastError',
'lastAffected',
'lastNumRows',
'lastInsertId'
);
foreach ($functions as $function) {
$this->assertTrue(method_exists($this->abc, $function));
}
}
function testConnectivity () {
$this->assertTrue($this->abc->connected);
}
function testFields () {
$fields = $this->abc->fields('__test');
$this->assertEquals(count($fields), 2, 'equals');
}
function testTables () {
$this->assertTrue(in_array('__test', $this->abc->tables()));
}
}
?>