Error message
You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).function UpdateScriptFunctionalTest::testUpdateAccess
Tests access to the update script.
File
-
modules/
system/ system.test, line 2542
Class
- UpdateScriptFunctionalTest
- Tests for the update system functionality.
Code
function testUpdateAccess() {
// Try accessing update.php without the proper permission.
$regular_user = $this->drupalCreateUser ();
$this->drupalLogin ($regular_user);
$this->drupalGet ($this->update_url , array(
'external' => TRUE,
));
$this->assertResponse (403);
// Try accessing update.php as an anonymous user.
$this->drupalLogout ();
$this->drupalGet ($this->update_url , array(
'external' => TRUE,
));
$this->assertResponse (403);
// Access the update page with the proper permission.
$this->drupalLogin ($this->update_user );
$this->drupalGet ($this->update_url , array(
'external' => TRUE,
));
$this->assertResponse (200);
// Access the update page as user 1.
$user1 = user_load (1);
$user1->pass_raw = user_password ();
require_once DRUPAL_ROOT . '/' . variable_get ('password_inc', 'includes/password.inc');
$user1->pass = user_hash_password (trim ($user1->pass_raw));
db_query ("UPDATE {users} SET pass = :pass WHERE uid = :uid", array(
':pass' => $user1->pass ,
':uid' => $user1->uid,
));
$this->drupalLogin ($user1);
$this->drupalGet ($this->update_url , array(
'external' => TRUE,
));
$this->assertResponse (200);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.