mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
ae6c6d0a36
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@129 3807eeeb-6ff5-0310-8944-8be069107fe0
74 lines
No EOL
1.6 KiB
Text
74 lines
No EOL
1.6 KiB
Text
<?php
|
|
|
|
uses ('test', 'dbo_mysql');
|
|
|
|
class DboMysqlTest extends TestCase {
|
|
var $abc;
|
|
|
|
// constructor of the test suite
|
|
function DboMysqlTest($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_MySQL (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 () {
|
|
// $sql = "CREATE TABLE __test (id serial NOT NULL, body CHARACTER VARYING(255))"; // postgresql
|
|
$sql = "CREATE TABLE __test (id INT UNSIGNED PRIMARY KEY, body VARCHAR(255))"; // mysql
|
|
|
|
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()));
|
|
}
|
|
}
|
|
|
|
?> |