~catch-drupal/+junk/pressflow-content-cache-variable

« back to all changes in this revision

Viewing changes to modules/simpletest/drupal_web_test_case.php

  • Committer: David Strauss
  • Date: 2010-06-23 21:02:47 UTC
  • mfrom: (82.1.7 merge-drupal-6.17)
  • Revision ID: david@fourkitchens.com-20100623210247-ggd9fi82dyiayz98
Merge changes from the 6.17 branch that were intended for the mainline.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
// $Id: drupal_web_test_case.php,v 1.2.2.3.2.43 2009/09/14 23:22:56 boombatower Exp $
 
2
// $Id: drupal_web_test_case.php,v 1.2.2.3.2.46 2009/11/06 21:23:32 boombatower Exp $
3
3
// Core: Id: drupal_web_test_case.php,v 1.146 2009/08/31 18:30:26 webchick Exp $
4
4
 
5
5
/**
557
557
    $this->originalFileDirectory = file_directory_path();
558
558
 
559
559
    // Generate temporary prefixed database to ensure that tests have a clean starting point.
560
 
    $db_prefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
561
 
    $conf['file_public_path'] = $this->originalFileDirectory . '/' . $db_prefix;
 
560
//    $db_prefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
 
561
    $db_prefix = $db_prefix . 'simpletest' . mt_rand(1000, 1000000);
 
562
//    $conf['file_public_path'] = $this->originalFileDirectory . '/' . $db_prefix;
 
563
    $conf['file_directory_path'] = $this->originalFileDirectory . '/simpletest/' . substr($db_prefix, 10);
562
564
 
563
565
    // If locale is enabled then t() will try to access the database and
564
566
    // subsequently will fail as the database is not accessible.
573
575
  function tearDown() {
574
576
    global $db_prefix, $conf;
575
577
    if (preg_match('/simpletest\d+/', $db_prefix)) {
576
 
      $conf['file_public_path'] = $this->originalFileDirectory;
 
578
//      $conf['file_public_path'] = $this->originalFileDirectory;
 
579
      $conf['file_directory_path'] = $this->originalFileDirectory;
577
580
      // Return the database prefix to the original.
578
581
      $db_prefix = $this->originalPrefix;
579
582
      // Restore modules if necessary.
711
714
  protected function drupalCreateNode($settings = array()) {
712
715
    // Populate defaults array.
713
716
    $settings += array(
 
717
//      'body'      => array(FIELD_LANGUAGE_NONE => array(array())),
714
718
      'body'      => $this->randomName(32),
715
719
      'title'     => $this->randomName(8),
716
720
      'comment'   => 2,
 
721
//      'changed'   => REQUEST_TIME,
717
722
      'changed'   => time(),
718
723
      'format'    => FILTER_FORMAT_DEFAULT,
719
724
      'moderate'  => 0,
1158
1163
 
1159
1164
    // Restore necessary variables.
1160
1165
    variable_set('install_profile', 'default');
 
1166
//    variable_set('install_task', 'done');
1161
1167
    variable_set('install_task', 'profile-finished');
1162
1168
    variable_set('clean_url', $clean_url_original);
1163
1169
    variable_set('site_mail', 'simpletest@example.com');
1164
 
    variable_set('smtp_library', drupal_get_path('module', 'simpletest') . '/simpletest.test');
 
1170
//    // Set up English language.
 
1171
//    unset($GLOBALS['conf']['language_default']);
 
1172
//    $language = language_default();
 
1173
 
 
1174
    // Use the test mail class instead of the default mail handler class.
 
1175
//    variable_set('mail_sending_system', array('default-system' => 'TestingMailSystem'));
 
1176
    variable_set('smtp_library', drupal_get_path('module', 'simpletest') . '/simpletest.mail.inc');
1165
1177
 
1166
1178
    // Use temporary files directory with the same prefix as the database.
 
1179
//    $public_files_directory  = $this->originalFileDirectory . '/' . $db_prefix;
 
1180
//    $private_files_directory = $public_files_directory . '/private';
1167
1181
    $directory = $this->originalFileDirectory . '/' . $db_prefix;
1168
1182
 
1169
1183
    // Set path variables
 
1184
//    variable_set('file_public_path', $public_files_directory);
 
1185
//    variable_set('file_private_path', $private_files_directory);
1170
1186
    variable_set('file_directory_path', $directory);
1171
1187
 
1172
1188
    // Create the directories
 
1189
//    $directory = file_directory_path('public');
 
1190
//    file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
 
1191
//    file_prepare_directory($private_files_directory, FILE_CREATE_DIRECTORY);
1173
1192
    file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
1174
1193
 
 
1194
//    drupal_set_time_limit($this->timeLimit);
1175
1195
    set_time_limit($this->timeLimit);
1176
1196
  }
1177
1197
 
 
1198
//  /**
 
1199
//   * This method is called by DrupalWebTestCase::setUp, and preloads the
 
1200
//   * registry from the testing site to cut down on the time it takes to
 
1201
//   * setup a clean environment for the current test run.
 
1202
//   */
 
