Beispiel #1
0
 /**
  * 主要测试,测试正常情况
  */
 public function testMain()
 {
     ControlResolver::setAppPath(dirname(__FILE__) . '/');
     AppHelper::Instance()->config("CMD_FILTER", '');
     //恢复默认
     $_POST["cmd"] = "test.test";
     CommandHandler::run();
     $this->assertEquals("test.test", file_get_contents(dirname(__FILE__) . "/temp/testForCmd.text"));
     $_GET["cmd"] = "";
     CommandHandler::run();
     $this->assertEquals("default.default", file_get_contents(dirname(__FILE__) . "/temp/testForCmd.text"));
     //输出异常
     $_GET["cmd"] = "test.test";
     $_GET["exc"] = "echo_exc";
     CommandHandler::run();
     $this->assertEquals("echo_exc", file_get_contents(dirname(__FILE__) . "/temp/testForCmd.text"));
     //一般异常
     $_GET["cmd"] = "test.test";
     $_GET["exc"] = "exc";
     CommandHandler::run();
     $this->assertEquals("exc", file_get_contents(dirname(__FILE__) . "/temp/testForCmd.text"));
     $_GET["cmd"] = "noHave";
     CommandHandler::run();
     $_GET["cmd"] = "Nocmd";
     CommandHandler::run();
     $_GET["cmd"] = "NoClassExist";
     CommandHandler::run();
     //测试控制过滤
     AppHelper::Instance()->config("CMD_FILTER", '/Controller$/');
     $_GET["cmd"] = "DefaultController";
     CommandHandler::run();
     $this->assertEquals("default.default", file_get_contents(dirname(__FILE__) . "/temp/testForCmd.text"));
 }