cakephp2-php8/tests/libs/dbo_factory.php
pies da79dff7d7 - merged in Brego's SimpleTest implementation, fixed some of the tests (the Folder test fails to delete one of the test directories on my system, so it's not perfectly clean yet)
- Dispatcher sets a Controller::here variable with the real URL used to access the page, so that tag generators can that use an url (linkTo and formTag for example) use the real url, not guess it from the controller and action names which often fails
- Log class works more reliably and a LogError() shortcut function was added
- Nstring class added, to store string-related functions (there are just four yet, including a random password generator and an string-to-array splitter
- SimpleTest library (with Rephlux) included in /vendors; I've tweaked SimpleScorer::inCli() function, because it didn't work on my setup, it should work everywhere now (it checks for empty REQUEST_METHOD, which should only be empty in CLI)

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@248 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-06-18 23:26:35 +00:00

68 lines
No EOL
1.5 KiB
PHP

<?php
uses('dbo_factory');
class DboFactoryTest extends UnitTestCase
{
var $dboFactory;
// constructor of the test suite
function DboFactoryTest()
{
$this->UnitTestCase('DBO Factory test');
}
// called before the test functions will be executed
// this function is defined in PHPUnit_TestCase and overwritten
// here
function setUp()
{
$this->dboFactory = new DboFactory();
}
// called after the test functions are executed
// this function is defined in PHPUnit_TestCase and overwritten
// here
function tearDown()
{
unset($this->dboFactory);
}
function testMake()
{
if(class_exists('DATABASE_CONFIG'))
{
$output = $this->dboFactory->make('test');
$this->assertTrue(is_object($output), 'We create dbo factory object');
$config = DATABASE_CONFIG::test();
if(preg_match('#^(adodb)_.*$#i', $config['driver'], $res))
{
$desiredDriverName = $res[1];
}
else
{
$desiredDriverName = $config['driver'];
}
$desiredClassName = 'dbo_'.strtolower($desiredDriverName);
$outputClassName = is_object($output)? strtolower(get_class($output)): false;
$this->assertEqual($outputClassName, $desiredClassName, "Class name should be $desiredClassName - is $outputClassName");
$this->assertTrue($output->connected, 'We are connected');
}
}
// 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->dboFactory->make(null);
// $this->assertTrue($output === false);
// }
}
?>