Beispiel #1
0
 public function testTestProduction()
 {
     $env = new Environment();
     $this->assertTrue($env->isProduction());
     $this->assertFalse($env->isDevelopment());
     $this->assertFalse($env->isTest());
 }
Beispiel #2
0
 /**
  * In the event of an uncaught Exception at point of run, this method will be called
  * by default it'll look for 'DefaultPackage::Error::uncaughtError' before
  * manipulating the response directly and returning to the user.
  * It's environmental sensitive, so will format things accordingly.
  * @param \Exception $throwable
  * @codeCoverageIgnore
  */
 private function error(\Exception $throwable)
 {
     if ($this->env->isProduction()) {
         if (false != ($errorClass = $this->getErrorClass())) {
             try {
                 $this->response->setStatus(500);
                 $instance = $this->getRunnable('DefaultPackage', 'Error', 'uncaughtException', $errorClass);
                 if (is_callable(array($instance, 'uncaughtException'))) {
                     $instance->uncaughtException();
                 } else {
                     $e = new RunnableNotFoundException('Runnable not found');
                     $e->setAdditionalData('Expected: ', '\\DefaultPackage\\src\\Error::uncaughtException()');
                     throw $e;
                 }
                 $instance->finalise();
                 return;
             } catch (\Exception $e) {
                 // Ignore, we're already here.
             }
         }
         @ob_get_clean();
         $this->response->setStatus(500);
         $this->response->setBody('<h1 style="font:28px/1.5 Helvetica,Arial,Verdana,sans-serif;">Application Error</h1>');
         $this->response->sendResponse();
         return;
     } else {
         FormattedException::display($throwable);
         return;
     }
 }