public static function call_simpletest($task, $type = 'text', $dirs = array())
 {
     // remove E_STRICT because simpletest is not E_STRICT compatible
     $old_error_reporting = error_reporting();
     $new_error_reporting = $old_error_reporting;
     if ($new_error_reporting & E_STRICT) {
         $new_error_reporting = $new_error_reporting ^ E_STRICT;
     }
     include_once 'simpletest/unit_tester.php';
     include_once 'simpletest/web_tester.php';
     if (!class_exists('GroupTest')) {
         throw new pakeException('You must install SimpleTest to use this task.');
     }
     require_once 'simpletest/reporter.php';
     require_once 'simpletest/mock_objects.php';
     set_include_path('test' . PATH_SEPARATOR . 'lib' . PATH_SEPARATOR . get_include_path());
     $base_test_dir = 'test';
     $test_dirs = array();
     // run tests only in these subdirectories
     if ($dirs) {
         foreach ($dirs as $dir) {
             $test_dirs[] = $base_test_dir . DIRECTORY_SEPARATOR . $dir;
         }
     } else {
         $test_dirs[] = $base_test_dir;
     }
     $test = new GroupTest('Test suite in (' . implode(', ', $test_dirs) . ')');
     $files = pakeFinder::type('file')->name('*Test.php')->in($test_dirs);
     if (count($files) > 0) {
         foreach ($files as $file) {
             $test->addTestFile($file);
         }
         ob_start();
         if ($type == 'html') {
             $result = $test->run(new HtmlReporter());
         } else {
             if ($type == 'xml') {
                 $result = $test->run(new XmlReporter());
             } else {
                 $result = $test->run(new TextReporter());
             }
         }
         $content = ob_get_contents();
         ob_end_clean();
         if ($task->is_verbose()) {
             echo $content;
         }
     } else {
         throw new pakeException('No test to run.');
     }
     error_reporting($old_error_reporting);
 }
Beispiel #2
0
 public function run()
 {
     $test = new GroupTest("Piwik - running '{$this->testGroupType}' tests...");
     $intro = '';
     if (!$this->databaseRequired) {
         $intro .= $this->getTestDatabaseInfoMessage();
     }
     $intro .= self::$testsHelpLinks . "<hr/>";
     $intro .= $this->introAppend;
     $toInclude = array();
     foreach ($this->dirsToGlob as $dir) {
         $toInclude = array_merge($toInclude, Piwik::globr(PIWIK_INCLUDE_PATH . $dir, '*.test.php'));
     }
     // if present, make sure Database.test.php is first
     $idx = array_search(PIWIK_INCLUDE_PATH . '/tests/core/Database.test.php', $toInclude);
     if ($idx !== FALSE) {
         unset($toInclude[$idx]);
         array_unshift($toInclude, PIWIK_INCLUDE_PATH . '/tests/core/Database.test.php');
     }
     foreach ($toInclude as $file) {
         $test->addFile($file);
     }
     $result = $test->run(new HtmlTimerReporter($intro));
     if (SimpleReporter::inCli()) {
         exit($result ? 0 : 1);
     }
 }
 public static function fromDir($name, $dir)
 {
     $classes = array();
     $dh = opendir($dir);
     while ($file = readdir($dh)) {
         if (!preg_match('/[.]php$/i', $file)) {
             continue;
         }
         if ($file == 'suite.php') {
             continue;
         }
         $className = preg_replace('/[.]php$/i', '', $file);
         array_push($classes, $className);
         $file = "{$dir}/{$file}";
         require_once $file;
     }
     closedir($dh);
     $test = new GroupTest($name);
     if (count($classes)) {
         foreach ($classes as $class) {
             $test->addTestCase(new $class());
         }
     } else {
         $test->addTestCase(new __tctemp());
     }
     $test->run(new DefaultReporter());
 }
 function run(&$reporter)
 {
     global $UNITTEST;
     $UNITTEST->running = true;
     $return = parent::run($reporter);
     unset($UNITTEST->running);
     return $return;
 }
