diff --git a/lib/installlib.php b/lib/installlib.php
index 40705f1..e8d2154 100644
--- a/lib/installlib.php
+++ b/lib/installlib.php
@@ -485,6 +485,11 @@ function install_cli_database(array $options, $interactive) {
     // set up admin user password
     $DB->set_field('user', 'password', hash_internal_user_password($options['adminpass']), array('username' => 'admin'));
 
+    // set the admin user's email address if necessary
+    if (isset($options['adminemail'])) {
+        $DB->set_field('user', 'email', $options['adminemail'], array('username' => 'admin'));
+    }
+
     // rename admin username if needed
     if (isset($options['adminuser']) and $options['adminuser'] !== 'admin' and $options['adminuser'] !== 'guest') {
         $DB->set_field('user', 'username', $options['adminuser'], array('username' => 'admin'));
diff --git a/lib/phpunit/classes/util.php b/lib/phpunit/classes/util.php
index 28d7ea5..ba28e30 100644
--- a/lib/phpunit/classes/util.php
+++ b/lib/phpunit/classes/util.php
@@ -380,6 +380,7 @@ class phpunit_util extends testing_util {
         $options = array();
         $options['adminpass'] = 'admin';
         $options['shortname'] = 'phpunit';
+        $options['adminemail'] = 'root@localhost';
         $options['fullname'] = 'PHPUnit test site';
 
         install_cli_database($options, false);
