class AdminUserTest in Multiple E-mail Addresses 2.x
Test admin user interactions with the module.
@group multiple_email
Hierarchy
- class \Drupal\multiple_email\Tests\AdminUserTest extends \Drupal\simpletest\WebTestBase
Expanded class hierarchy of AdminUserTest
File
- src/
Tests/ AdminUserTest.php, line 17 - Definition of Drupal\multiple_email\Tests\AdminUserTest.
Namespace
Drupal\multiple_email\TestsView source
class AdminUserTest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array(
'multiple_email',
);
protected function setUp() {
// Set up basic Drupal install.
parent::setUp();
// Create a user allowed to administer users.
$this->adminuser = $this
->drupalCreateUser(array(
'administer users',
'administer multiple emails',
));
$this->basicuser = $this
->drupalCreateUser();
$this
->drupalLogin($this->adminuser);
}
/**
* Test that the Multiple E-mails user can add a new e-mail address.
*/
public function testMultipleEmailsAdminUser() {
// Test settings page is accessable
$this
->drupalGet('admin/config/people/multiple-email');
$this
->assertText(t('Multiple E-mails'));
$this
->drupalPostForm('admin/config/people/multiple-email', array(), t('Save configuration'));
$this
->assertText(t('The configuration options have been saved.'));
// Test management of other users' multiple emails
$this
->drupalGet('user/' . $this->basicuser
->id() . '/edit/email-addresses');
$email = multiple_email_find_address($this->basicuser
->getEmail());
// Check for access denied on the edit form
$this
->drupalGet('user/' . $this->basicuser
->id() . '/edit/email-addresses/edit/' . $email->eid);
$this
->assertText(t('Access denied'), t('No access to edit form.'));
// Submit the basicuser edit form
$this
->drupalPostForm('user/' . $this->basicuser
->id() . '/edit', array(), t('Save'));
$this
->assertText(t('The changes have been saved.'));
// Submit the basicuser edit form with a new e-mail address
$new_email = $this
->randomMachineName() . '@example.com';
$edit = array(
'mail' => $new_email,
);
$this
->drupalPostForm('user/' . $this->basicuser
->id() . '/edit', $edit, t('Save'));
$this
->assertRaw(t('The changes have been saved.'));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AdminUserTest:: |
public static | property | Modules to enable. | |
AdminUserTest:: |
protected | function | ||
AdminUserTest:: |
public | function | Test that the Multiple E-mails user can add a new e-mail address. |