Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* @file
* Definition of Drupal\user\Tests\UserCreateTest.
*/
namespace Drupal\user\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Test the create user administration page.
*/
class UserCreateTest extends WebTestBase {
public static function getInfo() {
return array(
'name' => 'User create',
'description' => 'Test the create user administration page.',
'group' => 'User',
);
}
/**
* Create a user through the administration interface and ensure that it
* displays in the user list.
*/
protected function testUserAdd() {
$user = $this->drupalCreateUser(array('administer users'));
$this->drupalLogin($user);
foreach (array(FALSE, TRUE) as $notify) {
$edit = array(
'name' => $this->randomName(),
'mail' => $this->randomName() . '@example.com',
'pass[pass1]' => $pass = $this->randomString(),
'pass[pass2]' => $pass,
'notify' => $notify,
);
$this->drupalPost('admin/people/create', $edit, t('Create new account'));
if ($notify) {
$this->assertText(t('A welcome message with further instructions has been e-mailed to the new user @name.', array('@name' => $edit['name'])), 'User created');
$this->assertEqual(count($this->drupalGetMails()), 1, 'Notification e-mail sent');
}
else {
$this->assertText(t('Created a new user account for @name. No e-mail has been sent.', array('@name' => $edit['name'])), 'User created');
$this->assertEqual(count($this->drupalGetMails()), 0, 'Notification e-mail not sent');
}
$this->drupalGet('admin/people');
$this->assertText($edit['name'], 'User found in list of users');
}
}
}