forked from laruence/yaf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
152 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
--TEST-- | ||
Check for Sample application with exception | ||
--SKIPIF-- | ||
<?php if (!extension_loaded("yaf")) print "skip"; ?> | ||
--INI-- | ||
yaf.use_spl_autoload=0 | ||
yaf.lowcase_path=0 | ||
report_memleaks=0 | ||
--FILE-- | ||
<?php | ||
require "build.inc"; | ||
define("APPLICATION_PATH", dirname(__FILE__)); | ||
startup(APPLICATION_PATH . '/application'); | ||
$config = array( | ||
"application" => array( | ||
"directory" => APPLICATION_PATH . "/application/", | ||
"dispatcher" => array ( | ||
"catchException" => true, | ||
), | ||
"library" => array( | ||
), | ||
), | ||
); | ||
|
||
file_put_contents(APPLICATION_PATH . "/application/controllers/Error.php", <<<PHP | ||
<?php | ||
class ErrorController extends Yaf_Controller_Abstract { | ||
public function errorAction(\$exception) { | ||
\$this->_view->msg = \$exception->getMessage(); | ||
} | ||
} | ||
PHP | ||
); | ||
|
||
file_put_contents(APPLICATION_PATH . "/application/Bootstrap.php", <<<PHP | ||
<?php | ||
class Bootstrap extends Yaf_Bootstrap_Abstract { | ||
public function _initConfig(Yaf_Dispatcher \$dispatcher) { | ||
Yaf_Registry::set("config", Yaf_Application::app()->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", <<<PHP | ||
<?php | ||
class TestPlugin extends Yaf_Plugin_Abstract { | ||
public function routerStartup(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) { | ||
var_dump("routerStartup"); | ||
} | ||
public function routerShutdown(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) { | ||
var_dump("routerShutdown"); | ||
} | ||
public function dispatchLoopStartup(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) { | ||
var_dump("dispatchLoopStartup"); | ||
} | ||
public function preDispatch(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) { | ||
var_dump("preDispatch"); | ||
} | ||
public function postDispatch(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) { | ||
var_dump("postDispatch"); | ||
} | ||
public function dispatchLoopShutdown(Yaf_Request_Abstract \$request, Yaf_Response_Abstract \$response) { | ||
var_dump("dispatchLoopShutdown"); | ||
} | ||
} | ||
PHP | ||
); | ||
|
||
file_put_contents(APPLICATION_PATH . "/application/controllers/Index.php", <<<PHP | ||
<?php | ||
class IndexController extends Yaf_Controller_Abstract { | ||
public function init() { | ||
var_dump("init"); | ||
} | ||
public function indexAction() { | ||
var_dump("action"); | ||
} | ||
} | ||
PHP | ||
); | ||
|
||
file_put_contents(APPLICATION_PATH . "/application/views/index/index.phtml", | ||
"<?php throw new Exception('view exception'); ?>"); | ||
mkdir(APPLICATION_PATH . "/application/views/error/"); | ||
file_put_contents(APPLICATION_PATH . "/application/views/error/error.phtml", | ||
"catched: <?=\$msg?>"); | ||
|
||
$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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--TEST-- | ||
Check for Sample application with return response | ||
--SKIPIF-- | ||
<?php if (!extension_loaded("yaf")) print "skip"; ?> | ||
--INI-- | ||
yaf.use_spl_autoload=0 | ||
yaf.lowcase_path=0 | ||
report_memleaks=0 | ||
--FILE-- | ||
<?php | ||
require "build.inc"; | ||
define("APPLICATION_PATH", dirname(__FILE__)); | ||
startup(APPLICATION_PATH . '/application'); | ||
$config = array( | ||
"application" => array( | ||
"directory" => APPLICATION_PATH . "/application/", | ||
), | ||
); | ||
|
||
file_put_contents(APPLICATION_PATH . "/application/Bootstrap.php", <<<PHP | ||
<?php | ||
class Bootstrap extends Yaf_Bootstrap_Abstract { | ||
public function _initReturn(Yaf_Dispatcher \$dispatcher) { | ||
\$dispatcher->returnResponse(true); | ||
} | ||
} | ||
PHP | ||
); | ||
|
||
file_put_contents(APPLICATION_PATH . "/application/controllers/Index.php", <<<PHP | ||
<?php | ||
class IndexController extends Yaf_Controller_Abstract { | ||
public function indexAction() { | ||
} | ||
} | ||
PHP | ||
); | ||
|
||
file_put_contents(APPLICATION_PATH . "/application/views/index/index.phtml", "view"); | ||
|
||
$app = new Yaf_Application($config); | ||
$response = $app->bootstrap()->run(); | ||
var_dump("-------"); | ||
echo $response; | ||
--EXPECTF-- | ||
string(7) "-------" | ||
view |