1203
//  protected function preloadRegistry() {
 
1204
//    db_query('INSERT INTO {registry} SELECT * FROM ' . $this->originalPrefix . 'registry');
 
1205
//    db_query('INSERT INTO {registry_file} SELECT * FROM ' . $this->originalPrefix . 'registry_file');
 
1206
//  }
 
1207
 
1178
1208
  /**
1179
1209
   * Refresh the in-memory set of variables. Useful after a page request is made
1180
1210
   * that changes a variable in a different thread.
1190
1220
  protected function refreshVariables() {
1191
1221
    global $conf;
1192
1222
    cache_clear_all('variables', 'cache');
 
1223
//    $conf = variable_initialize();
1193
1224
    $conf = variable_init();
1194
1225
  }
1195
1226
 
1215
1246
 
1216
1247
    if (preg_match('/simpletest\d+/', $db_prefix)) {
1217
1248
      // Delete temporary files directory.
 
1249
//      file_unmanaged_delete_recursive(file_directory_path());
1218
1250
      simpletest_clean_temporary_directory(file_directory_path());
1219
1251
 
1220
1252
      // Remove all prefixed tables (all the tables in the schema).
1229
1261
 
1230
1262
      // Return the user to the original one.
1231
1263
      $user = $this->originalUser;
 
1264
//      drupal_save_session(TRUE);
1232
1265
      session_save_session(TRUE);
1233
1266
 
1234
1267
      // Bring back default language. (Drupal 6)
1244
1277
      // Reload module list and implementations to ensure that test module hooks
1245
1278
      // aren't called after tests.
1246
1279
      module_list(TRUE);
 
1280
//      module_implements('', FALSE, TRUE);
1247
1281
      module_implements('', '', TRUE);
1248
1282
 
 
1283
      // Reset the Field API.
 
1284
//      field_cache_clear();
 
1285
 
1249
1286
      // Rebuild caches.
1250
1287
      $this->refreshVariables();
1251
1288
 
 
1289
//      // Reset language.
 
1290
//      $language = $this->originalLanguage;
 
1291
//      if ($this->originalLanguageDefault) {
 
1292
//        $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
 
1293
//      }
 
1294
 
1252
1295
      // Close the CURL handler.
1253
1296
      $this->curlClose();
1254
1297
    }
1492
1535
            // is broken. This is a less than elegant workaround. Alternatives
1493
1536
            // are being explored at #253506.
1494
1537
            foreach ($upload as $key => $file) {
 
1538
//              $file = drupal_realpath($file);
1495
1539
              $file = realpath($file);
1496
1540
              if ($file && is_file($file)) {
1497
1541
                $post[$key] = '@' . $file;
1962
2006
 
1963
2007
    foreach ($captured_emails as $message) {
1964
2008
      foreach ($filter as $key => $value) {
 
2009
//        if (!isset($message[$key]) || $message[$key] != $value) {
1965
2010
        if (!isset($message['params'][$key]) || $message['params'][$key] != $value) {
1966
2011
          continue 2;
1967
2012
        }
2516
2561
  protected function assertMail($name, $value = '', $message = '') {
2517
2562
    $captured_emails = variable_get('drupal_test_email_collector', array());
2518
2563
    $email = end($captured_emails);
2519
 
    return $this->assertTrue($email && isset($email['params'][$name]) && $email['params'][$name] == $value, $message, t('E-mail'));
 
2564
//    return $this->assertTrue($email && isset($email[$name]) && $email[$name] == $value, $message, t('E-mail'));
 
2565
    return $this->assertTrue(
 
2566
      ($email && isset($email[$name]) && $email[$name] == $value) ||
 
2567
      ($email && isset($email['params'][$name]) && $email['params'][$name] == $value),
 
2568
      $message,
 
2569
      t('E-mail'));
2520
2570
  }
2521
2571
 
2522
2572
  /**
2557
2607
 */
2558
2608
function simpletest_verbose($message, $original_file_directory = NULL, $test_class = NULL) {
2559
2609
  static $file_directory = NULL, $class = NULL, $id = 1;
 
2610
//  $verbose = &drupal_static(__FUNCTION__);
2560
2611
  static $verbose;
2561
2612
 
2562
2613
  // Will pass first time during setup phase, and when verbose is TRUE.
2575
2626
    $class = $test_class;
2576
2627
    $verbose = variable_get('simpletest_verbose', FALSE);
2577
2628
    $directory = $file_directory . '/simpletest/verbose';
 
2629
//    return file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
2578
2630
    return file_check_directory($directory, FILE_CREATE_DIRECTORY);
2579
2631
  }
2580
2632
  return FALSE;