diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index ad82dd5..6f3afba 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -530,6 +530,12 @@ protected function drupalCreateUser(array $permissions = array(), $name = NULL) $edit = array(); $edit['name'] = !empty($name) ? $name : $this->getRandomGenerator()->string(8, TRUE, array($this, 'randomUsernameValidate')); $edit['mail'] = $edit['name'] . '@example.com'; + // It is possible that name + @example.com is not a valid email address + // since user names can contain whitespace and @ characters and start with a + // dot. + if (!valid_email_address($edit['mail'])) { + $edit['mail'] = $this->getRandomGenerator()->name() . '@example.com'; + } $edit['pass'] = user_password(); $edit['status'] = 1; if ($rid) {