Beispiel #5
0
 function generar_layout()
 {
     $selecciones = $this->controlador->get_selecciones();
     echo "<div style='background-color: white; border: 1px solid black; text-align: left; padding: 15px'>";
     try {
         //Se construye un suite por categoria que tenga test seleccionados
         foreach (toba_test_lista_casos::get_categorias() as $categoria) {
             $test = new GroupTest($categoria['nombre']);
             $hay_uno = false;
             foreach (toba_test_lista_casos::get_casos() as $caso) {
                 if ($caso['categoria'] == $categoria['id'] && in_array($caso['id'], $selecciones['casos'])) {
                     $hay_uno = true;
                     require_once $caso['archivo'];
                     $test->addTestCase(new $caso['id']($caso['nombre']));
                 }
             }
             if ($hay_uno) {
                 //--- COBERTURA DE CODIGO (OPCIONAL) ----
                 if (function_exists('xdebug_start_code_coverage')) {
                     xdebug_start_code_coverage();
                 }
                 //-------
                 $test->run(new toba_test_reporter());
                 //--- COBERTURA DE CODIGO (OPCIONAL) ----
                 $arch = 'PHPUnit2/Util/CodeCoverage/Renderer.php';
                 $existe = toba_manejador_archivos::existe_archivo_en_path($arch);
                 if (function_exists('xdebug_start_code_coverage') && $existe) {
                     require_once $arch;
                     $cubiertos = xdebug_get_code_coverage();
                     //Se limpian las referencias a simpletest y a librerias de testing en gral.
                     $archivos = array();
                     foreach (array_keys($cubiertos) as $archivo) {
                         if (!strpos($archivo, 'simpletest') && !strpos($archivo, 'PHPUnit') && !strpos($archivo, 'testing_automatico/') && !strpos($archivo, '/test_')) {
                             $archivos[$archivo] = $cubiertos[$archivo];
                         }
                     }
                     $cc = PHPUnit2_Util_CodeCoverage_Renderer::factory('HTML', array('tests' => $archivos));
                     $path_temp = toba::proyecto()->get_path_temp_www();
                     $salida = $path_temp['real'] . '/cobertura.html';
                     $cc->renderToFile($salida);
                     echo "<a href='{$path_temp['browser']}/cobertura.html' target='_blank'>Ver cobertura de código</a>";
                 }
                 //-------
             }
         }
     } catch (Exception $e) {
         if (method_exists($e, 'mensaje_web')) {
             echo ei_mensaje($e->mensaje_web(), 'error');
         } else {
             echo $e;
         }
     }
     echo '</div><br>';
     $this->dep('lista_archivos')->generar_html();
 }
Beispiel #6
0
<?php

require 'diff/difflib.php';
require 'diff/diffhtml.php';
if (!defined('SIMPLE_TEST')) {
    define('SIMPLE_TEST', 'simpletest/');
}
require_once SIMPLE_TEST . 'unit_tester.php';
require_once SIMPLE_TEST . 'reporter.php';
require_once SIMPLE_TEST . 'myhtmlreporter.class.php';
require_once SIMPLE_TEST . 'junittestcase.class.php';
require_once '../jtpl_standalone_prepend.php';
require_once 'compiler.php';
require_once 'expressions_parsing.php';
jTplConfig::$lang = 'fr';
$test = new GroupTest('All tests');
$test->addTestCase(new UTjtplcontent());
$test->addTestCase(new UTjtplexpr());
$test->run(new myHtmlReporter());
Beispiel #7
0
* test installation
*/
#$grouptest = new GroupTest('Installation');
#$grouptest->addTestFile('test_install.php');
#$grouptest->run(new HtmlReporter());
#
### create a function to make sure we are starting at index.php ###
function startedIndexPhp()
{
    return true;
}
### include some core libraries ###
require_once '../std/common.inc.php';
require_once dirname(__FILE__) . '/../conf/conf.inc.php';
require_once dirname(__FILE__) . '/class.test_environment.php';
#confChange('DB_TABLE_PREFIX_UNITTEST', '');   # overwrite development database!!!
TestEnvironment::initStreberUrl();
TestEnvironment::prepare('fixtures/project_setup.sql');
$grouptest = new GroupTest('Efforts');
$grouptest->addTestFile('test_efforts.php');
$grouptest->run(new HtmlReporter());
$grouptest = new GroupTest('Item visibility');
$grouptest->addTestFile('test_item_visibility.php');
$grouptest->run(new HtmlReporter());
$grouptest = new GroupTest('Login logic');
$grouptest->addTestFile('test_pages_login.php');
$grouptest->run(new HtmlReporter());
$grouptest = new GroupTest('Render all pages');
$grouptest->addTestFile('test_pages_all.php');
$result = $grouptest->run(new HtmlReporter());
#TestEnvironment::prepare('fixtures/remove_tables.sql');
Beispiel #8
0
        $breadcrumb = $this->getTestList();
        array_shift($breadcrumb);
        print implode(" -&gt; ", $breadcrumb);
        print " -&gt; " . htmlentities($message) . "<br />\n";
    }
    function paintSignal($type, &$payload)
    {
        print "<span class=\"fail\">{$type}</span>: ";
        $breadcrumb = $this->getTestList();
        array_shift($breadcrumb);
        print implode(" -&gt; ", $breadcrumb);
        print " -&gt; " . htmlentities(serialize($payload)) . "<br />\n";
    }
}
$test = new GroupTest("Visual test with 50 passes, 50 fails and 5 exceptions");
$test->addTestCase(new TestOfUnitTestCaseOutput());
$test->addTestCase(new TestOfMockObjectsOutput());
$test->addTestCase(new TestOfPastBugs());
$test->addTestCase(new TestOfVisualShell());
if (isset($_GET['xml']) || in_array('xml', isset($argv) ? $argv : array())) {
    $reporter = new XmlReporter();
} elseif (TextReporter::inCli()) {
    $reporter = new TextReporter();
} else {
    $reporter = new PassesAsWellReporter();
}
if (isset($_GET['dry']) || in_array('dry', isset($argv) ? $argv : array())) {
    $reporter->makeDry();
}
exit($test->run($reporter) ? 0 : 1);
Beispiel #9
0
    exit(1);
}
require_once SIMPLE_TEST . 'unit_tester.php';
require_once SIMPLE_TEST . 'reporter.php';
if (!empty($argc) and $argc > 1) {
    /* If command line arguments are given, then only test those. */
    array_shift($argv);
    $tests = $argv;
    $group = new GroupTest('Selected PEL tests');
} else {
    /* otherwive test all .php files, except this file (run-tests.php). */
    $tests = array_diff(glob('*.php'), array('run-tests.php', 'config.local.php', 'config.local.example.php'));
    $group = new GroupTest('All PEL tests');
    /* Also test all image tests (if they are available). */
    if (is_dir('image-tests')) {
        $image_tests = array_diff(glob('image-tests/*.php'), array('image-tests/make-image-test.php'));
        $image_group = new GroupTest('Image Tests');
        foreach ($image_tests as $image_test) {
            $image_group->addTestFile($image_test);
        }
        $group->addTestCase($image_group);
    } else {
        echo "Found no image tests, only core functionality will be tested.\n";
        echo "Image tests are available from http://pel.sourceforge.net/.\n";
    }
}
foreach ($tests as $test) {
    $group->addTestFile($test);
}
$group->run(new TextReporter());
 function single()
 {
     $rep = $this->_prepareResponse();
     $module = $this->param('mod');
     $testname = $this->param('test');
     if (isset($this->testsList[$module])) {
         $reporter = jClasses::create("junittests~jtextrespreporter");
         jClasses::inc('junittests~junittestcase');
         jClasses::inc('junittests~junittestcasedb');
         $reporter->setResponse($rep);
         foreach ($this->testsList[$module] as $test) {
             if ($test[1] == $testname) {
                 $group = new GroupTest('"' . $module . '" module , ' . $test[2]);
                 $group->addTestFile($GLOBALS['gJConfig']->_modulesPathList[$module] . 'tests/' . $test[0]);
                 jContext::push($module);
                 $result = $group->run($reporter);
                 if (!$result) {
                     $rep->setExitCode(jResponseCmdline::EXIT_CODE_ERROR);
                 }
                 jContext::pop();
                 break;
             }
         }
     } else {
         $rep->addContent("\n" . 'no tests for "' . $module . '" module.' . "\n");
     }
     return $this->_finishResponse($rep);
 }
