Problem/Motivation

Checking to see how 'groups' should be used in SimpleTests, I found a few inconsistencies in the comments, whether or not $group appears as a parameter in function definitions and whether or not it has a default.

Examples:

   * @param $group
   *   The group this message belongs to.
   * @param $be_unique
   *   TRUE if this text should be found only once, FALSE if it should be found more than once.
   * @return
   *   TRUE on pass, FALSE on fail.
   */
  protected function assertUniqueTextHelper($text, $message = '', $group, $be_unique) {
   * @param $expected
   *   The expected themed output string.
   * @param $message
   *   (optional) An assertion message.
   */
  protected function assertThemeOutput($callback, array $variables = array(), $expected, $message = '') {

and even:

   * @param $message
   *   Message to display.
   * @param $group
   *   The group this message belongs to.
   * @return
   *   TRUE on pass, FALSE on fail.
   */
  protected function assertFieldByName($name, $value = NULL, $message = NULL) {

Proposed resolution

1. Comment all uses of group in TestBase.php and WebTestBase.php:
* @param $group
* (optional) The group this message belongs to, defaults to 'Other'.

2. Make sure the $group parameter is defined and used, where appropriate.

3. Document when and where the group designation should be used. (This started at #1742830: Removing t() from asserts in simpletests in contact module where the group designation is being removed for consistency.)

4. As it's so closely related, fix the doxygen comments for $message at the same time.

Remaining tasks

Prepare a patch to remove the inconsistencies.

Context issue #500866: [META] remove t() from assert message

Comments

Lars Toomre’s picture

If we get to the point of removing unnecessary group parameters (because they match the default group parameter), I would suggest looking at the tests in File, Lock and User groups.

lazysoundsystem’s picture

Okay, I thought I'd looked at this before but couldn't find the issue.

There's a patch supplied here for the issues in WebTestBase.php:
#983528: support $group and $message parameters in all assert() functions

but still it's worth documenting the best way to use the $group parameter in tests. (In that issue, the suggestion is that modules should use it, so it's easier to find out where the tests failed.)

(And as a related, but more important issue - can someone have a look at: #1706878: Add WebTestBase::assertThemeOutput() to allow modules to test theme function output)

lazysoundsystem’s picture

Status: Active » Closed (duplicate)
lazysoundsystem’s picture

Issue summary: View changes

Updated issue summary.