diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestResultsForm.php b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestResultsForm.php index 3eb42ceb4b48cda3d197e8131a0931dc0f47c919..d1d339af534c54054a8391ce53297b8ff451492e 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestResultsForm.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestResultsForm.php @@ -7,16 +7,15 @@ namespace Drupal\simpletest\Form; -use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\Database\Connection; -use Drupal\Core\Form\FormInterface; +use Drupal\Core\Form\FormBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; /** * Test results form for $test_id. */ -class SimpletestResultsForm implements FormInterface, ControllerInterface { +class SimpletestResultsForm extends FormBase { /** * Associative array of themed result images keyed by status. @@ -53,28 +52,28 @@ public function __construct(Connection $database) { '#uri' => 'core/misc/watchdog-ok.png', '#width' => 18, '#height' => 18, - '#alt' => t('Pass'), + '#alt' => $this->t('Pass'), ); $image_fail = array( '#theme' => 'image', '#uri' => 'core/misc/watchdog-error.png', '#width' => 18, '#height' => 18, - '#alt' => t('Fail'), + '#alt' => $this->t('Fail'), ); $image_exception = array( '#theme' => 'image', '#uri' => 'core/misc/watchdog-warning.png', '#width' => 18, '#height' => 18, - '#alt' => t('Exception'), + '#alt' => $this->t('Exception'), ); $image_debug = array( '#theme' => 'image', '#uri' => 'core/misc/watchdog-warning.png', '#width' => 18, '#height' => 18, - '#alt' => t('Debug'), + '#alt' => $this->t('Debug'), ); $this->statusImageMap = array( 'pass' => drupal_render($image_pass), @@ -100,7 +99,7 @@ public function buildForm(array $form, array &$form_state, $test_id = NULL) { $results = array(); if (is_numeric($test_id) && !$results = $this->getResults($test_id)) { - drupal_set_message(t('No test results to display.'), 'error'); + drupal_set_message($this->t('No test results to display.'), 'error'); return new RedirectResponse(url('admin/config/development/testing', array('absolute' => TRUE))); } @@ -116,7 +115,7 @@ public function buildForm(array $form, array &$form_state, $test_id = NULL) { // Summary result widget. $form['result'] = array( '#type' => 'fieldset', - '#title' => t('Results'), + '#title' => $this->t('Results'), ); $form['result']['summary'] = $summary = array( '#theme' => 'simpletest_result_summary', @@ -130,12 +129,12 @@ public function buildForm(array $form, array &$form_state, $test_id = NULL) { // Cycle through each test group. $header = array( - t('Message'), - t('Group'), - t('Filename'), - t('Line'), - t('Function'), - array('colspan' => 2, 'data' => t('Status')) + $this->t('Message'), + $this->t('Group'), + $this->t('Filename'), + $this->t('Line'), + $this->t('Function'), + array('colspan' => 2, 'data' => $this->t('Status')) ); $form['result']['results'] = array(); foreach ($results as $group => $assertions) { @@ -183,14 +182,14 @@ public function buildForm(array $form, array &$form_state, $test_id = NULL) { $filter[$group_summary['#ok'] ? 'pass' : 'fail'][] = $group; } - // Overal summary status. + // Overall summary status. $form['result']['summary']['#ok'] = $form['result']['summary']['#fail'] + $form['result']['summary']['#exception'] == 0; // Actions. $form['#action'] = url('admin/config/development/testing/results/re-run'); $form['action'] = array( '#type' => 'fieldset', - '#title' => t('Actions'), + '#title' => $this->t('Actions'), '#attributes' => array('class' => array('container-inline')), '#weight' => -11, ); @@ -199,9 +198,9 @@ public function buildForm(array $form, array &$form_state, $test_id = NULL) { '#type' => 'select', '#title' => 'Filter', '#options' => array( - 'all' => t('All (@count)', array('@count' => count($filter['pass']) + count($filter['fail']))), - 'pass' => t('Pass (@count)', array('@count' => count($filter['pass']))), - 'fail' => t('Fail (@count)', array('@count' => count($filter['fail']))), + 'all' => $this->t('All (@count)', array('@count' => count($filter['pass']) + count($filter['fail']))), + 'pass' => $this->t('Pass (@count)', array('@count' => count($filter['pass']))), + 'fail' => $this->t('Fail (@count)', array('@count' => count($filter['fail']))), ), ); $form['action']['filter']['#default_value'] = ($filter['fail'] ? 'fail' : 'all'); @@ -218,12 +217,12 @@ public function buildForm(array $form, array &$form_state, $test_id = NULL) { $form['action']['op'] = array( '#type' => 'submit', - '#value' => t('Run tests'), + '#value' => $this->t('Run tests'), ); $form['action']['return'] = array( '#type' => 'link', - '#title' => t('Return to list'), + '#title' => $this->t('Return to list'), '#href' => 'admin/config/development/testing', ); @@ -234,12 +233,6 @@ public function buildForm(array $form, array &$form_state, $test_id = NULL) { return $form; } - /** - * {@inheritdoc} - */ - public function validateForm(array &$form, array &$form_state) { - } - /** * {@inheritdoc} */ diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestSettingsForm.php b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestSettingsForm.php index cce1a8a58938d1fef08c21e45cf9fd8ad9a305f5..8a59259862ec891c08b699fae54a4ab1278437f9 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestSettingsForm.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestSettingsForm.php @@ -1,4 +1,5 @@ <?php + /** * @file * Contains \Drupal\simpletest\Form\SimpletestSettingsForm. @@ -14,50 +15,50 @@ class SimpletestSettingsForm extends SystemConfigFormBase { /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc} */ public function getFormID() { return 'simpletest_settings_form'; } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { $config = $this->configFactory->get('simpletest.settings'); $form['general'] = array( '#type' => 'details', - '#title' => t('General'), + '#title' => $this->t('General'), ); $form['general']['simpletest_clear_results'] = array( '#type' => 'checkbox', - '#title' => t('Clear results after each complete test suite run'), - '#description' => t('By default SimpleTest will clear the results after they have been viewed on the results page, but in some cases it may be useful to leave the results in the database. The results can then be viewed at <em>admin/config/development/testing/results/[test_id]</em>. The test ID can be found in the database, simpletest table, or kept track of when viewing the results the first time. Additionally, some modules may provide more analysis or features that require this setting to be disabled.'), + '#title' => $this->t('Clear results after each complete test suite run'), + '#description' => $this->t('By default SimpleTest will clear the results after they have been viewed on the results page, but in some cases it may be useful to leave the results in the database. The results can then be viewed at <em>admin/config/development/testing/results/[test_id]</em>. The test ID can be found in the database, simpletest table, or kept track of when viewing the results the first time. Additionally, some modules may provide more analysis or features that require this setting to be disabled.'), '#default_value' => $config->get('clear_results'), ); $form['general']['simpletest_verbose'] = array( '#type' => 'checkbox', - '#title' => t('Provide verbose information when running tests'), - '#description' => t('The verbose data will be printed along with the standard assertions and is useful for debugging. The verbose data will be erased between each test suite run. The verbose data output is very detailed and should only be used when debugging.'), + '#title' => $this->t('Provide verbose information when running tests'), + '#description' => $this->t('The verbose data will be printed along with the standard assertions and is useful for debugging. The verbose data will be erased between each test suite run. The verbose data output is very detailed and should only be used when debugging.'), '#default_value' => $config->get('verbose'), ); $form['httpauth'] = array( '#type' => 'details', - '#title' => t('HTTP authentication'), - '#description' => t('HTTP auth settings to be used by the SimpleTest browser during testing. Useful when the site requires basic HTTP authentication.'), + '#title' => $this->t('HTTP authentication'), + '#description' => $this->t('HTTP auth settings to be used by the SimpleTest browser during testing. Useful when the site requires basic HTTP authentication.'), '#collapsed' => TRUE, ); $form['httpauth']['simpletest_httpauth_method'] = array( '#type' => 'select', - '#title' => t('Method'), + '#title' => $this->t('Method'), '#options' => array( - CURLAUTH_BASIC => t('Basic'), - CURLAUTH_DIGEST => t('Digest'), - CURLAUTH_GSSNEGOTIATE => t('GSS negotiate'), - CURLAUTH_NTLM => t('NTLM'), - CURLAUTH_ANY => t('Any'), - CURLAUTH_ANYSAFE => t('Any safe'), + CURLAUTH_BASIC => $this->t('Basic'), + CURLAUTH_DIGEST => $this->t('Digest'), + CURLAUTH_GSSNEGOTIATE => $this->t('GSS negotiate'), + CURLAUTH_NTLM => $this->t('NTLM'), + CURLAUTH_ANY => $this->t('Any'), + CURLAUTH_ANYSAFE => $this->t('Any safe'), ), '#default_value' => $config->get('httpauth.method'), ); @@ -65,25 +66,25 @@ public function buildForm(array $form, array &$form_state) { $password = $config->get('httpauth.password'); $form['httpauth']['simpletest_httpauth_username'] = array( '#type' => 'textfield', - '#title' => t('Username'), + '#title' => $this->t('Username'), '#default_value' => $username, ); if (!empty($username) && !empty($password)) { - $form['httpauth']['simpletest_httpauth_username']['#description'] = t('Leave this blank to delete both the existing username and password.'); + $form['httpauth']['simpletest_httpauth_username']['#description'] = $this->t('Leave this blank to delete both the existing username and password.'); } $form['httpauth']['simpletest_httpauth_password'] = array( '#type' => 'password', - '#title' => t('Password'), + '#title' => $this->t('Password'), ); if ($password) { - $form['httpauth']['simpletest_httpauth_password']['#description'] = t('To change the password, enter the new password here.'); + $form['httpauth']['simpletest_httpauth_password']['#description'] = $this->t('To change the password, enter the new password here.'); } return parent::buildForm($form, $form_state); } /** - * Implements \Drupal\Core\Form\FormInterface::validateForm(). + * {@inheritdoc} */ public function validateForm(array &$form, array &$form_state) { $config = $this->configFactory->get('simpletest.settings'); @@ -96,14 +97,14 @@ public function validateForm(array &$form, array &$form_state) { // If a password was provided but a username wasn't, the credentials are // incorrect, so throw an error. if (empty($form_state['values']['simpletest_httpauth_username']) && !empty($form_state['values']['simpletest_httpauth_password'])) { - form_set_error('simpletest_httpauth_username', t('HTTP authentication credentials must include a username in addition to a password.')); + form_set_error('simpletest_httpauth_username', $this->t('HTTP authentication credentials must include a username in addition to a password.')); } parent::validateForm($form, $form_state); } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $this->configFactory->get('simpletest.settings') diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestTestForm.php b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestTestForm.php index 193eefcc64ef5beecea2d279b09bfc2f7e05737f..0a756afa38f28a19bb8fec3d503553fdb303c968 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestTestForm.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestTestForm.php @@ -7,12 +7,12 @@ namespace Drupal\simpletest\Form; -use Drupal\Core\Form\FormInterface; +use Drupal\Core\Form\FormBase; /** * List tests arranged in groups that can be selected and run. */ -class SimpletestTestForm implements FormInterface { +class SimpletestTestForm extends FormBase { /** * {@inheritdoc} @@ -34,21 +34,21 @@ public function buildForm(array $form, array &$form_state) { ); $form['filters']['text'] = array( '#type' => 'search', - '#title' => t('Search'), + '#title' => $this->t('Search'), '#size' => 30, - '#placeholder' => t('Enter test name…'), + '#placeholder' => $this->t('Enter test name…'), '#attributes' => array( 'class' => array('table-filter-text'), 'data-table' => '#simpletest-test-form', 'autocomplete' => 'off', - 'title' => t('Enter at least 3 characters of the test name or description to filter by.'), + 'title' => $this->t('Enter at least 3 characters of the test name or description to filter by.'), ), ); $form['tests'] = array( '#type' => 'details', - '#title' => t('Tests'), - '#description' => t('Select the test(s) or test group(s) you would like to run, and click <em>Run tests</em>.'), + '#title' => $this->t('Tests'), + '#description' => $this->t('Select the test(s) or test group(s) you would like to run, and click <em>Run tests</em>.'), ); $form['tests']['table'] = array( @@ -77,16 +77,16 @@ public function buildForm(array $form, array &$form_state) { // Action buttons. $form['tests']['op'] = array( '#type' => 'submit', - '#value' => t('Run tests'), + '#value' => $this->t('Run tests'), ); $form['clean'] = array( '#type' => 'fieldset', - '#title' => t('Clean test environment'), - '#description' => t('Remove tables with the prefix "simpletest" and temporary directories that are left over from tests that crashed. This is intended for developers when creating tests.'), + '#title' => $this->t('Clean test environment'), + '#description' => $this->t('Remove tables with the prefix "simpletest" and temporary directories that are left over from tests that crashed. This is intended for developers when creating tests.'), ); $form['clean']['op'] = array( '#type' => 'submit', - '#value' => t('Clean environment'), + '#value' => $this->t('Clean environment'), '#submit' => array('simpletest_clean_environment'), ); @@ -122,7 +122,7 @@ public function submitForm(array &$form, array &$form_state) { $form_state['redirect'] = 'admin/config/development/testing/results/' . $test_id; } else { - drupal_set_message(t('No test(s) selected.'), 'error'); + drupal_set_message($this->t('No test(s) selected.'), 'error'); } }