Exemplo n.º 1
0
 public function test_should_format_as_array_with_correct_layout()
 {
     $exception = new \Exception('Something broke!');
     $raw_backtrace = $exception->getTrace();
     $raw_backtrace[0]['file'] = path_to_fixture('MyClass.php');
     $raw_backtrace[0]['line'] = 1;
     $backtrace = Backtrace::parse($raw_backtrace);
     $data = array('backtrace' => $raw_backtrace, 'error_class' => 'Exception', 'error_message' => 'Exception [ 0 ]: Something broke!', 'url' => 'https://example.com/orders', 'component' => 'Orders', 'action' => 'create', 'params' => array('line_item_ids' => array(123, 456, 789)), 'session' => array('user_id' => 123), 'cgi_data' => array('HTTP_HOST' => 'example.com', 'REQUEST_METHOD' => 'POST'), 'context' => array('user' => array('name' => 'Joe Blow')), 'project_root' => '/var/www/application', 'environment_name' => 'production');
     $notice = $this->build_notice($data);
     $this->assertEquals(array('notifier' => array('name' => Honeybadger::NOTIFIER_NAME, 'url' => Honeybadger::NOTIFIER_URL, 'version' => Honeybadger::VERSION, 'language' => 'php'), 'error' => array('class' => $data['error_class'], 'message' => $data['error_message'], 'backtrace' => $backtrace->as_array(), 'source' => $backtrace->lines[0]->source), 'request' => array('url' => $data['url'], 'component' => $data['component'], 'action' => $data['action'], 'params' => $data['params'], 'session' => $data['session'], 'cgi_data' => $data['cgi_data'], 'context' => $data['context']), 'server' => array('project_root' => $data['project_root'], 'environment_name' => $data['environment_name'], 'hostname' => gethostname())), $notice->as_array());
 }
Exemplo n.º 2
0
 public function test_source_replaces_tabs_with_spaces()
 {
     $line = new Line(path_to_fixture('MyClass.php'), 9, 'does_amazing_things');
     $this->assertEquals(array('6' => '    {', '7' => '        for ($i = 0; $i < 25; $i++)', '8' => '        {', '9' => '            echo "Check out this amazing stuff!\\n";', '10' => '        }'), $line->source);
 }