2006-09-23 01:20:21 +04:00
|
|
|
<?php
|
|
|
|
require_once("../draft/DB.php");
|
|
|
|
|
2006-11-06 20:56:14 +03:00
|
|
|
class Doctrine_Db_TestLogger implements Doctrine_Overloadable {
|
2006-09-23 14:44:39 +04:00
|
|
|
private $messages = array();
|
|
|
|
|
|
|
|
public function __call($m, $a) {
|
|
|
|
$this->messages[] = $m;
|
|
|
|
}
|
|
|
|
public function pop() {
|
|
|
|
return array_pop($this->messages);
|
|
|
|
}
|
|
|
|
public function getAll() {
|
|
|
|
return $this->messages;
|
|
|
|
}
|
|
|
|
}
|
2006-11-06 20:56:14 +03:00
|
|
|
class Doctrine_Db_TestValidListener extends Doctrine_Db_EventListener { }
|
|
|
|
class Doctrine_Db_TestInvalidListener { }
|
2006-09-23 14:44:39 +04:00
|
|
|
|
2006-11-06 20:56:14 +03:00
|
|
|
class Doctrine_Db_TestCase extends Doctrine_UnitTestCase {
|
2006-09-23 01:20:21 +04:00
|
|
|
public function prepareData() { }
|
|
|
|
public function prepareTables() { }
|
|
|
|
public function init() { }
|
2006-09-23 14:44:39 +04:00
|
|
|
|
2006-09-27 14:55:02 +04:00
|
|
|
public function testFetchAll() {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('sqlite::memory:');
|
2006-09-27 14:55:02 +04:00
|
|
|
$dbh->connect();
|
|
|
|
|
|
|
|
|
|
|
|
$dbh->query('CREATE TABLE entity (id INTEGER, name TEXT)');
|
|
|
|
|
|
|
|
$dbh->query("INSERT INTO entity (id, name) VALUES (1, 'zYne')");
|
|
|
|
$dbh->query("INSERT INTO entity (id, name) VALUES (2, 'John')");
|
|
|
|
|
|
|
|
$a = $dbh->fetchAll('SELECT * FROM entity');
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertEqual($a, array (
|
|
|
|
0 =>
|
|
|
|
array (
|
|
|
|
'id' => '1',
|
|
|
|
'name' => 'zYne',
|
|
|
|
),
|
|
|
|
1 =>
|
|
|
|
array (
|
|
|
|
'id' => '2',
|
|
|
|
'name' => 'John',
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
public function testFetchOne() {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('sqlite::memory:');
|
2006-09-27 14:55:02 +04:00
|
|
|
|
|
|
|
$c = $dbh->fetchOne('SELECT COUNT(1) FROM entity');
|
|
|
|
|
|
|
|
$this->assertEqual($c, 2);
|
|
|
|
|
|
|
|
$c = $dbh->fetchOne('SELECT COUNT(1) FROM entity WHERE id = ?', array(1));
|
|
|
|
|
|
|
|
$this->assertEqual($c, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testFetchAssoc() {
|
|
|
|
|
|
|
|
}
|
|
|
|
public function testFetchColumn() {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('sqlite::memory:');
|
2006-09-27 14:55:02 +04:00
|
|
|
|
|
|
|
$a = $dbh->fetchColumn('SELECT * FROM entity');
|
|
|
|
|
|
|
|
$this->assertEqual($a, array (
|
|
|
|
0 => '1',
|
|
|
|
1 => '2',
|
|
|
|
));
|
|
|
|
|
|
|
|
$a = $dbh->fetchColumn('SELECT * FROM entity WHERE id = ?', array(1));
|
|
|
|
|
|
|
|
$this->assertEqual($a, array (
|
|
|
|
0 => '1',
|
|
|
|
));
|
|
|
|
}
|
|
|
|
public function testFetchArray() {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('sqlite::memory:');
|
2006-09-27 14:55:02 +04:00
|
|
|
|
|
|
|
$a = $dbh->fetchArray('SELECT * FROM entity');
|
|
|
|
|
|
|
|
$this->assertEqual($a, array (
|
|
|
|
0 => '1',
|
|
|
|
1 => 'zYne',
|
|
|
|
));
|
|
|
|
|
|
|
|
$a = $dbh->fetchArray('SELECT * FROM entity WHERE id = ?', array(1));
|
|
|
|
|
|
|
|
$this->assertEqual($a, array (
|
|
|
|
0 => '1',
|
|
|
|
1 => 'zYne',
|
|
|
|
));
|
|
|
|
}
|
|
|
|
public function testFetchRow() {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('sqlite::memory:');
|
2006-09-27 14:55:02 +04:00
|
|
|
|
|
|
|
$c = $dbh->fetchRow('SELECT * FROM entity');
|
|
|
|
|
|
|
|
$this->assertEqual($c, array (
|
|
|
|
'id' => '1',
|
|
|
|
'name' => 'zYne',
|
|
|
|
));
|
|
|
|
|
|
|
|
$c = $dbh->fetchRow('SELECT * FROM entity WHERE id = ?', array(1));
|
|
|
|
|
|
|
|
$this->assertEqual($c, array (
|
|
|
|
'id' => '1',
|
|
|
|
'name' => 'zYne',
|
|
|
|
));
|
|
|
|
}
|
|
|
|
public function testFetchPairs() {
|
|
|
|
|
|
|
|
}
|
2006-09-23 14:44:39 +04:00
|
|
|
public function testAddValidEventListener() {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('sqlite::memory:');
|
2006-09-23 14:44:39 +04:00
|
|
|
|
2006-11-06 20:56:14 +03:00
|
|
|
$this->assertTrue($dbh->getListener() instanceof Doctrine_Db_EventListener);
|
2006-09-23 14:44:39 +04:00
|
|
|
try {
|
2006-11-06 20:56:14 +03:00
|
|
|
$ret = $dbh->addListener(new Doctrine_Db_TestLogger());
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->pass();
|
2006-11-06 20:56:14 +03:00
|
|
|
$this->assertTrue($ret instanceof Doctrine_Db2);
|
|
|
|
} catch(Doctrine_Db_Exception $e) {
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->fail();
|
|
|
|
}
|
2006-11-06 20:56:14 +03:00
|
|
|
$this->assertTrue($dbh->getListener() instanceof Doctrine_Db_EventListener_Chain);
|
|
|
|
$this->assertTrue($dbh->getListener()->get(0) instanceof Doctrine_Db_TestLogger);
|
2006-09-23 14:44:39 +04:00
|
|
|
|
|
|
|
try {
|
2006-11-06 20:56:14 +03:00
|
|
|
$ret = $dbh->addListener(new Doctrine_Db_TestValidListener());
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->pass();
|
2006-11-06 20:56:14 +03:00
|
|
|
$this->assertTrue($ret instanceof Doctrine_Db2);
|
|
|
|
} catch(Doctrine_Db_Exception $e) {
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->fail();
|
|
|
|
}
|
2006-11-06 20:56:14 +03:00
|
|
|
$this->assertTrue($dbh->getListener() instanceof Doctrine_Db_EventListener_Chain);
|
|
|
|
$this->assertTrue($dbh->getListener()->get(0) instanceof Doctrine_Db_TestLogger);
|
|
|
|
$this->assertTrue($dbh->getListener()->get(1) instanceof Doctrine_Db_TestValidListener);
|
2006-09-23 14:44:39 +04:00
|
|
|
|
|
|
|
try {
|
2006-11-06 20:56:14 +03:00
|
|
|
$ret = $dbh->addListener(new Doctrine_Db_EventListener_Chain(), 'chain');
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->pass();
|
2006-11-06 20:56:14 +03:00
|
|
|
$this->assertTrue($ret instanceof Doctrine_Db2);
|
|
|
|
} catch(Doctrine_Db_Exception $e) {
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->fail();
|
|
|
|
}
|
2006-11-06 20:56:14 +03:00
|
|
|
$this->assertTrue($dbh->getListener() instanceof Doctrine_Db_EventListener_Chain);
|
|
|
|
$this->assertTrue($dbh->getListener()->get(0) instanceof Doctrine_Db_TestLogger);
|
|
|
|
$this->assertTrue($dbh->getListener()->get(1) instanceof Doctrine_Db_TestValidListener);
|
|
|
|
$this->assertTrue($dbh->getListener()->get('chain') instanceof Doctrine_Db_EventListener_Chain);
|
2006-09-23 14:44:39 +04:00
|
|
|
|
|
|
|
// replacing
|
|
|
|
|
|
|
|
try {
|
2006-11-06 20:56:14 +03:00
|
|
|
$ret = $dbh->addListener(new Doctrine_Db_EventListener_Chain(), 'chain');
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->pass();
|
2006-11-06 20:56:14 +03:00
|
|
|
$this->assertTrue($ret instanceof Doctrine_Db2);
|
|
|
|
} catch(Doctrine_Db_Exception $e) {
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->fail();
|
|
|
|
}
|
2006-11-06 20:56:14 +03:00
|
|
|
$this->assertTrue($dbh->getListener() instanceof Doctrine_Db_EventListener_Chain);
|
|
|
|
$this->assertTrue($dbh->getListener()->get(0) instanceof Doctrine_Db_TestLogger);
|
|
|
|
$this->assertTrue($dbh->getListener()->get(1) instanceof Doctrine_Db_TestValidListener);
|
|
|
|
$this->assertTrue($dbh->getListener()->get('chain') instanceof Doctrine_Db_EventListener_Chain);
|
2006-09-23 14:44:39 +04:00
|
|
|
}
|
|
|
|
public function testListeningEventsWithSingleListener() {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('sqlite::memory:');
|
2006-09-23 14:44:39 +04:00
|
|
|
$dbh->connect();
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh->setListener(new Doctrine_Db_TestLogger());
|
2006-09-23 14:44:39 +04:00
|
|
|
$listener = $dbh->getListener();
|
|
|
|
$stmt = $dbh->prepare('INSERT INTO entity (id) VALUES(?)');
|
|
|
|
|
|
|
|
$this->assertEqual($listener->pop(), 'onPrepare');
|
|
|
|
$this->assertEqual($listener->pop(), 'onPrePrepare');
|
|
|
|
|
|
|
|
$stmt->execute(array(1));
|
|
|
|
|
|
|
|
$this->assertEqual($listener->pop(), 'onExecute');
|
|
|
|
$this->assertEqual($listener->pop(), 'onPreExecute');
|
|
|
|
|
|
|
|
$dbh->exec('DELETE FROM entity');
|
|
|
|
|
|
|
|
$this->assertEqual($listener->pop(), 'onExec');
|
|
|
|
$this->assertEqual($listener->pop(), 'onPreExec');
|
|
|
|
|
|
|
|
$dbh->beginTransaction();
|
|
|
|
|
|
|
|
$this->assertEqual($listener->pop(), 'onBeginTransaction');
|
|
|
|
$this->assertEqual($listener->pop(), 'onPreBeginTransaction');
|
|
|
|
|
|
|
|
$dbh->query('INSERT INTO entity (id) VALUES (1)');
|
|
|
|
|
|
|
|
$dbh->commit();
|
|
|
|
|
|
|
|
$this->assertEqual($listener->pop(), 'onCommit');
|
|
|
|
$this->assertEqual($listener->pop(), 'onPreCommit');
|
|
|
|
|
|
|
|
$this->assertEqual($listener->pop(), 'onQuery');
|
|
|
|
$this->assertEqual($listener->pop(), 'onPreQuery');
|
|
|
|
|
|
|
|
$dbh->query('DROP TABLE entity');
|
|
|
|
}
|
|
|
|
public function testListeningEventsWithListenerChain() {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('sqlite::memory:');
|
2006-09-23 14:44:39 +04:00
|
|
|
$dbh->connect();
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh->addListener(new Doctrine_Db_TestLogger());
|
|
|
|
$dbh->addListener(new Doctrine_Db_TestLogger());
|
2006-09-23 14:44:39 +04:00
|
|
|
|
|
|
|
$dbh->query('CREATE TABLE entity (id INT)');
|
|
|
|
|
|
|
|
$listener = $dbh->getListener()->get(0);
|
|
|
|
$listener2 = $dbh->getListener()->get(1);
|
|
|
|
$this->assertEqual($listener->pop(), 'onQuery');
|
|
|
|
$this->assertEqual($listener->pop(), 'onPreQuery');
|
|
|
|
|
|
|
|
$this->assertEqual($listener2->pop(), 'onQuery');
|
|
|
|
$this->assertEqual($listener2->pop(), 'onPreQuery');
|
|
|
|
|
|
|
|
|
|
|
|
$stmt = $dbh->prepare('INSERT INTO entity (id) VALUES(?)');
|
|
|
|
|
|
|
|
$this->assertEqual($listener->pop(), 'onPrepare');
|
|
|
|
$this->assertEqual($listener->pop(), 'onPrePrepare');
|
|
|
|
|
|
|
|
$this->assertEqual($listener2->pop(), 'onPrepare');
|
|
|
|
$this->assertEqual($listener2->pop(), 'onPrePrepare');
|
|
|
|
|
|
|
|
$stmt->execute(array(1));
|
|
|
|
|
|
|
|
$this->assertEqual($listener->pop(), 'onExecute');
|
|
|
|
$this->assertEqual($listener->pop(), 'onPreExecute');
|
|
|
|
|
|
|
|
$this->assertEqual($listener2->pop(), 'onExecute');
|
|
|
|
$this->assertEqual($listener2->pop(), 'onPreExecute');
|
|
|
|
|
|
|
|
$dbh->exec('DELETE FROM entity');
|
|
|
|
|
|
|
|
$this->assertEqual($listener->pop(), 'onExec');
|
|
|
|
$this->assertEqual($listener->pop(), 'onPreExec');
|
|
|
|
|
|
|
|
$this->assertEqual($listener2->pop(), 'onExec');
|
|
|
|
$this->assertEqual($listener2->pop(), 'onPreExec');
|
|
|
|
|
|
|
|
$dbh->beginTransaction();
|
|
|
|
|
|
|
|
$this->assertEqual($listener->pop(), 'onBeginTransaction');
|
|
|
|
$this->assertEqual($listener->pop(), 'onPreBeginTransaction');
|
|
|
|
|
|
|
|
$this->assertEqual($listener2->pop(), 'onBeginTransaction');
|
|
|
|
$this->assertEqual($listener2->pop(), 'onPreBeginTransaction');
|
|
|
|
|
|
|
|
$dbh->query('INSERT INTO entity (id) VALUES (1)');
|
|
|
|
|
|
|
|
$dbh->commit();
|
|
|
|
|
|
|
|
$this->assertEqual($listener->pop(), 'onCommit');
|
|
|
|
$this->assertEqual($listener->pop(), 'onPreCommit');
|
|
|
|
|
|
|
|
$this->assertEqual($listener->pop(), 'onQuery');
|
|
|
|
$this->assertEqual($listener->pop(), 'onPreQuery');
|
|
|
|
|
|
|
|
$dbh->query('DROP TABLE entity');
|
|
|
|
}
|
|
|
|
public function testSetValidEventListener() {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('sqlite::memory:');
|
2006-09-23 14:44:39 +04:00
|
|
|
try {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh->setListener(new Doctrine_Db_TestLogger());
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->pass();
|
2006-11-06 20:56:14 +03:00
|
|
|
} catch(Doctrine_Db_Exception $e) {
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->fail();
|
|
|
|
}
|
2006-11-06 20:56:14 +03:00
|
|
|
$this->assertTrue($dbh->getListener() instanceof Doctrine_Db_TestLogger);
|
2006-09-23 14:44:39 +04:00
|
|
|
try {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh->setListener(new Doctrine_Db_TestValidListener());
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->pass();
|
2006-11-06 20:56:14 +03:00
|
|
|
} catch(Doctrine_Db_Exception $e) {
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->fail();
|
|
|
|
}
|
2006-11-06 20:56:14 +03:00
|
|
|
$this->assertTrue($dbh->getListener() instanceof Doctrine_Db_TestValidListener);
|
2006-09-23 14:44:39 +04:00
|
|
|
try {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh->setListener(new Doctrine_Db_EventListener_Chain());
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->pass();
|
|
|
|
|
2006-11-06 20:56:14 +03:00
|
|
|
} catch(Doctrine_Db_Exception $e) {
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->fail();
|
|
|
|
}
|
2006-11-06 20:56:14 +03:00
|
|
|
$this->assertTrue($dbh->getListener() instanceof Doctrine_Db_EventListener_Chain);
|
2006-09-23 14:44:39 +04:00
|
|
|
try {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh->setListener(new Doctrine_Db_EventListener());
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->pass();
|
2006-11-06 20:56:14 +03:00
|
|
|
} catch(Doctrine_Db_Exception $e) {
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->fail();
|
|
|
|
}
|
2006-11-06 20:56:14 +03:00
|
|
|
$this->assertTrue($dbh->getListener() instanceof Doctrine_Db_EventListener);
|
2006-09-23 14:44:39 +04:00
|
|
|
}
|
|
|
|
public function testSetInvalidEventListener() {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('sqlite::memory:');
|
2006-09-23 14:44:39 +04:00
|
|
|
try {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh->setListener(new Doctrine_Db_TestInvalidListener());
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->fail();
|
2006-11-06 20:56:14 +03:00
|
|
|
} catch(Doctrine_Db_Exception $e) {
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->pass();
|
|
|
|
}
|
|
|
|
}
|
2006-09-23 01:20:21 +04:00
|
|
|
public function testInvalidDSN() {
|
|
|
|
try {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('');
|
2006-09-23 01:20:21 +04:00
|
|
|
$this->fail();
|
2006-11-06 20:56:14 +03:00
|
|
|
} catch(Doctrine_Db_Exception $e) {
|
2006-09-23 01:20:21 +04:00
|
|
|
$this->pass();
|
|
|
|
}
|
|
|
|
try {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('unknown');
|
2006-09-23 01:20:21 +04:00
|
|
|
$this->fail();
|
2006-11-06 20:56:14 +03:00
|
|
|
} catch(Doctrine_Db_Exception $e) {
|
2006-09-23 01:20:21 +04:00
|
|
|
$this->pass();
|
|
|
|
}
|
|
|
|
try {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection(0);
|
2006-09-23 01:20:21 +04:00
|
|
|
$this->fail();
|
2006-11-06 20:56:14 +03:00
|
|
|
} catch(Doctrine_Db_Exception $e) {
|
2006-09-23 01:20:21 +04:00
|
|
|
$this->pass();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public function testInvalidScheme() {
|
|
|
|
try {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('unknown://:memory:');
|
2006-09-23 01:20:21 +04:00
|
|
|
$this->fail();
|
2006-11-06 20:56:14 +03:00
|
|
|
} catch(Doctrine_Db_Exception $e) {
|
2006-09-23 01:20:21 +04:00
|
|
|
$this->pass();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public function testInvalidHost() {
|
|
|
|
try {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('mysql://user:password@');
|
2006-09-23 01:20:21 +04:00
|
|
|
$this->fail();
|
2006-11-06 20:56:14 +03:00
|
|
|
} catch(Doctrine_Db_Exception $e) {
|
2006-09-23 01:20:21 +04:00
|
|
|
$this->pass();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public function testInvalidDatabase() {
|
|
|
|
try {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('mysql://user:password@host/');
|
2006-09-23 01:20:21 +04:00
|
|
|
$this->fail();
|
2006-11-06 20:56:14 +03:00
|
|
|
} catch(Doctrine_Db_Exception $e) {
|
2006-09-23 01:20:21 +04:00
|
|
|
$this->pass();
|
|
|
|
}
|
|
|
|
}
|
2006-09-23 02:29:06 +04:00
|
|
|
public function testGetConnectionPdoLikeDSN() {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('mysql:host=localhost;dbname=test', 'root', 'password');
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->assertEqual($dbh->getDSN(), 'mysql:host=localhost;dbname=test');
|
|
|
|
$this->assertEqual($dbh->getUsername(), 'root');
|
|
|
|
$this->assertEqual($dbh->getPassword(), 'password');
|
2006-09-23 02:29:06 +04:00
|
|
|
|
2006-09-23 01:20:21 +04:00
|
|
|
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('sqlite::memory:');
|
2006-09-23 02:29:06 +04:00
|
|
|
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->assertEqual($dbh->getDSN(), 'sqlite::memory:');
|
|
|
|
$this->assertEqual($dbh->getUsername(), null);
|
|
|
|
$this->assertEqual($dbh->getPassword(), null);
|
2006-09-23 02:29:06 +04:00
|
|
|
}
|
2006-09-23 14:44:39 +04:00
|
|
|
public function testDriverName() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-09-23 02:29:06 +04:00
|
|
|
public function testGetConnectionWithPearLikeDSN() {
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('mysql://zYne:password@localhost/test');
|
2006-09-23 14:44:39 +04:00
|
|
|
$this->assertEqual($dbh->getDSN(), 'mysql:host=localhost;dbname=test');
|
|
|
|
$this->assertEqual($dbh->getUsername(), 'zYne');
|
|
|
|
$this->assertEqual($dbh->getPassword(), 'password');
|
2006-09-23 01:20:21 +04:00
|
|
|
|
2006-09-23 14:44:39 +04:00
|
|
|
|
2006-11-06 20:56:14 +03:00
|
|
|
$dbh = Doctrine_Db2::getConnection('sqlite://:memory:');
|
2006-09-23 14:44:39 +04:00
|
|
|
|
|
|
|
$this->assertEqual($dbh->getDSN(), 'sqlite::memory:');
|
|
|
|
$this->assertEqual($dbh->getUsername(), null);
|
|
|
|
$this->assertEqual($dbh->getPassword(), null);
|
2006-09-23 01:20:21 +04:00
|
|
|
}
|
2006-09-23 02:29:06 +04:00
|
|
|
|
2006-09-23 01:20:21 +04:00
|
|
|
}
|