public function testLoadConfig() { //加载后缀 .ini 类型 $config = AppHelper::loadConfig(__DIR__ . "/temp/config.ini"); $this->assertEquals(1, $config["file_uploads"], "load the config with suffix :.ini"); //加载后缀 .xml 类型 $config = AppHelper::loadConfig(__DIR__ . "/temp/config.xml"); // print_r($config); $this->assertEquals("test", $config["directory"], "load the config with suffix :.ini"); //加载后缀 .json 类型 $config = AppHelper::loadConfig(__DIR__ . "/temp/config.json"); // print_r($config); $this->assertEquals("test", $config["name"], "load the config with suffix :.json"); //用外部解析办法解析配置文件 function parse($name) { return array("name" => $name); } $config = AppHelper::loadConfig(__DIR__ . "/temp/config.exit", "parse"); $this->assertEquals($this->pathHandler(__DIR__ . "/temp/config.exit"), $config["name"], "load the config with own parse's method "); //加载不存在解析办法的 try { $config = AppHelper::loadConfig(__DIR__ . "/temp/config.exit"); $this->assertTrue(false, "load the file without parse's method"); } catch (Exception $e) { $this->assertTrue(true, $e->getMessage()); } }