diff --git a/includes/common.inc b/includes/common.inc index 613596ffa0b372b416147afa1ade66b283d9cdb7..e8734e0c57e477d8784f4fbd65ae7f8f8d49513b 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -807,20 +807,16 @@ function drupal_http_request($url, array $options = array()) { $result = new stdClass(); - // Parse the URL and make sure we can handle the schema. - $uri = @parse_url($url); - - if ($uri == FALSE) { + // Validate the passed URL. FILTER_VALIDATE_URL uses parse_url() internally, + // but unlike parse_url() itself, it will not throw a run-time notice for + // bogus URLs. + if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) { $result->error = 'unable to parse URL'; $result->code = -1001; return $result; } - if (!isset($uri['scheme'])) { - $result->error = 'missing schema'; - $result->code = -1002; - return $result; - } + $uri = parse_url($url); timer_start(__FUNCTION__); diff --git a/includes/stream_wrappers.inc b/includes/stream_wrappers.inc index c58c58231136f428f0b699ccc6f21d7bb974c624..bfbe528b443b9ec5c997bb96df2a8d3a69631257 100644 --- a/includes/stream_wrappers.inc +++ b/includes/stream_wrappers.inc @@ -500,7 +500,12 @@ public function rmdir($uri, $options) { public function url_stat($uri, $flags) { $this->uri = $uri; if ($flags & STREAM_URL_STAT_QUIET) { - return @stat($this->getLocalPath()); + if (file_exists($this->getLocalPath())) { + return stat($this->getLocalPath()); + } + else { + return FALSE; + } } else { return stat($this->getLocalPath()); diff --git a/modules/comment/comment.test b/modules/comment/comment.test index 047cb91b390fdfb3738c94befc775fdf7aeee6a6..60c4b3142e37a32274eed0e35d6bbf3863339ed2 100644 --- a/modules/comment/comment.test +++ b/modules/comment/comment.test @@ -21,8 +21,11 @@ class CommentHelperCase extends DrupalWebTestCase { * @param string $comment Comment body. * @param string $subject Comment subject. * @param mixed $contact Set to NULL for no contact info, TRUE to ignore success checking, and array of values to set contact info. + * + * This needs to be static to be invoked via CommentHelperCase::postComment() + * in other tests. */ - function postComment($node, $comment, $subject = '', $contact = NULL) { + public static function postComment($node, $comment, $subject = '', $contact = NULL) { $edit = array(); $edit['comment'] = $comment; diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.module b/modules/field/modules/field_sql_storage/field_sql_storage.module index 20ccc690b75d50f0bada925c2e7910969875c834..c7c7d7b104a9420d3aa1b9c478b25d9d08a1f6f2 100644 --- a/modules/field/modules/field_sql_storage/field_sql_storage.module +++ b/modules/field/modules/field_sql_storage/field_sql_storage.module @@ -487,7 +487,11 @@ function field_sql_storage_field_storage_query($field_id, $conditions, $options) foreach ($conditions as $condition) { // A condition is either a (column, value, operator) triple, or a // (column, value) pair with implied operator. - @list($column, $value, $operator) = $condition; + list($column, $value) = $condition; + $operator = NULL; + if (isset($condition[2])) { + $operator = $condition[2]; + } // Translate operator and value if needed. switch ($operator) { case 'STARTS_WITH': diff --git a/modules/field/modules/list/list.test b/modules/field/modules/list/list.test index 684b60ec366064f6d0fabaae174eaa020c941248..a954fde92df6d321e555b666ba34e4b6d36ecbb4 100644 --- a/modules/field/modules/list/list.test +++ b/modules/field/modules/list/list.test @@ -91,32 +91,28 @@ class ListFieldTestCase extends DrupalWebTestCase { /** * List module UI tests. */ -class ListFieldUITestCase extends DrupalWebTestCase { - public static function getInfo() { +class ListFieldUITestCase extends FieldUITestCase { + public static function getInfo() { return array( 'name' => 'List field UI tests', 'description' => 'Test the List field UI functionality.', 'group' => 'Field types', ); } - - function setUp() { - FieldUITestCase::setUp(); - } - + /** * Tests that allowed values are properly validated in the UI. */ function testAllowedValues() { $element_name = "field[settings][allowed_values]"; - + //Test 'List' field type. $admin_path = $this->createListFieldAndEdit('list'); //Check that non-integer keys are rejected. $edit = array($element_name => "1.1|one\n"); $this->drupalPost($admin_path, $edit, t('Save settings')); $this->assertText("keys must be integers", t('Form vaildation failed.')); - + // Test 'List (number)' field type. $admin_path = $this->createListFieldAndEdit('list_number'); //Check that non-numeric keys are rejected. diff --git a/modules/field/tests/field.test b/modules/field/tests/field.test index a0290c1ebcdd1d4495d003b2e55073b375cc2f03..286d1a4930c841bba4ad49cc96a8ef0242eb2ff5 100644 --- a/modules/field/tests/field.test +++ b/modules/field/tests/field.test @@ -17,8 +17,9 @@ class FieldTestCase extends DrupalWebTestCase { */ function setUp() { // Call parent::setUp(). + // @see http://www.php.net/manual/en/function.call-user-func-array.php#73105 $args = func_get_args(); - call_user_func_array(array('parent', 'setUp'), $args); + call_user_func_array(array($this, 'parent::setUp'), $args); // Set default storage backend. variable_set('field_storage_default', $this->default_storage); } diff --git a/modules/filter/filter.module b/modules/filter/filter.module index 71f5c4c50b6e79d4f107c134b95fafb26fda7636..b552b7c2c5936f8526a6f00b36cd52eea6aa71ab 100644 --- a/modules/filter/filter.module +++ b/modules/filter/filter.module @@ -468,7 +468,8 @@ function filter_default_format($account = NULL) { } // Get a list of formats for this user, ordered by weight. The first one // available is the user's default format. - $format = array_shift(filter_formats($account)); + $formats = filter_formats($account); + $format = reset($formats); return $format->format; } @@ -825,10 +826,12 @@ function _filter_tips($format_id, $long = FALSE) { * A DOMDocument that represents the loaded (X)HTML snippet. */ function filter_dom_load($text) { - // Ignore warnings during HTML soup loading. - $dom_document = @DOMDocument::loadHTML('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body>' . $text . '</body></html>'); + // Suppress all libxml warnings during loading of HTML. + libxml_use_internal_errors(TRUE); + $document = new DOMDocument(); + $document->loadHTML('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body>' . $text . '</body></html>'); - return $dom_document; + return $document; } /** diff --git a/modules/image/image.test b/modules/image/image.test index ccac5d5ec60d689cc3fd69362b9d1d13dd64f0b8..29d674b81a18e9200f364bd9db1e1bebee2f3fa8 100644 --- a/modules/image/image.test +++ b/modules/image/image.test @@ -84,14 +84,17 @@ class ImageStylesPathAndUrlUnitTest extends DrupalWebTestCase { // Make the default scheme neither "public" nor "private" to verify the // functions work for other than the default scheme. variable_set('file_default_scheme', 'temporary'); - file_prepare_directory($d = 'temporary://', FILE_CREATE_DIRECTORY); + $d = 'temporary://'; + file_prepare_directory($d, FILE_CREATE_DIRECTORY); // Create the directories for the styles. - $status = file_prepare_directory($d = $scheme . '://styles/' . $this->style_name, FILE_CREATE_DIRECTORY); + $d = $scheme . '://styles/' . $this->style_name; + $status = file_prepare_directory($d, FILE_CREATE_DIRECTORY); $this->assertNotIdentical(FALSE, $status, t('Created the directory for the generated images for the test style.' )); // Create a working copy of the file. - $file = reset($this->drupalGetTestFiles('image')); + $files = $this->drupalGetTestFiles('image'); + $file = reset($files); $image_info = image_get_info($file->uri); $original_uri = file_unmanaged_copy($file->uri, $scheme . '://', FILE_EXISTS_RENAME); $this->assertNotIdentical(FALSE, $original_uri, t('Created the generated image file.')); @@ -273,7 +276,8 @@ class ImageAdminStylesUnitTest extends DrupalWebTestCase { // First, we need to make sure we have an image in our testing // file directory. Copy over an image on the first run. if (!isset($file_path)) { - $file = reset($this->drupalGetTestFiles('image')); + $files = $this->drupalGetTestFiles('image'); + $file = reset($files); $file_path = file_unmanaged_copy($file->uri); } diff --git a/modules/locale/locale.install b/modules/locale/locale.install index 78a0a564d70449076b934bcb1bf3a6140d7716f6..fc8307ad9cafc3e70b6fd3a873b4aae4a447f70d 100644 --- a/modules/locale/locale.install +++ b/modules/locale/locale.install @@ -100,7 +100,9 @@ function locale_uninstall() { } } // Delete the JavaScript translations directory if empty. - @rmdir($locale_js_directory); + if (!file_scan_directory($locale_js_directory, '/.*/')) { + rmdir($locale_js_directory); + } // Clear variables. variable_del('language_default'); diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 59413e5846ff42c6acd477afba0438b6fdf2b126..09c1923768829b46b7056e1edb5eaa13649012f2 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -424,29 +424,26 @@ public function run() { } /** - * Handle errors. + * Handle errors during test runs. * * Because this is registered in set_error_handler(), it has to be public. * @see set_error_handler - * */ public function errorHandler($severity, $message, $file = NULL, $line = NULL) { - if ($severity & error_reporting()) { - $error_map = array( - E_STRICT => 'Run-time notice', - E_WARNING => 'Warning', - E_NOTICE => 'Notice', - E_CORE_ERROR => 'Core error', - E_CORE_WARNING => 'Core warning', - E_USER_ERROR => 'User error', - E_USER_WARNING => 'User warning', - E_USER_NOTICE => 'User notice', - E_RECOVERABLE_ERROR => 'Recoverable error', - ); + $error_map = array( + E_STRICT => 'Run-time notice', + E_WARNING => 'Warning', + E_NOTICE => 'Notice', + E_CORE_ERROR => 'Core error', + E_CORE_WARNING => 'Core warning', + E_USER_ERROR => 'User error', + E_USER_WARNING => 'User warning', + E_USER_NOTICE => 'User notice', + E_RECOVERABLE_ERROR => 'Recoverable error', + ); - $backtrace = debug_backtrace(); - $this->error($message, $error_map[$severity], _drupal_get_last_caller($backtrace)); - } + $backtrace = debug_backtrace(); + $this->error($message, $error_map[$severity], _drupal_get_last_caller($backtrace)); return TRUE; } @@ -532,13 +529,18 @@ function __construct($test_id = NULL) { $this->skipClasses[__CLASS__] = TRUE; } - function setUp() { + protected function setUp() { global $db_prefix, $conf; // Store necessary current values before switching to prefixed database. $this->originalPrefix = $db_prefix; $this->originalFileDirectory = file_directory_path(); + // Log fatal errors. + ini_set('log_errors', 1); + // Make all errors visible. + error_reporting(E_ALL); + // Reset all statics so that test is performed with a clean environment. drupal_static_reset(); @@ -556,7 +558,7 @@ function setUp() { } } - function tearDown() { + protected function tearDown() { global $db_prefix, $conf; if (preg_match('/simpletest\d+/', $db_prefix)) { $conf['file_public_path'] = $this->originalFileDirectory; @@ -1055,6 +1057,8 @@ protected function setUp() { // Log fatal errors. ini_set('log_errors', 1); ini_set('error_log', $directory . '/error.log'); + // Make all errors visible. + error_reporting(E_ALL); // Reset all statics so that test is performed with a clean environment. drupal_static_reset(); @@ -1357,14 +1361,16 @@ protected function curlClose() { */ protected function parse() { if (!$this->elements) { - // DOM can load HTML soup. But, HTML soup can throw warnings, suppress - // them. - @$htmlDom = DOMDocument::loadHTML($this->content); - if ($htmlDom) { + // Suppress all libxml warnings during loading of HTML. + // @todo Remove this when core produces XHTML valid output. + libxml_use_internal_errors(TRUE); + $document = new DOMDocument(); + $result = $document->loadHTML($this->content); + if ($result) { $this->pass(t('Valid HTML found on "@path"', array('@path' => $this->getUrl())), t('Browser')); // It's much easier to work with simplexml than DOM, luckily enough // we can just simply import our DOM tree. - $this->elements = simplexml_import_dom($htmlDom); + $this->elements = simplexml_import_dom($document); } } if (!$this->elements) { diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index 35a2a7f8798d26e7bcbae80695b7affe29fd682d..b2223d5793f3d0e3f04258ecc5418beb2843f128 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -801,8 +801,8 @@ class DrupalHTTPRequestTestCase extends DrupalWebTestCase { // Parse URL schema. $missing_scheme = drupal_http_request('example.com/path'); - $this->assertEqual($missing_scheme->code, -1002, t('Returned with "-1002" error code.')); - $this->assertEqual($missing_scheme->error, 'missing schema', t('Returned with "missing schema" error message.')); + $this->assertEqual($missing_scheme->code, -1001, t('Returned with "-1001" error code.')); + $this->assertEqual($missing_scheme->error, 'unable to parse URL', t('Returned with "unable to parse URL" error message.')); $unable_to_parse = drupal_http_request('http:///path'); $this->assertEqual($unable_to_parse->code, -1001, t('Returned with "-1001" error code.')); @@ -860,8 +860,8 @@ class DrupalHTTPRequestTestCase extends DrupalWebTestCase { $this->assertFalse(isset($redirect_301->redirect_code), t('drupal_http_request does not follow 301 redirect if max_redirects = 0.')); $redirect_invalid = drupal_http_request(url('system-test/redirect-noscheme', array('absolute' => TRUE)), array('max_redirects' => 1)); - $this->assertEqual($redirect_invalid->code, -1002, t('301 redirect to invalid URL returned with error code !error.', array('!error' => $redirect_invalid->error))); - $this->assertEqual($redirect_invalid->error, 'missing schema', t('301 redirect to invalid URL returned with error message "!error".', array('!error' => $redirect_invalid->error))); + $this->assertEqual($redirect_invalid->code, -1001, t('301 redirect to invalid URL returned with error code !error.', array('!error' => $redirect_invalid->error))); + $this->assertEqual($redirect_invalid->error, 'unable to parse URL', t('301 redirect to invalid URL returned with error message "!error".', array('!error' => $redirect_invalid->error))); $redirect_invalid = drupal_http_request(url('system-test/redirect-noparse', array('absolute' => TRUE)), array('max_redirects' => 1)); $this->assertEqual($redirect_invalid->code, -1001, t('301 redirect to invalid URL returned with error message code "!error".', array('!error' => $redirect_invalid->error))); diff --git a/modules/simpletest/tests/file.test b/modules/simpletest/tests/file.test index 46c24508b99327d31b7b87dd79afbf3953246139..08263668cb702184a426c4d155e8b8dfdf757556 100644 --- a/modules/simpletest/tests/file.test +++ b/modules/simpletest/tests/file.test @@ -288,16 +288,22 @@ class FileSpaceUsedTest extends FileTestCase { parent::setUp(); // Create records for a couple of users with different sizes. - drupal_write_record('file', $file = array('uid' => 2, 'uri' => 'public://example1.txt', 'filesize' => 50, 'status' => FILE_STATUS_PERMANENT)); - drupal_write_record('file', $file = array('uid' => 2, 'uri' => 'public://example2.txt', 'filesize' => 20, 'status' => FILE_STATUS_PERMANENT)); - drupal_write_record('file', $file = array('uid' => 3, 'uri' => 'public://example3.txt', 'filesize' => 100, 'status' => FILE_STATUS_PERMANENT)); - drupal_write_record('file', $file = array('uid' => 3, 'uri' => 'public://example4.txt', 'filesize' => 200, 'status' => FILE_STATUS_PERMANENT)); + $file = array('uid' => 2, 'uri' => 'public://example1.txt', 'filesize' => 50, 'status' => FILE_STATUS_PERMANENT); + drupal_write_record('file', $file); + $file = array('uid' => 2, 'uri' => 'public://example2.txt', 'filesize' => 20, 'status' => FILE_STATUS_PERMANENT); + drupal_write_record('file', $file); + $file = array('uid' => 3, 'uri' => 'public://example3.txt', 'filesize' => 100, 'status' => FILE_STATUS_PERMANENT); + drupal_write_record('file', $file); + $file = array('uid' => 3, 'uri' => 'public://example4.txt', 'filesize' => 200, 'status' => FILE_STATUS_PERMANENT); + drupal_write_record('file', $file); // Now create some with other statuses. These values were chosen arbitrarily // for the sole purpose of testing that bitwise operators were used // correctly on the field. - drupal_write_record('file', $file = array('uid' => 2, 'uri' => 'public://example5.txt', 'filesize' => 1, 'status' => 2 | 8)); - drupal_write_record('file', $file = array('uid' => 3, 'uri' => 'public://example6.txt', 'filesize' => 3, 'status' => 2 | 4)); + $file = array('uid' => 2, 'uri' => 'public://example5.txt', 'filesize' => 1, 'status' => 2 | 8); + drupal_write_record('file', $file); + $file = array('uid' => 3, 'uri' => 'public://example6.txt', 'filesize' => 3, 'status' => 2 | 4); + drupal_write_record('file', $file); } /** @@ -722,7 +728,9 @@ class FileDirectoryTest extends FileTestCase { // Remove .htaccess file to then test that it gets re-created. $directory = file_directory_path(); - @unlink($directory . '/.htaccess'); + if (file_exists($directory . '/.htaccess')) { + unlink($directory . '/.htaccess'); + } $this->assertFalse(is_file($directory . '/.htaccess'), t('Successfully removed the .htaccess file in the files directory.'), 'File'); file_ensure_htaccess(); $this->assertTrue(is_file($directory . '/.htaccess'), t('Successfully re-created the .htaccess file in the files directory.'), 'File'); @@ -1582,7 +1590,8 @@ class FileLoadTest extends FileHookTestCase { * Try to load a non-existent file by URI. */ function testLoadMissingFilepath() { - $this->assertFalse(reset(file_load_multiple(array(), array('uri' => 'foobar://misc/druplicon.png'))), t("Try to load a file that doesn't exist in the database fails.")); + $files = file_load_multiple(array(), array('uri' => 'foobar://misc/druplicon.png')); + $this->assertFalse(reset($files), t("Try to load a file that doesn't exist in the database fails.")); $this->assertFileHooksCalled(array()); } @@ -1590,7 +1599,8 @@ class FileLoadTest extends FileHookTestCase { * Try to load a non-existent file by status. */ function testLoadInvalidStatus() { - $this->assertFalse(reset(file_load_multiple(array(), array('status' => -99))), t("Trying to load a file with an invalid status fails.")); + $files = file_load_multiple(array(), array('status' => -99)); + $this->assertFalse(reset($files), t("Trying to load a file with an invalid status fails.")); $this->assertFileHooksCalled(array()); } diff --git a/modules/simpletest/tests/session.test b/modules/simpletest/tests/session.test index 70bf705654d4ef5df2ca6a40a4e22246ec199fad..ec16207f5608c9ee2ead937e2fa5294259625990 100644 --- a/modules/simpletest/tests/session.test +++ b/modules/simpletest/tests/session.test @@ -345,7 +345,7 @@ class SessionHttpsTestCase extends DrupalWebTestCase { // Check that user login form action is secure. $this->drupalGet('user'); - $form = &$this->xpath('//form[@id="user-login"]'); + $form = $this->xpath('//form[@id="user-login"]'); $this->assertEqual(substr($form[0]['action'], 0, 6), 'https:', 'Login form action is secure'); $form[0]['action'] = $this->httpsUrl('user'); diff --git a/modules/system/system.module b/modules/system/system.module index 47d6acf0345574d51013c13e47718c4584261380..50a426dcf5c18823892684a3382aabb56268e657 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -2137,6 +2137,7 @@ function _system_rebuild_module_data() { // Include the install profile in modules that are loaded. $profile = drupal_get_profile(); + $modules[$profile] = new stdClass; $modules[$profile]->name = $profile; $modules[$profile]->uri = 'profiles/' . $profile . '/' . $profile . '.profile'; $modules[$profile]->filename = $profile . '.profile'; diff --git a/modules/system/system.test b/modules/system/system.test index 8f94d0c56e13f39f22ccc86df1480dd6308bbcfb..ee649946df0d80cbf9aeba8b6f0bc6ca139946e3 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -235,7 +235,7 @@ class ModuleVersionTestCase extends ModuleTestCase { ); } - function setup() { + function setUp() { parent::setUp('module_test'); } diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 4cc5de737677dad3d65b679d64d5835003b60937..290162e26a945edb6ba6e05f203fe6ccd59662b5 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -903,7 +903,8 @@ function taxonomy_vocabulary_load_multiple($vids = array(), $conditions = array( * Results are statically cached. */ function taxonomy_vocabulary_load($vid) { - return reset(taxonomy_vocabulary_load_multiple(array($vid))); + $vocabularies = taxonomy_vocabulary_load_multiple(array($vid)); + return reset($vocabularies); } /** diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test index 726f29f15bc42b080f503ce7be82f7f47dd0526f..025e902f3f718414bfe81825fd60de587a1e0951 100644 --- a/modules/taxonomy/taxonomy.test +++ b/modules/taxonomy/taxonomy.test @@ -441,7 +441,8 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { // Create the term to edit. $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->vid . '/add', $edit, t('Save')); - $term = reset(taxonomy_get_term_by_name($edit['name'])); + $terms = taxonomy_get_term_by_name($edit['name']); + $term = reset($terms); $this->assertNotNull($term, t('Term found in database')); // Submitting a term takes us to the add page; we need the List page. @@ -672,7 +673,8 @@ class TaxonomyHooksTestCase extends TaxonomyWebTestCase { 'antonym' => 'Long', ); $this->drupalPost('admin/structure/taxonomy/' . $vocabulary->vid . '/add', $edit, t('Save')); - $term = reset(taxonomy_get_term_by_name($edit['name'])); + $terms = taxonomy_get_term_by_name($edit['name']); + $term = reset($terms); $this->assertEqual($term->antonym, $edit['antonym'], t('Antonym was loaded into the term object')); // Update the term with a different antonym. diff --git a/modules/user/user.test b/modules/user/user.test index 3ee3f15f672f33a47a59c47d49443a8e6a5bf316..1365f2f6ed6f007bbb820484bda7628ee23c62c4 100644 --- a/modules/user/user.test +++ b/modules/user/user.test @@ -26,7 +26,8 @@ class UserRegistrationTestCase extends DrupalWebTestCase { $edit['mail'] = $mail = $edit['name'] . '@example.com'; $this->drupalPost('user/register', $edit, t('Create new account')); $this->assertText(t('Your password and further instructions have been sent to your e-mail address.'), t('User registered successfully.')); - $new_user = reset(user_load_multiple(array(), array('name' => $name, 'mail' => $mail))); + $accounts = user_load_multiple(array(), array('name' => $name, 'mail' => $mail)); + $new_user = reset($accounts); $this->assertTrue($new_user->status, t('New account is active after registration.')); // Allow registration by site visitors, but require administrator approval. @@ -35,7 +36,8 @@ class UserRegistrationTestCase extends DrupalWebTestCase { $edit['name'] = $name = $this->randomName(); $edit['mail'] = $mail = $edit['name'] . '@example.com'; $this->drupalPost('user/register', $edit, t('Create new account')); - $new_user = reset(user_load_multiple(array(), array('name' => $name, 'mail' => $mail))); + $accounts = user_load_multiple(array(), array('name' => $name, 'mail' => $mail)); + $new_user = reset($accounts); $this->assertFalse($new_user->status, t('New account is blocked until approved by an administrator.')); } @@ -59,7 +61,8 @@ class UserRegistrationTestCase extends DrupalWebTestCase { $edit['pass[pass1]'] = $new_pass = $this->randomName(); $edit['pass[pass2]'] = $new_pass; $this->drupalPost('user/register', $edit, t('Create new account')); - $new_user = reset(user_load_multiple(array(), array('name' => $name, 'mail' => $mail))); + $accounts = user_load_multiple(array(), array('name' => $name, 'mail' => $mail)); + $new_user = reset($accounts); $this->assertText(t('Registration successful. You are now logged in.'), t('Users are logged in after registering.')); $this->drupalLogout(); @@ -82,7 +85,8 @@ class UserRegistrationTestCase extends DrupalWebTestCase { $this->assertText(t('The username @name has not been activated or is blocked.', array('@name' => $name)), t('User cannot login yet.')); // Activate the new account. - $new_user = reset(user_load_multiple(array(), array('name' => $name, 'mail' => $mail))); + $accounts = user_load_multiple(array(), array('name' => $name, 'mail' => $mail)); + $new_user = reset($accounts); $admin_user = $this->drupalCreateUser(array('administer users')); $this->drupalLogin($admin_user); $edit = array( @@ -115,7 +119,8 @@ class UserRegistrationTestCase extends DrupalWebTestCase { $this->drupalPost('user/register', $edit, t('Create new account')); // Check user fields. - $new_user = reset(user_load_multiple(array(), array('name' => $name, 'mail' => $mail))); + $accounts = user_load_multiple(array(), array('name' => $name, 'mail' => $mail)); + $new_user = reset($accounts); $this->assertEqual($new_user->name, $name, t('Username matches.')); $this->assertEqual($new_user->mail, $mail, t('E-mail address matches.')); $this->assertEqual($new_user->theme, '', t('Correct theme field.')); @@ -371,7 +376,8 @@ class UserCancelTestCase extends DrupalWebTestCase { $bogus_timestamp = $timestamp - 86400 - 60; $this->drupalGet("user/$account->uid/cancel/confirm/$bogus_timestamp/" . user_pass_rehash($account->pass, $bogus_timestamp, $account->login)); $this->assertText(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'), t('Expired cancel account request rejected.')); - $this->assertTrue(reset(user_load_multiple(array($account->uid), array('status' => 1))), t('User account was not canceled.')); + $accounts = user_load_multiple(array($account->uid), array('status' => 1)); + $this->assertTrue(reset($accounts), t('User account was not canceled.')); // Confirm user's content has not been altered. $test_node = node_load($node->nid, NULL, TRUE); @@ -725,7 +731,8 @@ class UserPictureTestCase extends DrupalWebTestCase { // Images are sorted first by size then by name. We need an image // bigger than 1 KB so we'll grab the last one. - $image = end($this->drupalGetTestFiles('image')); + $files = $this->drupalGetTestFiles('image'); + $image = end($files); $info = image_get_info($image->uri); // Set new variables: valid dimensions, invalid filesize.