public function RealnameBasicTest::testRealnameConfiguration in Real Name 8
Same name and namespace in other branches
- 2.x tests/src/Functional/RealnameBasicTest.php \Drupal\Tests\realname\Functional\RealnameBasicTest::testRealnameConfiguration()
Test realname configuration.
File
- tests/
src/ Functional/ RealnameBasicTest.php, line 59
Class
- RealnameBasicTest
- Test basic functionality of Realname module.
Namespace
Drupal\Tests\realname\FunctionalCode
public function testRealnameConfiguration() {
$assert_session = $this
->assertSession();
// Check if Configure link is available on 'Modules' page.
// Requires 'administer modules' permission.
$this
->drupalGet('admin/modules');
// Assert that the configure link from Modules page to Realname settings
// page exists.
$assert_session
->responseContains('admin/config/people/realname');
// Check for setting page's presence.
$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.'));
}