8
8
use PHPUnit \Framework \TestCase ;
9
9
use DI \Bridge \Slim \Test \Mock \RequestFactory ;
10
10
use Slim \Http \Response ;
11
- use Throwable ;
12
11
13
12
class ErrorTest extends TestCase
14
13
{
@@ -32,7 +31,7 @@ public function default_exception_handling()
32
31
33
32
/** @var Error $error */
34
33
$ error = $ c ->get ('errorHandler ' );
35
- $ response = $ error (RequestFactory::create ('/ ' ), new Response (), new TestException ());
34
+ $ response = $ error (RequestFactory::create ('/ ' ), new Response (), new \ Exception ());
36
35
$ reasonPhrase = $ response ->getReasonPhrase ();
37
36
$ this ->assertEquals ('Internal Server Error ' , $ reasonPhrase );
38
37
@@ -52,10 +51,10 @@ public function custom_exception_handling()
52
51
ini_set ('error_log ' , $ logFile );
53
52
54
53
$ app = new BridgeApp (
55
- [
56
- 'settings.displayErrorDetails ' => true ,
57
- 'settings.outputBuffering ' => 'append '
58
- ]);
54
+ [
55
+ 'settings.displayErrorDetails ' => true ,
56
+ 'settings.outputBuffering ' => 'append '
57
+ ]);
59
58
$ c = $ app ->getContainer ();
60
59
61
60
// Sanity checks
@@ -67,7 +66,7 @@ public function custom_exception_handling()
67
66
/** @var Error $error */
68
67
$ error = $ c ->get ('errorHandler ' );
69
68
70
- $ response = $ error (RequestFactory::create ('/ ' ), new Response (), new TestException ());
69
+ $ response = $ error (RequestFactory::create ('/ ' ), new Response (), new \ Exception ());
71
70
$ reasonPhrase = $ response ->getReasonPhrase ();
72
71
$ this ->assertEquals ('Internal Server Error ' , $ reasonPhrase );
73
72
@@ -76,27 +75,6 @@ public function custom_exception_handling()
76
75
}
77
76
}
78
77
79
- /**
80
- * Class TestException
81
- *
82
- * Test Exception that starts its own output buffer
83
- */
84
- class TestException extends \Exception
85
- {
86
- public function __construct ($ message = "" , $ code = 0 , Throwable $ previous = null )
87
- {
88
- parent ::__construct ($ message , $ code , $ previous );
89
-
90
- // the Slim Error handler calls `ob_get_clean()` regardless of any outputBuffering setting:
91
- // 'preappend' => $body->write(ob_get_clean() . $output);
92
- // 'append' => $body->write($output . ob_get_clean());
93
- // false || anything else => ob_get_clean(); $body->write($output);
94
- //
95
- // We start our own OB for testing to keep the OB stack clean
96
- ob_start ();
97
- }
98
- }
99
-
100
78
/**
101
79
* Class BridgeApp
102
80
*
0 commit comments