drupal_set_message(t('No test(s) selected.'), 'error');
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hass’s picture

Title: Plural form is missing. » format_plural is missing
hass’s picture

Strings is not context sensitive:

'init_message' => t('SimpleTest is initializing...') . ' ' . format_plural(count($test_list), "one test case will run.", "@count test cases will run."),
hass’s picture

format_plural is missing for situation where we only have one stale table:

drupal_set_message(t('Removed @count left over tables.', array('@count' => count($ret))));
hass’s picture

Same again:

drupal_set_message(t('Removed @count temporary directories.', array('@count' => $count)));
hass’s picture

drupal_set_message(t('Removed @count test results.', array('@count' => $count)));
hass’s picture

Maybe we have only ONE test:

  if ($success) {
    drupal_set_message(t('The tests have finished running.'));
  }
  else {
    drupal_set_message(t('The tests did not successfully finish.'), 'error');
  }
boombatower’s picture

Project: SimpleTest » Drupal core
Version: 6.x-2.5 » 7.x-dev
Component: Code » simpletest.module
Category: bug » task
Priority: Normal » Minor

...unltra minor, please provide a patch for core and then this can be backported.

webchick’s picture

Issue tags: +Novice
JamesAn’s picture

FileSize
3.06 KB

#2 seems to no longer be in the HEAD.

The fix for #6 is more involved as I needed to fetch the test results from the db using the test_id and count them. The counting mirrors how the test summary is aggregated in simpletest_test_form(), in a simplified way.

JamesAn’s picture

Status: Active » Needs review

I swear I flipped the switch just now.. =\

hass’s picture

What about the singular of drupal_set_message(t('No tests selected.'), 'error');?

JamesAn’s picture

FileSize
3.39 KB

I didn't think the singular of drupal_set_message(t('No tests selected.'), 'error'); would ever be used. That message is only displayed when no tests are selected. Zero is conventionally placed in the plural form: you say, "I have 0 items," not "I have 0 item."

But according to wiki (http://en.wikipedia.org/wiki/Plural#Zero), English uses the plural form for zero, but not all languages do that. For example, French uses the singular form for zero: they say, "j'ai 0 élément."

I've fixed another error message is displayed when no test cases are found (which happens also when no tests are selected):
drupal_set_message('No test cases found.', 'error');. It was also missing the t() function.

Status: Needs review » Needs work

The last submitted patch failed testing.

JamesAn’s picture

Status: Needs work » Needs review
FileSize
2.37 KB

The patch has been updated against the intervening changes to simpletest.module.

The code in #6 has been changed to use "test(s)" instead of "tests" to show that one test is possible. The patch in #12 actually counts the number of tests performed to run the statement through format_plural. It felt inappropriate to do all that processing just to decide whether or not to pluralize the statement.

Damien Tournoud’s picture

Status: Needs review » Needs work
 function _simpletest_batch_finished($success, $results, $operations, $elapsed) {
   if ($success) {
-    drupal_set_message(t('The tests finished in @elapsed.', array('@elapsed' => $elapsed)));
+    drupal_set_message(t('The test(s) finished in @elapsed.', array('@elapsed' => $elapsed)));
   }
   else {
-    drupal_set_message(t('The tests did not successfully finish.'), 'error');
+    drupal_set_message(t('The test(s) did not successfully finish.'), 'error');
   }
   module_invoke_all('test_group_finished');
 }

I suggest to replace "The test(s)" by "The test run", which is slightly less ugly.

   if (count($classes) == 0) {
-    drupal_set_message('No test cases found.', 'error');
+    drupal_set_message(format_plural(0, 'No test case found.', 'No test cases found.'), 'error');
     return FALSE;
   }
   return $classes;

This change serves no purpose: format_plural() is only useful when the translation can actually change, which is not the case here. The fact that the grammar might be different between languages is perfectly irrelevant.

   if (count($ret) > 0) {
-    drupal_set_message(t('Removed @count left over tables.', array('@count' => count($ret))));
+    drupal_set_message(format_plural(count($ret), 'Removed 1 left over table.', 'Removed @count left over tables.'));
   }

Shouldn't that be "left-over", instead of "left over"?

hass’s picture

format_plural() is only useful when the translation can actually change

Cannot follow... in German I would translate 'No test case found.' to "Es wurde kein Testfall gefunden" and 'No test cases found.' to "Es wurden keine Testfälle gefunden". If there is no plural form we are not able to translate correctly. Code looks absolutely correct.

'The test(s) finished in @elapsed.' is not good - it need to become 'The test finished in @elapsed.' and 'The tests finished in @elapsed.' to translate to "Der Test wurde abgeschlossen in @elapsed" and "Die Tests wurden abgeschlossen in @elapsed" (German).

Damien Tournoud’s picture

@hass: the English sentence "No test cases found" is absolutely not ambiguous. It means that 0 test cases have been found. You will translate it using the correct form in German. In French, it will become "Aucun cas de test n'a été trouvé", using a singular form.

About the ugly "The test(s)", please see my proposal above.

hass’s picture

Ups, I missed (count($classes) == 0)... sorry

JamesAn’s picture

Status: Needs work » Needs review
FileSize
2.37 KB

Oops indeed. I didn't think much about my use of format_plural() for zero either. XD

I like your suggestion of "test run". It removes the need to consider singular and plural cases since a test run is always singular regardless of the number of tests being done.

Doing some digging around about "left over" vs. "left-over" vs. "leftover", I didn't find very much on the usage of "left-over". It seemed that "leftover" is more common than "left over" as an adjective. "left over" tends to be used in the verb form, i.e., the tables were left over from the test crash.

I found a Wiktionary entry saying that "leftover" is preferred over "left over" when used as an adjective. Unfortunately, there's no citation and I couldn't find the source of that tidbit.

http://en.wiktionary.org/wiki/leftover
http://en.wiktionary.org/wiki/left_over
http://dictionary.reference.com/browse/leftover
http://dictionary.reference.com/browse/left%20over

----------------

In this patch, I've

  • replaced test(s) with test run,
  • removed that instance of format_plural(), and
  • changed all adjective instances of "left over" to "leftover".
Dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks!

Status: Fixed » Closed (fixed)
Issue tags: -Novice

Automatically closed -- issue fixed for 2 weeks with no activity.