Inheritance: extends SimpleReporter
Esempio n. 1
0
 /**
  * Paints the end of the test with a summary of
  * the passes and failures.
  *
  * @param string $test_name Name class of test.
  * @access public
  */
 function paintFooter($test_name)
 {
     parent::paintFooter($test_name);
     echo 'Time taken by tests (in seconds): ' . $this->_timeDuration . "\n";
     if (function_exists('memory_get_peak_usage')) {
         echo 'Peak memory use: (in bytes): ' . number_format(memory_get_peak_usage()) . "\n";
     }
 }
 public static function setPreference()
 {
     if (TextReporter::inCli()) {
         SimpleTest::prefer(new Xml_Chris());
     } else {
         SimpleTest::prefer(new Html_Chris());
     }
 }
 /**
  * Genereates a nice report of the test.
  *
  * It instantiate a SimpleTest TestSuite and launches a Reporter.
  * This method is typically called by a TestRunner.
  *
  * @return void
  * @see    KortTestRunner
  * @see    KortCliReporter
  * @see    KortHTMLReporter
  */
 public function report()
 {
     $test = new \TestSuite($this->getLabel());
     $test->add($this);
     if (\TextReporter::inCli()) {
         exit($test->run(new KortCliReporter()) ? 0 : 1);
     }
     $test->run(new KortHTMLReporter());
 }
Esempio n. 4
0
 function paintPass($message)
 {
     parent::paintPass($message);
     if ($this->verbose) {
         print 'Pass ' . $this->getPassCount() . ") {$message}\n";
         $breadcrumb = $this->getTestList();
         array_shift($breadcrumb);
         print "\tin " . implode("\n\tin ", array_reverse($breadcrumb));
         print "\n";
     }
 }
 function paintPass($message)
 {
     parent::paintPass($message);
     $breadcrumb = $this->getTestList();
     array_shift($breadcrumb);
     if ($this->lastfile != $breadcrumb[0]) {
         print "{$breadcrumb['0']}\n";
         $this->lastfile = $breadcrumb[0];
     }
     array_shift($breadcrumb);
     print "\t" . implode(":", $breadcrumb) . ": OK\n";
     //print ": $message\n";
 }
 /**
  * Capture the attempt to display the final test results and insert the 
  * ANSI-color codes in place.
  *
  * @param string
  * @see TextReporter
  * @access public
  */
 function paintFooter($test_name)
 {
     ob_start();
     parent::paintFooter($test_name);
     $output = trim(ob_get_clean());
     if ($output) {
         if ($this->getFailCount() + $this->getExceptionCount() == 0) {
             $color = $this->_passColor;
         } else {
             $color = $this->_failColor;
         }
         $this->_setColor($color);
         echo $output;
         $this->_resetColor();
     }
 }
Esempio n. 7
0
<?php

require_once 'simpletest/unit_tester.php';
require_once 'simpletest/reporter.php';
require_once dirname(__FILE__) . '/addendum_test.php';
require_once dirname(__FILE__) . '/acceptance_test.php';
require_once dirname(__FILE__) . '/annotation_test.php';
require_once dirname(__FILE__) . '/constrained_annotation_test.php';
require_once dirname(__FILE__) . '/annotation_parser_test.php';
require_once dirname(__FILE__) . '/doc_comment_test.php';
$suite = new TestSuite('All tests');
$suite->add(new TestOfAddendum());
$suite->add(new TestOfAnnotations());
$suite->add(new TestOfPerformanceFeatures());
$suite->add(new TestOfSupportingFeatures());
$suite->add(new TestOfAnnotation());
$suite->add(new TestOfAnnotationCollection());
$suite->add(new TestOfConstrainedAnnotation());
$suite->add(new TestOfMatchers());
$suite->add(new TestOfAnnotationMatchers());
$suite->add(new TestOfDocComment());
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
    require_once dirname(__FILE__) . '/namespaces_test.php';
    $suite->add(new TestOfNamespaces());
}
$reporter = TextReporter::inCli() ? new TextReporter() : new HtmlReporter();
Addendum::setRawMode(false);
$suite->run($reporter);
Addendum::setRawMode(true);
$suite->run($reporter);
 function paintException($exception)
 {
     parent::paintException($exception);
     print "Exception full message:\n";
     print $exception->__toString();
     $this->failed_tests[] = '[EXP] ' . $this->_extractExceptionFileAndLine($exception);
 }
 function paintCaseEnd($test_name)
 {
   parent :: paintCaseEnd($test_name);
   
   print $this->getTestCaseProgress() . " of " . $this->getTestCaseCount() . " done({$test_name})\n";
 }
