public function testInstantiateDaoWithoutConfigFile() { $this->removeConfigFile(); Config::destroyInstance(); $cfg_values = array("table_prefix"=>"tu_", "db_host"=>"localhost"); $config = Config::getInstance($cfg_values); $test_dao = new TestMySQLDAO($cfg_values); $users = $test_dao->getUserCount(0, 'mary'); $this->assertIsA($users, "array"); $this->assertEqual(count($users), 2); $this->assertEqual($users[0]['user_name'], 'mary'); $this->assertEqual($users[1]['user_name'], 'sweetmary'); $this->restoreConfigFile(); }
public function testInstantiateDaoWithoutConfigFile() { $config = Config::getInstance(); $config_array = $config->getValuesArray(); $this->builders = self::buildData(); try { $this->removeConfigFile(); Config::destroyInstance(); $cfg_values = array("table_prefix" => $config_array['table_prefix'], "db_host" => "localhost"); $config = Config::getInstance($cfg_values); $test_dao = new TestMySQLDAO($cfg_values); $users = $test_dao->getUserCount(0, 'mary'); $this->assertIsA($users, "array"); $this->assertEqual(count($users), 2); $this->assertEqual($users[0]['user_name'], 'mary'); $this->assertEqual($users[1]['user_name'], 'sweetmary'); } catch (Exception $e) { // restore config file if something goes wrong $this->restoreConfigFile(); throw $e; } $this->restoreConfigFile(); }