~davidstrauss/drupal/195416-per-connection-prefixes

« back to all changes in this revision

Viewing changes to modules/system/system.test

  • Committer: webchick
  • Date: 2009-10-09 07:48:06 UTC
  • Revision ID: vcs-imports@canonical.com-20091009074806-zn7k09yrhq5b5e6x
#67234 by Ralf, Dave Reid, David_Rothstein, Rob Loach, dww, et al: Added a permission to update.php.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
// $Id: system.test,v 1.81 2009/10/03 19:16:04 dries Exp $
 
2
// $Id: system.test,v 1.82 2009/10/09 07:48:07 webchick Exp $
3
3
 
4
4
/**
5
5
 * Helper class for module test cases.
1210
1210
    // passed properly through the call stack and being handled correctly by a 'known'
1211
1211
    // token, [node:title].
1212
1212
    $this->assertFalse(strcmp($target, $result), t('Basic placeholder tokens replaced.'));
1213
 
    
 
1213
 
1214
1214
    $raw_tokens = array('title' => '[node:title]');
1215
1215
    $generated = token_generate('node', $raw_tokens, array('node' => $node));
1216
1216
    $this->assertFalse(strcmp($generated['[node:title]'], check_plain($node->title)), t('Token sanitized.'));
1290
1290
    $this->assertEqual($parsed, $expected, t('Entire parsed .info string and expected array are identical.'));
1291
1291
  }
1292
1292
}
 
1293
 
 
1294
/**
 
1295
 * Tests for the update system functionality.
 
1296
 */
 
1297
class UpdateScriptFunctionalTest extends DrupalWebTestCase {
 
1298
  private $update_url;
 
1299
  private $update_user;
 
1300
 
 
1301
  public static function getInfo() {
 
1302
    return array(
 
1303
      'name' => 'Update functionality',
 
1304
      'description' => 'Tests the update script access and functionality.',
 
1305
      'group' => 'System',
 
1306
    );
 
1307
  }
 
1308
 
 
1309
  function setUp() {
 
1310
    parent::setUp();
 
1311
    $this->update_url = $GLOBALS['base_url'] . '/update.php';
 
1312
    $this->update_user = $this->drupalCreateUser(array('administer software updates'));
 
1313
  }
 
1314
 
 
1315
  /**
 
1316
   * Tests access to the update script.
 
1317
   */
 
1318
  function testUpdateAccess() {
 
1319
    // Try accessing update.php without the proper permission.
 
1320
    $regular_user = $this->drupalCreateUser();
 
1321
    $this->drupalLogin($regular_user);
 
1322
    $this->drupalGet($this->update_url, array('external' => TRUE));
 
1323
    $this->assertResponse(403);
 
1324
 
 
1325
    // Try accessing update.php as an anonymous user.
 
1326
    $this->drupalLogout();
 
1327
    $this->drupalGet($this->update_url, array('external' => TRUE));
 
1328
    $this->assertResponse(403);
 
1329
 
 
1330
    // Access the update page with the proper permission.
 
1331
    $this->drupalLogin($this->update_user);
 
1332
    $this->drupalGet($this->update_url, array('external' => TRUE));
 
1333
    $this->assertResponse(200);
 
1334
 
 
1335
    // Access the update page as user 1.
 
1336
    $user1 = user_load(1);
 
1337
    $user1->pass_raw = user_password();
 
1338
    require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
 
1339
    $user1->pass = user_hash_password(trim($user1->pass_raw));
 
1340
    db_query("UPDATE {users} SET pass = :pass WHERE uid = :uid", array(':pass' => $user1->pass, ':uid' => $user1->uid));
 
1341
    $this->drupalLogin($user1);
 
1342
    $this->drupalGet($this->update_url, array('external' => TRUE));
 
1343
    $this->assertResponse(200);
 
1344
  }
 
1345
}