Esempio n. 10
0
 public function run_tests($argv)
 {
     error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);
     define("ENV", "test");
     $this->app_setup();
     define("CLI_ENV", true);
     if (!(include 'simpletest/unit_tester.php') || !(include 'simpletest/mock_objects.php')) {
         throw new WXDependencyException("Simpletest library required. Install it somewhere in the include path", "Simpletest Dependency Failure");
     }
     if ($argv[1] == "wax") {
         $testdir = FRAMEWORK_DIR . "/tests";
     } elseif ($argv[1] && is_dir(PLUGIN_DIR . $argv[1] . "/tests")) {
         $testdir = PLUGIN_DIR . $argv[1] . "/tests";
     } else {
         $testdir = APP_DIR . "tests";
     }
     AutoLoader::include_dir($testdir);
     $test = new GroupTest('All tests');
     foreach (scandir($testdir) as $file) {
         if (substr($file, -3) == "php" && substr($file, 0, 1) != ".") {
             $class = substr($file, 0, -4);
             $test->addTestClass($class);
         }
     }
     if (TextReporter::inCli()) {
         exit($test->run(new TextReporter()) ? 0 : 1);
     }
     $test->run(new HtmlReporter());
 }
 function __construct()
 {
     parent::__construct();
     $this->esc_start = chr(27) . '[';
 }
Esempio n. 12
0
 /**
  * Display the start of each method
  *
  * @param string $test_name
  */
 function paintMethodStart($test_name)
 {
     parent::paintMethodStart($test_name);
     print "Method: {$test_name}\n";
 }
Esempio n. 13
0
 public function paintException($exception)
 {
     parent::paintException($exception);
     print $exception->getTraceAsString();
     print "\n";
 }
Esempio n. 14
0
File: setup.php Progetto: ssrsfs/blg
 function getCss()
 {
     return parent::getCss() . ' blockquote {margin: 0 0 0 2em;}';
 }
Esempio n. 15
0
 /**
  * Paint exception faildetail to STDERR.
  */
 function paintException($message)
 {
     parent::paintException($message);
     fwrite(STDERR, 'EXCEPTION' . $this->faildetail_separator . $this->_paintTestFailDetail($message));
 }
Esempio n. 16
0
function ak_test($test_case_name, $use_sessions = false, $prevent_double_test_running = true, $custom_reporter = false)
{
    static $ran_tests = array();
    if (!isset($ran_tests[$test_case_name]) || !$prevent_double_test_running) {
        if (!defined('ALL_TESTS_CALL')) {
            $use_sessions ? @session_start() : null;
            $test = new $test_case_name();
            if (empty($custom_reporter)) {
                if (defined('AK_CLI') && AK_CLI || TextReporter::inCli() || defined('AK_CONSOLE_MODE') && AK_CONSOLE_MODE || defined('AK_WEB_REQUEST') && !AK_WEB_REQUEST) {
                    $test->run(new TextReporter());
                } else {
                    $test->run(new HtmlReporter());
                }
            } else {
                $test->run(new $custom_reporter());
            }
        }
        $ran_tests[$test_case_name] = true;
    }
}
 function paintMethodEnd($test_name)
 {
     //while(ob_get_status())
     //	ob_end_clean();
     parent::paintMethodEnd($test_name);
 }
Esempio n. 18
0
function ak_test($test_case_name, $use_sessions = false)
{
    if (!defined('ALL_TESTS_CALL')) {
        $use_sessions ? @session_start() : null;
        $test =& new $test_case_name();
        if (defined('AK_CLI') && AK_CLI || TextReporter::inCli() || defined('AK_CONSOLE_MODE') && AK_CONSOLE_MODE || defined('AK_WEB_REQUEST') && !AK_WEB_REQUEST) {
            $test->run(new TextReporter());
        } else {
            $test->run(new HtmlReporter());
        }
    }
}
Esempio n. 19
0
 function paintPass($message)
 {
     parent::paintPass($message);
 }
Esempio n. 20
0
 public function paintFooter($test_name)
 {
     parent::paintFooter($test_name);
     echo 'Time: ' . $GLOBALS['TIME'] . "\n";
 }
Esempio n. 21
0
 public function paintSkip($message)
 {
     parent::paintSkip(AkAnsiColor::style($message, 'warning'));
 }
Esempio n. 22
0
<?php

