/** * Constructor * * {@inheritdoc} * * @see \Paulus\Paulus::__construct() * @param string $base_path The bash path to load and define constants from * @param string $app_namespace The name of the application's namespace, to be used in the autoloader * @param array $config A configuration array that matches Paulus' config pattern * @access public */ public function __construct($base_path = __DIR__, $app_namespace = null, array $config = null) { // Fall back to a default config path $this->app_base_path = $base_path; // Quickly define some constants $this->define_global_constants(); // Load our config if we didn't pass one $config = $config ?: (new FileArrayLoader($this->app_base_path . '/../configs/', null, 'load_config'))->load(); if (!is_null($app_namespace)) { $this->app_namespace = $app_namespace; // Register our autoloader spl_autoload_register(array($this, 'app_autoloader')); } // Call our parent constructor parent::__construct($config); }
/** * runAndGetOutput * * Run's our app and captures our output, returning our API result * * @param Paulus $app_context If no context is passed, a new Paulus app * will be instanciated for us * @access protected * @return mixed */ protected function runAndGetOutput($app_context = null) { if (is_null($app_context)) { // New Paulus app $app_context = new Paulus($this->config); } // Start a NEW output buffer (so we can grab JUST our app's output) ob_start(); $app_context->run(); // Grab our output from our buffer $output = $this->getJSONOutput(ob_get_contents()); // End and clean our buffer, so it doesn't show up in our Unit Test output ob_end_clean(); return $output; }