fail(); } catch(Doctrine_DB_Exception $e) { $this->pass(); } try { $conn = Doctrine_DB2::getConnection('unknown'); $this->fail(); } catch(Doctrine_DB_Exception $e) { $this->pass(); } try { $conn = Doctrine_DB2::getConnection(0); $this->fail(); } catch(Doctrine_DB_Exception $e) { $this->pass(); } } public function testInvalidScheme() { try { $conn = Doctrine_DB2::getConnection('unknown://:memory:'); $this->fail(); } catch(Doctrine_DB_Exception $e) { $this->pass(); } } public function testInvalidHost() { try { $conn = Doctrine_DB2::getConnection('mysql://user:password@'); $this->fail(); } catch(Doctrine_DB_Exception $e) { $this->pass(); } } public function testInvalidDatabase() { try { $conn = Doctrine_DB2::getConnection('mysql://user:password@host/'); $this->fail(); } catch(Doctrine_DB_Exception $e) { $this->pass(); } } public function testGetConnectionPdoLikeDSN() { $conn = Doctrine_DB2::getConnection('mysql:host=localhost;dbname=test', 'root', 'password'); $this->assertEqual($conn->getDSN(), 'mysql:host=localhost;dbname=test'); $this->assertEqual($conn->getUsername(), 'root'); $this->assertEqual($conn->getPassword(), 'password'); $conn = Doctrine_DB2::getConnection('sqlite::memory:'); $this->assertEqual($conn->getDSN(), 'sqlite::memory:'); $this->assertEqual($conn->getUsername(), null); $this->assertEqual($conn->getPassword(), null); } public function testGetConnectionWithPearLikeDSN() { $conn = Doctrine_DB2::getConnection('mysql://zYne:password@localhost/test'); $this->assertEqual($conn->getDSN(), 'mysql:host=localhost;dbname=test'); $this->assertEqual($conn->getUsername(), 'zYne'); $this->assertEqual($conn->getPassword(), 'password'); $conn = Doctrine_DB2::getConnection('sqlite://:memory:'); $this->assertEqual($conn->getDSN(), 'sqlite::memory:'); $this->assertEqual($conn->getUsername(), null); $this->assertEqual($conn->getPassword(), null); } } ?>