Пример #1
0
function run_testset($testset)
{
    require_code('_tests/tests/' . filter_naughty($testset) . '.php');
    $loader = new SimpleFileLoader();
    $suite = $loader->createSuiteFromClasses($testset, array(basename($testset) . '_test_set'));
    /*$result = */
    $suite->run(new DefaultReporter());
}
Пример #2
0
/**
 *    run all recent test cases if no test has
 *    so far been run. Uses the DefaultReporter which can have
 *    it's output controlled with SimpleTest::prefer().
 */
function run_local_tests()
{
    try {
        $candidates = capture_new_classes();
        $loader = new SimpleFileLoader();
        $suite = $loader->createSuiteFromClasses(basename(initial_file()), $loader->selectRunnableTests($candidates));
        $result = $suite->run(new DefaultReporter());
    } catch (Exception $stack_frame_fix) {
        print $stack_frame_fix->getMessage();
        $result = false;
    }
}
Пример #3
0
/**
 *    Exit handler to run all recent test cases if no test has
 *    so far been run. Uses the DefaultReporter which can have
 *    it's output controlled with SimpleTest::prefer().
 */
function simpletest_autorun()
{
    if (tests_have_run()) {
        return;
    }
    $candidates = array_intersect(capture_new_classes(), classes_defined_in_initial_file());
    $loader = new SimpleFileLoader();
    $suite = $loader->createSuiteFromClasses(basename(initial_file()), $loader->selectRunnableTests($candidates));
    $result = $suite->run(new DefaultReporter());
    if (SimpleReporter::inCli()) {
        exit($result ? 0 : 1);
    }
}
Пример #4
0
 protected function _prepareTestCase($test)
 {
     require_once $this->file;
     $candidates = $this->_getClassesDefinedInFile();
     $loader = new SimpleFileLoader();
     foreach ($loader->selectRunnableTests($candidates) as $class) {
         if ($this->_isFiltered($class)) {
             continue;
         }
         $case = new $class();
         $case->filter(lmbTestOptions::get('methods_filter'));
         $test->addTestCase($case);
         //a dirty SimpleTest PHP4 compatibility hack
         //otherwise $case is overwrittne since it is a reference
         unset($case);
     }
 }
Пример #5
0
/**
 *    Exit handler to run all recent test cases if no test has
 *    so far been run. Uses the DefaultReporter which can have
 *    it's output controlled with SimpleTest::prefer().
 */
function simpletest_autorun()
{
    try {
        if (tests_have_run()) {
            return;
        }
        $candidates = array_intersect(capture_new_classes(), classes_defined_in_initial_file());
        $loader = new SimpleFileLoader();
        $suite = $loader->createSuiteFromClasses(basename(initial_file()), $loader->selectRunnableTests($candidates));
        $result = $suite->run(new DefaultReporter());
    } catch (Exception $e) {
        // This is here, because under normal circumstances shutdown
        // functions don't have a stack frame, leading to obscure errors.
        echo $e->__toString();
        $result = false;
    }
    if (SimpleReporter::inCli()) {
        exit($result ? 0 : 1);
    }
}
Пример #6
0
 /**
  *    Builds a test suite from a library of test cases.
  *    The new suite is composed into this one.
  *    @param string $test_file        File name of library with
  *                                    test case classes.
  *    @access public
  */
 function addFile($test_file) {
     $extractor = new SimpleFileLoader();
     $this->add($extractor->load($test_file));
 }