@@ -207,6 +207,34 @@ class BlueberryController extends AppController {
207
207
var $ components = array ('Auth ' );
208
208
}
209
209
210
+ /**
211
+ * MyCustomErrorHandler class
212
+ *
213
+ * @package cake
214
+ * @subpackage cake.tests.cases.libs
215
+ */
216
+ class MyCustomErrorHandler extends ErrorHandler {
217
+
218
+ /**
219
+ * custom error message type.
220
+ *
221
+ * @return void
222
+ **/
223
+ function missingWidgetThing () {
224
+ echo 'widget thing is missing ' ;
225
+ }
226
+
227
+ /**
228
+ * stop method
229
+ *
230
+ * @access public
231
+ * @return void
232
+ */
233
+ function _stop () {
234
+ return ;
235
+ }
236
+ }
237
+
210
238
/**
211
239
* TestErrorHandler class
212
240
*
@@ -244,6 +272,35 @@ function skip() {
244
272
$ this ->skipIf (PHP_SAPI === 'cli ' , '%s Cannot be run from console ' );
245
273
}
246
274
275
+ /**
276
+ * test that methods declared in an ErrorHandler subclass are not converted
277
+ * into error404 when debug == 0
278
+ *
279
+ * @return void
280
+ **/
281
+ function testSubclassMethodsNotBeingConvertedToError () {
282
+ $ back = Configure::read ('debug ' );
283
+ Configure::write ('debug ' , 2 );
284
+ ob_start ();
285
+ $ ErrorHandler = new MyCustomErrorHandler ('missingWidgetThing ' , array ('message ' => 'doh! ' ));
286
+ $ result = ob_get_clean ();
287
+ $ this ->assertEqual ($ result , 'widget thing is missing ' );
288
+
289
+ Configure::write ('debug ' , 0 );
290
+ ob_start ();
291
+ $ ErrorHandler = new MyCustomErrorHandler ('missingWidgetThing ' , array ('message ' => 'doh! ' ));
292
+ $ result = ob_get_clean ();
293
+ $ this ->assertEqual ($ result , 'widget thing is missing ' , 'Method declared in subclass converted to error404. %s ' );
294
+
295
+ Configure::write ('debug ' , 0 );
296
+ ob_start ();
297
+ $ ErrorHandler = new MyCustomErrorHandler ('missingController ' , array ('message ' => 'Page not found ' ));
298
+ $ result = ob_get_clean ();
299
+ $ this ->assertPattern ('/Not Found/ ' , $ result , 'Method declared in error handler not converted to error404. %s ' );
300
+
301
+ Configure::write ('debug ' , $ back );
302
+ }
303
+
247
304
/**
248
305
* testError method
249
306
*
0 commit comments