/** * Test custom global error handler */ public function testHandleErrors() { $defaultErrorReporting = error_reporting(); // Test 1 error_reporting(E_ALL ^ E_NOTICE); // <-- Report all errors EXCEPT notices try { \Slim\Slim::handleErrors(E_NOTICE, 'test error', 'Slim.php', 119); } catch (\ErrorException $e) { $this->fail('Slim::handleErrors reported a disabled error level.'); } // Test 2 error_reporting(E_ALL | E_STRICT); // <-- Report all errors, including E_STRICT try { \Slim\Slim::handleErrors(E_STRICT, 'test error', 'Slim.php', 119); $this->fail('Slim::handleErrors didn\'t report a enabled error level'); } catch (\ErrorException $e) { } error_reporting($defaultErrorReporting); }
/** * Test custom global error handler */ public function testHandleErrors() { $defaultErrorReporting = error_reporting(); // Assert Slim ignores E_NOTICE errors error_reporting(E_ALL ^ E_NOTICE); // <-- Report all errors EXCEPT notices try { $this->assertTrue(\Slim\Slim::handleErrors(E_NOTICE, 'test error', 'Slim.php', 119)); } catch (\ErrorException $e) { $this->fail('Slim::handleErrors reported a disabled error level.'); } // Assert Slim reports E_STRICT errors error_reporting(E_ALL | E_STRICT); // <-- Report all errors, including E_STRICT try { \Slim\Slim::handleErrors(E_STRICT, 'test error', 'Slim.php', 119); $this->fail('Slim::handleErrors didn\'t report a enabled error level'); } catch (\ErrorException $e) { $this->assertEquals('test error', $e->getMessage()); } error_reporting($defaultErrorReporting); }