557
557
$this->originalFileDirectory = file_directory_path();
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);
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),
721
// 'changed' => REQUEST_TIME,
717
722
'changed' => time(),
718
723
'format' => FILTER_FORMAT_DEFAULT,
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();
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');
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;
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);
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);
1194
// drupal_set_time_limit($this->timeLimit);
1175
1195
set_time_limit($this->timeLimit);
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.
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');
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.
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());
1220
1252
// Remove all prefixed tables (all the tables in the schema).
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);
1283
// Reset the Field API.
1284
// field_cache_clear();
1249
1286
// Rebuild caches.
1250
1287
$this->refreshVariables();
1289
// // Reset language.
1290
// $language = $this->originalLanguage;
1291
// if ($this->originalLanguageDefault) {
1292
// $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
1252
1295
// Close the CURL handler.
1253
1296
$this->curlClose();
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;
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),
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;
2562
2613
// Will pass first time during setup phase, and when verbose is TRUE.