forked from laruence/yaf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
049.phpt
112 lines (103 loc) · 3.19 KB
/
049.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
--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
--FILE--
<?php
require "build.inc";
startup();
$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
"dispatcher" => array (
"catchException" => true,
),
"library" => array(
),
),
);
file_put_contents(APPLICATION_PATH . "/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 . "/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 . "/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 . "/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 . "/views/index/index.phtml",
"<?php throw new Exception('view exception'); ?>");
mkdir(APPLICATION_PATH . "/views/error/");
file_put_contents(APPLICATION_PATH . "/views/error/error.phtml",
"catched: <?=\$msg?>");
$app = new Yaf_Application($config);
$app->bootstrap()->run();
?>
--CLEAN--
<?php
/* unlink foo2.phtml permission denied */
require "build.inc";
shutdown();
?>
--EXPECTF--
string(13) "routerStartup"
string(14) "routerShutdown"
string(19) "dispatchLoopStartup"
string(11) "preDispatch"
string(4) "init"
string(6) "action"
catched: view exception