defined('ALL_TESTS_CALL') ? null : define("ALL_TESTS_CALL", true);
defined('AK_ENABLE_PROFILER') ? null : define('AK_ENABLE_PROFILER', true);
defined('AK_TEST_DATABASE_ON') ? null : define('AK_TEST_DATABASE_ON', true);
require_once dirname(__FILE__) . '/../../fixtures/config/config.php';
if (!defined('ALL_TESTS_RUNNER') && empty($test)) {
    $test = new GroupTest('Akelos Framework Active Record Tests');
    define('ALL_TESTS_RUNNER', false);
    @session_start();
}
//these partials are not refactored yet. so they must be run in sequence!
$partial_tests = array('_AkActiveRecord_1.php', '_AkActiveRecord_2.php', '_AkActiveRecord_3.php');
foreach ($partial_tests as $partial_test) {
    $test->addTestFile(AK_LIB_TESTS_DIRECTORY . DS . 'AkActiveRecord' . DS . $partial_test);
}
foreach (Ak::dir(AK_LIB_TESTS_DIRECTORY . DS . 'AkActiveRecord') as $active_record_test) {
    if (!is_array($active_record_test) && !in_array($active_record_test, $partial_tests)) {
        if (!ALL_TESTS_RUNNER || $active_record_test[0] == '_') {
            $test->addTestFile(AK_LIB_TESTS_DIRECTORY . DS . 'AkActiveRecord' . DS . $active_record_test);
        }
    }
}
if (!ALL_TESTS_RUNNER) {
    if (TextReporter::inCli()) {
        exit($test->run(new TextReporter()) ? 0 : 1);
    }
    $test->run(new HtmlReporter());
}
Esempio n. 23
0
    /**
     *    Paints the end of a group test. Will paint the page
     *    footer if the stack of tests has unwound.
     *    @param string $test_name   Name of test that is ending.
     *    @param integer $progress   Number of test cases ending.
     *    @access public
     */
    function paintGroupEnd($test_name) {
        parent::paintGroupEnd($test_name);
        $this->group_depth--;
        if ($this->group_depth==0) {
            //$contents = ob_get_contents();
            //ob_end_clean();
            $phpversion='php5';
            $backend="mysql";
            $this->_outstring='<?xml version="1.0" encoding="'.$this->_character_set.'"?>
<testsuites php-version="'.$this->phpversion.'" backend="'.$this->backend.'">';
            //foreach ($this->output as $level=>$out) {
            $this->_outstring.=implode("\n",$this->output);
            //}
            $this->_outstring.='</testsuites>';
            unset($this->output);
            $this->output=array();
            unset($this->_out);
            $this->_out=array();
        } else if ($this->group_depth==1) {
            $time = time()+microtime(true) - $this->_starttime;
            //$contents = ob_get_contents();
            //ob_end_clean();
            $out="";
            //package="'.$this->suiteName.'"
            $out.='<testsuite name="'.$this->suiteName.'" package="'.$this->suiteName.'" file="'.$this->fileName.'"  tests="'.$this->_sizes[$this->suiteName].'" failures="'.(isset($this->_failCounts[$this->suiteName])?$this->_failCounts[$this->suiteName]:0).'" errors="'.(isset($this->_exceptionCounts[$this->suiteName])?$this->_exceptionCounts[$this->suiteName]:0).'" time="'.$time.'">';
            if (isset($this->_out[$this->group_depth]) && is_array($this->_out[$this->group_depth])) {
                foreach ($this->_out[$this->group_depth] as $level=>$string) {
                    $out.=$string;
                }
            }
            $out.="</testsuite>";
            $this->_out[$this->group_depth] = array();
            $this->output[]=$out;
        } else if($this->group_depth==3) {
            //$contents = ob_get_contents();
            //ob_end_clean();
            $time = time()+microtime(true) - $this->_startsubtime;
            $out = "";
            $out.='<testsuite name="'.$this->suiteName.'::'.basename($this->testFileName).'" file="'.$this->testFileName.'" package="'.$this->suiteName.'" tests="'.(isset($this->_sizes[$this->testFileName])?$this->_sizes[$this->testFileName]:0).'" failures="'.(isset($this->_failCounts[$this->testFileName])?$this->_failCounts[$this->testFileName]:0).'" errors="'.(isset($this->_exceptionCounts[$this->testFileName])?$this->_exceptionCounts[$this->testFileName]:0).'" time="'.$time.'">';
            if (isset($this->_out[$this->group_depth+1]) && is_array($this->_out[$this->group_depth+1]) && count($this->_out[$this->group_depth+1])>0) {
                foreach ($this->_out[$this->group_depth+1] as $level=>$string) {
                    $out.=$string;
                }
            } else {
                if (@$this->_failCounts[$this->suiteName]+@$this->_exceptionCounts[$this->suiteName]>0) {
                    for($i=0;$i<@$this->_failCounts[$this->suiteName]+@$this->_exceptionCounts[$this->suiteName];$i++) {
                        $message = @array_shift($this->fail_messages);
                        if($message!=null) {
                            $out.='<error>';
                            $out.="<![CDATA[";
                            $out.=$message;
                            $out.="]]>";
                            $out.='</error>';
                        }
                    }
                }
            }
            $out.="</testsuite>";
            if (!isset($this->_out[1])) {
                $this->_out[1] = array();
            }
            $this->_out[1][]=$out;
            $this->_out[$this->group_depth+1] = array();
        }

        //$this->_fails = 0;
        //$this->_passes = 0;
    }