示例#1
0
 /**
  * Creates a predefined environment using the default environment
  *
  * Extending classes that have their own setUp() should call
  * parent::setUp()
  */
 public function setUp()
 {
     $this->_helpers = new Helpers();
     if (!isset($this->_environment_default['\\Honeybadger\\Honeybadger::$config'])) {
         $api_key = Arr::get($_SERVER, 'HONEYBADGER_API_KEY');
         $config = new Config(Arr::merge(array('project_root' => realpath(__DIR__ . '/../..'), 'framework' => 'PHPUnit', 'environment_name' => 'testing', 'api_key' => empty($api_key) ? NULL : $api_key), $this->_default_config));
         $this->_environment_default['\\Honeybadger\\Honeybadger::$config'] = $config;
     }
     if (!isset($this->_environment_default['\\Honeybadger\\Honeybadger::$sender'])) {
         $this->_environment_default['\\Honeybadger\\Honeybadger::$sender'] = new Sender();
     }
     if (!isset($this->_environment_default['\\Honeybadger\\Honeybadger::$logger'])) {
         $this->_environment_default['\\Honeybadger\\Honeybadger::$logger'] = new Logger\Test();
     }
     $this->setEnvironment($this->_environment_default);
 }
示例#2
0
 public function __construct(array $args = array())
 {
     // Store self to allow access in callbacks.
     self::$current = $this;
     $this->args = $args;
     $this->cgi_data = Environment::factory(Arr::get($args, 'cgi_data'));
     $this->project_root = Arr::get($args, 'project_root');
     $this->url = Arr::get($args, 'url', $this->cgi_data['url']);
     $this->environment_name = Arr::get($args, 'environment_name');
     $this->notifier_name = Arr::get($args, 'notifier_name');
     $this->notifier_version = Arr::get($args, 'notifier_version');
     $this->notifier_url = Arr::get($args, 'notifier_url');
     $this->ignore = Arr::get($args, 'ignore', array());
     $this->ignore_by_filters = Arr::get($args, 'ignore_by_filters', array());
     $this->backtrace_filters = Arr::get($args, 'backtrace_filters', array());
     $this->params_filters = Arr::get($args, 'params_filters', array());
     if (isset($args['parameters'])) {
         $this->params = $args['parameters'];
     } elseif (isset($args['params'])) {
         $this->params = $args['params'];
     }
     if (isset($args['component'])) {
         $this->component = $args['component'];
     } elseif (isset($args['controller'])) {
         $this->component = $args['controller'];
     } elseif (isset($this->params['controller'])) {
         $this->component = $this->params['controller'];
     }
     if (isset($args['action'])) {
         $this->action = $args['action'];
     } elseif (isset($this->params['action'])) {
         $this->action = $this->params['action'];
     }
     $this->exception = Arr::get($args, 'exception');
     if ($this->exception instanceof \Exception) {
         $backtrace = $this->exception->getTrace();
         if (empty($backtrace)) {
             $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
         }
         $this->error_class = get_class($this->exception);
         $this->error_message = HoneybadgerError::text($this->exception);
     } else {
         if (isset($args['backtrace']) and is_array($args['backtrace'])) {
             $backtrace = $args['backtrace'];
         } else {
             $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
         }
         $this->error_class = Arr::get($args, 'error_class');
         $this->error_message = Arr::get($args, 'error_message', 'Notification');
     }
     $this->backtrace = Backtrace::parse($backtrace, array('filters' => $this->backtrace_filters));
     $this->hostname = gethostname();
     $this->source_extract_radius = Arr::get($args, 'source_extract_radius', 2);
     $this->source_extract = $this->extract_source_from_backtrace();
     $this->send_request_session = Arr::get($args, 'send_request_session', TRUE);
     $this->find_session_data();
     $this->clean_params();
     $this->set_context();
 }
示例#3
0
 /**
  * Tests Arr::get()
  *
  * @test
  * @dataProvider provider_get()
  * @param array          $array      Array to look in
  * @param string|integer $key        Key to look for
  * @param mixed          $default    What to return if $key isn't set
  * @param mixed          $expected   The expected value returned
  */
 public function test_get(array $array, $key, $default, $expected)
 {
     $this->assertSame($expected, Arr::get($array, $key, $default));
 }