Beispiel #11
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());
 }
Beispiel #12
0
// Configuration
$simpletest_location = 'simpletest/';
if (file_exists('../test-settings.php')) {
    include_once '../test-settings.php';
}
// Includes
require_once '../class.csstidy.php';
require_once 'Text/Diff.php';
require_once 'Text/Diff/Renderer.php';
require_once $simpletest_location . 'unit_tester.php';
require_once $simpletest_location . 'reporter.php';
require_once 'unit-tests/class.csstidy_reporter.php';
require_once 'unit-tests/class.csstidy_harness.php';
require_once 'unit-tests.inc';
// Test files
$test_files = array();
require 'unit-tests/_files.php';
// Setup test files
$test = new GroupTest('CSSTidy unit tests');
foreach ($test_files as $test_file) {
    require_once "unit-tests/{$test_file}";
    list($x, $class_suffix) = explode('.', $test_file);
    $test->addTestClass("csstidy_test_{$class_suffix}");
}
if (SimpleReporter::inCli()) {
    $reporter = new TextReporter();
} else {
    $reporter = new csstidy_reporter('UTF-8');
}
$test->run($reporter);
Beispiel #13
0
// include_once('simpletest/web_tester.php');
include_once 'simpletest/unit_tester.php';
include_once 'simpletest/reporter.php';
include_once 'configurator/LoggerConfigurator.php';
include_once 'logger/Logger.php';
// }}}
// {{{ configure console
$options = new ConsoleOptions();
$options->setNoValueFor('debug', '-d', '--debug');
$options->load(isset($argv) ? $argv : $_SERVER['argv']);
$options->alias('debug', '-d, --debug');
// }}}
// {{{ logger.
$logger = new Logger(new LoggerConfigurator());
// }}}
$test = new GroupTest("=== Medick Framework Unit Tests ===");
$test_files = Folder::recursiveFindRelative('.', 'test', 'Test.php');
foreach ($test_files as $file) {
    if ($options->has('debug')) {
        $logger->debug('Adding test file: ' . $file);
    }
    $test->addTestFile($file);
}
$test->run(new TextReporter());
if ($options->has('debug')) {
    $time_end = microtime(true);
    $logger->debug('Done in ' . round($time_end - $time_start, 4) . ' seconds');
}
// {{{ clean-up
@unlink(TMP . 'test.db');
// }}}
Beispiel #14
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());
}
Beispiel #15
0
 /**
  *  ユニットテストを実行する
  *
  *  @access private
  *  @return mixed   0:正常終了 Ethna_Error:エラー
  */
 function run()
 {
     $action_class_list = $this->_getTestAction();
     $view_class_list = $this->_getTestView();
     $test = new GroupTest("Ethna UnitTest");
     // アクション
     foreach ($action_class_list as $action_name) {
         $action_class = $this->ctl->getDefaultActionClass($action_name, false) . '_TestCase';
         $action_form = $this->ctl->getDefaultFormClass($action_name, false) . '_TestCase';
         $test->addTestCase(new $action_class($this->ctl));
         $test->addTestCase(new $action_form($this->ctl));
     }
     // ビュー
     foreach ($view_class_list as $view_name) {
         $view_class = $this->ctl->getDefaultViewClass($view_name, false) . '_TestCase';
         $test->addTestCase(new $view_class($this->ctl));
     }
     // 一般
     foreach ($this->testcase as $class_name => $file_name) {
         $dir = $this->ctl->getBasedir() . '/';
         include_once $dir . $file_name;
         $testcase_name = $class_name . '_TestCase';
         $test->addTestCase(new $testcase_name($this->ctl));
     }
     // ActionFormのバックアップ
     $af = $this->ctl->getActionForm();
     //出力したい形式にあわせて切り替える
     $cli_enc = $this->ctl->getClientEncoding();
     $reporter = new Ethna_UnitTestReporter($cli_enc);
     $test->run($reporter);
     // ActionFormのリストア
     $this->ctl->action_form = $af;
     $this->backend->action_form = $af;
     $this->backend->af = $af;
     return array($reporter->report, $reporter->result);
 }
 /**
  * Run the tests
  *
  * This method will run the tests with the correct Reporter. It will run 
  * grouped tests if asked to and filter results. It also has support for 
  * running coverage report. 
  *
  */
 public function run()
 {
     $testGroup = $this->testGroup;
     if (PHP_SAPI === 'cli') {
         require_once dirname(__FILE__) . '/DoctrineTest/Reporter/Cli.php';
         $reporter = new DoctrineTest_Reporter_Cli();
         $argv = $_SERVER['argv'];
         array_shift($argv);
         $options = $this->parseOptions($argv);
     } else {
         require_once dirname(__FILE__) . '/DoctrineTest/Reporter/Html.php';
         $options = $_GET;
         if (isset($options['filter'])) {
             if (!is_array($options['filter'])) {
                 $options['filter'] = explode(',', $options['filter']);
             }
         }
         if (isset($options['group'])) {
             if (!is_array($options['group'])) {
                 $options['group'] = explode(',', $options['group']);
             }
         }
         $reporter = new DoctrineTest_Reporter_Html();
     }
     //replace global group with custom group if we have group option set
     if (isset($options['group'])) {
         $testGroup = new GroupTest('Doctrine Custom Test', 'custom');
         foreach ($options['group'] as $group) {
             if (isset($this->groups[$group])) {
                 $testGroup->addTestCase($this->groups[$group]);
             } else {
                 if (class_exists($group)) {
                     $testGroup->addTestCase(new $group());
                 } else {
                     die($group . " is not a valid group or doctrine test class\n ");
                 }
             }
         }
     }
     if (isset($options['ticket'])) {
         $testGroup = new GroupTest('Doctrine Custom Test', 'custom');
         foreach ($options['ticket'] as $ticket) {
             $class = 'Doctrine_Ticket_' . $ticket . '_TestCase';
             $testGroup->addTestCase(new $class());
         }
     }
     $filter = '';
     if (isset($options['filter'])) {
         $filter = $options['filter'];
     }
     //show help text
     if (isset($options['help'])) {
         $availableGroups = sort(array_keys($this->groups));
         echo "Doctrine test runner help\n";
         echo "===========================\n";
         echo " To run all tests simply run this script without arguments. \n";
         echo "\n Flags:\n";
         echo " -coverage will generate coverage report data that can be viewed with the cc.php script in this folder. NB! This takes time. You need xdebug to run this\n";
         echo " -group <groupName1> <groupName2> <className1> Use this option to run just a group of tests or tests with a given classname. Groups are currently defined as the variable name they are called in this script.\n";
         echo " -filter <string1> <string2> case insensitive strings that will be applied to the className of the tests. A test_classname must contain all of these strings to be run\n";
         echo "\nAvailable groups:\n " . implode(', ', $availableGroups) . "\n";
         die;
     }
     //generate coverage report
     if (isset($options['coverage'])) {
         /*
         * The below code will not work for me (meus). It would be nice if 
         * somebody could give it a try. Just replace this block of code 
         * with the one below
         *
         define('PHPCOVERAGE_HOME', dirname(dirname(__FILE__)) . '/vendor/spikephpcoverage');
                     require_once PHPCOVERAGE_HOME . '/CoverageRecorder.php';
                     require_once PHPCOVERAGE_HOME . '/reporter/HtmlCoverageReporter.php';
         
                     $covReporter = new HtmlCoverageReporter('Doctrine Code Coverage Report', '', 'coverage2');
         
                     $includePaths = array('../lib');
                     $excludePaths = array();
                     $cov = new CoverageRecorder($includePaths, $excludePaths, $covReporter);
         
                     $cov->startInstrumentation();
                     $ret = $testGroup->run($reporter, $filter);
                     $cov->stopInstrumentation();
         
                     $cov->generateReport();
                     $covReporter->printTextSummary();
                     return $ret;
         */
         xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
         $ret = $testGroup->run($reporter, $filter);
         $result['coverage'] = xdebug_get_code_coverage();
         xdebug_stop_code_coverage();
         file_put_contents(dirname(__FILE__) . '/coverage/coverage.txt', serialize($result));
         require_once dirname(__FILE__) . '/DoctrineTest/Coverage.php';
         $coverageGeneration = new DoctrineTest_Coverage();
         $coverageGeneration->generateReport();
         return $ret;
         // */
     }
     if (array_key_exists('only-failed', $options)) {
         $testGroup->onlyRunFailed(true);
     }
     $result = $testGroup->run($reporter, $filter);
     global $startTime;
     $endTime = time();
     $time = $endTime - $startTime;
     if (PHP_SAPI === 'cli') {
         echo "\nTests ran in " . $time . " seconds and used " . memory_get_peak_usage() / 1024 . " KB of memory\n\n";
     } else {
         echo "<p>Tests ran in " . $time . " seconds and used " . memory_get_peak_usage() / 1024 . " KB of memory</p>";
     }
     return $result;
 }
    /**
     * Run the tests
     *
     * This method will run the tests with the correct Reporter. It will run 
     * grouped tests if asked to and filter results. It also has support for 
     * running coverage report. 
     *
     */
    public function run(){
        $testGroup = $this->testGroup;
        if (PHP_SAPI === 'cli') {
            require_once(dirname(__FILE__) . '/DoctrineTest/Reporter/Cli.php');
            $reporter = new DoctrineTest_Reporter_Cli();
            $argv = $_SERVER['argv'];
            array_shift($argv);
            $options = $this->parseOptions($argv);
        } else {
            require_once(dirname(__FILE__) . '/DoctrineTest/Reporter/Html.php');
            $options = $_GET;
            if(isset($options["filter"])){
                $options["filter"] = explode(",", $options["filter"]);
            }
            if(isset($options["group"])){
                $options["group"] = explode(",", $options["group"]);
            }
            $reporter = new DoctrineTest_Reporter_Html();
        }

        //replace global group with custom group if we have group option set
        if (isset($options['group'])) {
            $testGroup = new GroupTest('Doctrine Framework Custom test', 'custom');
            foreach($options['group'] as $group) {
                if (isset($this->groups[$group])) {
                    $testGroup->addTestCase($this->groups[$group]);
                } else if (class_exists($group)) {
                    $testGroup->addTestCase(new $group);
                } else {
                    die($group . " is not a valid group or doctrine test class\n ");
                }
            }
        } 

        if (isset($options['ticket'])) {
            $testGroup = new GroupTest('Doctrine Framework Custom test', 'custom');
            foreach ($options['ticket'] as $ticket) {
                $class = 'Doctrine_Ticket_' . $ticket. '_TestCase';
                $testGroup->addTestCase(new $class);
            }
        }

        $filter = '';
        if (isset($options['filter'])) {
            $filter = $options['filter'];
        }

        //show help text
        if (isset($options['help'])) {
            echo "Doctrine test runner help\n";
            echo "===========================\n";
            echo " To run all tests simply run this script without arguments. \n";
            echo "\n Flags:\n";
            echo " -coverage will generate coverage report data that can be viewed with the cc.php script in this folder. NB! This takes time. You need xdebug to run this\n";
            echo " -group <groupName1> <groupName2> <className1> Use this option to run just a group of tests or tests with a given classname. Groups are currently defined as the variable name they are called in this script.\n";
            echo " -filter <string1> <string2> case insensitive strings that will be applied to the className of the tests. A test_classname must contain all of these strings to be run\n"; 
            echo "\nAvailable groups:\n tickets, transaction, driver, data_dict, sequence, export, import, expression, core, relation, data_types, utility, db, event_listener, query_tests, record, cache\n";
            die();
        }

        //generate coverage report
        if (isset($options['coverage'])) {

            /*
             * The below code will not work for me (meus). It would be nice if 
             * somebody could give it a try. Just replace this block of code 
             * with the one below
             *
             define('PHPCOVERAGE_HOME', dirname(dirname(__FILE__)) . '/vendor/spikephpcoverage');
            require_once PHPCOVERAGE_HOME . '/CoverageRecorder.php';
            require_once PHPCOVERAGE_HOME . '/reporter/HtmlCoverageReporter.php';

            $covReporter = new HtmlCoverageReporter('Doctrine Code Coverage Report', '', 'coverage2');

            $includePaths = array('../lib');
            $excludePaths = array();
            $cov = new CoverageRecorder($includePaths, $excludePaths, $covReporter);

            $cov->startInstrumentation();
            $testGroup->run($reporter, $filter);
            $cov->stopInstrumentation();

            $cov->generateReport();
            $covReporter->printTextSummary();
             */
            xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
            $testGroup->run($reporter, $filter);
            $result['coverage'] = xdebug_get_code_coverage();
            xdebug_stop_code_coverage();
            file_put_contents(dirname(__FILE__) . '/coverage/coverage.txt', serialize($result));
            require_once dirname(__FILE__) . '/DoctrineTest/Coverage.php';
            $coverageGeneration = new DoctrineTest_Coverage();
            $coverageGeneration->generateReport();
            return;
            // */

        }
        $testGroup->run($reporter, $filter);
    }
