예제 #1
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 public function testSetUp()
 {
     $testSql = dirname(dirname(dirname(dirname(__FILE__)))) . '/testfiles/test.sql';
     $testConfig = dirname(dirname(dirname(dirname(__FILE__)))) . '/testfiles/test_config.json';
     //create test database
     $mysqli = new mysqli("localhost", "root", "root");
     $mysqli->query("CREATE DATABASE airymvc_unit_test");
     $mysqli->select_db("airymvc_unit_test");
     $query = file_get_contents($testSql);
     $mysqli->multi_query($query);
     $mysqli->close();
     $configArr = json_decode(file_get_contents($testConfig), TRUE);
     $dbConfigArr = $configArr["%application_configs"][0]["%db"][0];
     $this->object = new MysqlComponent();
     $this->object->setDbConfig($dbConfigArr);
     $this->object->setConnection();
 }