コード例 #1
0
 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());
 }
コード例 #2
0
ファイル: casos_web.php プロジェクト: emma5021/toba
 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();
 }
コード例 #3
0
ファイル: visual_test.php プロジェクト: Hassanj343/candidats
        print "<span class=\"pass\">Pass</span>: ";
        $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);
コード例 #4
0
ファイル: run-tests.php プロジェクト: kbrack1/UptoBox
    print "SimpleTest could not be found and so no tests can be made.\n";
    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());
コード例 #5
0
ファイル: simple_test_test.php プロジェクト: sebs/simpletest
    function test2()
    {
        $this->assertTrue($this->test_variable == 13, "True");
    }
    function setUp()
    {
        $this->test_variable = 13;
    }
    function tearDown()
    {
        $this->test_variable = 0;
    }
}
$test = new GroupTest("Me");
$test_case = new MyTestCase();
$test->addTestCase($test_case);
$test->attachObserver(new TestOfTestReporter(array("Me", "mytestcase", "test", null, "test", "test2", null, "test2", "mytestcase", "Me"), array(null, null, null, true, null, null, true, null, null, null), array(null, null, null, "True", null, null, "True", null, null, null)));
$test->run();
assertion(0 == $test_case->test_variable, "Expected [0] got [" . $test_case->test_variable . "]");
// Collect test cases from a script.
//
$test = new GroupTest("Script");
$test->addTestFile("support/dummy_test_1.php");
$test->addTestFile("support/dummy_test_2.php");
$test->attachObserver(new TestOfTestReporter(array("Script", "support/dummy_test_1.php", "DummyTestOneA", "testOneA", null, "testOneA", "DummyTestOneA", "DummyTestOneB", "testOneB", null, "testOneB", "DummyTestOneB", "support/dummy_test_1.php", "support/dummy_test_2.php", "DummyTestTwo", "testTwo", null, "testTwo", "DummyTestTwo", "support/dummy_test_2.php", "Script"), array(null, null, null, null, true, null, null, null, null, true, null, null, null, null, null, null, true, null, null, null, null), array(null, null, null, null, "True", null, null, null, null, "True", null, null, null, null, null, null, "True", null, null, null, null)));
$test->run();
?>
        </ol>
        <div><em>Should have all passed.</em></div>
    </body>
</html>
コード例 #6
0
ファイル: simple_test.php プロジェクト: sebs/simpletest
 /**
  *    Builds a group test from a library of test cases.
  *    The new group is composed into this one.
  *    @param $test_file        File name of library with
  *                             test case classes.
  */
 function addTestFile($test_file)
 {
     $existing_classes = get_declared_classes();
     require $test_file;
     $group = new GroupTest($test_file);
     foreach (get_declared_classes() as $class) {
         if (in_array($class, $existing_classes)) {
             continue;
         }
         if (!$this->_is_test_case($class)) {
             continue;
         }
         $group->addTestCase(new $class());
     }
     $this->addTestCase($group);
 }
コード例 #7
0
ファイル: run.php プロジェクト: prismhdd/victorioussecret
// Migration Tests
$migration = new GroupTest('Migration Tests', 'migration');
$migration->addTestCase(new Doctrine_Migration_TestCase());
$test->addTestCase($migration);

// File Parser Tests
$parser = new GroupTest('Parser Tests', 'parser');
$parser->addTestCase(new Doctrine_Parser_TestCase());
$test->addTestCase($parser);

// Data Fixtures Tests
$data = new GroupTest('Data exporting/importing fixtures', 'data_fixtures');
$data->addTestCase(new Doctrine_Data_Import_TestCase());
$data->addTestCase(new Doctrine_Data_Export_TestCase());
$test->addTestCase($data);

