/** * @param $error_number * @param $message * @param string $file * @param int $line * @param array $context * * @return bool */ public function handle_error($error_number, $message, $file = '', $line = 0, $context = []) { $readable_error = readable_error_type($error_number); switch ($error_number) { case E_NOTICE: case E_USER_NOTICE: dump(compact('error_number', 'readable_error', 'message', 'file', 'line', 'context')); return FALSE; break; case E_USER_ERROR: dump(compact('error_number', 'readable_error', 'message', 'file', 'line', 'context')); break; case E_WARNING: case E_USER_WARNING: dump(compact('error_number', 'readable_error', 'message', 'file', 'line', 'context')); return FALSE; break; default: dump(compact('error_number', 'readable_error', 'message', 'file', 'line', 'context')); break; } return TRUE; }
public function test01() { ### elapsed_time_since_request() $now = elapsed_time_since_request(TRUE); $this->assertGreaterThan($now, elapsed_time_since_request(TRUE)); $this->assertStringEndsWith('ms', elapsed_time_since_request()); $this->assertStringEndsNotWith('ms', (string) elapsed_time_since_request(TRUE)); ### location_from_backtrace($index = 2) # The current location should be the call to ReflectionMethod. # Be aware that this may change if PHPUnit alters its execution pipeline. $this->assertStringEndsWith('ReflectionMethod::invokeArgs', location_from_backtrace()); ### expose($value = NULL, $depth = 8) # these functions would otherwise halt the tests, so output is restricted # by use of the PHPUNIT_TESTS constant. The best we can do (until I find # another solution) is to call them for code coverage. //expose("expose test"); //die_dump('die_dump test'); ### readable_error_type($error_type) #@formatter:off $this->assertEquals('E_COMPILE_ERROR', readable_error_type(E_COMPILE_ERROR)); $this->assertEquals('E_COMPILE_WARNING', readable_error_type(E_COMPILE_WARNING)); $this->assertEquals('E_CORE_ERROR', readable_error_type(E_CORE_ERROR)); $this->assertEquals('E_CORE_WARNING', readable_error_type(E_CORE_WARNING)); $this->assertEquals('E_DEPRECATED', readable_error_type(E_DEPRECATED)); $this->assertEquals('E_ERROR', readable_error_type(E_ERROR)); $this->assertEquals('E_NOTICE', readable_error_type(E_NOTICE)); $this->assertEquals('E_PARSE', readable_error_type(E_PARSE)); $this->assertEquals('E_RECOVERABLE_ERROR', readable_error_type(E_RECOVERABLE_ERROR)); $this->assertEquals('E_STRICT', readable_error_type(E_STRICT)); $this->assertEquals('E_USER_DEPRECATED', readable_error_type(E_USER_DEPRECATED)); $this->assertEquals('E_USER_ERROR', readable_error_type(E_USER_ERROR)); $this->assertEquals('E_USER_NOTICE', readable_error_type(E_USER_NOTICE)); $this->assertEquals('E_USER_WARNING', readable_error_type(E_USER_WARNING)); $this->assertEquals('E_WARNING', readable_error_type(E_WARNING)); $this->assertEquals('UNKNOWN_ERROR', readable_error_type('NON_EXISTENT_ERROR')); }