public function RealnameBasicTest::testRealnameConfiguration in Real Name 7
Test realname configuration.
File
- tests/
realname.test, line 49 - Test file for Realname module.
Class
- RealnameBasicTest
- Test basic functionality of Realname module.
Code
public function testRealnameConfiguration() {
// Check if Configure link is available on 'Modules' page.
// Requires 'administer modules' permission.
$this
->drupalGet('admin/modules');
$this
->assertRaw('admin/config/people/realname', '[testRealnameConfiguration]: Configure link from Modules page to Realname settings page exists.');
// Check for setting page's presence.
$this
->drupalGet('admin/config/people/realname');
$this
->assertRaw(t('Realname pattern'), '[testRealnameConfiguration]: Settings page displayed.');
// Save form with allowed token.
$edit['realname_pattern'] = '[user:name-raw]';
$this
->drupalPost('admin/config/people/realname', $edit, t('Save configuration'));
$this
->assertRaw(t('The configuration options have been saved.'), '[testRealnameConfiguration]: Settings form has been saved.');
// Check if Configure link is available on 'Status Reports' page.
// Requires 'administer site configuration' permission.
$this
->drupalGet('admin/reports/status');
$this
->assertRaw(t('E-mail: "Welcome (new user created by administrator)" template'), '[testRealnameConfiguration]: "Welcome (new user created by administrator)" template warning shown.');
$this
->assertRaw(t('E-mail: "Welcome (no approval required)" template'), '[testRealnameConfiguration]: "Welcome (no approval required)" template warning shown.');
$this
->assertRaw(t('E-mail: "Account activation" template'), '[testRealnameConfiguration]: "Account activation" template warning shown.');
// Save form with allowed token.
$edit['realname_pattern'] = '[user:name-raw]';
$edit['realname_suppress_user_name_mail_validation'] = TRUE;
$this
->drupalPost('admin/config/people/realname', $edit, t('Save configuration'));
$this
->assertRaw(t('The configuration options have been saved.'), '[testRealnameConfiguration]: Settings form has been saved.');
// Test suppress missing token warning in e-mail templates.
$this
->drupalGet('admin/reports/status');
$this
->assertNoRaw(t('E-mail: "Welcome (new user created by administrator)" template'), '[testRealnameConfiguration]: "Welcome (new user created by administrator)" template warning shown.');
$this
->assertNoRaw(t('E-mail: "Welcome (no approval required)" template'), '[testRealnameConfiguration]: "Welcome (no approval required)" template warning shown.');
$this
->assertNoRaw(t('E-mail: "Account activation" template'), '[testRealnameConfiguration]: "Account activation" template warning shown.');
// Check token recursion protection.
$edit['realname_pattern'] = '[user:name]';
$this
->drupalPost('admin/config/people/realname', $edit, t('Save configuration'));
$this
->assertRaw(t('The %token token cannot be used as it will cause recursion.', array(
'%token' => '[user:name]',
)), '[testRealnameConfiguration]: Invalid token found.');
}