/** * 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); }
/** * Returns an array of all configurable options merged with `$config`. * * @param array $config Options to merge with configuration * @return array The merged configuration. */ public function merge(array $config = array()) { return Arr::merge($this->as_array(), $config); }
/** * Combines the request and route parameters into one array for * Honeybadger notices. * * @param Slim\Http\Request $request * @return array The combined request and route parameters. */ private function combined_params($request) { $router = $this->app->router(); // Find the matching route for the request, to extract parameters for // routes such as: `/books/:id`. $router->getMatchedRoutes($request->getMethod(), $request->getPathInfo()); if ($route = $router->getCurrentRoute()) { $params = $route->getParams(); } else { $params = array(); } // Merge the route and request parameters into one array. return Arr::merge($request->params(), $params); }
private static function build_notice_for($exception, array $options = array()) { if ($exception instanceof \Exception) { $options['exception'] = self::unwrap_exception($exception); } elseif (Arr::is_array($exception)) { $options = Arr::merge($options, $exception); } return Notice::factory($options); }
/** * * @test * @dataProvider provider_merge */ public function test_merge($expected, $array1, $array2) { $this->assertSame($expected, Arr::merge($array1, $array2)); }