Beispiel #18
0
 function runGroupTest($group_test_name, $group_test_directory, &$reporter)
 {
     $manager = new TestManager();
     $group_test_name = preg_replace('/[^a-zA-Z0-9_:]/', '', $group_test_name);
     $group_test_name = str_replace(':', DIRECTORY_SEPARATOR, $group_test_name);
     $file_path = $group_test_directory . DIRECTORY_SEPARATOR . strtolower($group_test_name) . $manager->_grouptest_extension;
     if (!file_exists($file_path)) {
         trigger_error("Group test {$group_test_name} cannot be found at {$file_path}", E_USER_ERROR);
     }
     require_once $file_path;
     $test = new GroupTest($group_test_name . ' group test');
     foreach ($manager->_getGroupTestClassNames($file_path) as $group_test) {
         $test->addTestCase(new $group_test());
     }
     $test->run($reporter);
 }
Beispiel #19
0
require_once 'Ethna/class/Getopt.php';
$opt = new Ethna_Getopt();
$args = $opt->readPHPArgv();
list($args, $opts) = $opt->getopt($args, '', array());
array_shift($opts);
if (count($opts) > 0) {
    $file_list = $opts;
} else {
    $file_list = getFileList($test_dir);
}
// テストケースを登録
foreach ($file_list as $file) {
    $test->addTestFile($file);
}
// 結果をコマンドラインに出力
$test->run(new TextDetailReporter());
if ($symlink_filename !== null && is_link($symlink_filename)) {
    unlink($symlink_filename);
}
//{{{ getFileList
/**
 * getFileList
 *
 * @param string $dir_path
 */
