t() should not be used in test classes

Created on 11 May 2023, about 1 year ago
Updated 31 July 2023, 11 months ago

The code in the RealnameBasicTest.php file is calling t(), when test classes should not use translated strings.

$this->drupalGet('admin/config/people/realname');
// Assert the settings page is displayed.
$assert_session->pageTextContains(t('Realname pattern'));

// Save form with allowed token.
$edit['realname_pattern'] = '[user:account-name]';
$this->drupalGet('admin/config/people/realname');
$this->submitForm($edit, 'Save configuration');

$this->drupalGet('admin/config/people/realname');
$this->submitForm($edit, 'Save configuration');

// Assert that the settings form has been saved.
$assert_session->pageTextContains(t('The configuration options have been saved.'));

// Check token recursion protection.
$edit['realname_pattern'] = '[user:name]';
$this->drupalGet('admin/config/people/realname');
$this->submitForm($edit, 'Save configuration');
// Assert that an invalid token is found.
$assert_session->pageTextContains(t('The [user:name] token cannot be used as it will cause recursion.'));

Those t() calls need to be removed.

๐Ÿ“Œ Task
Status

Needs review

Version

2.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia yashmalviya

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024