2005-05-21 22:40:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
uses ('test', 'dbo_factory');
|
2005-06-05 19:42:54 +00:00
|
|
|
config ('database');
|
2005-05-21 22:40:51 +00:00
|
|
|
|
|
|
|
class DboFactoryTest extends TestCase {
|
|
|
|
var $abc;
|
|
|
|
|
|
|
|
// constructor of the test suite
|
|
|
|
function DboFactoryTest($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 DboFactory ();
|
|
|
|
}
|
|
|
|
|
|
|
|
// called after the test functions are executed
|
|
|
|
// this function is defined in PHPUnit_TestCase and overwritten
|
|
|
|
// here
|
|
|
|
function tearDown() {
|
|
|
|
unset($this->abc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-05 19:42:54 +00:00
|
|
|
function testMake ()
|
|
|
|
{
|
|
|
|
if (class_exists(DATABASE_CONFIG))
|
|
|
|
{
|
2005-05-22 23:24:09 +00:00
|
|
|
$output = $this->abc->make('test');
|
|
|
|
$this->assertTrue(is_object($output));
|
|
|
|
|
|
|
|
$config = DATABASE_CONFIG::test();
|
|
|
|
if (preg_match('#^(adodb)_.*$#i', $config['driver'], $res)) {
|
|
|
|
$desired_driver_name = $res[1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
$desired_driver_name = $config['driver'];
|
2005-05-21 22:40:51 +00:00
|
|
|
|
2005-05-22 23:24:09 +00:00
|
|
|
$desired_class_name = 'dbo_'.strtolower($desired_driver_name);
|
|
|
|
$output_class_name = is_object($output)? get_class($output): false;
|
2005-05-21 22:40:51 +00:00
|
|
|
|
2005-05-22 23:24:09 +00:00
|
|
|
$this->assertEquals($output_class_name, $desired_class_name);
|
2005-05-21 22:40:51 +00:00
|
|
|
|
2005-05-22 23:24:09 +00:00
|
|
|
$this->assertTrue($output->connected);
|
|
|
|
}
|
2005-05-21 22:40:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// this test expect an E_USER_ERROR to occur during it's run
|
|
|
|
// I've disabled it until I find a way to assert it happen
|
|
|
|
//
|
|
|
|
// function testBadConfig () {
|
|
|
|
// $output = $this->abc->make(null);
|
|
|
|
// $this->assertTrue($output === false);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
2005-05-17 20:55:27 +00:00
|
|
|
?>
|