diff --git a/core/modules/simpletest/src/Form/SimpletestResultsForm.php b/core/modules/simpletest/src/Form/SimpletestResultsForm.php index 054b405..9ddc451 100644 --- a/core/modules/simpletest/src/Form/SimpletestResultsForm.php +++ b/core/modules/simpletest/src/Form/SimpletestResultsForm.php @@ -12,7 +12,6 @@ use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormState; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\Core\Url; use Drupal\simpletest\TestDiscovery; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -20,6 +19,12 @@ /** * Test results form for $test_id. + * + * Note that the UI strings are not translated because this form is also used + * from run-tests.sh. + * + * @see simpletest_script_open_browser() + * @see run-tests.sh */ class SimpletestResultsForm extends FormBase { @@ -59,35 +64,34 @@ public function __construct(Connection $database) { /** * Builds the status image map. */ - protected static function buildStatusImageMap(TranslationInterface $translation) { - // Initialize image mapping property. + protected static function buildStatusImageMap() { $image_pass = array( '#theme' => 'image', '#uri' => 'core/misc/icons/73b355/check.svg', '#width' => 18, '#height' => 18, - '#alt' => $translation->translate('Pass'), + '#alt' => 'Pass', ); $image_fail = array( '#theme' => 'image', '#uri' => 'core/misc/icons/ea2800/error.svg', '#width' => 18, '#height' => 18, - '#alt' => $translation->translate('Fail'), + '#alt' => 'Fail', ); $image_exception = array( '#theme' => 'image', '#uri' => 'core/misc/icons/e29700/warning.svg', '#width' => 18, '#height' => 18, - '#alt' => $translation->translate('Exception'), + '#alt' => 'Exception', ); $image_debug = array( '#theme' => 'image', '#uri' => 'core/misc/icons/e29700/warning.svg', '#width' => 18, '#height' => 18, - '#alt' => $translation->translate('Debug'), + '#alt' => 'Debug', ); return array( 'pass' => drupal_render($image_pass), @@ -232,20 +236,22 @@ protected function getResults($test_id) { * Adds the result form to a $form. * * This is a static method so that run-tests.sh can use it to generate a - * results page completely external to Drupal. + * results page completely external to Drupal. This is why the UI strings are + * not wrapped in t(). * * @param array $form * The form to attach the results to. * @param array $test_results * The simpletest results. - * @param \Drupal\Core\StringTranslation\TranslationInterface $translation - * The string translation service. * * @return array * A list of tests the passed and failed. The array has two keys, 'pass' and * 'fail'. Each contains a list of test classes. + * + * @see simpletest_script_open_browser() + * @see run-tests.sh */ - public static function addResultForm(array &$form, array $results, TranslationInterface $translation) { + public static function addResultForm(array &$form, array $results) { // Transform the test results to be grouped by test class. $test_results = array(); foreach ($results as $result) { @@ -255,7 +261,7 @@ public static function addResultForm(array &$form, array $results, TranslationIn $test_results[$result->test_class][] = $result; } - $image_status_map = static::buildStatusImageMap($translation); + $image_status_map = static::buildStatusImageMap(); // Keep track of which test cases passed or failed. $filter = array( @@ -266,7 +272,7 @@ public static function addResultForm(array &$form, array $results, TranslationIn // Summary result widget. $form['result'] = array( '#type' => 'fieldset', - '#title' => $translation->translate('Results'), + '#title' => 'Results', // Because this is used in a theme-less situation need to provide a // default. '#attributes' => array(), @@ -283,12 +289,12 @@ public static function addResultForm(array &$form, array $results, TranslationIn // Cycle through each test group. $header = array( - $translation->translate('Message'), - $translation->translate('Group'), - $translation->translate('Filename'), - $translation->translate('Line'), - $translation->translate('Function'), - array('colspan' => 2, 'data' => $translation->translate('Status')) + 'Message', + 'Group', + 'Filename', + 'Line', + 'Function', + array('colspan' => 2, 'data' => 'Status') ); $form['result']['results'] = array(); foreach ($test_results as $group => $assertions) { diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index eb0fa55..f5c5b74 100644 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -1197,17 +1197,21 @@ function simpletest_script_open_browser() { ->fetchAll(); // Generate html results. $form = array(); - SimpletestResultsForm::addResultForm($form, $results, \Drupal::service('string_translation')); + SimpletestResultsForm::addResultForm($form, $results); $html = '
' . drupal_render($form) .''; - $uuid = new Php(); + + // Ensure we have a verbose directory - tests with no verbose output will not + // have created one. $directory = PublicStream::basePath() . '/simpletest/verbose'; file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); + $uuid = new Php(); $filename = $directory .'/results-'. $uuid->generate() .'.html'; file_put_contents($filename, $html); + // See if we can find an OS helper to open URLs in default browser. if (shell_exec('which xdg-open')) { $browser = 'xdg-open';