本文整理汇总了PHP中GroupTest::addTestCase方法的典型用法代码示例。如果您正苦于以下问题:PHP GroupTest::addTestCase方法的具体用法?PHP GroupTest::addTestCase怎么用?PHP GroupTest::addTestCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GroupTest
的用法示例。
在下文中一共展示了GroupTest::addTestCase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromDir
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: foreach
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: implode
print "<span class=\"pass\">Pass</span>: ";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
print implode(" -> ", $breadcrumb);
print " -> " . htmlentities($message) . "<br />\n";
}
function paintSignal($type, &$payload)
{
print "<span class=\"fail\">{$type}</span>: ";
$breadcrumb = $this->getTestList();
array_shift($breadcrumb);
print implode(" -> ", $breadcrumb);
print " -> " . 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: exit
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: setUp
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: addTestFile
/**
* 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: GroupTest
// 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: run
/**
* 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();
//.........这里部分代码省略.........
示例9: runSelectedTests
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: foreach
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: GroupTest
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: GroupTest
<?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: GroupTest
// 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: define
<?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());
示例15: run
/**
* ユニットテストを実行する
*
* @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);
}