make('e_db_mysql'); } protected function _before() { require_once(e_HANDLER."mysql_class.php"); try { $this->db = $this->makeDb(); } catch (Exception $e) { $this->fail("Couldn't load e_db_mysql object"); } // Simulate PHP 5.6 defined('MYSQL_ASSOC') or define('MYSQL_ASSOC', 1); defined('MYSQL_NUM') or define('MYSQL_NUM', 2); defined('MYSQL_BOTH') or define('MYSQL_BOTH', 3); $this->db->__construct(); $this->loadConfig(); $this->db->db_Connect( $this->dbConfig['mySQLserver'], $this->dbConfig['mySQLuser'], $this->dbConfig['mySQLpassword'], $this->dbConfig['mySQLdefaultdb'] ); } public function _after() { $db_impl = $this->getDbImplementation(); if (@empty($db_impl->server_info)) return; parent::_after(); } public function testGetPDO() { $result = $this->db->getPDO(); $this->assertFalse($result); } public function testGetServerInfo() { $result = $this->db->getServerInfo(); $this->assertRegExp('/[0-9]+\./', $result); } public function testGetLastErrorNumber() { $this->db->select('doesnt_exists'); $result = $this->db->getLastErrorNumber(); $this->assertEquals("1146", $result); } public function testEscape() { $result = $this->db->escape(123); $this->assertEquals(123,$result); $result = $this->db->escape("Can't", true); $this->assertEquals("Can\'t", $result); } public function testDb_Close() { $db_impl = $this->getDbImplementation(); if (!empty($db_impl->server_info)) { $this->db->db_Close(); self::assertTrue(empty($db_impl->server_info)); } else { self::assertTrue(true); // Connection is already closed, so the test passes } } private function getDbImplementation() { $reflection_object = new ReflectionObject($this->db); $db_property = $reflection_object->getProperty('mySQLaccess'); $db_property->setAccessible(true); return $db_property->getValue($this->db); } }