示例#1
0
文件: Reporter.php 项目: rixrix/agnos
 /**
  * Displays overall test summary
  *
  * @param  timestamp   Time tests started
  * @param  timestatmp  Time tests ended
  * @param  integer     Total number of tests found
  * @param  array       Array of failed tests
  */
 public function testSummary($_timeStart, $timeEnd, $totalTestCases, $failedTest)
 {
     $countFailed = sizeof($failedTest['FAILED']);
     $countSkipped = sizeof($failedTest['SKIPPED']);
     $countPassed = $totalTestCases - ($countFailed + $countSkipped);
     $avgTime = $timeEnd - $_timeStart;
     $timeStart = @date('Y-m-d H:i:s', $_timeStart);
     $timeEnd = @date('Y-m-d H:i:s', $timeEnd);
     $date = @date('D, Y-m-d H:i:s a', $_timeStart);
     $uniqid = @date('Y-m-d-H:i:s', $_timeStart);
     $filename = "agnos-report-{$uniqid}.txt";
     $testSummary = "\n                             TEST RESULT SUMMARY\n                       Copyright (C) 2008 agnos v0.0.1\n                       \nFilename    : {$filename}\nDate        : {$date}\n--------------------------------------------------------------------------------\nTotal Tests : {$totalTestCases}\nPassed      : {$countPassed}\nFailed      : {$countFailed}\nSkipped     : {$countSkipped}\n--------------------------------------------------------------------------------\n\nTIMESTAMP\n--------------------------------------------------------------------------------\nStarted     : {$timeStart}\nEnded       : {$timeEnd}\nTotal time  : {$avgTime} seconds\n--------------------------------------------------------------------------------\n";
     if ($countFailed >= 1) {
         $contents = agnosUtil::arrayToString($failedTest['FAILED'], 'name');
         $failedTestReport = "\nFAILED TESTS REPORT\n--------------------------------------------------------------------------------\n{$contents}\n--------------------------------------------------------------------------------\n";
         $testSummary .= $failedTestReport;
     }
     agnosConsole::message($testSummary);
     if (agnosFileDir::createDir('agnos-reports')) {
         agnosUtil::saveText('agnos-reports' . DIRECTORY_SEPARATOR . $filename, $testSummary);
     }
     return true;
 }
示例#2
0
文件: Utility.php 项目: rixrix/agnos
 /**
  * Saves information to a local file
  *
  * @param   string  File filename
  * @param   string  File contents
  * 
  * @access  public
  */
 public function saveText($filename, $contents)
 {
     if (!empty($filename) && !empty($contents)) {
         if (@file_put_contents($filename, $contents) === false) {
             agnosConsole::error("Unable to write file '{$filename}'");
             return false;
         }
         return true;
     }
     return false;
 }
示例#3
0
文件: Tester.php 项目: rixrix/agnos
 /**
  * Saves the information found in --FILE-- section into a temporary file
  * e.g. mytestcase.php
  * 
  * @param  string  filename in full path
  * @param  string  text/source codes found in --FILE-- section
  * @param  string  filename copy (optional)
  * @return boolean true; 
  */
 public function saveTestFile($filename, $text, $filenameCopy = null)
 {
     if (!empty($filename) && $filenameCopy != $filename) {
         if (@file_put_contents($filenameCopy, $text) === false) {
             agnosConsole::error("Cannot open file '{$filenameCopy}'");
             return false;
         }
     } else {
         if (@file_put_contents($filename, $text) === false) {
             agnosConsole::error("Cannot open file '{$filename}'");
             return false;
         }
     }
     # if verbose == true, show detailed info
     return true;
 }