From b23a97df0eba4ee0c4c0d2e860f422e2e1b37ef2 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Sun, 2 Sep 2012 15:46:15 +0800 Subject: [PATCH] more tests --- tests/048.phpt | 8 +--- tests/049.phpt | 104 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/050.phpt | 47 ++++++++++++++++++++++ 3 files changed, 152 insertions(+), 7 deletions(-) create mode 100644 tests/049.phpt create mode 100644 tests/050.phpt diff --git a/tests/048.phpt b/tests/048.phpt index 4f08b08d..a24cdc90 100644 --- a/tests/048.phpt +++ b/tests/048.phpt @@ -94,13 +94,7 @@ file_put_contents(APPLICATION_PATH . "/application/views/index/index.phtml", ""); $app = new Yaf_Application($config); -$response = $app->bootstrap()->run(); -unlink(APPLICATION_PATH . "/application/views/index/index.phtml"); -unlink(APPLICATION_PATH . "/application/controllers/Index.php"); -unlink(APPLICATION_PATH . "/application/controllers/Error.php"); -unlink(APPLICATION_PATH . "/application/plugins/Test.php"); -unlink(APPLICATION_PATH . "/application/Bootstrap.php"); - +$app->bootstrap()->run(); --EXPECTF-- string(13) "routerStartup" string(14) "routerShutdown" diff --git a/tests/049.phpt b/tests/049.phpt new file mode 100644 index 00000000..43302f64 --- /dev/null +++ b/tests/049.phpt @@ -0,0 +1,104 @@ +--TEST-- +Check for Sample application with exception +--SKIPIF-- + +--INI-- +yaf.use_spl_autoload=0 +yaf.lowcase_path=0 +report_memleaks=0 +--FILE-- + array( + "directory" => APPLICATION_PATH . "/application/", + "dispatcher" => array ( + "catchException" => true, + ), + "library" => array( + ), + ), +); + +file_put_contents(APPLICATION_PATH . "/application/controllers/Error.php", <<_view->msg = \$exception->getMessage(); + } + } +PHP +); + +file_put_contents(APPLICATION_PATH . "/application/Bootstrap.php", <<getConfig()); + } + public function _initPlugin(Yaf_Dispatcher \$dispatcher) { + \$dispatcher->registerPlugin(new TestPlugin()); + } + public function _initReturn(Yaf_Dispatcher \$dispatcher) { + \$dispatcher->returnResponse(true); + } + } +PHP +); + +file_put_contents(APPLICATION_PATH . "/application/plugins/Test.php", <<"); +mkdir(APPLICATION_PATH . "/application/views/error/"); +file_put_contents(APPLICATION_PATH . "/application/views/error/error.phtml", + "catched: "); + +$app = new Yaf_Application($config); +$app->bootstrap()->run(); +--EXPECTF-- +string(13) "routerStartup" +string(14) "routerShutdown" +string(19) "dispatchLoopStartup" +string(11) "preDispatch" +string(4) "init" +string(6) "action" +catched: view exception diff --git a/tests/050.phpt b/tests/050.phpt new file mode 100644 index 00000000..a1fc7e0b --- /dev/null +++ b/tests/050.phpt @@ -0,0 +1,47 @@ +--TEST-- +Check for Sample application with return response +--SKIPIF-- + +--INI-- +yaf.use_spl_autoload=0 +yaf.lowcase_path=0 +report_memleaks=0 +--FILE-- + array( + "directory" => APPLICATION_PATH . "/application/", + ), +); + +file_put_contents(APPLICATION_PATH . "/application/Bootstrap.php", <<returnResponse(true); + } + } +PHP +); + +file_put_contents(APPLICATION_PATH . "/application/controllers/Index.php", <<bootstrap()->run(); +var_dump("-------"); +echo $response; +--EXPECTF-- +string(7) "-------" +view