AdminUserTest.php in Multiple E-mail Addresses 2.x
Definition of Drupal\multiple_email\Tests\AdminUserTest.
Namespace
Drupal\multiple_email\TestsFile
src/Tests/AdminUserTest.phpView source
<?php
/**
* @file
* Definition of Drupal\multiple_email\Tests\AdminUserTest.
*/
namespace Drupal\multiple_email\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Test admin user interactions with the module.
*
* @group multiple_email
*/
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.'));
}
}
Classes
Name | Description |
---|---|
AdminUserTest | Test admin user interactions with the module. |