/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { global $base_url; // Test discovery does not run upon form submission. simpletest_classloader_register(); // This form accepts arbitrary user input for 'tests'. // An invalid value will cause the $class_name lookup below to die with a // fatal error. Regular user access mechanisms to this form are intact. // The only validation effectively being skipped is the validation of // available checkboxes vs. submitted checkboxes. // @todo Refactor Form API to allow to POST values without constructing the // entire form more easily, BUT retaining routing access security and // retaining Form API CSRF #token security validation, and without having // to rely on form caching. $user_input = $form_state->getUserInput(); if ($form_state->isValueEmpty('tests') && !empty($user_input['tests'])) { $form_state->setValue('tests', $user_input['tests']); } $tests_list = array(); foreach ($form_state->getValue('tests') as $class_name => $value) { if ($value === $class_name) { if (is_subclass_of($class_name, 'PHPUnit_Framework_TestCase')) { $test_type = 'phpunit'; } else { $test_type = 'simpletest'; } $tests_list[$test_type][] = $class_name; } } if (!empty($tests_list)) { putenv('SIMPLETEST_BASE_URL=' . $base_url); $test_id = simpletest_run_tests($tests_list, 'drupal'); $form_state->setRedirect('simpletest.result_form', array('test_id' => $test_id)); } }
/** * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { // Test discovery does not run upon form submission. simpletest_classloader_register(); // This form accepts arbitrary user input for 'tests'. // An invalid value will cause the $class_name lookup below to die with a // fatal error. Regular user access mechanisms to this form are intact. // The only validation effectively being skipped is the validation of // available checkboxes vs. submitted checkboxes. // @todo Refactor Form API to allow to POST values without constructing the // entire form more easily, BUT retaining routing access security and // retaining Form API CSRF #token security validation, and without having // to rely on form caching. if (empty($form_state['values']['tests']) && !empty($form_state['input']['tests'])) { $form_state['values']['tests'] = $form_state['input']['tests']; } $tests_list = array(); foreach ($form_state['values']['tests'] as $class_name => $value) { if ($value === $class_name) { if (is_subclass_of($class_name, 'PHPUnit_Framework_TestCase')) { $test_type = 'phpunit'; } else { $test_type = 'simpletest'; } $tests_list[$test_type][] = $class_name; } } if (!empty($tests_list)) { $test_id = simpletest_run_tests($tests_list, 'drupal'); $form_state['redirect_route'] = array('route_name' => 'simpletest.result_form', 'route_parameters' => array('test_id' => $test_id)); } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // Test discovery does not run upon form submission. simpletest_classloader_register(); // This form accepts arbitrary user input for 'tests'. // An invalid value will cause the $class_name lookup below to die with a // fatal error. Regular user access mechanisms to this form are intact. // The only validation effectively being skipped is the validation of // available checkboxes vs. submitted checkboxes. // @todo Refactor Form API to allow to POST values without constructing the // entire form more easily, BUT retaining routing access security and // retaining Form API CSRF #token security validation, and without having // to rely on form caching. $user_input = $form_state->getUserInput(); if ($form_state->isValueEmpty('tests') && !empty($user_input['tests'])) { $form_state->setValue('tests', $user_input['tests']); } $tests_list = array_filter($form_state->getValue('tests')); if (!empty($tests_list)) { $test_id = simpletest_run_tests($tests_list, 'drupal'); $form_state->setRedirect('simpletest.result_form', array('test_id' => $test_id)); } }
<?php // $Id: run_all_tests.php,v 1.3 2006/04/05 00:44:32 thomasilsche Exp $ /** * @file * Run all unit tests for all enabled modules. */ chdir(realpath(dirname(__FILE__) . '/../../')); require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); // If not in 'safe mode', increase the maximum execution time: if (!ini_get('safe_mode')) { set_time_limit(360); } simpletest_run_tests();
include_once './includes/bootstrap.inc'; } else { exit("bootstrap.inc could not be loaded\n"); } } drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); //load simpletest files simpletest_load(); // If not in 'safe mode', increase the maximum execution time: if (!ini_get('safe_mode')) { set_time_limit(360); } $tests = NULL; $reporter = 'html'; if (SimpleReporter::inCli()) { $reporter = 'text'; if ($argc == 2) { $tests = explode(',', $argv[1]); } } else { if ($_GET['include']) { $tests = explode(',', $_GET['include']); } if ($_GET['reporter'] && ($_GET['reporter'] == 'xml' || $_GET['reporter'] == 'html')) { $reporter = $_GET['reporter']; } else { $reporter = 'html'; } } simpletest_run_tests($tests, $reporter);