function getFileList($dir_path)
{
    $file_list = array();
    $dir = opendir($dir_path);
    if ($dir == false) {
        return false;
Beispiel #20
0
    if (!preg_match('/^epTest\\w+\\.php$/', $filename)) {
        continue;
    }
    // add this test file into group
    $t->addTestFile($file);
}
// start coverage
if (EP_COVERAGE_TEST) {
    startCoverage($c_recorder, $c_reporter);
}
$status = false;
if (epIsWebRun()) {
    // start timer
    $tm = microtime(true);
    // use the web reporter
    $status = $t->run(new HtmlReporter());
    // stop timer
    $elapsed = microtime(true) - $tm;
    // output timing
    echo epNewLine() . 'Time elapsed: ' . $elapsed . ' seconds';
} else {
    // use the cli reporter from Rephlux
    include_once EP_TESTS . '/src/epCliReporter.php';
    $status = $t->run(new epCliReporter());
}
// end coverage
if (EP_COVERAGE_TEST) {
    // suppress undefined token warning
    error_reporting(E_ALL ^ E_NOTICE);
    // generate coverage reports
    endCoverage($c_recorder, $c_reporter);
 public static function runTestCase($testCase = "")
 {
     $testGroup = new GroupTest("Individual Test Case: " . Inflector::humanize($testCase));
     $testGroup->addTestFile(App::path("Core", "tests/cases/{$testCase}.test"));
     $testGroup->run(new HtmlReporter());
 }
Beispiel #22
0
 private function runSelectedTests()
 {
     include './modules/tests/testcases/UnitTests.php';
     include './modules/tests/testcases/WebTests.php';
     include './modules/tests/testcases/AJAXTests.php';
     $microTimeArray = explode(' ', microtime());
     $microTimeStart = $microTimeArray[1] + $microTimeArray[0];
     /* FIXME: 3 groups! Unit, Web, AJAX. */
     $groupTest = new GroupTest('CATS Test Suite');
     foreach ($this->_unitTestCases as $offset => $value) {
         if ($this->isChecked($value[0], $_POST)) {
             $groupTest->addTestCase(new $value[0]());
         }
     }
     foreach ($this->_systemTestCases as $offset => $value) {
         if ($this->isChecked($value[0], $_POST)) {
             $groupTest->addTestCase(new $value[0]());
         }
     }
     foreach ($this->_AJAXTestCases as $offset => $value) {
         if ($this->isChecked($value[0], $_POST)) {
             $groupTest->addTestCase(new $value[0]());
         }
     }
     $reporter = new CATSTestReporter($microTimeStart);
     $reporter->showPasses = true;
     $reporter->showFails = true;
     $groupTest->run($reporter);
 }
Beispiel #23
0
<?php

ini_set('error_reporting', E_ALL ^ E_NOTICE);
ini_set('display_errors', 1);
ini_set('log_errors', 'Off');
require_once 'config.php';
require_once SIMPLETESTDIR . 'simpletest.php';
require_once SIMPLETESTDIR . 'unit_tester.php';
require_once SIMPLETESTDIR . 'reporter.php';
$base_dir = dirname(__FILE__) . "/unit/";
if (isset($_GET['test']) && file_exists($base_dir . $_GET['test'])) {
    $testfile = $_GET['test'];
    $title = "Test File {$testfile}";
} else {
    $testfile = '';
    $title = 'All Test Files';
}
//$test = new TestSuite($title);
$test = new GroupTest($title);
if ($testfile) {
    $test->addTestFile($base_dir . $testfile);
} else {
    foreach (glob($base_dir . "*Test.php") as $testfile) {
        $test->addTestFile($testfile);
    }
}
if (TextReporter::inCli()) {
    $test->run(new TextReporter());
} else {
    $test->run(new HtmlReporter());
}
Beispiel #24
0
/*		require_once(CONCERTO.'/tests/dbconnect.inc.php'); */
/*	} */
require_once HARMONI . "errorHandler/ErrorHandler.class.php";
$errorHandler = Services::getService("ErrorHandler");
$context = new OsidContext();
$configuration = new ConfigurationProperties();
Services::startManagerAsService("DatabaseManager", $context, $configuration);
$test = new GroupTest('CourseManagementTest');
$test->addTestFile(dirname(__FILE__) . '/CanonicalCourseTestCase.class.php');
$test->addTestFile(dirname(__FILE__) . '/CourseGroupTestCase.class.php');
$test->addTestFile(dirname(__FILE__) . '/CourseOfferingTestCase.class.php');
$test->addTestFile(dirname(__FILE__) . '/TermTest.class.php');
$test->addTestFile(dirname(__FILE__) . '/CourseSectionTestCase.class.php');
$test->addTestFile(dirname(__FILE__) . '/EnrollmentRecordTestCase.class.php');
$test->addTestFile(dirname(__FILE__) . '/CourseGradeRecordTest.class.php');
$test->attachObserver(new DoboTestHtmlDisplay());
$test->run();
$timer->end();
print "\n<br />Harmoni Load Time: " . $harmonyLoadupTimer->printTime();
print "\n<br />Overall Time: " . $timer->printTime();
$dbhandler = Services::getService("DBHandler");
printpre("NumQueries: " . $dbhandler->getTotalNumberOfQueries());
print "\n</p>";
// $num = $dbHandler->getTotalNumberOfQueries();
// debug::output("Total # of queries: ".$num,1,"DBHandler");
//debug::printAll();
// unset($dbHandler,$errorHandler, $userError);
// unset($num);
//	$errorHandler->printErrors(HIGH_DETAIL);
//	print "<pre>";
//	print_r($errorHandler);
Beispiel #25
0
        $coverage->show();
    } else {
        echo 'Access Denied!';
    }
    die;
}
if ($doTest) {
    ob_start();
    $test = new GroupTest('All tests');
    $dir = dir(dirname(__FILE__));
    while (false !== ($entry = $dir->read())) {
        if (is_file($entry) && strtolower(substr($entry, 0, 4)) == 'test') {
            if (strpos(strtolower($entry), 'mysql')) {
                if (extension_loaded('mysql')) {
                    $test->addTestFile($entry);
                }
            } else {
                $test->addTestFile($entry);
            }
        }
    }
    $dir->close();
    $sapi = php_sapi_name();
    if ($sapi == 'cli' || $sapi == 'cgi-fcgi') {
        exit($test->run(new TextReporter()) ? 0 : 1);
    }
    $test->run(new HtmlReporterWithCoverage('index.php', FRAMEWORK_BASE));
    file_put_contents($mycachefile, ob_get_contents());
} else {
    echo file_get_contents($mycachefile);
}
Beispiel #26
0
<?php

