示例#1
0
文件: Html.php 项目: nrocy/phpspec
 /**
  * Gets the code based on the exception backtrace
  * 
  * @param \Exception $e
  * @return string
  */
 protected function getCode($e)
 {
     if (!$e instanceof \Exception) {
         return '';
     }
     if (!$e instanceof \PHPSpec\Specification\Result\DeliberateFailure) {
         $traceline = Backtrace::getFileAndLine($e->getTrace(), 1);
     } else {
         $traceline = Backtrace::getFileAndLine($e->getTrace());
     }
     $lines = '';
     if (!empty($traceline)) {
         $lines .= $this->getLine($traceline, -2);
         $lines .= $this->getLine($traceline, -1);
         $lines .= $this->getLine($traceline, 0, 'offending');
         $lines .= $this->getLine($traceline, 1);
     }
     $template = new \Text_Template($this->templateDir() . '/Code.html.dist');
     $template->setVar(array('code' => $lines));
     return $template->render();
 }
示例#2
0
文件: Junit.php 项目: nrocy/phpspec
 /**
  * Gets the code based on the exception backtrace
  * 
  * @param \Exception $e
  * @return string
  */
 protected function getCode($e)
 {
     if (!$e instanceof \Exception) {
         return '';
     }
     if (!$e instanceof \PHPSpec\Specification\Result\DeliberateFailure) {
         $traceline = Backtrace::getFileAndLine($e->getTrace(), 1);
     } else {
         $traceline = Backtrace::getFileAndLine($e->getTrace());
     }
     $lines = '';
     if (!empty($traceline)) {
         $lines .= $this->getLine($traceline, -2);
         $lines .= $this->getLine($traceline, -1);
         $lines .= $this->getLine($traceline, 0, 'offending');
         $lines .= $this->getLine($traceline, 1);
     }
     return $lines;
 }