You are here

function UpdateScriptTest::testUpdateAccess in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Update/UpdateScriptTest.php \Drupal\system\Tests\Update\UpdateScriptTest::testUpdateAccess()

Tests access to the update script.

File

core/modules/system/src/Tests/Update/UpdateScriptTest.php, line 56
Contains \Drupal\system\Tests\Update\UpdateScriptTest.

Class

UpdateScriptTest
Tests the update script access and functionality.

Namespace

Drupal\system\Tests\Update

Code

function testUpdateAccess() {

  // Try accessing update.php without the proper permission.
  $regular_user = $this
    ->drupalCreateUser();
  $this
    ->drupalLogin($regular_user);
  $this
    ->drupalGet($this->updateUrl, array(
    'external' => TRUE,
  ));
  $this
    ->assertResponse(403);

  // Try accessing update.php as an anonymous user.
  $this
    ->drupalLogout();
  $this
    ->drupalGet($this->updateUrl, array(
    'external' => TRUE,
  ));
  $this
    ->assertResponse(403);

  // Access the update page with the proper permission.
  $this
    ->drupalLogin($this->updateUser);
  $this
    ->drupalGet($this->updateUrl, array(
    'external' => TRUE,
  ));
  $this
    ->assertResponse(200);

  // Access the update page as user 1.
  $this
    ->drupalLogin($this->rootUser);
  $this
    ->drupalGet($this->updateUrl, array(
    'external' => TRUE,
  ));
  $this
    ->assertResponse(200);
}