require_once 'setup_tests_environment.php';
define('SIMPLE_RUNNING', true);
$tests = new GroupTest("Running all tests");
$tests->addTestFile('test_domain_product.php');
$success = $tests->run(new TextReporter());
if (!$success) {
    exit(1);
}
exit;
Beispiel #27
0
    exit(1);
}
$files = array();
$reportClass = 'TextReporter';
array_shift($argv);
foreach ($argv as $option) {
    if ($option == '--earl') {
        require_once dirname(__FILE__) . '/EarlReporter.php';
        $reportClass = 'EarlReporter';
    } else {
        //file?
        if (!file_exists($option)) {
            echo "File {$option} does not exist\n";
            exit(2);
        }
        $files[] = $option;
    }
}
require_once SIMPLETEST_INCLUDE_DIR . 'unit_tester.php';
require_once SIMPLETEST_INCLUDE_DIR . 'reporter.php';
require_once 'show_passes.php';
require_once RDFAPI_INCLUDE_DIR . 'RdfAPI.php';
$_SESSION['passes'] = 0;
$_SESSION['fails'] = 0;
$test_sparql = new GroupTest('some RDF API for PHP tests');
foreach ($files as $file) {
    $test_sparql->addTestFile($file);
}
//$test_sparql->run(new ShowPasses());
$test_sparql->run(new $reportClass());
Beispiel #28
0
require_once $dir_plugins . '/tbs_plugin_mergeonfly.php';
require_once $dir_plugins . '/tbs_plugin_navbar.php';
// @require_once($dir_plugins.'/tbs_plugin_ref.php');
// @require_once($dir_plugins.'/tbs_plugin_syntaxes.php');
// other files required for unit tests
require_once $dir_testu . '/include/TBSUnitTestCase.php';
require_once $dir_testu . '/include/HtmlCodeCoverageReporter.php';
// include unit test classes
include $dir_testu . '/testcase/AttTestCase.php';
include $dir_testu . '/testcase/QuoteTestCase.php';
include $dir_testu . '/testcase/FrmTestCase.php';
include $dir_testu . '/testcase/StrconvTestCase.php';
include $dir_testu . '/testcase/FieldTestCase.php';
include $dir_testu . '/testcase/BlockTestCase.php';
include $dir_testu . '/testcase/MiscTestCase.php';
include $dir_testu . '/testcase/SubTplTestCase.php';
// launch tests
ini_set("display_errors", "On");
set_time_limit(0);
$tbs = new clsTinyButStrong();
$test = new GroupTest('TinyButStrong v' . $tbs->Version . ' (with PHP ' . PHP_VERSION . ')');
$test->addTestCase(new FieldTestCase());
$test->addTestCase(new BlockTestCase());
$test->addTestCase(new AttTestCase());
$test->addTestCase(new QuoteTestCase());
$test->addTestCase(new FrmTestCase());
$test->addTestCase(new StrconvTestCase());
$test->addTestCase(new MiscTestCase());
$test->addTestCase(new SubTplTestCase());
$test->run(new HtmlCodeCoverageReporter(array($tbsFileName, $dir_tbs . '/plugins/')));
 function single()
 {
     if (!isset($GLOBALS['gJConfig']->enableTests) || !$GLOBALS['gJConfig']->enableTests) {
         // security
         $rep = $this->getResponse('html', true);
         $rep->title = 'Error';
         $rep->setHttpStatus('404', 'Not found');
         $rep->addContent('<p>404 Not Found</p>');
         return $rep;
     }
     $rep = $this->_prepareResponse();
     $module = $this->param('mod');
     $testname = $this->param('test');
     if (isset($this->testsList[$module])) {
         $reporter = jClasses::create("junittests~jhtmlrespreporter");
         jClasses::inc('junittests~junittestcase');
         jClasses::inc('junittests~junittestcasedb');
         $reporter->setResponse($rep);
         foreach ($this->testsList[$module] as $test) {
             if ($test[1] == $testname) {
                 $group = new GroupTest('"' . $module . '" module , ' . $test[2]);
                 $group->addTestFile($GLOBALS['gJConfig']->_modulesPathList[$module] . 'tests/' . $test[0]);
                 jContext::push($module);
                 $group->run($reporter);
                 jContext::pop();
                 break;
             }
         }
     } else {
         $rep->body->assign('MAIN', '<p>no tests for "' . $module . '" module.</p>');
     }
     return $this->_finishResponse($rep);
 }