// Unsorted Tests. These need to be sorted and placed in the appropriate group
$unsorted = new GroupTest('Unsorted Tests', 'unsorted');
$unsorted->addTestCase(new Doctrine_CustomPrimaryKey_TestCase());
$unsorted->addTestCase(new Doctrine_CustomResultSetOrder_TestCase());
$unsorted->addTestCase(new Doctrine_ColumnAlias_TestCase());
//$unsorted->addTestCase(new Doctrine_RawSql_TestCase());
$unsorted->addTestCase(new Doctrine_NewCore_TestCase());
$unsorted->addTestCase(new Doctrine_Template_TestCase());
$unsorted->addTestCase(new Doctrine_NestedSet_SingleRoot_TestCase());
$unsorted->addTestCase(new Doctrine_NestedSet_MultiRoot_TestCase());
$unsorted->addTestCase(new Doctrine_PessimisticLocking_TestCase());
$test->addTestCase($unsorted);

$test->run();
コード例 #8
0
 /**
  * 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;
 }
コード例 #9
0
ファイル: TestsUI.php プロジェクト: PublicityPort/OpenCATS
 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);
 }
コード例 #10
0
    foreach ($rows as $line => $row) {
        echo " <tr>\n";
        printf("  <td>%s</td>", $line);
        foreach ($row as $column) {
            printf("  <td>%s</td>", $column);
        }
        echo " </tr>\n";
    }
    echo "</table>\n";
}
// include simpletest classes
require_once 'simpletest/unit_tester.php';
require_once 'simpletest/reporter.php';
require_once 'simpletest/mock_objects.php';
// include all tests
require_once 'TestCases/Reader.php';
// require_once 'TestCases/Writer.php';
// require_once 'TestCases/AutoDetect.php';
// require_once 'TestCases/Dialect.php';
// require_once 'TestCases/Docs.php';
// run tests in html reporter
$test = new GroupTest('Core CSV Utilities Tests');
$test->addTestCase(new Test_Of_Csv_Reader());
// $test->addTestCase(new Test_Of_Csv_Writer);
// $test->addTestCase(new Test_Of_Csv_AutoDetect);
// $test->addTestCase(new Test_Of_Csv_Dialect);
// $test->addTestCase(new Test_Of_Csv_Docs);
if (TextReporter::inCli()) {
    exit($test->run(new TextReporter()) ? 0 : 1);
}
$test->run(new HtmlReporter());
コード例 #11
0
define('TESTCLASS_PATH', TESTCASE_PATH . '/testclasses');
define('DS', DIRECTORY_SEPARATOR);
define('PS', PATH_SEPARATOR);
// establish include path
set_include_path(SIMPLETEST_PATH . PS . QCAL_PATH . PS . TESTCASE_PATH . PS . TESTCLASS_PATH . PS . get_include_path());
// require autoloader
require_once QCAL_PATH . '/autoload.php';
// require convenience functions
require_once TESTCASE_PATH . '/convenience.php';
// require necessary simpletest files
require_once SIMPLETEST_PATH . '/unit_tester.php';
require_once SIMPLETEST_PATH . '/reporter.php';
require_once SIMPLETEST_PATH . '/mock_objects.php';
// add tests cases to group and run the tests
$test = new GroupTest('Core qCal Tests');
$test->addTestCase(new UnitTestCase_Parser());
$test->addTestCase(new UnitTestCase_Component());
$test->addTestCase(new UnitTestCase_Component_Alarm());
$test->addTestCase(new UnitTestCase_Component_Calendar());
$test->addTestCase(new UnitTestCase_Component_Timezone());
$test->addTestCase(new UnitTestCase_Component_Event());
$test->addTestCase(new UnitTestCase_Property());
$test->addTestCase(new UnitTestCase_Value());
$test->addTestCase(new UnitTestCase_Value_Date());
$test->addTestCase(new UnitTestCase_Value_Recur());
$test->addTestCase(new UnitTestCase_Value_Multi());
$test->addTestCase(new UnitTestCase_Renderer());
$test->addTestCase(new UnitTestCase_DateTime());
$test->addTestCase(new UnitTestCase_Date());
$test->addTestCase(new UnitTestCase_Duration());
$test->addTestCase(new UnitTestCase_Period());
コード例 #12
0
ファイル: test.php プロジェクト: cjvaz/expressomail
<?php

error_reporting(error_reporting() & ~2048 & ~8192);
// Make sure E_STRICT and E_DEPRECATED are disabled
require_once 'simpletest/unit_tester.php';
require_once 'simpletest/reporter.php';
$core = new GroupTest('Core');
require_once '../lib/tonic.php';
$core->addTestFile('request.php');
$core->addTestFile('resource.php');
$core->addTestFile('response.php');
$core->addTestFile('filesystem.php');
$core->addTestFile('filesystemcollection.php');
$test = new GroupTest('Tonic');
$test->addTestCase($core);
//*
@(include_once 'PHP/CodeCoverage.php');
if (class_exists('PHP_CodeCoverage')) {
    $coverage = new PHP_CodeCoverage();
    $coverage->start('Tonic');
}
//*/
if (TextReporter::inCli()) {
    $test->run(new TextReporter());
} else {
    $test->run(new HtmlReporter());
}
if (isset($coverage)) {
    $coverage->stop();
    require_once 'PHP/CodeCoverage/Report/HTML.php';
    $writer = new PHP_CodeCoverage_Report_HTML();
コード例 #13
0
// File Parser Tests
$parser = new GroupTest('Parser Tests', 'parser');
$parser->addTestCase(new Doctrine_Parser_TestCase());
$test->addTestCase($parser);
// Data Fixtures Tests
$data = new GroupTest('Data exporting/importing fixtures', 'data_fixtures');
$data->addTestCase(new Doctrine_Data_Import_TestCase());
$data->addTestCase(new Doctrine_Data_Export_TestCase());
$test->addTestCase($data);
// Unsorted Tests. These need to be sorted and placed in the appropriate group
$unsorted = new GroupTest('Unsorted Tests', 'unsorted');
$unsorted->addTestCase(new Doctrine_CustomPrimaryKey_TestCase());
$unsorted->addTestCase(new Doctrine_CustomResultSetOrder_TestCase());
$unsorted->addTestCase(new Doctrine_ColumnAlias_TestCase());
$unsorted->addTestCase(new Doctrine_RawSql_TestCase());
$unsorted->addTestCase(new Doctrine_NewCore_TestCase());
$unsorted->addTestCase(new Doctrine_Template_TestCase());
$unsorted->addTestCase(new Doctrine_PessimisticLocking_TestCase());
$test->addTestCase($unsorted);
$nestedSet = new GroupTest('Nested set tests', 'nestedset');
$nestedSet->addTestCase(new Doctrine_NestedSet_SingleRoot_TestCase());
$nestedSet->addTestCase(new Doctrine_NestedSet_MultiRoot_TestCase());
$nestedSet->addTestCase(new Doctrine_NestedSet_TimestampableMultiRoot_TestCase());
$nestedSet->addTestCase(new Doctrine_NestedSet_Hydration_TestCase());
$test->addTestCase($nestedSet);
/*
$unsorted = new GroupTest('Performance', 'performance');
$unsorted->addTestCase(new Doctrine_Hydrate_Performance_TestCase());
$test->addTestCase($unsorted);
*/
exit($test->run() ? 0 : 1);
コード例 #14
0
    foreach ($rows as $line => $row) {
        echo " <tr>\n";
        printf("  <td>%s</td>", $line);
        foreach ($row as $column) {
            printf("  <td>%s</td>", $column);
        }
        echo " </tr>\n";
    }
    echo "</table>\n";
}
// include simpletest classes
require_once 'simpletest/unit_tester.php';
require_once 'simpletest/reporter.php';
require_once 'simpletest/mock_objects.php';
// include all tests
require_once 'TestCases/Reader.php';
require_once 'TestCases/Writer.php';
require_once 'TestCases/AutoDetect.php';
require_once 'TestCases/Dialect.php';
require_once 'TestCases/Docs.php';
// run tests in html reporter
$test = new GroupTest('Core CSV Utilities Tests');
$test->addTestCase(new Test_Of_Csv_Reader());
$test->addTestCase(new Test_Of_Csv_Writer());
$test->addTestCase(new Test_Of_Csv_AutoDetect());
$test->addTestCase(new Test_Of_Csv_Dialect());
$test->addTestCase(new Test_Of_Csv_Docs());
if (TextReporter::inCli()) {
    exit($test->run(new TextReporter()) ? 0 : 1);
}
$test->run(new HtmlReporter());
コード例 #15
0
ファイル: index.php プロジェクト: hadrienl/jelix
<?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());
コード例 #16
0
ファイル: UnitTestManager.php プロジェクト: riaf/pastit
 /**
  *  ユニットテストを実行する
  *
  *  @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);
 }
コード例 #17
0
ファイル: testmanager.php プロジェクト: stretchyboy/dokuwiki
 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);
 }
コード例 #18
0
        $this->assertIdentical($a, $b);
        // Fail.
        $this->assertNotIdentical($a, $b);
    }
    function testOfReference()
    {
        $a = "fred";
        $b = $a;
        $this->assertReference($a, $b);
        $this->assertCopy($a, $b);
        // Fail.
        $c = "Hello";
        $this->assertReference($a, $c);
        // Fail.
        $this->assertCopy($a, $c);
    }
    function testOfPatterns()
    {
        $this->assertWantedPattern('/hello/i', "Hello there");
        $this->assertNoUnwantedPattern('/hello/', "Hello there");
        $this->assertWantedPattern('/hello/', "Hello there");
        // Fail.
        $this->assertNoUnwantedPattern('/hello/i', "Hello there");
        // Fail.
    }
}
$test = new GroupTest("Unit test case test, 14 fails and 14 passes");
$display = new TestHTMLDisplay();
$test->attachObserver($display);
$test->addTestCase(new TestOfUnitTestCase());
$test->run();
コード例 #19
0
<?php

// $Id: detached_test.php 424 2006-07-21 02:20:17Z will $
require_once '../detached.php';
require_once '../reporter.php';
// The following URL will depend on your own installation.
$command = 'php ' . dirname(__FILE__) . '/visual_test.php xml';
$test = new GroupTest('Remote tests');
$test->addTestCase(new DetachedTestCase($command));
if (SimpleReporter::inCli()) {
    exit($test->run(new TextReporter()) ? 0 : 1);
}
$test->run(new HtmlReporter());
コード例 #20
0
ファイル: remote_test.php プロジェクト: Hassanj343/candidats
<?php

// $Id: remote_test.php 424 2006-07-21 02:20:17Z will $
require_once '../remote.php';
require_once '../reporter.php';
// The following URL will depend on your own installation.
if (isset($_SERVER['SCRIPT_URI'])) {
    $base_uri = $_SERVER['SCRIPT_URI'];
} elseif (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['PHP_SELF'])) {
    $base_uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
}
$test_url = str_replace('remote_test.php', 'visual_test.php', $base_uri);
$test = new GroupTest('Remote tests');
$test->addTestCase(new RemoteTestCase($test_url . '?xml=yes', $test_url . '?xml=yes&dry=yes'));
if (SimpleReporter::inCli()) {
    exit($test->run(new TextReporter()) ? 0 : 1);
}
$test->run(new HtmlReporter());
コード例 #21
0
    /**
     * 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);
    }
コード例 #22
0
 function addTestFile($file, $internalcall = false)
 {
     if ($this->showsearch) {
         if ($internalcall) {
             echo '<li><b>' . basename($file) . '</b></li>';
         } else {
             echo '<p>Adding test file: ' . realpath($file) . '</p>';
         }
         // Make sure that syntax errors show up suring the search, otherwise you often
         // get blank screens because evil people turn down error_reporting elsewhere.
         error_reporting(E_ALL);
     }
     if (!is_file($file)) {
         parent::addTestCase(new BadTest($file, 'Not a file or does not exist'));
     }
     parent::addTestFile($file);
 }
コード例 #23
0
ファイル: casos_consola.php プロジェクト: emma5021/toba
if (isset($this->parametros['-t'])) {
    //Seleccion de un test particular
    if (isset($this->parametros['-t'])) {
        $particular = false;
        foreach ($seleccionados as $caso) {
            if ($caso['id'] == $this->parametros['-t']) {
                $particular = $caso;
            }
        }
        if ($particular) {
            $seleccionados = array($particular);
        } else {
            $seleccionados = array();
        }
    }
}
try {
    $test = new GroupTest('Casos de TEST');
    foreach ($seleccionados as $caso) {
        require_once $caso['archivo'];
        $test->addTestCase(new $caso['id']($caso['nombre']));
    }
    //Termina la ejecución con 0 o 1 para que pueda comunicarse con al consola
    exit($test->run(new TextReporter()) ? 0 : 1);
} catch (Exception $e) {
    if (method_exists($e, 'mensaje_consola')) {
        echo $e->mensaje_consola();
    } else {
        echo $e;
    }
}
コード例 #24
0
require_once $dir_plugins . '/tbs_plugin_cache.php';
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/')));
コード例 #25
0
ファイル: test.php プロジェクト: noah-goodrich/phpdoctor
$parser->addTestFile('tests' . DIRECTORY_SEPARATOR . 'cases' . DIRECTORY_SEPARATOR . 'namespace-syntax.php');
$standardDoclet = new GroupTest('Standard Doclet');
$standardDoclet->addTestFile('tests' . DIRECTORY_SEPARATOR . 'cases' . DIRECTORY_SEPARATOR . 'standard-doclet.php');
$standardDoclet->addTestFile('tests' . DIRECTORY_SEPARATOR . 'cases' . DIRECTORY_SEPARATOR . 'access.php');
$standardDoclet->addTestFile('tests' . DIRECTORY_SEPARATOR . 'cases' . DIRECTORY_SEPARATOR . 'access-php5.php');
$standardDoclet->addTestFile('tests' . DIRECTORY_SEPARATOR . 'cases' . DIRECTORY_SEPARATOR . 'throws-tag.php');
$fixes = new GroupTest('Bugfixes');
// these tests will work with PHP5 < 5.3
$fixes->addTestFile('tests' . DIRECTORY_SEPARATOR . 'cases' . DIRECTORY_SEPARATOR . 'linefeed.php');
$fixes->addTestFile('tests' . DIRECTORY_SEPARATOR . 'cases' . DIRECTORY_SEPARATOR . 'lastline.php');
$fixes->addTestFile('tests' . DIRECTORY_SEPARATOR . 'cases' . DIRECTORY_SEPARATOR . 'zerovalue.php');
$fixes->addTestFile('tests' . DIRECTORY_SEPARATOR . 'cases' . DIRECTORY_SEPARATOR . 'todo.php');
$fixes->addTestFile('tests' . DIRECTORY_SEPARATOR . 'cases' . DIRECTORY_SEPARATOR . 'comment-links.php');
$formatters = new GroupTest('Formatters');
// these tests will work with PHP5 < 5.3
$formatters->addTestFile('tests' . DIRECTORY_SEPARATOR . 'cases' . DIRECTORY_SEPARATOR . 'lists-ul.php');
include_once "markdown.php";
if (function_exists('Markdown')) {
    $formatters->addTestFile('tests' . DIRECTORY_SEPARATOR . 'cases' . DIRECTORY_SEPARATOR . 'markdown.php');
} else {
    $reporter->paintMessage("Not running Markdown test, Markdown not available on system");
}
$test = new GroupTest('PHPDoctor');
$test->addTestCase($parser);
$test->addTestCase($standardDoclet);
$test->addTestCase($fixes);
$test->addTestCase($formatters);
if (TextReporter::inCli()) {
    exit($test->run($reporter) ? 0 : 1);
}
$test->run($reporter);