diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 5b655b8b..464f5efb 100755 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,4 +1,52 @@ +Drupal 7.23, 2013-08-07 +----------------------- +- Fixed a fatal error on PostgreSQL databases when updating the Taxonomy module + from Drupal 6 to Drupal 7. +- Fixed the default ordering of CSS files for sites using right-to-left + languages, to consistently place the right-to-left override file immediately + after the CSS it is overriding (API change: https://drupal.org/node/2058463). +- Added a drupal_check_memory_limit() API function to allow the memory limit to + be checked consistently (API addition). +- Changed the default web.config file for IIS servers to allow favicon.ico + files which are present in the filesystem to be accessed. +- Fixed inconsistent support for the 'tel' protocol in Drupal's URL filtering + functions. +- Performance improvement: Allowed all hooks to be included in the + module_implements() cache, even those that are only invoked on HTTP POST + requests. +- Made the database system replace truncate queries with delete queries when + inside a transaction, to fix issues with PostgreSQL and other databases. +- Fixed a bug which caused nested contextual links to display improperly. +- Fixed a bug which prevented cached image derivatives from being flushed for + private files and other non-default file schemes. +- Fixed drupal_render() to always return an empty string when there is no + output, rather than sometimes returning NULL (minor API change). +- Added protection to cache_clear_all() to ensure that non-cache tables cannot + be truncated (API addition: a new isValidBin() method has been added to the + default database cache implementation). +- Changed the default .htaccess file to support HTTP authorization in CGI + environments. +- Changed the password reset form to pre-fill the username when requested via a + URL query parameter, and used this in the error message that appears after a + failed login attempt (minor data structure and behavior change). +- Fixed broken support for foreign keys in the field API. +- Fixed "No active batch" error when a user cancels their own account. +- Added a description to the "access content overview" permission on the + permissions page (string change). +- Added a drupal_array_diff_assoc_recursive() function to allow associative + arrays to be compared recursively (API addition). +- Added human-readable labels to image styles, in addition to the existing + machine-readable name (API change: https://drupal.org/node/2058503). +- Moved the drupal_get_hash_salt() function to bootstrap.inc and used it in + additional places in the code, for added security in the case where there is + no hash salt in settings.php. +- Fixed a regression in Drupal 7.22 that caused internal server errors for + sites running on very old Apache 1.x web servers. +- Numerous small bug fixes. +- Numerous API documentation improvements. +- Additional automated test coverage. + Drupal 7.22, 2013-04-03 ----------------------- - Allowed the drupal_http_request() function to be overridden so that @@ -53,7 +101,7 @@ Drupal 7.22, 2013-04-03 downloaded via the Update Manager (UI change). - Added an optional "exclusive" flag to installation profile .info files which allows Drupal distributions to force a profile to be selected during - installation (API addition). + installation (API addition: http://drupal.org/node/1961012). - Fixed a bug which caused the database API to not properly close database connections. - Added a link to the URL for running cron from outside the site to the Cron diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 728e4ec2..d27f8d14 100755 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -8,7 +8,7 @@ /** * The current system version. */ -define('VERSION', '7.22'); +define('VERSION', '7.23'); /** * Core API compatibility. @@ -218,12 +218,16 @@ define('LANGUAGE_RTL', 1); define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']); /** - * Flag for drupal_set_title(); text is not sanitized, so run check_plain(). + * Flag used to indicate that text is not sanitized, so run check_plain(). + * + * @see drupal_set_title() */ define('CHECK_PLAIN', 0); /** - * Flag for drupal_set_title(); text has already been sanitized. + * Flag used to indicate that text has already been sanitized. + * + * @see drupal_set_title() */ define('PASS_THROUGH', -1); @@ -380,11 +384,11 @@ abstract class DrupalCacheArray implements ArrayAccess { * without necessarily writing back to the persistent cache at the end. * * @param $offset - * The array offset that was request. + * The array offset that was requested. * @param $persist * Optional boolean to specify whether the offset should be persisted or * not, defaults to TRUE. When called with $persist = FALSE the offset will - * be unflagged so that it will not written at the end of the request. + * be unflagged so that it will not be written at the end of the request. */ protected function persist($offset, $persist = TRUE) { $this->keysToPersist[$offset] = $persist; @@ -791,7 +795,7 @@ function drupal_settings_initialize() { * * This function plays a key role in allowing Drupal's resources (modules * and themes) to be located in different places depending on a site's - * configuration. For example, a module 'foo' may legally be be located + * configuration. For example, a module 'foo' may legally be located * in any of these three places: * * modules/foo/foo.module @@ -802,7 +806,7 @@ function drupal_settings_initialize() { * the above, depending on where the module is located. * * @param $type - * The type of the item (i.e. theme, theme_engine, module, profile). + * The type of the item (theme, theme_engine, module, profile). * @param $name * The name of the item for which the filename is requested. * @param $filename @@ -1405,6 +1409,7 @@ function drupal_unpack($obj, $field = 'data') { * more information, including recommendations on how to break up or not * break up strings for translation. * + * @section sec_translating_vars Translating Variables * You should never use t() to translate variables, such as calling * @code t($text); @endcode, unless the text that the variable holds has been * passed through t() elsewhere (e.g., $text is one of several translated @@ -1424,6 +1429,7 @@ function drupal_unpack($obj, $field = 'data') { * Translators can then rearrange the string as necessary for the language * (e.g., in Spanish, it might be "blog de @name"). * + * @section sec_alt_funcs_install Use During Installation Phase * During the Drupal installation phase, some resources used by t() wil not be * available to code that needs localization. See st() and get_t() for * alternatives. @@ -2232,6 +2238,19 @@ function drupal_get_user_timezone() { } } +/** + * Gets a salt useful for hardening against SQL injection. + * + * @return + * A salt based on information in settings.php, not in the database. + */ +function drupal_get_hash_salt() { + global $drupal_hash_salt, $databases; + // If the $drupal_hash_salt variable is empty, a hash of the serialized + // database credentials is used as a fallback salt. + return empty($drupal_hash_salt) ? hash('sha256', serialize($databases)) : $drupal_hash_salt; +} + /** * Provides custom PHP error handling. * @@ -2452,7 +2471,6 @@ function drupal_get_bootstrap_phase() { * HMAC and timestamp. */ function drupal_valid_test_ua() { - global $drupal_hash_salt; // No reason to reset this. static $test_prefix; @@ -2466,7 +2484,7 @@ function drupal_valid_test_ua() { // We use the salt from settings.php to make the HMAC key, since // the database is not yet initialized and we can't access any Drupal variables. // The file properties add more entropy not easily accessible to others. - $key = $drupal_hash_salt . filectime(__FILE__) . fileinode(__FILE__); + $key = drupal_get_hash_salt() . filectime(__FILE__) . fileinode(__FILE__); $time_diff = REQUEST_TIME - $time; // Since we are making a local request a 5 second time window is allowed, // and the HMAC must match. @@ -2484,14 +2502,13 @@ function drupal_valid_test_ua() { * Generates a user agent string with a HMAC and timestamp for simpletest. */ function drupal_generate_test_ua($prefix) { - global $drupal_hash_salt; static $key; if (!isset($key)) { // We use the salt from settings.php to make the HMAC key, since // the database is not yet initialized and we can't access any Drupal variables. // The file properties add more entropy not easily accessible to others. - $key = $drupal_hash_salt . filectime(__FILE__) . fileinode(__FILE__); + $key = drupal_get_hash_salt() . filectime(__FILE__) . fileinode(__FILE__); } // Generate a moderately secure HMAC based on the database credentials. $salt = uniqid('', TRUE); @@ -3397,3 +3414,32 @@ function _drupal_shutdown_function() { } } } + +/** + * Compares the memory required for an operation to the available memory. + * + * @param $required + * The memory required for the operation, expressed as a number of bytes with + * optional SI or IEC binary unit prefix (e.g. 2, 3K, 5MB, 10G, 6GiB, 8bytes, + * 9mbytes). + * @param $memory_limit + * (optional) The memory limit for the operation, expressed as a number of + * bytes with optional SI or IEC binary unit prefix (e.g. 2, 3K, 5MB, 10G, + * 6GiB, 8bytes, 9mbytes). If no value is passed, the current PHP + * memory_limit will be used. Defaults to NULL. + * + * @return + * TRUE if there is sufficient memory to allow the operation, or FALSE + * otherwise. + */ +function drupal_check_memory_limit($required, $memory_limit = NULL) { + if (!isset($memory_limit)) { + $memory_limit = ini_get('memory_limit'); + } + + // There is sufficient memory if: + // - No memory limit is set. + // - The memory limit is set to unlimited (-1). + // - The memory limit is greater than the memory required for the operation. + return ((!$memory_limit) || ($memory_limit == -1) || (parse_size($memory_limit) >= parse_size($required))); +} diff --git a/includes/cache.inc b/includes/cache.inc index f76164b9..09f4d753 100755 --- a/includes/cache.inc +++ b/includes/cache.inc @@ -137,18 +137,20 @@ function cache_set($cid, $data, $bin = 'cache', $expire = CACHE_PERMANENT) { /** * Expires data from the cache. * - * If called without arguments, expirable entries will be cleared from the - * cache_page and cache_block bins. + * If called with the arguments $cid and $bin set to NULL or omitted, then + * expirable entries will be cleared from the cache_page and cache_block bins, + * and the $wildcard argument is ignored. * * @param $cid - * If set, the cache ID to delete. Otherwise, all cache entries that can - * expire are deleted. + * If set, the cache ID or an array of cache IDs. Otherwise, all cache entries + * that can expire are deleted. The $wildcard argument will be ignored if set + * to NULL. * @param $bin * If set, the cache bin to delete from. Mandatory argument if $cid is set. * @param $wildcard - * If TRUE, cache IDs starting with $cid are deleted in addition to the - * exact cache ID specified by $cid. If $wildcard is TRUE and $cid is '*', - * the entire cache bin is emptied. + * If TRUE, the $cid argument must contain a string value and cache IDs + * starting with $cid are deleted in addition to the exact cache ID specified + * by $cid. If $wildcard is TRUE and $cid is '*', the entire cache is emptied. */ function cache_clear_all($cid = NULL, $bin = NULL, $wildcard = FALSE) { if (!isset($cid) && !isset($bin)) { @@ -217,13 +219,6 @@ function cache_is_empty($bin) { * @see DrupalDatabaseCache */ interface DrupalCacheInterface { - /** - * Constructs a new cache interface. - * - * @param $bin - * The cache bin for which the object is created. - */ - function __construct($bin); /** * Returns data from the persistent cache. @@ -280,12 +275,14 @@ interface DrupalCacheInterface { * cache_page and cache_block bins. * * @param $cid - * If set, the cache ID to delete. Otherwise, all cache entries that can - * expire are deleted. + * If set, the cache ID or an array of cache IDs. Otherwise, all cache + * entries that can expire are deleted. The $wildcard argument will be + * ignored if set to NULL. * @param $wildcard - * If set to TRUE, the $cid is treated as a substring - * to match rather than a complete ID. The match is a right hand - * match. If '*' is given as $cid, the bin $bin will be emptied. + * If TRUE, the $cid argument must contain a string value and cache IDs + * starting with $cid are deleted in addition to the exact cache ID + * specified by $cid. If $wildcard is TRUE and $cid is '*', the entire + * cache is emptied. */ function clear($cid = NULL, $wildcard = FALSE); @@ -311,7 +308,10 @@ class DrupalDatabaseCache implements DrupalCacheInterface { protected $bin; /** - * Constructs a new DrupalDatabaseCache object. + * Constructs a DrupalDatabaseCache object. + * + * @param $bin + * The cache bin for which the object is created. */ function __construct($bin) { $this->bin = $bin; @@ -505,7 +505,16 @@ class DrupalDatabaseCache implements DrupalCacheInterface { else { if ($wildcard) { if ($cid == '*') { - db_truncate($this->bin)->execute(); + // Check if $this->bin is a cache table before truncating. Other + // cache_clear_all() operations throw a PDO error in this situation, + // so we don't need to verify them first. This ensures that non-cache + // tables cannot be truncated accidentally. + if ($this->isValidBin()) { + db_truncate($this->bin)->execute(); + } + else { + throw new Exception(t('Invalid or missing cache bin specified: %bin', array('%bin' => $this->bin))); + } } else { db_delete($this->bin) @@ -542,4 +551,25 @@ class DrupalDatabaseCache implements DrupalCacheInterface { ->fetchField(); return empty($result); } + + /** + * Checks if $this->bin represents a valid cache table. + * + * This check is required to ensure that non-cache tables are not truncated + * accidentally when calling cache_clear_all(). + * + * @return boolean + */ + function isValidBin() { + if ($this->bin == 'cache' || substr($this->bin, 0, 6) == 'cache_') { + // Skip schema check for bins with standard table names. + return TRUE; + } + // These fields are required for any cache table. + $fields = array('cid', 'data', 'expire', 'created', 'serialized'); + // Load the table schema. + $schema = drupal_get_schema($this->bin); + // Confirm that all fields are present. + return isset($schema['fields']) && !array_diff($fields, array_keys($schema['fields'])); + } } diff --git a/includes/common.inc b/includes/common.inc index 27fa190e..262e1c57 100755 --- a/includes/common.inc +++ b/includes/common.inc @@ -641,7 +641,7 @@ function drupal_encode_path($path) { } /** - * Sends the user to a different Drupal page. + * Sends the user to a different page. * * This issues an on-site HTTP redirect. The function makes sure the redirected * URL is formatted correctly. @@ -2086,6 +2086,9 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) { /** * Format a username. * + * This is also the label callback implementation of + * callback_entity_info_label() for user_entity_info(). + * * By default, the passed-in object's 'name' property is used if it exists, or * else, the site-defined value for the 'anonymous' variable. However, a module * may override this by implementing hook_username_alter(&$name, $account). @@ -3885,14 +3888,14 @@ function drupal_html_id($id) { // requested id. $_POST['ajax_html_ids'] contains the ids as they were // returned by this function, potentially with the appended counter, so // we parse that to reconstruct the $seen_ids array. - if (is_array($_POST['ajax_html_ids'])) { + if (isset($_POST['ajax_html_ids'][0]) && strpos($_POST['ajax_html_ids'][0], ',') === FALSE) { $ajax_html_ids = $_POST['ajax_html_ids']; } else { - // jquery.form.js may send the server a comma-separated string instead - // of an array (see http://drupal.org/node/1575060), so we need to - // convert it to an array in that case. - $ajax_html_ids = explode(',', $_POST['ajax_html_ids']); + // jquery.form.js may send the server a comma-separated string as the + // first element of an array (see http://drupal.org/node/1575060), so + // we need to convert it to an array in that case. + $ajax_html_ids = explode(',', $_POST['ajax_html_ids'][0]); } foreach ($ajax_html_ids as $seen_id) { // We rely on '--' being used solely for separating a base id from the @@ -5031,19 +5034,6 @@ function drupal_json_output($var = NULL) { } } -/** - * Gets a salt useful for hardening against SQL injection. - * - * @return - * A salt based on information in settings.php, not in the database. - */ -function drupal_get_hash_salt() { - global $drupal_hash_salt, $databases; - // If the $drupal_hash_salt variable is empty, a hash of the serialized - // database credentials is used as a fallback salt. - return empty($drupal_hash_salt) ? hash('sha256', serialize($databases)) : $drupal_hash_salt; -} - /** * Ensures the private key variable used to generate tokens is set. * @@ -5066,8 +5056,10 @@ function drupal_get_private_key() { * * @return string * A 43-character URL-safe token for validation, based on the user session ID, - * the global $drupal_hash_salt variable from settings.php, and the + * the hash salt provided from drupal_get_hash_salt(), and the * 'drupal_private_key' configuration variable. + * + * @see drupal_get_hash_salt() */ function drupal_get_token($value = '') { return drupal_hmac_base64($value, session_id() . drupal_get_private_key() . drupal_get_hash_salt()); @@ -5803,23 +5795,23 @@ function drupal_render_page($page) { * array to be rendered independently and prevents them from being rendered * more than once on subsequent calls to drupal_render() (e.g., as part of a * larger array). If the same array or array element is passed more than once - * to drupal_render(), it simply returns a NULL value. + * to drupal_render(), it simply returns an empty string. * - * @param $elements + * @param array $elements * The structured array describing the data to be rendered. * - * @return + * @return string * The rendered HTML. */ function drupal_render(&$elements) { // Early-return nothing if user does not have access. if (empty($elements) || (isset($elements['#access']) && !$elements['#access'])) { - return; + return ''; } // Do not print elements twice. if (!empty($elements['#printed'])) { - return; + return ''; } // Try to fetch the element's markup from cache and return. @@ -5855,7 +5847,7 @@ function drupal_render(&$elements) { // Allow #pre_render to abort rendering. if (!empty($elements['#printed'])) { - return; + return ''; } // Get the children of the element, sorted by weight. @@ -6477,6 +6469,44 @@ function element_set_attributes(array &$element, array $map) { } } +/** + * Recursively computes the difference of arrays with additional index check. + * + * This is a version of array_diff_assoc() that supports multidimensional + * arrays. + * + * @param array $array1 + * The array to compare from. + * @param array $array2 + * The array to compare to. + * + * @return array + * Returns an array containing all the values from array1 that are not present + * in array2. + */ +function drupal_array_diff_assoc_recursive($array1, $array2) { + $difference = array(); + + foreach ($array1 as $key => $value) { + if (is_array($value)) { + if (!array_key_exists($key, $array2) || !is_array($array2[$key])) { + $difference[$key] = $value; + } + else { + $new_diff = drupal_array_diff_assoc_recursive($value, $array2[$key]); + if (!empty($new_diff)) { + $difference[$key] = $new_diff; + } + } + } + elseif (!array_key_exists($key, $array2) || $array2[$key] !== $value) { + $difference[$key] = $value; + } + } + + return $difference; +} + /** * Sets a value in a nested array with variable depth. * diff --git a/includes/database/mysql/query.inc b/includes/database/mysql/query.inc index 2609aba0..fa698d90 100755 --- a/includes/database/mysql/query.inc +++ b/includes/database/mysql/query.inc @@ -86,21 +86,7 @@ class InsertQuery_mysql extends InsertQuery { } } -class TruncateQuery_mysql extends TruncateQuery { - public function __toString() { - // TRUNCATE is actually a DDL statement on MySQL, and DDL statements are - // not transactional, and result in an implicit COMMIT. When we are in a - // transaction, fallback to the slower, but transactional, DELETE. - if ($this->connection->inTransaction()) { - // Create a comment string to prepend to the query. - $comments = $this->connection->makeComment($this->comments); - return $comments . 'DELETE FROM {' . $this->connection->escapeTable($this->table) . '}'; - } - else { - return parent::__toString(); - } - } -} +class TruncateQuery_mysql extends TruncateQuery { } /** * @} End of "addtogroup database". diff --git a/includes/database/query.inc b/includes/database/query.inc index 8beeef1e..66495273 100755 --- a/includes/database/query.inc +++ b/includes/database/query.inc @@ -83,7 +83,7 @@ interface QueryConditionInterface { /** * Sets a condition that the specified subquery returns values. - * + * * @param SelectQueryInterface $select * The subquery that must contain results. * @@ -91,10 +91,10 @@ interface QueryConditionInterface { * The called object. */ public function exists(SelectQueryInterface $select); - + /** * Sets a condition that the specified subquery returns no values. - * + * * @param SelectQueryInterface $select * The subquery that must not contain results. * @@ -102,7 +102,7 @@ interface QueryConditionInterface { * The called object. */ public function notExists(SelectQueryInterface $select); - + /** * Gets a complete list of all conditions in this conditional clause. * @@ -283,14 +283,14 @@ abstract class Query implements QueryPlaceholderInterface { /** * The target of the connection object. - * + * * @var string */ protected $connectionTarget; /** * The key of the connection object. - * + * * @var string */ protected $connectionKey; @@ -804,7 +804,7 @@ class DeleteQuery extends Query implements QueryConditionInterface { $this->condition->notExists($select); return $this; } - + /** * Implements QueryConditionInterface::conditions(). */ @@ -942,7 +942,17 @@ class TruncateQuery extends Query { // Create a sanitized comment string to prepend to the query. $comments = $this->connection->makeComment($this->comments); - return $comments . 'TRUNCATE {' . $this->connection->escapeTable($this->table) . '} '; + // In most cases, TRUNCATE is not a transaction safe statement as it is a + // DDL statement which results in an implicit COMMIT. When we are in a + // transaction, fallback to the slower, but transactional, DELETE. + // PostgreSQL also locks the entire table for a TRUNCATE strongly reducing + // the concurrency with other transactions. + if ($this->connection->inTransaction()) { + return $comments . 'DELETE FROM {' . $this->connection->escapeTable($this->table) . '}'; + } + else { + return $comments . 'TRUNCATE {' . $this->connection->escapeTable($this->table) . '} '; + } } } @@ -1053,7 +1063,7 @@ class UpdateQuery extends Query implements QueryConditionInterface { $this->condition->notExists($select); return $this; } - + /** * Implements QueryConditionInterface::conditions(). */ @@ -1545,7 +1555,7 @@ class MergeQuery extends Query implements QueryConditionInterface { $this->condition->notExists($select); return $this; } - + /** * Implements QueryConditionInterface::conditions(). */ @@ -1762,14 +1772,14 @@ class DatabaseCondition implements QueryConditionInterface, Countable { public function exists(SelectQueryInterface $select) { return $this->condition('', $select, 'EXISTS'); } - + /** * Implements QueryConditionInterface::notExists(). */ public function notExists(SelectQueryInterface $select) { return $this->condition('', $select, 'NOT EXISTS'); } - + /** * Implements QueryConditionInterface::conditions(). */ diff --git a/includes/entity.inc b/includes/entity.inc index 0b80d53a..25f75846 100755 --- a/includes/entity.inc +++ b/includes/entity.inc @@ -13,14 +13,6 @@ */ interface DrupalEntityControllerInterface { - /** - * Constructor. - * - * @param $entityType - * The entity type for which the instance is created. - */ - public function __construct($entityType); - /** * Resets the internal, static entity cache. * @@ -119,6 +111,9 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface { /** * Constructor: sets basic variables. + * + * @param $entityType + * The entity type for which the instance is created. */ public function __construct($entityType) { $this->entityType = $entityType; @@ -159,18 +154,6 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface { */ public function load($ids = array(), $conditions = array()) { $entities = array(); - - # PATCH http://drupal.org/node/1003788#comment-5195682 - // Clean the $ids array to remove non-integer values that can be passed - // in from various sources, including menu callbacks. - if (is_array($ids)) { - foreach ($ids as $key => $id) { - if (empty($id) || ((string) $id !== (string) (int) $id)) { - unset($ids[$key]); - } - } - } - # endpatch // Revisions are not statically cached, and require a different query to // other conditions, so separate the revision id into its own variable. @@ -646,7 +629,7 @@ class EntityFieldQuery { /** * Adds a condition on field values. - * + * * Note that entities with empty field values will be excluded from the * EntityFieldQuery results when using this method. * diff --git a/includes/errors.inc b/includes/errors.inc index 7fd2de2f..fcf9ca85 100755 --- a/includes/errors.inc +++ b/includes/errors.inc @@ -169,7 +169,7 @@ function error_displayable($error = NULL) { * TRUE if the error is fatal. */ function _drupal_log_error($error, $fatal = FALSE) { - // Initialize a maintenance theme if the boostrap was not complete. + // Initialize a maintenance theme if the bootstrap was not complete. // Do it early because drupal_set_message() triggers a drupal_theme_initialize(). if ($fatal && (drupal_get_bootstrap_phase() != DRUPAL_BOOTSTRAP_FULL)) { unset($GLOBALS['theme']); diff --git a/includes/file.inc b/includes/file.inc index e9a567e9..06657cfb 100755 --- a/includes/file.inc +++ b/includes/file.inc @@ -2199,29 +2199,21 @@ function drupal_unlink($uri, $context = NULL) { } /** - * Returns the absolute local filesystem path of a stream URI. + * Resolves the absolute filepath of a local URI or filepath. * - * This function was originally written to ease the conversion of 6.x code to - * use 7.x stream wrappers. However, it assumes that every URI may be resolved - * to an absolute local filesystem path, and this assumption fails when stream - * wrappers are used to support remote file storage. Remote stream wrappers - * may implement the realpath method by always returning FALSE. The use of - * drupal_realpath() is discouraged, and is slowly being removed from core - * functions where possible. + * The use of drupal_realpath() is discouraged, because it does not work for + * remote URIs. Except in rare cases, URIs should not be manually resolved. * * Only use this function if you know that the stream wrapper in the URI uses * the local file system, and you need to pass an absolute path to a function * that is incompatible with stream URIs. * - * @param $uri - * A stream wrapper URI or a filesystem path, possibly including one or more - * symbolic links. + * @param string $uri + * A stream wrapper URI or a filepath, possibly including one or more symbolic + * links. * - * @return - * The absolute local filesystem path (with no symbolic links), or FALSE on - * failure. - * - * @todo This function is deprecated, and should be removed wherever possible. + * @return string|false + * The absolute local filepath (with no symbolic links), or FALSE on failure. * * @see DrupalStreamWrapperInterface::realpath() * @see http://php.net/manual/function.realpath.php diff --git a/includes/form.inc b/includes/form.inc index 8ae8065a..8ca048a9 100755 --- a/includes/form.inc +++ b/includes/form.inc @@ -727,8 +727,9 @@ function drupal_retrieve_form($form_id, &$form_state) { // Record the filepath of the include file containing the original form, so // the form builder callbacks can be loaded when the form is being rebuilt // from cache on a different path (such as 'system/ajax'). See - // form_get_cache(). - // $menu_get_item() is not available during installation. + // form_get_cache(). Don't do this in maintenance mode as Drupal may not be + // fully bootstrapped (i.e. during installation) in which case + // menu_get_item() is not available. if (!isset($form_state['build_info']['files']['menu']) && !defined('MAINTENANCE_MODE')) { $item = menu_get_item(); if (!empty($item['include_file'])) { diff --git a/includes/install.inc b/includes/install.inc index c4bcb88b..3631c36e 100755 --- a/includes/install.inc +++ b/includes/install.inc @@ -741,20 +741,27 @@ function drupal_install_system() { } /** - * Uninstalls a given list of modules. + * Uninstalls a given list of disabled modules. * - * @param $module_list - * The modules to uninstall. - * @param $uninstall_dependents - * If TRUE, the function will check that all modules which depend on the - * passed-in module list either are already uninstalled or contained in the - * list, and it will ensure that the modules are uninstalled in the correct - * order. This incurs a significant performance cost, so use FALSE if you - * know $module_list is already complete and in the correct order. + * @param array $module_list + * The modules to uninstall. It is the caller's responsibility to ensure that + * all modules in this list have already been disabled before this function + * is called. + * @param bool $uninstall_dependents + * (optional) If TRUE, the function will check that all modules which depend + * on the passed-in module list either are already uninstalled or contained in + * the list, and it will ensure that the modules are uninstalled in the + * correct order. This incurs a significant performance cost, so use FALSE if + * you know $module_list is already complete and in the correct order. + * Defaults to TRUE. * - * @return - * FALSE if one or more dependent modules are missing from the list, TRUE - * otherwise. + * @return bool + * Returns TRUE if the operation succeeds or FALSE if it aborts due to an + * unsafe condition, namely, $uninstall_dependents is TRUE and a module in + * $module_list has dependents which are not already uninstalled and not also + * included in $module_list). + * + * @see module_disable() */ function drupal_uninstall_modules($module_list = array(), $uninstall_dependents = TRUE) { if ($uninstall_dependents) { @@ -766,7 +773,7 @@ function drupal_uninstall_modules($module_list = array(), $uninstall_dependents $profile = drupal_get_profile(); while (list($module) = each($module_list)) { if (!isset($module_data[$module]) || drupal_get_installed_schema_version($module) == SCHEMA_UNINSTALLED) { - // This module doesn't exist or is already uninstalled, skip it. + // This module doesn't exist or is already uninstalled. Skip it. unset($module_list[$module]); continue; } @@ -799,7 +806,7 @@ function drupal_uninstall_modules($module_list = array(), $uninstall_dependents } if (!empty($module_list)) { - // Call hook_module_uninstall to let other modules act + // Let other modules react. module_invoke_all('modules_uninstalled', $module_list); } diff --git a/includes/menu.inc b/includes/menu.inc index 2be09032..a93ddad6 100755 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -309,7 +309,7 @@ define('MENU_PREFERRED_LINK', '1cf698d64d1aa4b83907cf6ed55db3a7f8e92c91'); * actually exists. This list of 'masks' is built in menu_rebuild(). * * @param $parts - * An array of path parts, for the above example + * An array of path parts; for the above example, * array('node', '12345', 'edit'). * * @return @@ -430,7 +430,7 @@ function menu_set_item($path, $router_item) { * Gets a router item. * * @param $path - * The path, for example node/5. The function will find the corresponding + * The path; for example, 'node/5'. The function will find the corresponding * node/% item and return that. * @param $router_item * Internal use only. @@ -542,7 +542,7 @@ function menu_execute_active_handler($path = NULL, $deliver = TRUE) { * @param $item * A menu router or menu link item * @param $map - * An array of path arguments (ex: array('node', '5')) + * An array of path arguments; for example, array('node', '5'). * * @return * Returns TRUE for success, FALSE if an object cannot be loaded. @@ -612,7 +612,7 @@ function _menu_load_objects(&$item, &$map) { * @param $item * A menu router or menu link item * @param $map - * An array of path arguments (ex: array('node', '5')) + * An array of path arguments; for example, array('node', '5'). * * @return * $item['access'] becomes TRUE if the item is accessible, FALSE otherwise. @@ -738,7 +738,7 @@ function _menu_item_localize(&$item, $map, $link_translate = FALSE) { * @param $router_item * A menu router item * @param $map - * An array of path arguments (ex: array('node', '5')) + * An array of path arguments; for example, array('node', '5'). * @param $to_arg * Execute $item['to_arg_functions'] or not. Use only if you want to render a * path from the menu table, for example tabs. @@ -801,9 +801,9 @@ function _menu_translate(&$router_item, $map, $to_arg = FALSE) { * Translates the path elements in the map using any to_arg helper function. * * @param $map - * An array of path arguments (ex: array('node', '5')) + * An array of path arguments; for example, array('node', '5'). * @param $to_arg_functions - * An array of helper function (ex: array(2 => 'menu_tail_to_arg')) + * An array of helper functions; for example, array(2 => 'menu_tail_to_arg'). * * @see hook_menu() */ @@ -2139,7 +2139,7 @@ function menu_local_tasks($level = 0) { * example 'node' or 'admin/structure/block/manage'. * @param $args * A list of dynamic path arguments to append to $parent_path to form the - * fully-qualified menu router path, for example array(123) for a certain + * fully-qualified menu router path; for example, array(123) for a certain * node or array('system', 'navigation') for a certain block. * * @return @@ -2430,7 +2430,7 @@ function menu_set_active_trail($new_trail = NULL) { * Looks up the preferred menu link for a given system path. * * @param $path - * The path, for example 'node/5'. The function will find the corresponding + * The path; for example, 'node/5'. The function will find the corresponding * menu link ('node/5' if it exists, or fallback to 'node/%'). * @param $selected_menu * The name of a menu used to restrict the search for a preferred menu link. diff --git a/includes/module.inc b/includes/module.inc index 341cd791..fe2a9805 100755 --- a/includes/module.inc +++ b/includes/module.inc @@ -610,9 +610,40 @@ function module_disable($module_list, $disable_dependents = TRUE) { * just models that you can modify. Only the hooks implemented within modules * are executed when running Drupal. * - * See also @link themeable the themeable group page. @endlink + * @see themeable + * @see callbacks */ + /** + * @defgroup callbacks Callbacks + * @{ + * Callback function signatures. + * + * Drupal's API sometimes uses callback functions to allow you to define how + * some type of processing happens. A callback is a function with a defined + * signature, which you define in a module. Then you pass the function name as + * a parameter to a Drupal API function or return it as part of a hook + * implementation return value, and your function is called at an appropriate + * time. For instance, when setting up batch processing you might need to + * provide a callback function for each processing step and/or a callback for + * when processing is finished; you would do that by defining these functions + * and passing their names into the batch setup function. + * + * Callback function signatures, like hook definitions, are described by + * creating and documenting dummy functions in a *.api.php file; normally, the + * dummy callback function's name should start with "callback_", and you should + * document the parameters and return value and provide a sample function body. + * Then your API documentation can refer to this callback function in its + * documentation. A user of your API can usually name their callback function + * anything they want, although a standard name would be to replace "callback_" + * with the module name. + * + * @see hooks + * @see themeable + * + * @} + */ + /** * Determines whether a module implements a hook. * @@ -803,10 +834,7 @@ function module_hook_info() { */ function module_implements_write_cache() { $implementations = &drupal_static('module_implements'); - // Check whether we need to write the cache. We do not want to cache hooks - // which are only invoked on HTTP POST requests since these do not need to be - // optimized as tightly, and not doing so keeps the cache entry smaller. - if (isset($implementations['#write_cache']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD')) { + if (isset($implementations['#write_cache'])) { unset($implementations['#write_cache']); cache_set('module_implements', $implementations, 'cache_bootstrap'); } @@ -815,6 +843,9 @@ function module_implements_write_cache() { /** * Invokes a hook in a particular module. * + * All arguments are passed by value. Use drupal_alter() if you need to pass + * arguments by reference. + * * @param $module * The name of the module (without the .module extension). * @param $hook @@ -824,6 +855,8 @@ function module_implements_write_cache() { * * @return * The return value of the hook implementation. + * + * @see drupal_alter() */ function module_invoke($module, $hook) { $args = func_get_args(); @@ -837,6 +870,9 @@ function module_invoke($module, $hook) { /** * Invokes a hook in all enabled modules that implement it. * + * All arguments are passed by value. Use drupal_alter() if you need to pass + * arguments by reference. + * * @param $hook * The name of the hook to invoke. * @param ... @@ -845,6 +881,8 @@ function module_invoke($module, $hook) { * @return * An array of return values of the hook implementations. If modules return * arrays from their implementations, those are merged into one array. + * + * @see drupal_alter() */ function module_invoke_all($hook) { $args = func_get_args(); diff --git a/includes/theme.inc b/includes/theme.inc index 5920624d..ee73965d 100755 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -508,7 +508,7 @@ class ThemeRegistry Extends DrupalCacheArray { * themes/bartik. * * @see theme() - * @see _theme_process_registry() + * @see _theme_build_registry() * @see hook_theme() * @see list_themes() */ @@ -869,11 +869,18 @@ function drupal_find_base_themes($themes, $key, $used_keys = array()) { /** * Generates themed output. * - * All requests for themed output must go through this function. It examines - * the request and routes it to the appropriate + * All requests for themed output must go through this function (however, + * calling the theme() function directly is strongly discouraged - see next + * paragraph). It examines the request and routes it to the appropriate * @link themeable theme function or template @endlink, by checking the theme * registry. * + * Avoid calling this function directly. It is preferable to replace direct + * calls to the theme() function with calls to drupal_render() by passing a + * render array with a #theme key to drupal_render(), which in turn calls + * theme(). + * + * @section sec_theme_hooks Theme Hooks * Most commonly, the first argument to this function is the name of the theme * hook. For instance, to theme a taxonomy term, the theme hook name is * 'taxonomy_term'. Modules register theme hooks within a hook_theme() @@ -885,6 +892,7 @@ function drupal_find_base_themes($themes, $key, $used_keys = array()) { * underscores changed to hyphens, so for the 'taxonomy_term' theme hook, the * default template is 'taxonomy-term.tpl.php'. * + * @subsection sub_overriding_theme_hooks Overriding Theme Hooks * Themes may also register new theme hooks within a hook_theme() * implementation, but it is more common for themes to override default * implementations provided by modules than to register entirely new theme @@ -897,6 +905,7 @@ function drupal_find_base_themes($themes, $key, $used_keys = array()) { * rendering engine, it overrides the default implementation of the 'page' theme * hook by containing a 'page.tpl.php' file within its folder structure). * + * @subsection sub_preprocess_templates Preprocessing for Template Files * If the implementation is a template file, several functions are called * before the template file is invoked, to modify the $variables array. These * fall into the "preprocessing" phase and the "processing" phase, and are @@ -945,12 +954,14 @@ function drupal_find_base_themes($themes, $key, $used_keys = array()) { * - THEME_process_HOOK(&$variables): Allows the theme to process the * variables specific to the theme hook. * + * @subsection sub_preprocess_theme_funcs Preprocessing for Theme Functions * If the implementation is a function, only the theme-hook-specific preprocess * and process functions (the ones ending in _HOOK) are called from the * list above. This is because theme hooks with function implementations * need to be fast, and calling the non-theme-hook-specific preprocess and * process functions for them would incur a noticeable performance penalty. * + * @subsection sub_alternate_suggestions Suggesting Alternate Hooks * There are two special variables that these preprocess and process functions * can set: 'theme_hook_suggestion' and 'theme_hook_suggestions'. These will be * merged together to form a list of 'suggested' alternate theme hooks to use, @@ -992,6 +1003,7 @@ function drupal_find_base_themes($themes, $key, $used_keys = array()) { * @return * An HTML string representing the themed output. * + * @see drupal_render() * @see themeable * @see hook_theme() * @see template_preprocess() @@ -1814,7 +1826,9 @@ function theme_breadcrumb($variables) { * - "data": The localized title of the table column. * - "field": The database field represented in the table column (required * if user is to be able to sort on this column). - * - "sort": A default sort order for this column ("asc" or "desc"). + * - "sort": A default sort order for this column ("asc" or "desc"). Only + * one column should be given a default sort order because table sorting + * only applies to one column at a time. * - Any HTML attributes, such as "colspan", to apply to the column header * cell. * - rows: An array of table rows. Every row is an array of cells, or an @@ -1973,25 +1987,24 @@ function theme_table($variables) { $flip = array('even' => 'odd', 'odd' => 'even'); $class = 'even'; foreach ($rows as $number => $row) { - $attributes = array(); - // Check if we're dealing with a simple or complex row if (isset($row['data'])) { - foreach ($row as $key => $value) { - if ($key == 'data') { - $cells = $value; - } - else { - $attributes[$key] = $value; - } - } + $cells = $row['data']; + $no_striping = isset($row['no_striping']) ? $row['no_striping'] : FALSE; + + // Set the attributes array and exclude 'data' and 'no_striping'. + $attributes = $row; + unset($attributes['data']); + unset($attributes['no_striping']); } else { $cells = $row; + $attributes = array(); + $no_striping = FALSE; } if (count($cells)) { // Add odd/even class - if (empty($row['no_striping'])) { + if (!$no_striping) { $class = $flip[$class]; $attributes['class'][] = $class; } diff --git a/misc/autocomplete.js b/misc/autocomplete.js index 56790817..8f7ac601 100755 --- a/misc/autocomplete.js +++ b/misc/autocomplete.js @@ -114,7 +114,6 @@ Drupal.jsAC.prototype.onkeyup = function (input, e) { */ Drupal.jsAC.prototype.select = function (node) { this.input.value = $(node).data('autocompleteValue'); - $(this.input).trigger('autocompleteSelect', [node]); }; /** @@ -168,7 +167,7 @@ Drupal.jsAC.prototype.unhighlight = function (node) { Drupal.jsAC.prototype.hidePopup = function (keycode) { // Select item if the right key or mousebutton was pressed. if (this.selected && ((keycode && keycode != 46 && keycode != 8 && keycode != 27) || !keycode)) { - this.select(this.selected); + this.input.value = $(this.selected).data('autocompleteValue'); } // Hide popup. var popup = this.popup; @@ -221,7 +220,7 @@ Drupal.jsAC.prototype.found = function (matches) { for (key in matches) { $('
') .html($('').html(matches[key])) - .mousedown(function () { ac.hidePopup(this); }) + .mousedown(function () { ac.select(this); }) .mouseover(function () { ac.highlight(this); }) .mouseout(function () { ac.unhighlight(this); }) .data('autocompleteValue', key) diff --git a/modules/aggregator/aggregator.api.php b/modules/aggregator/aggregator.api.php index cd5e47b1..d5cac4ec 100755 --- a/modules/aggregator/aggregator.api.php +++ b/modules/aggregator/aggregator.api.php @@ -189,7 +189,7 @@ function hook_aggregator_process($feed) { * * @ingroup aggregator */ -function hook_aggregator_process_info($feed) { +function hook_aggregator_process_info() { return array( 'title' => t('Default processor'), 'description' => t('Creates lightweight records of feed items.'), diff --git a/modules/aggregator/aggregator.info b/modules/aggregator/aggregator.info index 23a309f3..1bc261b6 100755 --- a/modules/aggregator/aggregator.info +++ b/modules/aggregator/aggregator.info @@ -7,8 +7,8 @@ files[] = aggregator.test configure = admin/config/services/aggregator/settings stylesheets[all][] = aggregator.css -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/aggregator/tests/aggregator_test.info b/modules/aggregator/tests/aggregator_test.info index 2508a29f..40a97034 100755 --- a/modules/aggregator/tests/aggregator_test.info +++ b/modules/aggregator/tests/aggregator_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/block/block.info b/modules/block/block.info index 67104878..08f7165b 100755 --- a/modules/block/block.info +++ b/modules/block/block.info @@ -6,8 +6,8 @@ core = 7.x files[] = block.test configure = admin/structure/block -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/block/block.module b/modules/block/block.module index ff77d9ec..3a988de2 100755 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -840,15 +840,42 @@ function _block_render_blocks($region_blocks) { // preserve the submission of forms in blocks, by fetching from cache only // if the request method is 'GET' (or 'HEAD'). $cacheable = !count(module_implements('node_grants')) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD'); + + // Proceed to loop over all blocks in order to compute their respective cache + // identifiers; this allows us to do one single cache_get_multiple() call + // instead of doing one cache_get() call per block. + $cached_blocks = array(); + $cids = array(); + + if ($cacheable) { + foreach ($region_blocks as $key => $block) { + if (!isset($block->content)) { + if (($cid = _block_get_cache_id($block))) { + $cids[$key] = $cid; + } + } + } + + if ($cids) { + // We cannot pass $cids in directly because cache_get_multiple() will + // modify it, and we need to use it later on in this function. + $cid_values = array_values($cids); + $cached_blocks = cache_get_multiple($cid_values, 'cache_block'); + } + } + foreach ($region_blocks as $key => $block) { // Render the block content if it has not been created already. if (!isset($block->content)) { // Erase the block from the static array - we'll put it back if it has // content. unset($region_blocks[$key]); - // Try fetching the block from cache. - if ($cacheable && ($cid = _block_get_cache_id($block)) && ($cache = cache_get($cid, 'cache_block'))) { - $array = $cache->data; + + $cid = empty($cids[$key]) ? NULL : $cids[$key]; + + // Try fetching the block from the previously loaded cache entries. + if (isset($cached_blocks[$cid])) { + $array = $cached_blocks[$cid]->data; } else { $array = module_invoke($block->module, 'block_view', $block->delta); diff --git a/modules/block/tests/block_test.info b/modules/block/tests/block_test.info index d1a01cfd..ec20b09a 100755 --- a/modules/block/tests/block_test.info +++ b/modules/block/tests/block_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/block/tests/themes/block_test_theme/block_test_theme.info b/modules/block/tests/themes/block_test_theme/block_test_theme.info index db7de24c..3a754800 100755 --- a/modules/block/tests/themes/block_test_theme/block_test_theme.info +++ b/modules/block/tests/themes/block_test_theme/block_test_theme.info @@ -13,8 +13,8 @@ regions[footer] = Footer regions[highlighted] = Highlighted regions[help] = Help -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/blog/blog.info b/modules/blog/blog.info index 0da27033..6ef427a1 100755 --- a/modules/blog/blog.info +++ b/modules/blog/blog.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = blog.test -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/book/book.info b/modules/book/book.info index cb8a5db8..45e3b2a3 100755 --- a/modules/book/book.info +++ b/modules/book/book.info @@ -7,8 +7,8 @@ files[] = book.test configure = admin/content/book/settings stylesheets[all][] = book.css -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/book/book.module b/modules/book/book.module index 71b89945..7afed9ae 100755 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -1375,7 +1375,7 @@ function book_link_load($mlid) { * A fully loaded menu link. * * @return - * An subtree of menu links in an array, in the order they should be rendered. + * A subtree of menu links in an array, in the order they should be rendered. */ function book_menu_subtree_data($link) { $tree = &drupal_static(__FUNCTION__, array()); diff --git a/modules/color/color.info b/modules/color/color.info index ba16536c..6b393ea5 100755 --- a/modules/color/color.info +++ b/modules/color/color.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = color.test -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/color/color.module b/modules/color/color.module index 9ae7f73d..53c54fbf 100755 --- a/modules/color/color.module +++ b/modules/color/color.module @@ -346,9 +346,10 @@ function color_scheme_form_submit($form, &$form_state) { // memory_get_usage(), therefore we won't inadvertently reject a color // scheme change based on a faulty memory calculation. $usage = memory_get_usage(TRUE); - $limit = parse_size(ini_get('memory_limit')); - if ($usage + $required > $limit) { - drupal_set_message(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size more. Check the PHP documentation for more information.', array('%size' => format_size($usage + $required - $limit), '@url' => 'http://www.php.net/manual/ini.core.php#ini.sect.resource-limits')), 'error'); + $memory_limit = ini_get('memory_limit'); + $size = parse_size($memory_limit); + if (!drupal_check_memory_limit($usage + $required, $memory_limit)) { + drupal_set_message(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size more. Check the PHP documentation for more information.', array('%size' => format_size($usage + $required - $size), '@url' => 'http://www.php.net/manual/ini.core.php#ini.sect.resource-limits')), 'error'); return; } } diff --git a/modules/comment/comment.info b/modules/comment/comment.info index 7912dfec..09aff8ac 100755 --- a/modules/comment/comment.info +++ b/modules/comment/comment.info @@ -9,8 +9,8 @@ files[] = comment.test configure = admin/content/comment stylesheets[all][] = comment.css -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 46115be0..a83069f6 100755 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -152,7 +152,7 @@ function comment_node_type_load($name) { } /** - * Entity URI callback. + * Implements callback_entity_info_uri(). */ function comment_uri($comment) { return array( diff --git a/modules/contact/contact.info b/modules/contact/contact.info index d78ba691..2f7b3dbf 100755 --- a/modules/contact/contact.info +++ b/modules/contact/contact.info @@ -6,8 +6,8 @@ core = 7.x files[] = contact.test configure = admin/structure/contact -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/contact/contact.test b/modules/contact/contact.test index 48c8bb01..6693b574 100755 --- a/modules/contact/contact.test +++ b/modules/contact/contact.test @@ -36,7 +36,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase { $edit = array(); $edit['contact_default_status'] = TRUE; $this->drupalPost('admin/config/people/accounts', $edit, t('Save configuration')); - $this->assertText(t('The configuration options have been saved.'), t('Setting successfully saved.')); + $this->assertText(t('The configuration options have been saved.'), 'Setting successfully saved.'); // Delete old categories to ensure that new categories are used. $this->deleteCategories(); @@ -56,21 +56,21 @@ class ContactSitewideTestCase extends DrupalWebTestCase { $invalid_recipients = array('invalid', 'invalid@', 'invalid@site.', '@site.', '@site.com'); foreach ($invalid_recipients as $invalid_recipient) { $this->addCategory($this->randomName(16), $invalid_recipient, '', FALSE); - $this->assertRaw(t('%recipient is an invalid e-mail address.', array('%recipient' => $invalid_recipient)), t('Caught invalid recipient (' . $invalid_recipient . ').')); + $this->assertRaw(t('%recipient is an invalid e-mail address.', array('%recipient' => $invalid_recipient)), format_string('Caught invalid recipient (@invalid_recipient).', array('@invalid_recipient' => $invalid_recipient))); } // Test validation of empty category and recipients fields. $this->addCategory($category = '', '', '', TRUE); - $this->assertText(t('Category field is required.'), t('Caught empty category field')); - $this->assertText(t('Recipients field is required.'), t('Caught empty recipients field.')); + $this->assertText(t('Category field is required.'), 'Caught empty category field'); + $this->assertText(t('Recipients field is required.'), 'Caught empty recipients field.'); // Create first valid category. $recipients = array('simpletest@example.com', 'simpletest2@example.com', 'simpletest3@example.com'); $this->addCategory($category = $this->randomName(16), implode(',', array($recipients[0])), '', TRUE); - $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), t('Category successfully saved.')); + $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), 'Category successfully saved.'); // Make sure the newly created category is included in the list of categories. - $this->assertNoUniqueText($category, t('New category included in categories list.')); + $this->assertNoUniqueText($category, 'New category included in categories list.'); // Test update contact form category. $categories = $this->getCategories(); @@ -80,80 +80,80 @@ class ContactSitewideTestCase extends DrupalWebTestCase { $this->assertEqual($category_array['recipients'], $recipients_str); $this->assertEqual($category_array['reply'], $reply); $this->assertFalse($category_array['selected']); - $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), t('Category successfully saved.')); + $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), 'Category successfully saved.'); // Ensure that the contact form is shown without a category selection input. user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form')); $this->drupalLogout(); $this->drupalGet('contact'); - $this->assertText(t('Your e-mail address'), t('Contact form is shown when there is one category.')); - $this->assertNoText(t('Category'), t('When there is only one category, the category selection element is hidden.')); + $this->assertText(t('Your e-mail address'), 'Contact form is shown when there is one category.'); + $this->assertNoText(t('Category'), 'When there is only one category, the category selection element is hidden.'); $this->drupalLogin($admin_user); // Add more categories. $this->addCategory($category = $this->randomName(16), implode(',', array($recipients[0], $recipients[1])), '', FALSE); - $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), t('Category successfully saved.')); + $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), 'Category successfully saved.'); $this->addCategory($category = $this->randomName(16), implode(',', array($recipients[0], $recipients[1], $recipients[2])), '', FALSE); - $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), t('Category successfully saved.')); + $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), 'Category successfully saved.'); // Try adding a category that already exists. $this->addCategory($category, '', '', FALSE); - $this->assertNoRaw(t('Category %category has been saved.', array('%category' => $category)), t('Category not saved.')); - $this->assertRaw(t('A contact form with category %category already exists.', array('%category' => $category)), t('Duplicate category error found.')); + $this->assertNoRaw(t('Category %category has been saved.', array('%category' => $category)), 'Category not saved.'); + $this->assertRaw(t('A contact form with category %category already exists.', array('%category' => $category)), 'Duplicate category error found.'); // Clear flood table in preparation for flood test and allow other checks to complete. db_delete('flood')->execute(); $num_records_after = db_query("SELECT COUNT(*) FROM {flood}")->fetchField(); - $this->assertIdentical($num_records_after, '0', t('Flood table emptied.')); + $this->assertIdentical($num_records_after, '0', 'Flood table emptied.'); $this->drupalLogout(); // Check to see that anonymous user cannot see contact page without permission. user_role_revoke_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form')); $this->drupalGet('contact'); - $this->assertResponse(403, t('Access denied to anonymous user without permission.')); + $this->assertResponse(403, 'Access denied to anonymous user without permission.'); // Give anonymous user permission and see that page is viewable. user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form')); $this->drupalGet('contact'); - $this->assertResponse(200, t('Access granted to anonymous user with permission.')); + $this->assertResponse(200, 'Access granted to anonymous user with permission.'); // Submit contact form with invalid values. $this->submitContact('', $recipients[0], $this->randomName(16), $categories[0], $this->randomName(64)); - $this->assertText(t('Your name field is required.'), t('Name required.')); + $this->assertText(t('Your name field is required.'), 'Name required.'); $this->submitContact($this->randomName(16), '', $this->randomName(16), $categories[0], $this->randomName(64)); - $this->assertText(t('Your e-mail address field is required.'), t('E-mail required.')); + $this->assertText(t('Your e-mail address field is required.'), 'E-mail required.'); $this->submitContact($this->randomName(16), $invalid_recipients[0], $this->randomName(16), $categories[0], $this->randomName(64)); - $this->assertText(t('You must enter a valid e-mail address.'), t('Valid e-mail required.')); + $this->assertText(t('You must enter a valid e-mail address.'), 'Valid e-mail required.'); $this->submitContact($this->randomName(16), $recipients[0], '', $categories[0], $this->randomName(64)); - $this->assertText(t('Subject field is required.'), t('Subject required.')); + $this->assertText(t('Subject field is required.'), 'Subject required.'); $this->submitContact($this->randomName(16), $recipients[0], $this->randomName(16), $categories[0], ''); - $this->assertText(t('Message field is required.'), t('Message required.')); + $this->assertText(t('Message field is required.'), 'Message required.'); // Test contact form with no default category selected. db_update('contact') ->fields(array('selected' => 0)) ->execute(); $this->drupalGet('contact'); - $this->assertRaw(t('- Please choose -'), t('Without selected categories the visitor is asked to chose a category.')); + $this->assertRaw(t('- Please choose -'), 'Without selected categories the visitor is asked to chose a category.'); // Submit contact form with invalid category id (cid 0). $this->submitContact($this->randomName(16), $recipients[0], $this->randomName(16), 0, ''); - $this->assertText(t('You must select a valid category.'), t('Valid category required.')); + $this->assertText(t('You must select a valid category.'), 'Valid category required.'); // Submit contact form with correct values and check flood interval. for ($i = 0; $i < $flood_limit; $i++) { $this->submitContact($this->randomName(16), $recipients[0], $this->randomName(16), $categories[0], $this->randomName(64)); - $this->assertText(t('Your message has been sent.'), t('Message sent.')); + $this->assertText(t('Your message has been sent.'), 'Message sent.'); } // Submit contact form one over limit. $this->drupalGet('contact'); - $this->assertResponse(403, t('Access denied to anonymous user after reaching message treshold.')); - $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => variable_get('contact_threshold_limit', 3), '@interval' => format_interval(600))), t('Message threshold reached.')); + $this->assertResponse(403, 'Access denied to anonymous user after reaching message treshold.'); + $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => variable_get('contact_threshold_limit', 3), '@interval' => format_interval(600))), 'Message threshold reached.'); // Delete created categories. $this->drupalLogin($admin_user); @@ -182,8 +182,8 @@ class ContactSitewideTestCase extends DrupalWebTestCase { // We are testing the auto-reply, so there should be one e-mail going to the sender. $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'foo@example.com')); - $this->assertEqual(count($captured_emails), 1, t('Auto-reply e-mail was sent to the sender for category "foo".'), t('Contact')); - $this->assertEqual($captured_emails[0]['body'], drupal_html_to_text($foo_autoreply), t('Auto-reply e-mail body is correct for category "foo".'), t('Contact')); + $this->assertEqual(count($captured_emails), 1, 'Auto-reply e-mail was sent to the sender for category "foo".', 'Contact'); + $this->assertEqual($captured_emails[0]['body'], drupal_html_to_text($foo_autoreply), 'Auto-reply e-mail body is correct for category "foo".', 'Contact'); // Test the auto-reply for category 'bar'. $email = $this->randomName(32) . '@example.com'; @@ -191,14 +191,14 @@ class ContactSitewideTestCase extends DrupalWebTestCase { // Auto-reply for category 'bar' should result in one auto-reply e-mail to the sender. $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'bar@example.com')); - $this->assertEqual(count($captured_emails), 1, t('Auto-reply e-mail was sent to the sender for category "bar".'), t('Contact')); - $this->assertEqual($captured_emails[0]['body'], drupal_html_to_text($bar_autoreply), t('Auto-reply e-mail body is correct for category "bar".'), t('Contact')); + $this->assertEqual(count($captured_emails), 1, 'Auto-reply e-mail was sent to the sender for category "bar".', 'Contact'); + $this->assertEqual($captured_emails[0]['body'], drupal_html_to_text($bar_autoreply), 'Auto-reply e-mail body is correct for category "bar".', 'Contact'); // Verify that no auto-reply is sent when the auto-reply field is left blank. $email = $this->randomName(32) . '@example.com'; $this->submitContact($this->randomName(16), $email, $this->randomString(64), 4, $this->randomString(128)); $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'no_autoreply@example.com')); - $this->assertEqual(count($captured_emails), 0, t('No auto-reply e-mail was sent to the sender for category "no-autoreply".'), t('Contact')); + $this->assertEqual(count($captured_emails), 0, 'No auto-reply e-mail was sent to the sender for category "no-autoreply".', 'Contact'); } /** @@ -279,7 +279,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase { foreach ($categories as $category) { $category_name = db_query("SELECT category FROM {contact} WHERE cid = :cid", array(':cid' => $category))->fetchField(); $this->drupalPost('admin/structure/contact/delete/' . $category, array(), t('Delete')); - $this->assertRaw(t('Category %category has been deleted.', array('%category' => $category_name)), t('Category deleted successfully.')); + $this->assertRaw(t('Category %category has been deleted.', array('%category' => $category_name)), 'Category deleted successfully.'); } } @@ -355,7 +355,7 @@ class ContactPersonalTestCase extends DrupalWebTestCase { $this->drupalLogin($this->admin_user); $edit = array('contact_default_status' => FALSE); $this->drupalPost('admin/config/people/accounts', $edit, t('Save configuration')); - $this->assertText(t('The configuration options have been saved.'), t('Setting successfully saved.')); + $this->assertText(t('The configuration options have been saved.'), 'Setting successfully saved.'); $this->drupalLogout(); // Re-create our contacted user with personal contact forms disabled by diff --git a/modules/contextual/contextual.css b/modules/contextual/contextual.css index 3829328c..93a17963 100755 --- a/modules/contextual/contextual.css +++ b/modules/contextual/contextual.css @@ -77,7 +77,7 @@ div.contextual-links-wrapper ul.contextual-links { -webkit-border-top-left-radius: 4px; /* LTR */ border-radius: 4px 0 4px 4px; /* LTR */ } -.contextual-links-region:hover a.contextual-links-trigger, +a.contextual-links-trigger-active, div.contextual-links-active a.contextual-links-trigger, div.contextual-links-active ul.contextual-links { display: block; diff --git a/modules/contextual/contextual.info b/modules/contextual/contextual.info index dec08994..e9cf706d 100755 --- a/modules/contextual/contextual.info +++ b/modules/contextual/contextual.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = contextual.test -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/contextual/contextual.js b/modules/contextual/contextual.js index ebe50913..4339780e 100755 --- a/modules/contextual/contextual.js +++ b/modules/contextual/contextual.js @@ -30,6 +30,10 @@ Drupal.behaviors.contextualLinks = { ); // Hide the contextual links when user clicks a link or rolls out of the .contextual-links-region. $region.bind('mouseleave click', Drupal.contextualLinks.mouseleave); + $region.hover( + function() { $trigger.addClass('contextual-links-trigger-active'); }, + function() { $trigger.removeClass('contextual-links-trigger-active'); } + ); // Prepend the trigger. $wrapper.prepend($trigger); }); diff --git a/modules/dashboard/dashboard.info b/modules/dashboard/dashboard.info index 6521eba5..c2a04a74 100755 --- a/modules/dashboard/dashboard.info +++ b/modules/dashboard/dashboard.info @@ -7,8 +7,8 @@ files[] = dashboard.test dependencies[] = block configure = admin/dashboard/customize -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/dashboard/dashboard.js b/modules/dashboard/dashboard.js index 83ffc1f2..62f13a41 100755 --- a/modules/dashboard/dashboard.js +++ b/modules/dashboard/dashboard.js @@ -9,7 +9,7 @@ * Implements Drupal.behaviors for the Dashboard module. */ Drupal.behaviors.dashboard = { - attach: function (context, settings) { + attach: function (context, settings) { $('#dashboard', context).once(function () { $(this).prepend(''); $('.customize .action-links a', this).click(Drupal.behaviors.dashboard.enterCustomizeMode); diff --git a/modules/dblog/dblog.info b/modules/dblog/dblog.info index 1655024d..760af5bd 100755 --- a/modules/dblog/dblog.info +++ b/modules/dblog/dblog.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x files[] = dblog.test -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/dblog/dblog.test b/modules/dblog/dblog.test index cd101930..f1d1034d 100755 --- a/modules/dblog/dblog.test +++ b/modules/dblog/dblog.test @@ -79,10 +79,10 @@ class DBLogTestCase extends DrupalWebTestCase { // Check row limit variable. $current_limit = variable_get('dblog_row_limit', 1000); - $this->assertTrue($current_limit == $row_limit, t('[Cache] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit))); + $this->assertTrue($current_limit == $row_limit, format_string('[Cache] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit))); // Verify dblog row limit equals specified row limit. $current_limit = unserialize(db_query("SELECT value FROM {variable} WHERE name = :dblog_limit", array(':dblog_limit' => 'dblog_row_limit'))->fetchField()); - $this->assertTrue($current_limit == $row_limit, t('[Variable table] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit))); + $this->assertTrue($current_limit == $row_limit, format_string('[Variable table] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit))); } /** @@ -96,14 +96,14 @@ class DBLogTestCase extends DrupalWebTestCase { $this->generateLogEntries($row_limit + 10); // Verify that the database log row count exceeds the row limit. $count = db_query('SELECT COUNT(wid) FROM {watchdog}')->fetchField(); - $this->assertTrue($count > $row_limit, t('Dblog row count of @count exceeds row limit of @limit', array('@count' => $count, '@limit' => $row_limit))); + $this->assertTrue($count > $row_limit, format_string('Dblog row count of @count exceeds row limit of @limit', array('@count' => $count, '@limit' => $row_limit))); // Run a cron job. $this->cronRun(); // Verify that the database log row count equals the row limit plus one // because cron adds a record after it runs. $count = db_query('SELECT COUNT(wid) FROM {watchdog}')->fetchField(); - $this->assertTrue($count == $row_limit + 1, t('Dblog row count of @count equals row limit of @limit plus one', array('@count' => $count, '@limit' => $row_limit))); + $this->assertTrue($count == $row_limit + 1, format_string('Dblog row count of @count equals row limit of @limit plus one', array('@count' => $count, '@limit' => $row_limit))); } /** @@ -153,35 +153,35 @@ class DBLogTestCase extends DrupalWebTestCase { $this->drupalGet('admin/help/dblog'); $this->assertResponse($response); if ($response == 200) { - $this->assertText(t('Database logging'), t('DBLog help was displayed')); + $this->assertText(t('Database logging'), 'DBLog help was displayed'); } // View the database log report page. $this->drupalGet('admin/reports/dblog'); $this->assertResponse($response); if ($response == 200) { - $this->assertText(t('Recent log messages'), t('DBLog report was displayed')); + $this->assertText(t('Recent log messages'), 'DBLog report was displayed'); } // View the database log page-not-found report page. $this->drupalGet('admin/reports/page-not-found'); $this->assertResponse($response); if ($response == 200) { - $this->assertText(t('Top ' . $quote . 'page not found' . $quote . ' errors'), t('DBLog page-not-found report was displayed')); + $this->assertText(t('Top ' . $quote . 'page not found' . $quote . ' errors'), 'DBLog page-not-found report was displayed'); } // View the database log access-denied report page. $this->drupalGet('admin/reports/access-denied'); $this->assertResponse($response); if ($response == 200) { - $this->assertText(t('Top ' . $quote . 'access denied' . $quote . ' errors'), t('DBLog access-denied report was displayed')); + $this->assertText(t('Top ' . $quote . 'access denied' . $quote . ' errors'), 'DBLog access-denied report was displayed'); } // View the database log event page. $this->drupalGet('admin/reports/event/1'); $this->assertResponse($response); if ($response == 200) { - $this->assertText(t('Details'), t('DBLog event node was displayed')); + $this->assertText(t('Details'), 'DBLog event node was displayed'); } } @@ -220,7 +220,7 @@ class DBLogTestCase extends DrupalWebTestCase { $this->assertResponse(200); // Retrieve the user object. $user = user_load_by_name($name); - $this->assertTrue($user != NULL, t('User @name was loaded', array('@name' => $name))); + $this->assertTrue($user != NULL, format_string('User @name was loaded', array('@name' => $name))); // pass_raw property is needed by drupalLogin. $user->pass_raw = $pass; // Login user. @@ -233,7 +233,7 @@ class DBLogTestCase extends DrupalWebTestCase { $ids[] = $row->wid; } $count_before = (isset($ids)) ? count($ids) : 0; - $this->assertTrue($count_before > 0, t('DBLog contains @count records for @name', array('@count' => $count_before, '@name' => $user->name))); + $this->assertTrue($count_before > 0, format_string('DBLog contains @count records for @name', array('@count' => $count_before, '@name' => $user->name))); // Login the admin user. $this->drupalLogin($this->big_user); @@ -249,11 +249,11 @@ class DBLogTestCase extends DrupalWebTestCase { // Add user. // Default display includes name and email address; if too long, the email // address is replaced by three periods. - $this->assertLogMessage(t('New user: %name (%email).', array('%name' => $name, '%email' => $user->mail)), t('DBLog event was recorded: [add user]')); + $this->assertLogMessage(t('New user: %name (%email).', array('%name' => $name, '%email' => $user->mail)), 'DBLog event was recorded: [add user]'); // Login user. - $this->assertLogMessage(t('Session opened for %name.', array('%name' => $name)), t('DBLog event was recorded: [login user]')); + $this->assertLogMessage(t('Session opened for %name.', array('%name' => $name)), 'DBLog event was recorded: [login user]'); // Logout user. - $this->assertLogMessage(t('Session closed for %name.', array('%name' => $name)), t('DBLog event was recorded: [logout user]')); + $this->assertLogMessage(t('Session closed for %name.', array('%name' => $name)), 'DBLog event was recorded: [logout user]'); // Delete user. $message = t('Deleted user: %name %email.', array('%name' => $name, '%email' => '<' . $user->mail . '>')); $message_text = truncate_utf8(filter_xss($message, array()), 56, TRUE, TRUE); @@ -268,12 +268,12 @@ class DBLogTestCase extends DrupalWebTestCase { $link = drupal_substr($value, strpos($value, 'admin/reports/event/')); $this->drupalGet($link); // Check for full message text on the details page. - $this->assertRaw($message, t('DBLog event details was found: [delete user]')); + $this->assertRaw($message, 'DBLog event details was found: [delete user]'); break; } } } - $this->assertTrue($link, t('DBLog event was recorded: [delete user]')); + $this->assertTrue($link, 'DBLog event was recorded: [delete user]'); // Visit random URL (to generate page not found event). $not_found_url = $this->randomName(60); $this->drupalGet($not_found_url); @@ -282,7 +282,7 @@ class DBLogTestCase extends DrupalWebTestCase { $this->drupalGet('admin/reports/page-not-found'); $this->assertResponse(200); // Check that full-length URL displayed. - $this->assertText($not_found_url, t('DBLog event was recorded: [page not found]')); + $this->assertText($not_found_url, 'DBLog event was recorded: [page not found]'); } /** @@ -307,7 +307,7 @@ class DBLogTestCase extends DrupalWebTestCase { $this->assertResponse(200); // Retrieve the node object. $node = $this->drupalGetNodeByTitle($title); - $this->assertTrue($node != NULL, t('Node @title was loaded', array('@title' => $title))); + $this->assertTrue($node != NULL, format_string('Node @title was loaded', array('@title' => $title))); // Edit the node. $edit = $this->getContentUpdate($type); $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); @@ -330,23 +330,23 @@ class DBLogTestCase extends DrupalWebTestCase { // Verify that node events were recorded. // Was node content added? - $this->assertLogMessage(t('@type: added %title.', array('@type' => $type, '%title' => $title)), t('DBLog event was recorded: [content added]')); + $this->assertLogMessage(t('@type: added %title.', array('@type' => $type, '%title' => $title)), 'DBLog event was recorded: [content added]'); // Was node content updated? - $this->assertLogMessage(t('@type: updated %title.', array('@type' => $type, '%title' => $title)), t('DBLog event was recorded: [content updated]')); + $this->assertLogMessage(t('@type: updated %title.', array('@type' => $type, '%title' => $title)), 'DBLog event was recorded: [content updated]'); // Was node content deleted? - $this->assertLogMessage(t('@type: deleted %title.', array('@type' => $type, '%title' => $title)), t('DBLog event was recorded: [content deleted]')); + $this->assertLogMessage(t('@type: deleted %title.', array('@type' => $type, '%title' => $title)), 'DBLog event was recorded: [content deleted]'); // View the database log access-denied report page. $this->drupalGet('admin/reports/access-denied'); $this->assertResponse(200); // Verify that the 'access denied' event was recorded. - $this->assertText(t('admin/reports/dblog'), t('DBLog event was recorded: [access denied]')); + $this->assertText(t('admin/reports/dblog'), 'DBLog event was recorded: [access denied]'); // View the database log page-not-found report page. $this->drupalGet('admin/reports/page-not-found'); $this->assertResponse(200); // Verify that the 'page not found' event was recorded. - $this->assertText(t('node/@nid', array('@nid' => $node->nid)), t('DBLog event was recorded: [page not found]')); + $this->assertText(t('node/@nid', array('@nid' => $node->nid)), 'DBLog event was recorded: [page not found]'); } /** @@ -433,14 +433,14 @@ class DBLogTestCase extends DrupalWebTestCase { // Add a watchdog entry. dblog_watchdog($log); // Make sure the table count has actually been incremented. - $this->assertEqual($count + 1, db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), t('dblog_watchdog() added an entry to the dblog :count', array(':count' => $count))); + $this->assertEqual($count + 1, db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), format_string('dblog_watchdog() added an entry to the dblog :count', array(':count' => $count))); // Login the admin user. $this->drupalLogin($this->big_user); // Post in order to clear the database table. $this->drupalPost('admin/reports/dblog', array(), t('Clear log messages')); // Count the rows in watchdog that previously related to the deleted user. $count = db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(); - $this->assertEqual($count, 0, t('DBLog contains :count records after a clear.', array(':count' => $count))); + $this->assertEqual($count, 0, format_string('DBLog contains :count records after a clear.', array(':count' => $count))); } /** @@ -512,7 +512,7 @@ class DBLogTestCase extends DrupalWebTestCase { // Clear all logs and make sure the confirmation message is found. $this->drupalPost('admin/reports/dblog', array(), t('Clear log messages')); - $this->assertText(t('Database log cleared.'), t('Confirmation message found')); + $this->assertText(t('Database log cleared.'), 'Confirmation message found'); } /** diff --git a/modules/field/field.api.php b/modules/field/field.api.php index 822f537b..463da551 100755 --- a/modules/field/field.api.php +++ b/modules/field/field.api.php @@ -23,14 +23,20 @@ * @see hook_field_extra_fields_alter() * * @return - * A nested array of 'pseudo-field' components. Each list is nested within - * the following keys: entity type, bundle name, context (either 'form' or + * A nested array of 'pseudo-field' elements. Each list is nested within the + * following keys: entity type, bundle name, context (either 'form' or * 'display'). The keys are the name of the elements as appearing in the * renderable array (either the entity form or the displayed entity). The * value is an associative array: - * - label: The human readable name of the component. - * - description: A short description of the component contents. + * - label: The human readable name of the element. + * - description: A short description of the element contents. * - weight: The default weight of the element. + * - edit: (optional) String containing markup (normally a link) used as the + * element's 'edit' operation in the administration interface. Only for + * 'form' context. + * - delete: (optional) String containing markup (normally a link) used as the + * element's 'delete' operation in the administration interface. Only for + * 'form' context. */ function hook_field_extra_fields() { $extra['node']['poll'] = array( @@ -2508,7 +2514,7 @@ function hook_field_delete_field($field) { * * @param $instance * The instance as it is post-update. - * @param $prior_$instance + * @param $prior_instance * The instance as it was pre-update. */ function hook_field_update_instance($instance, $prior_instance) { diff --git a/modules/field/field.crud.inc b/modules/field/field.crud.inc index e1acdd53..83863d6e 100755 --- a/modules/field/field.crud.inc +++ b/modules/field/field.crud.inc @@ -244,9 +244,11 @@ function field_update_field($field) { // $prior_field may no longer be right. module_load_install($field['module']); $schema = (array) module_invoke($field['module'], 'field_schema', $field); - $schema += array('columns' => array(), 'indexes' => array()); + $schema += array('columns' => array(), 'indexes' => array(), 'foreign keys' => array()); // 'columns' are hardcoded in the field type. $field['columns'] = $schema['columns']; + // 'foreign keys' are hardcoded in the field type. + $field['foreign keys'] = $schema['foreign keys']; // 'indexes' can be both hardcoded in the field type, and specified in the // incoming $field definition. $field += array( @@ -522,17 +524,30 @@ function field_create_instance($instance) { * Updates an instance of a field. * * @param $instance - * An associative array representing an instance structure. The required - * keys and values are: + * An associative array representing an instance structure. The following + * required array elements specify which field instance is being updated: * - entity_type: The type of the entity the field is attached to. * - bundle: The bundle this field belongs to. * - field_name: The name of an existing field. - * Read-only_id properties are assigned automatically. Any other - * properties specified in $instance overwrite the existing values for - * the instance. + * The other array elements represent properties of the instance, and all + * properties must be specified or their default values will be used (except + * internal-use properties, which are assigned automatically). To avoid + * losing the previously stored properties of the instance when making a + * change, first load the instance with field_info_instance(), then override + * the values you want to override, and finally save using this function. + * Example: + * @code + * // Fetch an instance info array. + * $instance_info = field_info_instance($entity_type, $field_name, $bundle_name); + * // Change a single property in the instance definition. + * $instance_info['definition']['required'] = TRUE; + * // Write the changed definition back. + * field_update_instance($instance_info['definition']); + * @endcode * * @throws FieldException * + * @see field_info_instance() * @see field_create_instance() */ function field_update_instance($instance) { diff --git a/modules/field/field.info b/modules/field/field.info index 280514eb..fc9c3191 100755 --- a/modules/field/field.info +++ b/modules/field/field.info @@ -11,8 +11,8 @@ dependencies[] = field_sql_storage required = TRUE stylesheets[all][] = theme/field.css -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/field/field.info.inc b/modules/field/field.info.inc index 396ad5fd..02b3c9ca 100755 --- a/modules/field/field.info.inc +++ b/modules/field/field.info.inc @@ -449,6 +449,17 @@ function field_info_bundles($entity_type = NULL) { * - type: The field type. * - bundles: The bundles in which the field appears, as an array with entity * types as keys and the array of bundle names as values. + * Example: + * @code + * array( + * 'body' => array( + * 'bundles' => array( + * 'node' => array('page', 'article'), + * ), + * 'type' => 'text_with_summary', + * ), + * ); + * @endcode */ function field_info_field_map() { $cache = _field_info_field_cache(); diff --git a/modules/field/field.install b/modules/field/field.install index a4b15348..c5c5005d 100755 --- a/modules/field/field.install +++ b/modules/field/field.install @@ -128,7 +128,7 @@ function field_schema() { 'not null' => TRUE, 'default' => '' ), - 'entity_type' => array( + 'entity_type' => array( 'type' => 'varchar', 'length' => 32, 'not null' => TRUE, diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.info b/modules/field/modules/field_sql_storage/field_sql_storage.info index 36c529f6..3f73a1b7 100755 --- a/modules/field/modules/field_sql_storage/field_sql_storage.info +++ b/modules/field/modules/field_sql_storage/field_sql_storage.info @@ -7,8 +7,8 @@ dependencies[] = field files[] = field_sql_storage.test required = TRUE -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" 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 c639f38f..93f20771 100755 --- a/modules/field/modules/field_sql_storage/field_sql_storage.module +++ b/modules/field/modules/field_sql_storage/field_sql_storage.module @@ -188,7 +188,7 @@ function _field_sql_storage_schema($field) { foreach ($field['foreign keys'] as $specifier => $specification) { $real_name = _field_sql_storage_indexname($field['field_name'], $specifier); $current['foreign keys'][$real_name]['table'] = $specification['table']; - foreach ($specification['columns'] as $column => $referenced) { + foreach ($specification['columns'] as $column_name => $referenced) { $sql_storage_column = _field_sql_storage_columnname($field['field_name'], $column_name); $current['foreign keys'][$real_name]['columns'][$sql_storage_column] = $referenced; } diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.test b/modules/field/modules/field_sql_storage/field_sql_storage.test index 773de3d0..12c54ba2 100755 --- a/modules/field/modules/field_sql_storage/field_sql_storage.test +++ b/modules/field/modules/field_sql_storage/field_sql_storage.test @@ -126,7 +126,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); foreach ($values as $delta => $value) { if ($delta < $this->field['cardinality']) { - $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("Value $delta is inserted correctly")); + $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], format_string("Value %delta is inserted correctly", array('%delta' => $delta))); } else { $this->assertFalse(array_key_exists($delta, $rows), "No extraneous value gets inserted."); @@ -145,7 +145,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); foreach ($values as $delta => $value) { if ($delta < $this->field['cardinality']) { - $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("Value $delta is updated correctly")); + $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], format_string("Value %delta is updated correctly", array('%delta' => $delta))); } else { $this->assertFalse(array_key_exists($delta, $rows), "No extraneous value gets updated."); @@ -175,7 +175,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); foreach ($values as $delta => $value) { if ($delta < $this->field['cardinality']) { - $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("Update with no field_name entry leaves value $delta untouched")); + $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], format_string("Update with no field_name entry leaves value %delta untouched", array('%delta' => $delta))); } } @@ -183,7 +183,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $entity->{$this->field_name} = NULL; field_attach_update($entity_type, $entity); $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); - $this->assertEqual(count($rows), 0, t("Update with an empty field_name entry empties the field.")); + $this->assertEqual(count($rows), 0, "Update with an empty field_name entry empties the field."); } /** @@ -326,7 +326,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { // Ensure that the field tables are still there. foreach (_field_sql_storage_schema($prior_field) as $table_name => $table_info) { - $this->assertTrue(db_table_exists($table_name), t('Table %table exists.', array('%table' => $table_name))); + $this->assertTrue(db_table_exists($table_name), format_string('Table %table exists.', array('%table' => $table_name))); } } @@ -345,8 +345,8 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { // Verify the indexes we will create do not exist yet. foreach ($tables as $table) { - $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value'), t("No index named value exists in $table")); - $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value_format'), t("No index named value_format exists in $table")); + $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value'), format_string("No index named value exists in %table", array('%table' => $table))); + $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value_format'), format_string("No index named value_format exists in %table", array('%table' => $table))); } // Add data so the table cannot be dropped. @@ -358,21 +358,21 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $field = array('field_name' => $field_name, 'indexes' => array('value' => array('value'))); field_update_field($field); foreach ($tables as $table) { - $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value created in $table")); + $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), format_string("Index on value created in %table", array('%table' => $table))); } // Add a different index, removing the existing custom one. $field = array('field_name' => $field_name, 'indexes' => array('value_format' => array('value', 'format'))); field_update_field($field); foreach ($tables as $table) { - $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), t("Index on value_format created in $table")); - $this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value removed in $table")); + $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), format_string("Index on value_format created in %table", array('%table' => $table))); + $this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), format_string("Index on value removed in %table", array('%table' => $table))); } // Verify that the tables were not dropped. $entity = field_test_create_stub_entity(0, 0, $instance['bundle']); field_attach_load('test_entity', array(0 => $entity)); - $this->assertEqual($entity->{$field_name}[LANGUAGE_NONE][0]['value'], 'field data', t("Index changes performed without dropping the tables")); + $this->assertEqual($entity->{$field_name}[LANGUAGE_NONE][0]['value'], 'field data', "Index changes performed without dropping the tables"); } /** @@ -387,19 +387,19 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { $instance = field_info_instance($this->instance['entity_type'], $this->instance['field_name'], $this->instance['bundle']); // The storage details are indexed by a storage engine type. - $this->assertTrue(array_key_exists('sql', $field['storage']['details']), t('The storage type is SQL.')); + $this->assertTrue(array_key_exists('sql', $field['storage']['details']), 'The storage type is SQL.'); // The SQL details are indexed by table name. $details = $field['storage']['details']['sql']; - $this->assertTrue(array_key_exists($current, $details[FIELD_LOAD_CURRENT]), t('Table name is available in the instance array.')); - $this->assertTrue(array_key_exists($revision, $details[FIELD_LOAD_REVISION]), t('Revision table name is available in the instance array.')); + $this->assertTrue(array_key_exists($current, $details[FIELD_LOAD_CURRENT]), 'Table name is available in the instance array.'); + $this->assertTrue(array_key_exists($revision, $details[FIELD_LOAD_REVISION]), 'Revision table name is available in the instance array.'); // Test current and revision storage details together because the columns // are the same. foreach ((array) $this->field['columns'] as $column_name => $attributes) { $storage_column_name = _field_sql_storage_columnname($this->field['field_name'], $column_name); - $this->assertEqual($details[FIELD_LOAD_CURRENT][$current][$column_name], $storage_column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $current))); - $this->assertEqual($details[FIELD_LOAD_REVISION][$revision][$column_name], $storage_column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $revision))); + $this->assertEqual($details[FIELD_LOAD_CURRENT][$current][$column_name], $storage_column_name, format_string('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $current))); + $this->assertEqual($details[FIELD_LOAD_REVISION][$revision][$column_name], $storage_column_name, format_string('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $revision))); } } @@ -407,21 +407,35 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase { * Test foreign key support. */ function testFieldSqlStorageForeignKeys() { - // Create a decimal field. + // Create a 'shape' field, with a configurable foreign key (see + // field_test_field_schema()). $field_name = 'testfield'; - $field = array('field_name' => $field_name, 'type' => 'text'); - $field = field_create_field($field); - // Retrieve the field and instance with field_info and verify the foreign - // keys are in place. + $foreign_key_name = 'shape'; + $field = array('field_name' => $field_name, 'type' => 'shape', 'settings' => array('foreign_key_name' => $foreign_key_name)); + field_create_field($field); + + // Retrieve the field definition and check that the foreign key is in place. $field = field_info_field($field_name); - $this->assertEqual($field['foreign keys']['format']['table'], 'filter_format', t('Foreign key table name preserved through CRUD')); - $this->assertEqual($field['foreign keys']['format']['columns']['format'], 'format', t('Foreign key column name preserved through CRUD')); + $this->assertEqual($field['foreign keys'][$foreign_key_name]['table'], $foreign_key_name, 'Foreign key table name preserved through CRUD'); + $this->assertEqual($field['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'id', 'Foreign key column name preserved through CRUD'); + + // Update the field settings, it should update the foreign key definition + // too. + $foreign_key_name = 'color'; + $field['settings']['foreign_key_name'] = $foreign_key_name; + field_update_field($field); + + // Retrieve the field definition and check that the foreign key is in place. + $field = field_info_field($field_name); + $this->assertEqual($field['foreign keys'][$foreign_key_name]['table'], $foreign_key_name, 'Foreign key table name modified after update'); + $this->assertEqual($field['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'id', 'Foreign key column name modified after update'); + // Now grab the SQL schema and verify that too. - $schema = drupal_get_schema(_field_sql_storage_tablename($field)); - $this->assertEqual(count($schema['foreign keys']), 1, t("There is 1 foreign key in the schema")); + $schema = drupal_get_schema(_field_sql_storage_tablename($field), TRUE); + $this->assertEqual(count($schema['foreign keys']), 1, 'There is 1 foreign key in the schema'); $foreign_key = reset($schema['foreign keys']); - $filter_column = _field_sql_storage_columnname($field['field_name'], 'format'); - $this->assertEqual($foreign_key['table'], 'filter_format', t('Foreign key table name preserved in the schema')); - $this->assertEqual($foreign_key['columns'][$filter_column], 'format', t('Foreign key column name preserved in the schema')); + $foreign_key_column = _field_sql_storage_columnname($field['field_name'], $foreign_key_name); + $this->assertEqual($foreign_key['table'], $foreign_key_name, 'Foreign key table name preserved in the schema'); + $this->assertEqual($foreign_key['columns'][$foreign_key_column], 'id', 'Foreign key column name preserved in the schema'); } } diff --git a/modules/field/modules/list/list.info b/modules/field/modules/list/list.info index 3cc21c1f..24dfc987 100755 --- a/modules/field/modules/list/list.info +++ b/modules/field/modules/list/list.info @@ -7,8 +7,8 @@ dependencies[] = field dependencies[] = options files[] = tests/list.test -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/field/modules/list/tests/list.test b/modules/field/modules/list/tests/list.test index 7a0f46c6..84de7e89 100755 --- a/modules/field/modules/list/tests/list.test +++ b/modules/field/modules/list/tests/list.test @@ -51,9 +51,9 @@ class ListFieldTestCase extends FieldTestCase { // All three options appear. $entity = field_test_create_stub_entity(); $form = drupal_get_form('field_test_entity_form', $entity); - $this->assertTrue(!empty($form[$this->field_name][$langcode][1]), t('Option 1 exists')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][3]), t('Option 3 exists')); + $this->assertTrue(!empty($form[$this->field_name][$langcode][1]), 'Option 1 exists'); + $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), 'Option 2 exists'); + $this->assertTrue(!empty($form[$this->field_name][$langcode][3]), 'Option 3 exists'); // Use one of the values in an actual entity, and check that this value // cannot be removed from the list. @@ -77,19 +77,19 @@ class ListFieldTestCase extends FieldTestCase { field_update_field($this->field); $entity = field_test_create_stub_entity(); $form = drupal_get_form('field_test_entity_form', $entity); - $this->assertTrue(empty($form[$this->field_name][$langcode][1]), t('Option 1 does not exist')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists')); - $this->assertTrue(empty($form[$this->field_name][$langcode][3]), t('Option 3 does not exist')); + $this->assertTrue(empty($form[$this->field_name][$langcode][1]), 'Option 1 does not exist'); + $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), 'Option 2 exists'); + $this->assertTrue(empty($form[$this->field_name][$langcode][3]), 'Option 3 does not exist'); // Completely new options appear. $this->field['settings']['allowed_values'] = array(10 => 'Update', 20 => 'Twenty'); field_update_field($this->field); $form = drupal_get_form('field_test_entity_form', $entity); - $this->assertTrue(empty($form[$this->field_name][$langcode][1]), t('Option 1 does not exist')); - $this->assertTrue(empty($form[$this->field_name][$langcode][2]), t('Option 2 does not exist')); - $this->assertTrue(empty($form[$this->field_name][$langcode][3]), t('Option 3 does not exist')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][10]), t('Option 10 exists')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][20]), t('Option 20 exists')); + $this->assertTrue(empty($form[$this->field_name][$langcode][1]), 'Option 1 does not exist'); + $this->assertTrue(empty($form[$this->field_name][$langcode][2]), 'Option 2 does not exist'); + $this->assertTrue(empty($form[$this->field_name][$langcode][3]), 'Option 3 does not exist'); + $this->assertTrue(!empty($form[$this->field_name][$langcode][10]), 'Option 10 exists'); + $this->assertTrue(!empty($form[$this->field_name][$langcode][20]), 'Option 20 exists'); // Options are reset when a new field with the same name is created. field_delete_field($this->field_name); @@ -107,9 +107,9 @@ class ListFieldTestCase extends FieldTestCase { $this->instance = field_create_instance($this->instance); $entity = field_test_create_stub_entity(); $form = drupal_get_form('field_test_entity_form', $entity); - $this->assertTrue(!empty($form[$this->field_name][$langcode][1]), t('Option 1 exists')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists')); - $this->assertTrue(!empty($form[$this->field_name][$langcode][3]), t('Option 3 exists')); + $this->assertTrue(!empty($form[$this->field_name][$langcode][1]), 'Option 1 exists'); + $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), 'Option 2 exists'); + $this->assertTrue(!empty($form[$this->field_name][$langcode][3]), 'Option 3 exists'); } } @@ -233,20 +233,20 @@ class ListFieldUITestCase extends FieldTestCase { // Flat list of textual values. $string = "Zero\nOne"; $array = array('0' => 'Zero', '1' => 'One'); - $this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are accepted.')); + $this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are accepted.'); // Explicit integer keys. $string = "0|Zero\n2|Two"; $array = array('0' => 'Zero', '2' => 'Two'); - $this->assertAllowedValuesInput($string, $array, t('Integer keys are accepted.')); + $this->assertAllowedValuesInput($string, $array, 'Integer keys are accepted.'); // Check that values can be added and removed. $string = "0|Zero\n1|One"; $array = array('0' => 'Zero', '1' => 'One'); - $this->assertAllowedValuesInput($string, $array, t('Values can be added and removed.')); + $this->assertAllowedValuesInput($string, $array, 'Values can be added and removed.'); // Non-integer keys. - $this->assertAllowedValuesInput("1.1|One", 'keys must be integers', t('Non integer keys are rejected.')); - $this->assertAllowedValuesInput("abc|abc", 'keys must be integers', t('Non integer keys are rejected.')); + $this->assertAllowedValuesInput("1.1|One", 'keys must be integers', 'Non integer keys are rejected.'); + $this->assertAllowedValuesInput("abc|abc", 'keys must be integers', 'Non integer keys are rejected.'); // Mixed list of keyed and unkeyed values. - $this->assertAllowedValuesInput("Zero\n1|One", 'invalid input', t('Mixed lists are rejected.')); + $this->assertAllowedValuesInput("Zero\n1|One", 'invalid input', 'Mixed lists are rejected.'); // Create a node with actual data for the field. $settings = array( @@ -256,22 +256,22 @@ class ListFieldUITestCase extends FieldTestCase { $node = $this->drupalCreateNode($settings); // Check that a flat list of values is rejected once the field has data. - $this->assertAllowedValuesInput( "Zero\nOne", 'invalid input', t('Unkeyed lists are rejected once the field has data.')); + $this->assertAllowedValuesInput( "Zero\nOne", 'invalid input', 'Unkeyed lists are rejected once the field has data.'); // Check that values can be added but values in use cannot be removed. $string = "0|Zero\n1|One\n2|Two"; $array = array('0' => 'Zero', '1' => 'One', '2' => 'Two'); - $this->assertAllowedValuesInput($string, $array, t('Values can be added.')); + $this->assertAllowedValuesInput($string, $array, 'Values can be added.'); $string = "0|Zero\n1|One"; $array = array('0' => 'Zero', '1' => 'One'); - $this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.')); - $this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', t('Values in use cannot be removed.')); + $this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.'); + $this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', 'Values in use cannot be removed.'); // Delete the node, remove the value. node_delete($node->nid); $string = "0|Zero"; $array = array('0' => 'Zero'); - $this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.')); + $this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.'); } /** @@ -284,19 +284,19 @@ class ListFieldUITestCase extends FieldTestCase { // Flat list of textual values. $string = "Zero\nOne"; $array = array('0' => 'Zero', '1' => 'One'); - $this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are accepted.')); + $this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are accepted.'); // Explicit numeric keys. $string = "0|Zero\n.5|Point five"; $array = array('0' => 'Zero', '0.5' => 'Point five'); - $this->assertAllowedValuesInput($string, $array, t('Integer keys are accepted.')); + $this->assertAllowedValuesInput($string, $array, 'Integer keys are accepted.'); // Check that values can be added and removed. $string = "0|Zero\n.5|Point five\n1.0|One"; $array = array('0' => 'Zero', '0.5' => 'Point five', '1' => 'One'); - $this->assertAllowedValuesInput($string, $array, t('Values can be added and removed.')); + $this->assertAllowedValuesInput($string, $array, 'Values can be added and removed.'); // Non-numeric keys. - $this->assertAllowedValuesInput("abc|abc\n", 'each key must be a valid integer or decimal', t('Non numeric keys are rejected.')); + $this->assertAllowedValuesInput("abc|abc\n", 'each key must be a valid integer or decimal', 'Non numeric keys are rejected.'); // Mixed list of keyed and unkeyed values. - $this->assertAllowedValuesInput("Zero\n1|One\n", 'invalid input', t('Mixed lists are rejected.')); + $this->assertAllowedValuesInput("Zero\n1|One\n", 'invalid input', 'Mixed lists are rejected.'); // Create a node with actual data for the field. $settings = array( @@ -306,22 +306,22 @@ class ListFieldUITestCase extends FieldTestCase { $node = $this->drupalCreateNode($settings); // Check that a flat list of values is rejected once the field has data. - $this->assertAllowedValuesInput("Zero\nOne", 'invalid input', t('Unkeyed lists are rejected once the field has data.')); + $this->assertAllowedValuesInput("Zero\nOne", 'invalid input', 'Unkeyed lists are rejected once the field has data.'); // Check that values can be added but values in use cannot be removed. $string = "0|Zero\n.5|Point five\n2|Two"; $array = array('0' => 'Zero', '0.5' => 'Point five', '2' => 'Two'); - $this->assertAllowedValuesInput($string, $array, t('Values can be added.')); + $this->assertAllowedValuesInput($string, $array, 'Values can be added.'); $string = "0|Zero\n.5|Point five"; $array = array('0' => 'Zero', '0.5' => 'Point five'); - $this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.')); - $this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', t('Values in use cannot be removed.')); + $this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.'); + $this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', 'Values in use cannot be removed.'); // Delete the node, remove the value. node_delete($node->nid); $string = "0|Zero"; $array = array('0' => 'Zero'); - $this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.')); + $this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.'); } /** @@ -334,21 +334,21 @@ class ListFieldUITestCase extends FieldTestCase { // Flat list of textual values. $string = "Zero\nOne"; $array = array('Zero' => 'Zero', 'One' => 'One'); - $this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are accepted.')); + $this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are accepted.'); // Explicit keys. $string = "zero|Zero\none|One"; $array = array('zero' => 'Zero', 'one' => 'One'); - $this->assertAllowedValuesInput($string, $array, t('Explicit keys are accepted.')); + $this->assertAllowedValuesInput($string, $array, 'Explicit keys are accepted.'); // Check that values can be added and removed. $string = "zero|Zero\ntwo|Two"; $array = array('zero' => 'Zero', 'two' => 'Two'); - $this->assertAllowedValuesInput($string, $array, t('Values can be added and removed.')); + $this->assertAllowedValuesInput($string, $array, 'Values can be added and removed.'); // Mixed list of keyed and unkeyed values. $string = "zero|Zero\nOne\n"; $array = array('zero' => 'Zero', 'One' => 'One'); - $this->assertAllowedValuesInput($string, $array, t('Mixed lists are accepted.')); + $this->assertAllowedValuesInput($string, $array, 'Mixed lists are accepted.'); // Overly long keys. - $this->assertAllowedValuesInput("zero|Zero\n" . $this->randomName(256) . "|One", 'each key must be a string at most 255 characters long', t('Overly long keys are rejected.')); + $this->assertAllowedValuesInput("zero|Zero\n" . $this->randomName(256) . "|One", 'each key must be a string at most 255 characters long', 'Overly long keys are rejected.'); // Create a node with actual data for the field. $settings = array( @@ -361,22 +361,22 @@ class ListFieldUITestCase extends FieldTestCase { // data. $string = "Zero\nOne"; $array = array('Zero' => 'Zero', 'One' => 'One'); - $this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are still accepted once the field has data.')); + $this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are still accepted once the field has data.'); // Check that values can be added but values in use cannot be removed. $string = "Zero\nOne\nTwo"; $array = array('Zero' => 'Zero', 'One' => 'One', 'Two' => 'Two'); - $this->assertAllowedValuesInput($string, $array, t('Values can be added.')); + $this->assertAllowedValuesInput($string, $array, 'Values can be added.'); $string = "Zero\nOne"; $array = array('Zero' => 'Zero', 'One' => 'One'); - $this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.')); - $this->assertAllowedValuesInput("Zero", 'some values are being removed while currently in use', t('Values in use cannot be removed.')); + $this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.'); + $this->assertAllowedValuesInput("Zero", 'some values are being removed while currently in use', 'Values in use cannot be removed.'); // Delete the node, remove the value. node_delete($node->nid); $string = "Zero"; $array = array('Zero' => 'Zero'); - $this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.')); + $this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.'); } /** @@ -395,15 +395,15 @@ class ListFieldUITestCase extends FieldTestCase { 'off' => $off, ); $this->drupalPost($this->admin_path, $edit, t('Save settings')); - $this->assertText("Saved field_list_boolean configuration.", t("The 'On' and 'Off' form fields work for boolean fields.")); + $this->assertText("Saved field_list_boolean configuration.", "The 'On' and 'Off' form fields work for boolean fields."); // Test the allowed_values on the field settings form. $this->drupalGet($this->admin_path); - $this->assertFieldByName('on', $on, t("The 'On' value is stored correctly.")); - $this->assertFieldByName('off', $off, t("The 'Off' value is stored correctly.")); + $this->assertFieldByName('on', $on, "The 'On' value is stored correctly."); + $this->assertFieldByName('off', $off, "The 'Off' value is stored correctly."); $field = field_info_field($this->field_name); - $this->assertEqual($field['settings']['allowed_values'], $allowed_values, t('The allowed value is correct')); - $this->assertFalse(isset($field['settings']['on']), t('The on value is not saved into settings')); - $this->assertFalse(isset($field['settings']['off']), t('The off value is not saved into settings')); + $this->assertEqual($field['settings']['allowed_values'], $allowed_values, 'The allowed value is correct'); + $this->assertFalse(isset($field['settings']['on']), 'The on value is not saved into settings'); + $this->assertFalse(isset($field['settings']['off']), 'The off value is not saved into settings'); } /** diff --git a/modules/field/modules/list/tests/list_test.info b/modules/field/modules/list/tests/list_test.info index 9587a74f..ff08ef95 100755 --- a/modules/field/modules/list/tests/list_test.info +++ b/modules/field/modules/list/tests/list_test.info @@ -5,8 +5,8 @@ package = Testing version = VERSION hidden = TRUE -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/field/modules/number/number.info b/modules/field/modules/number/number.info index 9aa71350..69fd1ac3 100755 --- a/modules/field/modules/number/number.info +++ b/modules/field/modules/number/number.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = number.test -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/field/modules/number/number.test b/modules/field/modules/number/number.test index e5e7e8c7..88029cdd 100755 --- a/modules/field/modules/number/number.test +++ b/modules/field/modules/number/number.test @@ -58,7 +58,7 @@ class NumberFieldTestCase extends DrupalWebTestCase { // Display creation form. $this->drupalGet('test-entity/add/test-bundle'); $langcode = LANGUAGE_NONE; - $this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value]", '', t('Widget is displayed')); + $this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value]", '', 'Widget is displayed'); // Submit a signed decimal value within the allowed precision and scale. $value = '-1234.5678'; @@ -68,8 +68,8 @@ class NumberFieldTestCase extends DrupalWebTestCase { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created')); - $this->assertRaw(round($value, 2), t('Value is displayed.')); + $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); + $this->assertRaw(round($value, 2), 'Value is displayed.'); // Try to create entries with more than one decimal separator; assert fail. $wrong_entries = array( @@ -89,7 +89,7 @@ class NumberFieldTestCase extends DrupalWebTestCase { $this->assertText( t('There should only be one decimal separator (@separator)', array('@separator' => $this->field['settings']['decimal_separator'])), - t('Correctly failed to save decimal value with more than one decimal point.') + 'Correctly failed to save decimal value with more than one decimal point.' ); } diff --git a/modules/field/modules/options/options.info b/modules/field/modules/options/options.info index 904945d5..5afe004c 100755 --- a/modules/field/modules/options/options.info +++ b/modules/field/modules/options/options.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = options.test -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/field/modules/options/options.test b/modules/field/modules/options/options.test index 69d6116e..44b3caf2 100755 --- a/modules/field/modules/options/options.test +++ b/modules/field/modules/options/options.test @@ -1,7 +1,7 @@ assertNoFieldChecked("edit-card-1-$langcode-0"); $this->assertNoFieldChecked("edit-card-1-$langcode-1"); $this->assertNoFieldChecked("edit-card-1-$langcode-2"); - $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); + $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); // Select first option. $edit = array("card_1[$langcode]" => 0); @@ -139,7 +139,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->assertNoFieldChecked("edit-card-2-$langcode-0"); $this->assertNoFieldChecked("edit-card-2-$langcode-1"); $this->assertNoFieldChecked("edit-card-2-$langcode-2"); - $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); + $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); // Submit form: select first and third options. $edit = array( @@ -178,7 +178,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { "card_2[$langcode][2]" => TRUE, ); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertText('this field cannot hold more than 2 values', t('Validation error was displayed.')); + $this->assertText('this field cannot hold more than 2 values', 'Validation error was displayed.'); // Submit form: uncheck all options. $edit = array( @@ -225,19 +225,19 @@ class OptionsWidgetsTestCase extends FieldTestCase { // Display form. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); // A required field without any value has a "none" option. - $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- Select a value -'))), t('A required select list has a "Select a value" choice.')); + $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- Select a value -'))), 'A required select list has a "Select a value" choice.'); // With no field data, nothing is selected. $this->assertNoOptionSelected("edit-card-1-$langcode", '_none'); $this->assertNoOptionSelected("edit-card-1-$langcode", 0); $this->assertNoOptionSelected("edit-card-1-$langcode", 1); $this->assertNoOptionSelected("edit-card-1-$langcode", 2); - $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); + $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); // Submit form: select invalid 'none' option. $edit = array("card_1[$langcode]" => '_none'); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertRaw(t('!title field is required.', array('!title' => $instance['field_name'])), t('Cannot save a required field when selecting "none" from the select list.')); + $this->assertRaw(t('!title field is required.', array('!title' => $instance['field_name'])), 'Cannot save a required field when selecting "none" from the select list.'); // Submit form: select first option. $edit = array("card_1[$langcode]" => 0); @@ -247,7 +247,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { // Display form: check that the right options are selected. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); // A required field with a value has no 'none' option. - $this->assertFalse($this->xpath('//select[@id=:id]//option[@value="_none"]', array(':id' => 'edit-card-1-' . $langcode)), t('A required select list with an actual value has no "none" choice.')); + $this->assertFalse($this->xpath('//select[@id=:id]//option[@value="_none"]', array(':id' => 'edit-card-1-' . $langcode)), 'A required select list with an actual value has no "none" choice.'); $this->assertOptionSelected("edit-card-1-$langcode", 0); $this->assertNoOptionSelected("edit-card-1-$langcode", 1); $this->assertNoOptionSelected("edit-card-1-$langcode", 2); @@ -259,7 +259,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { // Display form. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); // A non-required field has a 'none' option. - $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- None -'))), t('A non-required select list has a "None" choice.')); + $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- None -'))), 'A non-required select list has a "None" choice.'); // Submit form: Unselect the option. $edit = array("card_1[$langcode]" => '_none'); $this->drupalPost('test-entity/manage/' . $entity->ftid . '/edit', $edit, t('Save')); @@ -276,8 +276,8 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->assertNoOptionSelected("edit-card-1-$langcode", 0); $this->assertNoOptionSelected("edit-card-1-$langcode", 1); $this->assertNoOptionSelected("edit-card-1-$langcode", 2); - $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); - $this->assertRaw('Group 1', t('Option groups are displayed.')); + $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); + $this->assertRaw('Group 1', 'Option groups are displayed.'); // Submit form: select first option. $edit = array("card_1[$langcode]" => 0); @@ -323,7 +323,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->assertNoOptionSelected("edit-card-2-$langcode", 0); $this->assertNoOptionSelected("edit-card-2-$langcode", 1); $this->assertNoOptionSelected("edit-card-2-$langcode", 2); - $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); + $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); // Submit form: select first and third options. $edit = array("card_2[$langcode][]" => array(0 => 0, 2 => 2)); @@ -350,7 +350,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { // Submit form: select the three options while the field accepts only 2. $edit = array("card_2[$langcode][]" => array(0 => 0, 1 => 1, 2 => 2)); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertText('this field cannot hold more than 2 values', t('Validation error was displayed.')); + $this->assertText('this field cannot hold more than 2 values', 'Validation error was displayed.'); // Submit form: uncheck all options. $edit = array("card_2[$langcode][]" => array()); @@ -374,7 +374,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { $instance['required'] = TRUE; field_update_instance($instance); $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); - $this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2-' . $langcode)), t('A required select list does not have an empty key.')); + $this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2-' . $langcode)), 'A required select list does not have an empty key.'); // We do not have to test that a required select list with one option is // auto-selected because the browser does it for us. @@ -393,8 +393,8 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->assertNoOptionSelected("edit-card-2-$langcode", 0); $this->assertNoOptionSelected("edit-card-2-$langcode", 1); $this->assertNoOptionSelected("edit-card-2-$langcode", 2); - $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); - $this->assertRaw('Group 1', t('Option groups are displayed.')); + $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); + $this->assertRaw('Group 1', 'Option groups are displayed.'); // Submit form: select first option. $edit = array("card_2[$langcode][]" => array(0 => 0)); @@ -438,7 +438,7 @@ class OptionsWidgetsTestCase extends FieldTestCase { // Display form: with no field data, option is unchecked. $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); $this->assertNoFieldChecked("edit-bool-$langcode"); - $this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.')); + $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); // Submit form: check the option. $edit = array("bool[$langcode]" => TRUE); @@ -483,13 +483,13 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->assertText( 'Use field label instead of the "On value" as label ', - t('Display setting checkbox available.') + 'Display setting checkbox available.' ); $this->assertFieldByXPath( '*//label[@for="edit-' . $this->bool['field_name'] . '-und" and text()="MyOnValue "]', TRUE, - t('Default case shows "On value"') + 'Default case shows "On value"' ); // Enable setting @@ -502,16 +502,16 @@ class OptionsWidgetsTestCase extends FieldTestCase { $this->drupalGet($fieldEditUrl); $this->assertText( 'Use field label instead of the "On value" as label ', - t('Display setting checkbox is available') + 'Display setting checkbox is available' ); $this->assertFieldChecked( 'edit-instance-widget-settings-display-label', - t('Display settings checkbox checked') + 'Display settings checkbox checked' ); $this->assertFieldByXPath( '*//label[@for="edit-' . $this->bool['field_name'] . '-und" and text()="' . $this->bool['field_name'] . ' "]', TRUE, - t('Display label changes label of the checkbox') + 'Display label changes label of the checkbox' ); } } diff --git a/modules/field/modules/text/text.info b/modules/field/modules/text/text.info index 64f88c23..f3a6ae6f 100755 --- a/modules/field/modules/text/text.info +++ b/modules/field/modules/text/text.info @@ -7,8 +7,8 @@ dependencies[] = field files[] = text.test required = TRUE -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/field/modules/text/text.test b/modules/field/modules/text/text.test index 59369370..2f147382 100755 --- a/modules/field/modules/text/text.test +++ b/modules/field/modules/text/text.test @@ -110,8 +110,8 @@ class TextFieldTestCase extends DrupalWebTestCase { // Display creation form. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget is displayed')); - $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '1', t('Format selector is not displayed')); + $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', 'Widget is displayed'); + $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '1', 'Format selector is not displayed'); // Submit with some value. $value = $this->randomName(); @@ -121,7 +121,7 @@ class TextFieldTestCase extends DrupalWebTestCase { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created')); + $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); // Display the entity. $entity = field_test_entity_test_load($id); @@ -179,8 +179,8 @@ class TextFieldTestCase extends DrupalWebTestCase { // Display the creation form. Since the user only has access to one format, // no format selector will be displayed. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget is displayed')); - $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '', t('Format selector is not displayed')); + $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', 'Widget is displayed'); + $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '', 'Format selector is not displayed'); // Submit with data that should be filtered. $value = '' . $this->randomName() . ''; @@ -190,14 +190,14 @@ class TextFieldTestCase extends DrupalWebTestCase { $this->drupalPost(NULL, $edit, t('Save')); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); $id = $match[1]; - $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created')); + $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created'); // Display the entity. $entity = field_test_entity_test_load($id); $entity->content = field_attach_view($entity_type, $entity, 'full'); $this->content = drupal_render($entity->content); - $this->assertNoRaw($value, t('HTML tags are not displayed.')); - $this->assertRaw(check_plain($value), t('Escaped HTML is displayed correctly.')); + $this->assertNoRaw($value, 'HTML tags are not displayed.'); + $this->assertRaw(check_plain($value), 'Escaped HTML is displayed correctly.'); // Create a new text format that does not escape HTML, and grant the user // access to it. @@ -219,21 +219,21 @@ class TextFieldTestCase extends DrupalWebTestCase { // Display edition form. // We should now have a 'text format' selector. $this->drupalGet('test-entity/manage/' . $id . '/edit'); - $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", NULL, t('Widget is displayed')); - $this->assertFieldByName("{$this->field_name}[$langcode][0][format]", NULL, t('Format selector is displayed')); + $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", NULL, 'Widget is displayed'); + $this->assertFieldByName("{$this->field_name}[$langcode][0][format]", NULL, 'Format selector is displayed'); // Edit and change the text format to the new one that was created. $edit = array( "{$this->field_name}[$langcode][0][format]" => $format_id, ); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), t('Entity was updated')); + $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated'); // Display the entity. $entity = field_test_entity_test_load($id); $entity->content = field_attach_view($entity_type, $entity, 'full'); $this->content = drupal_render($entity->content); - $this->assertRaw($value, t('Value is displayed unfiltered')); + $this->assertRaw($value, 'Value is displayed unfiltered'); } } @@ -383,7 +383,7 @@ class TextSummaryTestCase extends DrupalWebTestCase { */ function callTextSummary($text, $expected, $format = NULL, $size = NULL) { $summary = text_summary($text, $format, $size); - $this->assertIdentical($summary, $expected, t('Generated summary "@summary" matches expected "@expected".', array('@summary' => $summary, '@expected' => $expected))); + $this->assertIdentical($summary, $expected, format_string('Generated summary "@summary" matches expected "@expected".', array('@summary' => $summary, '@expected' => $expected))); } /** @@ -401,7 +401,7 @@ class TextSummaryTestCase extends DrupalWebTestCase { $this->drupalPost('node/add/article', $edit, t('Save')); $node = $this->drupalGetNodeByTitle($edit['title']); - $this->assertIdentical($node->body['und'][0]['summary'], $summary, t('Article with with summary and no body has been submitted.')); + $this->assertIdentical($node->body['und'][0]['summary'], $summary, 'Article with with summary and no body has been submitted.'); } } @@ -436,7 +436,7 @@ class TextTranslationTestCase extends DrupalWebTestCase { // Set "Article" content type to use multilingual support with translation. $edit = array('language_content_type' => 2); $this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type')); - $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Article')), t('Article content type has been updated.')); + $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Article')), 'Article content type has been updated.'); } /** @@ -464,7 +464,7 @@ class TextTranslationTestCase extends DrupalWebTestCase { $node = $this->drupalGetNodeByTitle($edit['title']); $this->drupalGet("node/$node->nid/translate"); $this->clickLink(t('add translation')); - $this->assertFieldByXPath("//textarea[@name='body[$langcode][0][value]']", $body, t('The textfield widget is populated.')); + $this->assertFieldByXPath("//textarea[@name='body[$langcode][0][value]']", $body, 'The textfield widget is populated.'); } /** @@ -476,7 +476,7 @@ class TextTranslationTestCase extends DrupalWebTestCase { $edit = array('field[cardinality]' => -1); $this->drupalPost('admin/structure/types/manage/article/fields/body', $edit, t('Save settings')); $this->drupalGet('node/add/article'); - $this->assertFieldByXPath("//input[@name='body_add_more']", t('Add another item'), t('Body field cardinality set to multiple.')); + $this->assertFieldByXPath("//input[@name='body_add_more']", t('Add another item'), 'Body field cardinality set to multiple.'); $body = array( $this->randomName(), @@ -501,7 +501,7 @@ class TextTranslationTestCase extends DrupalWebTestCase { "body[$langcode][$delta][format]" => array_shift($formats), ); $this->drupalPost('node/1/edit', $edit, t('Save')); - $this->assertText($body[$delta], t('The body field with delta @delta has been saved.', array('@delta' => $delta))); + $this->assertText($body[$delta], format_string('The body field with delta @delta has been saved.', array('@delta' => $delta))); } // Login as translator. @@ -511,7 +511,7 @@ class TextTranslationTestCase extends DrupalWebTestCase { $node = $this->drupalGetNodeByTitle($title); $this->drupalGet("node/$node->nid/translate"); $this->clickLink(t('add translation')); - $this->assertNoText($body[0], t('The body field with delta @delta is hidden.', array('@delta' => 0))); - $this->assertText($body[1], t('The body field with delta @delta is shown.', array('@delta' => 1))); + $this->assertNoText($body[0], format_string('The body field with delta @delta is hidden.', array('@delta' => 0))); + $this->assertText($body[1], format_string('The body field with delta @delta is shown.', array('@delta' => 1))); } } diff --git a/modules/field/tests/field.test b/modules/field/tests/field.test index 2852f67d..1e593154 100755 --- a/modules/field/tests/field.test +++ b/modules/field/tests/field.test @@ -64,9 +64,9 @@ class FieldTestCase extends DrupalWebTestCase { $e = clone $entity; field_attach_load('test_entity', array($e->ftid => $e)); $values = isset($e->{$field_name}[$langcode]) ? $e->{$field_name}[$langcode] : array(); - $this->assertEqual(count($values), count($expected_values), t('Expected number of values were saved.')); + $this->assertEqual(count($values), count($expected_values), 'Expected number of values were saved.'); foreach ($expected_values as $key => $value) { - $this->assertEqual($values[$key][$column], $value, t('Value @value was saved correctly.', array('@value' => $value))); + $this->assertEqual($values[$key][$column], $value, format_string('Value @value was saved correctly.', array('@value' => $value))); } } } @@ -182,12 +182,12 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']); field_attach_load($entity_type, array(0 => $entity)); // Number of values per field loaded equals the field cardinality. - $this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], t('Current revision: expected number of values')); + $this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], 'Current revision: expected number of values'); for ($delta = 0; $delta < $this->field['cardinality']; $delta++) { // The field value loaded matches the one inserted or updated. - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['value'] , $values[$current_revision][$delta]['value'], t('Current revision: expected value %delta was found.', array('%delta' => $delta))); + $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['value'] , $values[$current_revision][$delta]['value'], format_string('Current revision: expected value %delta was found.', array('%delta' => $delta))); // The value added in hook_field_load() is found. - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['additional_key'], 'additional_value', t('Current revision: extra information for value %delta was found', array('%delta' => $delta))); + $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['additional_key'], 'additional_value', format_string('Current revision: extra information for value %delta was found', array('%delta' => $delta))); } // Confirm each revision loads the correct data. @@ -195,12 +195,12 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = field_test_create_stub_entity(0, $revision_id, $this->instance['bundle']); field_attach_load_revision($entity_type, array(0 => $entity)); // Number of values per field loaded equals the field cardinality. - $this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], t('Revision %revision_id: expected number of values.', array('%revision_id' => $revision_id))); + $this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], format_string('Revision %revision_id: expected number of values.', array('%revision_id' => $revision_id))); for ($delta = 0; $delta < $this->field['cardinality']; $delta++) { // The field value loaded matches the one inserted or updated. - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['value'], $values[$revision_id][$delta]['value'], t('Revision %revision_id: expected value %delta was found.', array('%revision_id' => $revision_id, '%delta' => $delta))); + $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['value'], $values[$revision_id][$delta]['value'], format_string('Revision %revision_id: expected value %delta was found.', array('%revision_id' => $revision_id, '%delta' => $delta))); // The value added in hook_field_load() is found. - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['additional_key'], 'additional_value', t('Revision %revision_id: extra information for value %delta was found', array('%revision_id' => $revision_id, '%delta' => $delta))); + $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['additional_key'], 'additional_value', format_string('Revision %revision_id: extra information for value %delta was found', array('%revision_id' => $revision_id, '%delta' => $delta))); } } } @@ -266,19 +266,19 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $instances = field_info_instances($entity_type, $bundles[$index]); foreach ($instances as $field_name => $instance) { // The field value loaded matches the one inserted. - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], $values[$index][$field_name], t('Entity %index: expected value was found.', array('%index' => $index))); + $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], $values[$index][$field_name], format_string('Entity %index: expected value was found.', array('%index' => $index))); // The value added in hook_field_load() is found. - $this->assertEqual($entity->{$field_name}[$langcode][0]['additional_key'], 'additional_value', t('Entity %index: extra information was found', array('%index' => $index))); + $this->assertEqual($entity->{$field_name}[$langcode][0]['additional_key'], 'additional_value', format_string('Entity %index: extra information was found', array('%index' => $index))); } } // Check that the single-field load option works. $entity = field_test_create_stub_entity(1, 1, $bundles[1]); field_attach_load($entity_type, array(1 => $entity), FIELD_LOAD_CURRENT, array('field_id' => $field_ids[1])); - $this->assertEqual($entity->{$field_names[1]}[$langcode][0]['value'], $values[1][$field_names[1]], t('Entity %index: expected value was found.', array('%index' => 1))); - $this->assertEqual($entity->{$field_names[1]}[$langcode][0]['additional_key'], 'additional_value', t('Entity %index: extra information was found', array('%index' => 1))); - $this->assert(!isset($entity->{$field_names[2]}), t('Entity %index: field %field_name is not loaded.', array('%index' => 2, '%field_name' => $field_names[2]))); - $this->assert(!isset($entity->{$field_names[3]}), t('Entity %index: field %field_name is not loaded.', array('%index' => 3, '%field_name' => $field_names[3]))); + $this->assertEqual($entity->{$field_names[1]}[$langcode][0]['value'], $values[1][$field_names[1]], format_string('Entity %index: expected value was found.', array('%index' => 1))); + $this->assertEqual($entity->{$field_names[1]}[$langcode][0]['additional_key'], 'additional_value', format_string('Entity %index: extra information was found', array('%index' => 1))); + $this->assert(!isset($entity->{$field_names[2]}), format_string('Entity %index: field %field_name is not loaded.', array('%index' => 2, '%field_name' => $field_names[2]))); + $this->assert(!isset($entity->{$field_names[3]}), format_string('Entity %index: field %field_name is not loaded.', array('%index' => 3, '%field_name' => $field_names[3]))); } /** @@ -328,7 +328,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); foreach ($fields as $field) { - $this->assertEqual($values[$field['field_name']], $entity->{$field['field_name']}[$langcode], t('%storage storage: expected values were found.', array('%storage' => $field['storage']['type']))); + $this->assertEqual($values[$field['field_name']], $entity->{$field['field_name']}[$langcode], format_string('%storage storage: expected values were found.', array('%storage' => $field['storage']['type']))); } } @@ -357,20 +357,20 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $instance = field_info_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']); // The storage details are indexed by a storage engine type. - $this->assertTrue(array_key_exists('drupal_variables', $field['storage']['details']), t('The storage type is Drupal variables.')); + $this->assertTrue(array_key_exists('drupal_variables', $field['storage']['details']), 'The storage type is Drupal variables.'); $details = $field['storage']['details']['drupal_variables']; // The field_test storage details are indexed by variable name. The details // are altered, so moon and mars are correct for this test. - $this->assertTrue(array_key_exists('moon', $details[FIELD_LOAD_CURRENT]), t('Moon is available in the instance array.')); - $this->assertTrue(array_key_exists('mars', $details[FIELD_LOAD_REVISION]), t('Mars is available in the instance array.')); + $this->assertTrue(array_key_exists('moon', $details[FIELD_LOAD_CURRENT]), 'Moon is available in the instance array.'); + $this->assertTrue(array_key_exists('mars', $details[FIELD_LOAD_REVISION]), 'Mars is available in the instance array.'); // Test current and revision storage details together because the columns // are the same. foreach ((array) $field['columns'] as $column_name => $attributes) { - $this->assertEqual($details[FIELD_LOAD_CURRENT]['moon'][$column_name], $column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => 'moon[FIELD_LOAD_CURRENT]'))); - $this->assertEqual($details[FIELD_LOAD_REVISION]['mars'][$column_name], $column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => 'mars[FIELD_LOAD_REVISION]'))); + $this->assertEqual($details[FIELD_LOAD_CURRENT]['moon'][$column_name], $column_name, format_string('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => 'moon[FIELD_LOAD_CURRENT]'))); + $this->assertEqual($details[FIELD_LOAD_REVISION]['mars'][$column_name], $column_name, format_string('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => 'mars[FIELD_LOAD_REVISION]'))); } } @@ -388,7 +388,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}), t('Insert: missing field results in no value saved')); + $this->assertTrue(empty($entity->{$this->field_name}), 'Insert: missing field results in no value saved'); // Insert: Field is NULL. field_cache_clear(); @@ -398,7 +398,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}), t('Insert: NULL field results in no value saved')); + $this->assertTrue(empty($entity->{$this->field_name}), 'Insert: NULL field results in no value saved'); // Add some real data. field_cache_clear(); @@ -409,7 +409,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Field data saved')); + $this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Field data saved'); // Update: Field is missing. Data should survive. field_cache_clear(); @@ -418,7 +418,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Update: missing field leaves existing values in place')); + $this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Update: missing field leaves existing values in place'); // Update: Field is NULL. Data should be wiped. field_cache_clear(); @@ -428,7 +428,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}), t('Update: NULL field removes existing values')); + $this->assertTrue(empty($entity->{$this->field_name}), 'Update: NULL field removes existing values'); // Re-add some data. field_cache_clear(); @@ -439,7 +439,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Field data saved')); + $this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Field data saved'); // Update: Field is empty array. Data should be wiped. field_cache_clear(); @@ -449,7 +449,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}), t('Update: empty array removes existing values')); + $this->assertTrue(empty($entity->{$this->field_name}), 'Update: empty array removes existing values'); } /** @@ -471,7 +471,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}[$langcode]), t('Insert: NULL field results in no value saved')); + $this->assertTrue(empty($entity->{$this->field_name}[$langcode]), 'Insert: NULL field results in no value saved'); // Insert: Field is missing. field_cache_clear(); @@ -481,7 +481,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); $values = field_test_default_value($entity_type, $entity, $this->field, $this->instance); - $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Insert: missing field results in default value saved')); + $this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Insert: missing field results in default value saved'); } /** @@ -536,7 +536,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { } $read = field_test_create_stub_entity(0, 2, $this->instance['bundle']); field_attach_load($entity_type, array(0 => $read)); - $this->assertIdentical($read->{$this->field_name}, array(), t('The test entity current revision is deleted.')); + $this->assertIdentical($read->{$this->field_name}, array(), 'The test entity current revision is deleted.'); } /** @@ -812,7 +812,7 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { break; } } - $this->assertTrue($result, t('Variable $@field_name correctly populated.', array('@field_name' => $this->field_name))); + $this->assertTrue($result, format_string('Variable $@field_name correctly populated.', array('@field_name' => $this->field_name))); } /** @@ -878,18 +878,18 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { $cid = "field:$entity_type:{$entity_init->ftid}"; // Check that no initial cache entry is present. - $this->assertFalse(cache_get($cid, 'cache_field'), t('Non-cached: no initial cache entry')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Non-cached: no initial cache entry'); // Save, and check that no cache entry is present. $entity = clone($entity_init); $entity->{$this->field_name}[$langcode] = $values; field_attach_insert($entity_type, $entity); - $this->assertFalse(cache_get($cid, 'cache_field'), t('Non-cached: no cache entry on insert')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Non-cached: no cache entry on insert'); // Load, and check that no cache entry is present. $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertFalse(cache_get($cid, 'cache_field'), t('Non-cached: no cache entry on load')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Non-cached: no cache entry on load'); // Cacheable entity type. @@ -900,38 +900,38 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { field_create_instance($instance); // Check that no initial cache entry is present. - $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no initial cache entry')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no initial cache entry'); // Save, and check that no cache entry is present. $entity = clone($entity_init); $entity->{$this->field_name}[$langcode] = $values; field_attach_insert($entity_type, $entity); - $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on insert')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no cache entry on insert'); // Load a single field, and check that no cache entry is present. $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity), FIELD_LOAD_CURRENT, array('field_id' => $this->field_id)); $cache = cache_get($cid, 'cache_field'); - $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on loading a single field')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no cache entry on loading a single field'); // Load, and check that a cache entry is present with the expected values. $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); $cache = cache_get($cid, 'cache_field'); - $this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load')); + $this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load'); // Update with different values, and check that the cache entry is wiped. $values = $this->_generateTestFieldValues($this->field['cardinality']); $entity = clone($entity_init); $entity->{$this->field_name}[$langcode] = $values; field_attach_update($entity_type, $entity); - $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on update')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no cache entry on update'); // Load, and check that a cache entry is present with the expected values. $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); $cache = cache_get($cid, 'cache_field'); - $this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load')); + $this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load'); // Create a new revision, and check that the cache entry is wiped. $entity_init = field_test_create_stub_entity(1, 2, $this->instance['bundle']); @@ -940,17 +940,17 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { $entity->{$this->field_name}[$langcode] = $values; field_attach_update($entity_type, $entity); $cache = cache_get($cid, 'cache_field'); - $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry on new revision creation')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no cache entry on new revision creation'); // Load, and check that a cache entry is present with the expected values. $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); $cache = cache_get($cid, 'cache_field'); - $this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load')); + $this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load'); // Delete, and check that the cache entry is wiped. field_attach_delete($entity_type, $entity); - $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry after delete')); + $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no cache entry after delete'); } /** @@ -1202,42 +1202,42 @@ class FieldInfoTestCase extends FieldTestCase { $info = field_info_field_types(); foreach ($field_test_info as $t_key => $field_type) { foreach ($field_type as $key => $val) { - $this->assertEqual($info[$t_key][$key], $val, t("Field type $t_key key $key is $val")); + $this->assertEqual($info[$t_key][$key], $val, format_string('Field type %t_key key %key is %value', array('%t_key' => $t_key, '%key' => $key, '%value' => print_r($val, TRUE)))); } - $this->assertEqual($info[$t_key]['module'], 'field_test', t("Field type field_test module appears")); + $this->assertEqual($info[$t_key]['module'], 'field_test', "Field type field_test module appears"); } $formatter_info = field_test_field_formatter_info(); $info = field_info_formatter_types(); foreach ($formatter_info as $f_key => $formatter) { foreach ($formatter as $key => $val) { - $this->assertEqual($info[$f_key][$key], $val, t("Formatter type $f_key key $key is $val")); + $this->assertEqual($info[$f_key][$key], $val, format_string('Formatter type %f_key key %key is %value', array('%f_key' => $f_key, '%key' => $key, '%value' => print_r($val, TRUE)))); } - $this->assertEqual($info[$f_key]['module'], 'field_test', t("Formatter type field_test module appears")); + $this->assertEqual($info[$f_key]['module'], 'field_test', "Formatter type field_test module appears"); } $widget_info = field_test_field_widget_info(); $info = field_info_widget_types(); foreach ($widget_info as $w_key => $widget) { foreach ($widget as $key => $val) { - $this->assertEqual($info[$w_key][$key], $val, t("Widget type $w_key key $key is $val")); + $this->assertEqual($info[$w_key][$key], $val, format_string('Widget type %w_key key %key is %value', array('%w_key' => $w_key, '%key' => $key, '%value' => print_r($val, TRUE)))); } - $this->assertEqual($info[$w_key]['module'], 'field_test', t("Widget type field_test module appears")); + $this->assertEqual($info[$w_key]['module'], 'field_test', "Widget type field_test module appears"); } $storage_info = field_test_field_storage_info(); $info = field_info_storage_types(); foreach ($storage_info as $s_key => $storage) { foreach ($storage as $key => $val) { - $this->assertEqual($info[$s_key][$key], $val, t("Storage type $s_key key $key is $val")); + $this->assertEqual($info[$s_key][$key], $val, format_string('Storage type %s_key key %key is %value', array('%s_key' => $s_key, '%key' => $key, '%value' => print_r($val, TRUE)))); } - $this->assertEqual($info[$s_key]['module'], 'field_test', t("Storage type field_test module appears")); + $this->assertEqual($info[$s_key]['module'], 'field_test', "Storage type field_test module appears"); } // Verify that no unexpected instances exist. $instances = field_info_instances('test_entity'); $expected = array('test_bundle' => array()); - $this->assertIdentical($instances, $expected, "field_info_instances('test_entity') returns " . var_export($expected, TRUE) . '.'); + $this->assertIdentical($instances, $expected, format_string("field_info_instances('test_entity') returns %expected.", array('%expected' => var_export($expected, TRUE)))); $instances = field_info_instances('test_entity', 'test_bundle'); $this->assertIdentical($instances, array(), "field_info_instances('test_entity', 'test_bundle') returns an empty array."); @@ -1249,16 +1249,16 @@ class FieldInfoTestCase extends FieldTestCase { ); field_create_field($field); $fields = field_info_fields(); - $this->assertEqual(count($fields), count($core_fields) + 1, t('One new field exists')); - $this->assertEqual($fields[$field['field_name']]['field_name'], $field['field_name'], t('info fields contains field name')); - $this->assertEqual($fields[$field['field_name']]['type'], $field['type'], t('info fields contains field type')); - $this->assertEqual($fields[$field['field_name']]['module'], 'field_test', t('info fields contains field module')); + $this->assertEqual(count($fields), count($core_fields) + 1, 'One new field exists'); + $this->assertEqual($fields[$field['field_name']]['field_name'], $field['field_name'], 'info fields contains field name'); + $this->assertEqual($fields[$field['field_name']]['type'], $field['type'], 'info fields contains field type'); + $this->assertEqual($fields[$field['field_name']]['module'], 'field_test', 'info fields contains field module'); $settings = array('test_field_setting' => 'dummy test string'); foreach ($settings as $key => $val) { - $this->assertEqual($fields[$field['field_name']]['settings'][$key], $val, t("Field setting $key has correct default value $val")); + $this->assertEqual($fields[$field['field_name']]['settings'][$key], $val, format_string('Field setting %key has correct default value %value', array('%key' => $key, '%value' => $val))); } - $this->assertEqual($fields[$field['field_name']]['cardinality'], 1, t('info fields contains cardinality 1')); - $this->assertEqual($fields[$field['field_name']]['active'], 1, t('info fields contains active 1')); + $this->assertEqual($fields[$field['field_name']]['cardinality'], 1, 'info fields contains cardinality 1'); + $this->assertEqual($fields[$field['field_name']]['active'], 1, 'info fields contains active 1'); // Create an instance, verify that it shows up $instance = array( @@ -1280,7 +1280,7 @@ class FieldInfoTestCase extends FieldTestCase { $this->assertEqual(count($instances), 1, format_string('One instance shows up in info when attached to a bundle on a @label.', array( '@label' => $info['label'] ))); - $this->assertTrue($instance < $instances[$instance['field_name']], t('Instance appears in info correctly')); + $this->assertTrue($instance < $instances[$instance['field_name']], 'Instance appears in info correctly'); // Test a valid entity type but an invalid bundle. $instances = field_info_instances('test_entity', 'invalid_bundle'); @@ -1297,7 +1297,7 @@ class FieldInfoTestCase extends FieldTestCase { // Test with an entity type that has no bundles. $instances = field_info_instances('user'); $expected = array('user' => array()); - $this->assertIdentical($instances, $expected, "field_info_instances('user') returns " . var_export($expected, TRUE) . '.'); + $this->assertIdentical($instances, $expected, format_string("field_info_instances('user') returns %expected.", array('%expected' => var_export($expected, TRUE)))); $instances = field_info_instances('user', 'user'); $this->assertIdentical($instances, array(), "field_info_instances('user', 'user') returns an empty array."); @@ -1340,7 +1340,7 @@ class FieldInfoTestCase extends FieldTestCase { // Check that all expected settings are in place. $field_type = field_info_field_types($field_definition['type']); - $this->assertIdentical($field['settings'], $field_type['settings'], t('All expected default field settings are present.')); + $this->assertIdentical($field['settings'], $field_type['settings'], 'All expected default field settings are present.'); } /** @@ -1382,18 +1382,18 @@ class FieldInfoTestCase extends FieldTestCase { // Check that all expected instance settings are in place. $field_type = field_info_field_types($field_definition['type']); - $this->assertIdentical($instance['settings'], $field_type['instance_settings'] , t('All expected instance settings are present.')); + $this->assertIdentical($instance['settings'], $field_type['instance_settings'] , 'All expected instance settings are present.'); // Check that the default widget is used and expected settings are in place. - $this->assertIdentical($instance['widget']['type'], $field_type['default_widget'], t('Unavailable widget replaced with default widget.')); + $this->assertIdentical($instance['widget']['type'], $field_type['default_widget'], 'Unavailable widget replaced with default widget.'); $widget_type = field_info_widget_types($instance['widget']['type']); - $this->assertIdentical($instance['widget']['settings'], $widget_type['settings'] , t('All expected widget settings are present.')); + $this->assertIdentical($instance['widget']['settings'], $widget_type['settings'] , 'All expected widget settings are present.'); // Check that display settings are set for the 'default' mode. $display = $instance['display']['default']; - $this->assertIdentical($display['type'], $field_type['default_formatter'], t("Formatter is set for the 'default' view mode")); + $this->assertIdentical($display['type'], $field_type['default_formatter'], "Formatter is set for the 'default' view mode"); $formatter_type = field_info_formatter_types($display['type']); - $this->assertIdentical($display['settings'], $formatter_type['settings'] , t("Formatter settings are set for the 'default' view mode")); + $this->assertIdentical($display['settings'], $formatter_type['settings'] , "Formatter settings are set for the 'default' view mode"); } /** @@ -1416,7 +1416,7 @@ class FieldInfoTestCase extends FieldTestCase { // Disable coment module. This clears field_info cache. module_disable(array('comment')); - $this->assertNull(field_info_instance('comment', 'field', 'comment_node_article'), t('No instances are returned on disabled entity types.')); + $this->assertNull(field_info_instance('comment', 'field', 'comment_node_article'), 'No instances are returned on disabled entity types.'); } /** @@ -1503,18 +1503,18 @@ class FieldInfoTestCase extends FieldTestCase { $info[$name]['instance_settings']['user_register_form'] = FALSE; } foreach ($info as $type => $data) { - $this->assertIdentical(field_info_field_settings($type), $data['settings'], "field_info_field_settings returns {$type}'s field settings"); - $this->assertIdentical(field_info_instance_settings($type), $data['instance_settings'], "field_info_field_settings returns {$type}'s field instance settings"); + $this->assertIdentical(field_info_field_settings($type), $data['settings'], format_string("field_info_field_settings returns %type's field settings", array('%type' => $type))); + $this->assertIdentical(field_info_instance_settings($type), $data['instance_settings'], format_string("field_info_field_settings returns %type's field instance settings", array('%type' => $type))); } $info = field_test_field_widget_info(); foreach ($info as $type => $data) { - $this->assertIdentical(field_info_widget_settings($type), $data['settings'], "field_info_widget_settings returns {$type}'s widget settings"); + $this->assertIdentical(field_info_widget_settings($type), $data['settings'], format_string("field_info_widget_settings returns %type's widget settings", array('%type' => $type))); } $info = field_test_field_formatter_info(); foreach ($info as $type => $data) { - $this->assertIdentical(field_info_formatter_settings($type), $data['settings'], "field_info_formatter_settings returns {$type}'s formatter settings"); + $this->assertIdentical(field_info_formatter_settings($type), $data['settings'], format_string("field_info_formatter_settings returns %type's formatter settings", array('%type' => $type))); } } @@ -1865,7 +1865,7 @@ class FieldFormTestCase extends FieldTestCase { // Display creation form. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertFieldByName("{$this->field_name}[$langcode]", '', t('Widget is displayed.')); + $this->assertFieldByName("{$this->field_name}[$langcode]", '', 'Widget is displayed.'); // Create entity with three values. $edit = array("{$this->field_name}[$langcode]" => '1, 2, 3'); @@ -1879,12 +1879,12 @@ class FieldFormTestCase extends FieldTestCase { // Display the form, check that the values are correctly filled in. $this->drupalGet('test-entity/manage/' . $id . '/edit'); - $this->assertFieldByName("{$this->field_name}[$langcode]", '1, 2, 3', t('Widget is displayed.')); + $this->assertFieldByName("{$this->field_name}[$langcode]", '1, 2, 3', 'Widget is displayed.'); // Submit the form with more values than the field accepts. $edit = array("{$this->field_name}[$langcode]" => '1, 2, 3, 4, 5'); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertRaw('this field cannot hold more than 4 values', t('Form validation failed.')); + $this->assertRaw('this field cannot hold more than 4 values', 'Form validation failed.'); // Check that the field values were not submitted. $this->assertFieldValues($entity_init, $this->field_name, $langcode, array(1, 2, 3)); } @@ -1932,7 +1932,7 @@ class FieldFormTestCase extends FieldTestCase { // Display creation form. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertNoFieldByName("{$field_name_no_access}[$langcode][0][value]", '', t('Widget is not displayed if field access is denied.')); + $this->assertNoFieldByName("{$field_name_no_access}[$langcode][0][value]", '', 'Widget is not displayed if field access is denied.'); // Create entity. $edit = array("{$field_name}[$langcode][0][value]" => 1); @@ -1942,8 +1942,8 @@ class FieldFormTestCase extends FieldTestCase { // Check that the default value was saved. $entity = field_test_entity_test_load($id); - $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, t('Default value was saved for the field with no edit access.')); - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 1, t('Entered value vas saved for the field with edit access.')); + $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, 'Default value was saved for the field with no edit access.'); + $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 1, 'Entered value vas saved for the field with edit access.'); // Create a new revision. $edit = array("{$field_name}[$langcode][0][value]" => 2, 'revision' => TRUE); @@ -1951,13 +1951,13 @@ class FieldFormTestCase extends FieldTestCase { // Check that the new revision has the expected values. $entity = field_test_entity_test_load($id); - $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, t('New revision has the expected value for the field with no edit access.')); - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, t('New revision has the expected value for the field with edit access.')); + $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, 'New revision has the expected value for the field with no edit access.'); + $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, 'New revision has the expected value for the field with edit access.'); // Check that the revision is also saved in the revisions table. $entity = field_test_entity_test_load($id, $entity->ftvid); - $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, t('New revision has the expected value for the field with no edit access.')); - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, t('New revision has the expected value for the field with edit access.')); + $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, 'New revision has the expected value for the field with no edit access.'); + $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, 'New revision has the expected value for the field with edit access.'); } /** @@ -1989,10 +1989,10 @@ class FieldFormTestCase extends FieldTestCase { // Display the 'combined form'. $this->drupalGet('test-entity/nested/1/2'); - $this->assertFieldByName('field_single[und][0][value]', 0, t('Entity 1: field_single value appears correctly is the form.')); - $this->assertFieldByName('field_unlimited[und][0][value]', 1, t('Entity 1: field_unlimited value 0 appears correctly is the form.')); - $this->assertFieldByName('entity_2[field_single][und][0][value]', 10, t('Entity 2: field_single value appears correctly is the form.')); - $this->assertFieldByName('entity_2[field_unlimited][und][0][value]', 11, t('Entity 2: field_unlimited value 0 appears correctly is the form.')); + $this->assertFieldByName('field_single[und][0][value]', 0, 'Entity 1: field_single value appears correctly is the form.'); + $this->assertFieldByName('field_unlimited[und][0][value]', 1, 'Entity 1: field_unlimited value 0 appears correctly is the form.'); + $this->assertFieldByName('entity_2[field_single][und][0][value]', 10, 'Entity 2: field_single value appears correctly is the form.'); + $this->assertFieldByName('entity_2[field_unlimited][und][0][value]', 11, 'Entity 2: field_unlimited value 0 appears correctly is the form.'); // Submit the form and check that the entities are updated accordingly. $edit = array( @@ -2018,16 +2018,16 @@ class FieldFormTestCase extends FieldTestCase { 'field_unlimited[und][1][value]' => -1, ); $this->drupalPost('test-entity/nested/1/2', $edit, t('Save')); - $this->assertRaw(t('%label does not accept the value -1', array('%label' => 'Unlimited field')), t('Entity 1: the field validation error was reported.')); + $this->assertRaw(t('%label does not accept the value -1', array('%label' => 'Unlimited field')), 'Entity 1: the field validation error was reported.'); $error_field = $this->xpath('//input[@id=:id and contains(@class, "error")]', array(':id' => 'edit-field-unlimited-und-1-value')); - $this->assertTrue($error_field, t('Entity 1: the error was flagged on the correct element.')); + $this->assertTrue($error_field, 'Entity 1: the error was flagged on the correct element.'); $edit = array( 'entity_2[field_unlimited][und][1][value]' => -1, ); $this->drupalPost('test-entity/nested/1/2', $edit, t('Save')); - $this->assertRaw(t('%label does not accept the value -1', array('%label' => 'Unlimited field')), t('Entity 2: the field validation error was reported.')); + $this->assertRaw(t('%label does not accept the value -1', array('%label' => 'Unlimited field')), 'Entity 2: the field validation error was reported.'); $error_field = $this->xpath('//input[@id=:id and contains(@class, "error")]', array(':id' => 'edit-entity-2-field-unlimited-und-1-value')); - $this->assertTrue($error_field, t('Entity 2: the error was flagged on the correct element.')); + $this->assertTrue($error_field, 'Entity 2: the error was flagged on the correct element.'); // Test that reordering works on both entities. $edit = array( @@ -2047,10 +2047,10 @@ class FieldFormTestCase extends FieldTestCase { // 'Add more' button in the first entity: $this->drupalGet('test-entity/nested/1/2'); $this->drupalPostAJAX(NULL, array(), 'field_unlimited_add_more'); - $this->assertFieldByName('field_unlimited[und][0][value]', 3, t('Entity 1: field_unlimited value 0 appears correctly is the form.')); - $this->assertFieldByName('field_unlimited[und][1][value]', 2, t('Entity 1: field_unlimited value 1 appears correctly is the form.')); - $this->assertFieldByName('field_unlimited[und][2][value]', '', t('Entity 1: field_unlimited value 2 appears correctly is the form.')); - $this->assertFieldByName('field_unlimited[und][3][value]', '', t('Entity 1: an empty widget was added for field_unlimited value 3.')); + $this->assertFieldByName('field_unlimited[und][0][value]', 3, 'Entity 1: field_unlimited value 0 appears correctly is the form.'); + $this->assertFieldByName('field_unlimited[und][1][value]', 2, 'Entity 1: field_unlimited value 1 appears correctly is the form.'); + $this->assertFieldByName('field_unlimited[und][2][value]', '', 'Entity 1: field_unlimited value 2 appears correctly is the form.'); + $this->assertFieldByName('field_unlimited[und][3][value]', '', 'Entity 1: an empty widget was added for field_unlimited value 3.'); // 'Add more' button in the first entity (changing field values): $edit = array( 'entity_2[field_unlimited][und][0][value]' => 13, @@ -2058,10 +2058,10 @@ class FieldFormTestCase extends FieldTestCase { 'entity_2[field_unlimited][und][2][value]' => 15, ); $this->drupalPostAJAX(NULL, $edit, 'entity_2_field_unlimited_add_more'); - $this->assertFieldByName('entity_2[field_unlimited][und][0][value]', 13, t('Entity 2: field_unlimited value 0 appears correctly is the form.')); - $this->assertFieldByName('entity_2[field_unlimited][und][1][value]', 14, t('Entity 2: field_unlimited value 1 appears correctly is the form.')); - $this->assertFieldByName('entity_2[field_unlimited][und][2][value]', 15, t('Entity 2: field_unlimited value 2 appears correctly is the form.')); - $this->assertFieldByName('entity_2[field_unlimited][und][3][value]', '', t('Entity 2: an empty widget was added for field_unlimited value 3.')); + $this->assertFieldByName('entity_2[field_unlimited][und][0][value]', 13, 'Entity 2: field_unlimited value 0 appears correctly is the form.'); + $this->assertFieldByName('entity_2[field_unlimited][und][1][value]', 14, 'Entity 2: field_unlimited value 1 appears correctly is the form.'); + $this->assertFieldByName('entity_2[field_unlimited][und][2][value]', 15, 'Entity 2: field_unlimited value 2 appears correctly is the form.'); + $this->assertFieldByName('entity_2[field_unlimited][und][3][value]', '', 'Entity 2: an empty widget was added for field_unlimited value 3.'); // Save the form and check values are saved correclty. $this->drupalPost(NULL, array(), t('Save')); field_cache_clear(); @@ -2132,9 +2132,9 @@ class FieldDisplayAPITestCase extends FieldTestCase { $this->drupalSetContent(drupal_render($output)); $settings = field_info_formatter_settings('field_test_default'); $setting = $settings['test_formatter_setting']; - $this->assertText($this->label, t('Label was displayed.')); + $this->assertText($this->label, 'Label was displayed.'); foreach ($this->values as $delta => $value) { - $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } // Check that explicit display settings are used. @@ -2149,13 +2149,13 @@ class FieldDisplayAPITestCase extends FieldTestCase { $output = field_view_field('test_entity', $this->entity, $this->field_name, $display); $this->drupalSetContent(drupal_render($output)); $setting = $display['settings']['test_formatter_setting_multiple']; - $this->assertNoText($this->label, t('Label was not displayed.')); - $this->assertText('field_test_field_attach_view_alter', t('Alter fired, display passed.')); + $this->assertNoText($this->label, 'Label was not displayed.'); + $this->assertText('field_test_field_attach_view_alter', 'Alter fired, display passed.'); $array = array(); foreach ($this->values as $delta => $value) { $array[] = $delta . ':' . $value['value']; } - $this->assertText($setting . '|' . implode('|', $array), t('Values were displayed with expected setting.')); + $this->assertText($setting . '|' . implode('|', $array), 'Values were displayed with expected setting.'); // Check the prepare_view steps are invoked. $display = array( @@ -2169,10 +2169,10 @@ class FieldDisplayAPITestCase extends FieldTestCase { $view = drupal_render($output); $this->drupalSetContent($view); $setting = $display['settings']['test_formatter_setting_additional']; - $this->assertNoText($this->label, t('Label was not displayed.')); - $this->assertNoText('field_test_field_attach_view_alter', t('Alter not fired.')); + $this->assertNoText($this->label, 'Label was not displayed.'); + $this->assertNoText('field_test_field_attach_view_alter', 'Alter not fired.'); foreach ($this->values as $delta => $value) { - $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } // View mode: check that display settings specified in the instance are @@ -2180,9 +2180,9 @@ class FieldDisplayAPITestCase extends FieldTestCase { $output = field_view_field('test_entity', $this->entity, $this->field_name, 'teaser'); $this->drupalSetContent(drupal_render($output)); $setting = $this->instance['display']['teaser']['settings']['test_formatter_setting']; - $this->assertText($this->label, t('Label was displayed.')); + $this->assertText($this->label, 'Label was displayed.'); foreach ($this->values as $delta => $value) { - $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } // Unknown view mode: check that display settings for 'default' view mode @@ -2190,9 +2190,9 @@ class FieldDisplayAPITestCase extends FieldTestCase { $output = field_view_field('test_entity', $this->entity, $this->field_name, 'unknown_view_mode'); $this->drupalSetContent(drupal_render($output)); $setting = $this->instance['display']['default']['settings']['test_formatter_setting']; - $this->assertText($this->label, t('Label was displayed.')); + $this->assertText($this->label, 'Label was displayed.'); foreach ($this->values as $delta => $value) { - $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } } @@ -2207,7 +2207,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } // Check that explicit display settings are used. @@ -2223,7 +2223,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, $display); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|0:' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|0:' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } // Check that prepare_view steps are invoked. @@ -2239,7 +2239,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, $display); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } // View mode: check that display settings specified in the instance are @@ -2249,7 +2249,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, 'teaser'); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } // Unknown view mode: check that display settings for 'default' view mode @@ -2259,7 +2259,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, 'unknown_view_mode'); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); + $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } } } @@ -2302,18 +2302,18 @@ class FieldCrudTestCase extends FieldTestCase { $record['data'] = unserialize($record['data']); // Ensure that basic properties are preserved. - $this->assertEqual($record['field_name'], $field_definition['field_name'], t('The field name is properly saved.')); - $this->assertEqual($record['type'], $field_definition['type'], t('The field type is properly saved.')); + $this->assertEqual($record['field_name'], $field_definition['field_name'], 'The field name is properly saved.'); + $this->assertEqual($record['type'], $field_definition['type'], 'The field type is properly saved.'); // Ensure that cardinality defaults to 1. - $this->assertEqual($record['cardinality'], 1, t('Cardinality defaults to 1.')); + $this->assertEqual($record['cardinality'], 1, 'Cardinality defaults to 1.'); // Ensure that default settings are present. $field_type = field_info_field_types($field_definition['type']); - $this->assertIdentical($record['data']['settings'], $field_type['settings'], t('Default field settings have been written.')); + $this->assertIdentical($record['data']['settings'], $field_type['settings'], 'Default field settings have been written.'); // Ensure that default storage was set. - $this->assertEqual($record['storage_type'], variable_get('field_storage_default'), t('The field type is properly saved.')); + $this->assertEqual($record['storage_type'], variable_get('field_storage_default'), 'The field type is properly saved.'); // Guarantee that the name is unique. try { @@ -2440,7 +2440,7 @@ class FieldCrudTestCase extends FieldTestCase { // Read the field back. $field = field_read_field($field_definition['field_name']); - $this->assertTrue($field_definition < $field, t('The field was properly read.')); + $this->assertTrue($field_definition < $field, 'The field was properly read.'); } /** @@ -2490,7 +2490,7 @@ class FieldCrudTestCase extends FieldTestCase { field_create_field($field_definition); $field = field_read_field($field_definition['field_name']); $expected_indexes = array('value' => array('value')); - $this->assertEqual($field['indexes'], $expected_indexes, t('Field type indexes saved by default')); + $this->assertEqual($field['indexes'], $expected_indexes, 'Field type indexes saved by default'); // Check that indexes specified by the field definition override the field // type indexes. @@ -2504,7 +2504,7 @@ class FieldCrudTestCase extends FieldTestCase { field_create_field($field_definition); $field = field_read_field($field_definition['field_name']); $expected_indexes = array('value' => array()); - $this->assertEqual($field['indexes'], $expected_indexes, t('Field definition indexes override field type indexes')); + $this->assertEqual($field['indexes'], $expected_indexes, 'Field definition indexes override field type indexes'); // Check that indexes specified by the field definition add to the field // type indexes. @@ -2518,7 +2518,7 @@ class FieldCrudTestCase extends FieldTestCase { field_create_field($field_definition); $field = field_read_field($field_definition['field_name']); $expected_indexes = array('value' => array('value'), 'value_2' => array('value')); - $this->assertEqual($field['indexes'], $expected_indexes, t('Field definition indexes are merged with field type indexes')); + $this->assertEqual($field['indexes'], $expected_indexes, 'Field definition indexes are merged with field type indexes'); } /** @@ -2549,41 +2549,41 @@ class FieldCrudTestCase extends FieldTestCase { // Test that the first field is not deleted, and then delete it. $field = field_read_field($this->field['field_name'], array('include_deleted' => TRUE)); - $this->assertTrue(!empty($field) && empty($field['deleted']), t('A new field is not marked for deletion.')); + $this->assertTrue(!empty($field) && empty($field['deleted']), 'A new field is not marked for deletion.'); field_delete_field($this->field['field_name']); // Make sure that the field is marked as deleted when it is specifically // loaded. $field = field_read_field($this->field['field_name'], array('include_deleted' => TRUE)); - $this->assertTrue(!empty($field['deleted']), t('A deleted field is marked for deletion.')); + $this->assertTrue(!empty($field['deleted']), 'A deleted field is marked for deletion.'); // Make sure that this field's instance is marked as deleted when it is // specifically loaded. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE)); - $this->assertTrue(!empty($instance['deleted']), t('An instance for a deleted field is marked for deletion.')); + $this->assertTrue(!empty($instance['deleted']), 'An instance for a deleted field is marked for deletion.'); // Try to load the field normally and make sure it does not show up. $field = field_read_field($this->field['field_name']); - $this->assertTrue(empty($field), t('A deleted field is not loaded by default.')); + $this->assertTrue(empty($field), 'A deleted field is not loaded by default.'); // Try to load the instance normally and make sure it does not show up. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertTrue(empty($instance), t('An instance for a deleted field is not loaded by default.')); + $this->assertTrue(empty($instance), 'An instance for a deleted field is not loaded by default.'); // Make sure the other field (and its field instance) are not deleted. $another_field = field_read_field($this->another_field['field_name']); - $this->assertTrue(!empty($another_field) && empty($another_field['deleted']), t('A non-deleted field is not marked for deletion.')); + $this->assertTrue(!empty($another_field) && empty($another_field['deleted']), 'A non-deleted field is not marked for deletion.'); $another_instance = field_read_instance('test_entity', $this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']); - $this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), t('An instance of a non-deleted field is not marked for deletion.')); + $this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), 'An instance of a non-deleted field is not marked for deletion.'); // Try to create a new field the same name as a deleted field and // write data into it. field_create_field($this->field); field_create_instance($this->instance_definition); $field = field_read_field($this->field['field_name']); - $this->assertTrue(!empty($field) && empty($field['deleted']), t('A new field with a previously used name is created.')); + $this->assertTrue(!empty($field) && empty($field['deleted']), 'A new field with a previously used name is created.'); $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertTrue(!empty($instance) && empty($instance['deleted']), t('A new instance for a previously used field name is created.')); + $this->assertTrue(!empty($instance) && empty($instance['deleted']), 'A new instance for a previously used field name is created.'); // Save an entity with data for the field $entity = field_test_create_stub_entity(0, 0, $instance['bundle']); @@ -2736,18 +2736,18 @@ class FieldCrudTestCase extends FieldTestCase { // Read the field. $field = field_read_field($field_name); - $this->assertTrue($field_definition <= $field, t('The field was properly read.')); + $this->assertTrue($field_definition <= $field, 'The field was properly read.'); module_disable($modules, FALSE); $fields = field_read_fields(array('field_name' => $field_name), array('include_inactive' => TRUE)); - $this->assertTrue(isset($fields[$field_name]) && $field_definition < $field, t('The field is properly read when explicitly fetching inactive fields.')); + $this->assertTrue(isset($fields[$field_name]) && $field_definition < $field, 'The field is properly read when explicitly fetching inactive fields.'); // Re-enable modules one by one, and check that the field is still inactive // while some modules remain disabled. while ($modules) { $field = field_read_field($field_name); - $this->assertTrue(empty($field), t('%modules disabled. The field is marked inactive.', array('%modules' => implode(', ', $modules)))); + $this->assertTrue(empty($field), format_string('%modules disabled. The field is marked inactive.', array('%modules' => implode(', ', $modules)))); $module = array_shift($modules); module_enable(array($module), FALSE); @@ -2756,7 +2756,7 @@ class FieldCrudTestCase extends FieldTestCase { // Check that the field is active again after all modules have been // enabled. $field = field_read_field($field_name); - $this->assertTrue($field_definition <= $field, t('The field was was marked active.')); + $this->assertTrue($field_definition <= $field, 'The field was was marked active.'); } } @@ -2808,17 +2808,17 @@ class FieldInstanceCrudTestCase extends FieldTestCase { $formatter_type = field_info_formatter_types($field_type['default_formatter']); // Check that default values are set. - $this->assertIdentical($record['data']['required'], FALSE, t('Required defaults to false.')); - $this->assertIdentical($record['data']['label'], $this->instance_definition['field_name'], t('Label defaults to field name.')); - $this->assertIdentical($record['data']['description'], '', t('Description defaults to empty string.')); - $this->assertIdentical($record['data']['widget']['type'], $field_type['default_widget'], t('Default widget has been written.')); - $this->assertTrue(isset($record['data']['display']['default']), t('Display for "full" view_mode has been written.')); - $this->assertIdentical($record['data']['display']['default']['type'], $field_type['default_formatter'], t('Default formatter for "full" view_mode has been written.')); + $this->assertIdentical($record['data']['required'], FALSE, 'Required defaults to false.'); + $this->assertIdentical($record['data']['label'], $this->instance_definition['field_name'], 'Label defaults to field name.'); + $this->assertIdentical($record['data']['description'], '', 'Description defaults to empty string.'); + $this->assertIdentical($record['data']['widget']['type'], $field_type['default_widget'], 'Default widget has been written.'); + $this->assertTrue(isset($record['data']['display']['default']), 'Display for "full" view_mode has been written.'); + $this->assertIdentical($record['data']['display']['default']['type'], $field_type['default_formatter'], 'Default formatter for "full" view_mode has been written.'); // Check that default settings are set. - $this->assertIdentical($record['data']['settings'], $field_type['instance_settings'] , t('Default instance settings have been written.')); - $this->assertIdentical($record['data']['widget']['settings'], $widget_type['settings'] , t('Default widget settings have been written.')); - $this->assertIdentical($record['data']['display']['default']['settings'], $formatter_type['settings'], t('Default formatter settings for "full" view_mode have been written.')); + $this->assertIdentical($record['data']['settings'], $field_type['instance_settings'] , 'Default instance settings have been written.'); + $this->assertIdentical($record['data']['widget']['settings'], $widget_type['settings'] , 'Default widget settings have been written.'); + $this->assertIdentical($record['data']['display']['default']['settings'], $formatter_type['settings'], 'Default formatter settings for "full" view_mode have been written.'); // Guarantee that the field/bundle combination is unique. try { @@ -2883,7 +2883,7 @@ class FieldInstanceCrudTestCase extends FieldTestCase { // Read the instance back. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertTrue($this->instance_definition < $instance, t('The field was properly read.')); + $this->assertTrue($this->instance_definition < $instance, 'The field was properly read.'); } /** @@ -2906,13 +2906,13 @@ class FieldInstanceCrudTestCase extends FieldTestCase { field_update_instance($instance); $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertEqual($instance['required'], $instance_new['required'], t('"required" change is saved')); - $this->assertEqual($instance['label'], $instance_new['label'], t('"label" change is saved')); - $this->assertEqual($instance['description'], $instance_new['description'], t('"description" change is saved')); - $this->assertEqual($instance['widget']['settings']['test_widget_setting'], $instance_new['widget']['settings']['test_widget_setting'], t('Widget setting change is saved')); - $this->assertEqual($instance['widget']['weight'], $instance_new['widget']['weight'], t('Widget weight change is saved')); - $this->assertEqual($instance['display']['default']['settings']['test_formatter_setting'], $instance_new['display']['default']['settings']['test_formatter_setting'], t('Formatter setting change is saved')); - $this->assertEqual($instance['display']['default']['weight'], $instance_new['display']['default']['weight'], t('Widget weight change is saved')); + $this->assertEqual($instance['required'], $instance_new['required'], '"required" change is saved'); + $this->assertEqual($instance['label'], $instance_new['label'], '"label" change is saved'); + $this->assertEqual($instance['description'], $instance_new['description'], '"description" change is saved'); + $this->assertEqual($instance['widget']['settings']['test_widget_setting'], $instance_new['widget']['settings']['test_widget_setting'], 'Widget setting change is saved'); + $this->assertEqual($instance['widget']['weight'], $instance_new['widget']['weight'], 'Widget weight change is saved'); + $this->assertEqual($instance['display']['default']['settings']['test_formatter_setting'], $instance_new['display']['default']['settings']['test_formatter_setting'], 'Formatter setting change is saved'); + $this->assertEqual($instance['display']['default']['weight'], $instance_new['display']['default']['weight'], 'Widget weight change is saved'); // Check that changing widget and formatter types updates the default settings. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); @@ -2921,13 +2921,13 @@ class FieldInstanceCrudTestCase extends FieldTestCase { field_update_instance($instance); $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertEqual($instance['widget']['type'], $instance_new['widget']['type'] , t('Widget type change is saved.')); + $this->assertEqual($instance['widget']['type'], $instance_new['widget']['type'] , 'Widget type change is saved.'); $settings = field_info_widget_settings($instance_new['widget']['type']); - $this->assertIdentical($settings, array_intersect_key($instance_new['widget']['settings'], $settings) , t('Widget type change updates default settings.')); - $this->assertEqual($instance['display']['default']['type'], $instance_new['display']['default']['type'] , t('Formatter type change is saved.')); + $this->assertIdentical($settings, array_intersect_key($instance_new['widget']['settings'], $settings) , 'Widget type change updates default settings.'); + $this->assertEqual($instance['display']['default']['type'], $instance_new['display']['default']['type'] , 'Formatter type change is saved.'); $info = field_info_formatter_types($instance_new['display']['default']['type']); $settings = $info['settings']; - $this->assertIdentical($settings, array_intersect_key($instance_new['display']['default']['settings'], $settings) , t('Changing formatter type updates default settings.')); + $this->assertIdentical($settings, array_intersect_key($instance_new['display']['default']['settings'], $settings) , 'Changing formatter type updates default settings.'); // Check that adding a new view mode is saved and gets default settings. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); @@ -2935,11 +2935,11 @@ class FieldInstanceCrudTestCase extends FieldTestCase { field_update_instance($instance); $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertTrue(isset($instance_new['display']['teaser']), t('Display for the new view_mode has been written.')); - $this->assertIdentical($instance_new['display']['teaser']['type'], $field_type['default_formatter'], t('Default formatter for the new view_mode has been written.')); + $this->assertTrue(isset($instance_new['display']['teaser']), 'Display for the new view_mode has been written.'); + $this->assertIdentical($instance_new['display']['teaser']['type'], $field_type['default_formatter'], 'Default formatter for the new view_mode has been written.'); $info = field_info_formatter_types($instance_new['display']['teaser']['type']); $settings = $info['settings']; - $this->assertIdentical($settings, $instance_new['display']['teaser']['settings'] , t('Default formatter settings for the new view_mode have been written.')); + $this->assertIdentical($settings, $instance_new['display']['teaser']['settings'] , 'Default formatter settings for the new view_mode have been written.'); // TODO: test failures. } @@ -2961,26 +2961,26 @@ class FieldInstanceCrudTestCase extends FieldTestCase { // Test that the first instance is not deleted, and then delete it. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE)); - $this->assertTrue(!empty($instance) && empty($instance['deleted']), t('A new field instance is not marked for deletion.')); + $this->assertTrue(!empty($instance) && empty($instance['deleted']), 'A new field instance is not marked for deletion.'); field_delete_instance($instance); // Make sure the instance is marked as deleted when the instance is // specifically loaded. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE)); - $this->assertTrue(!empty($instance['deleted']), t('A deleted field instance is marked for deletion.')); + $this->assertTrue(!empty($instance['deleted']), 'A deleted field instance is marked for deletion.'); // Try to load the instance normally and make sure it does not show up. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertTrue(empty($instance), t('A deleted field instance is not loaded by default.')); + $this->assertTrue(empty($instance), 'A deleted field instance is not loaded by default.'); // Make sure the other field instance is not deleted. $another_instance = field_read_instance('test_entity', $this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']); - $this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), t('A non-deleted field instance is not marked for deletion.')); + $this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), 'A non-deleted field instance is not marked for deletion.'); // Make sure the field is deleted when its last instance is deleted. field_delete_instance($another_instance); $field = field_read_field($another_instance['field_name'], array('include_deleted' => TRUE)); - $this->assertTrue(!empty($field['deleted']), t('A deleted field is marked for deletion after all its instances have been marked for deletion.')); + $this->assertTrue(!empty($field['deleted']), 'A deleted field is marked for deletion after all its instances have been marked for deletion.'); } } @@ -3047,17 +3047,17 @@ class FieldTranslationsTestCase extends FieldTestCase { $available_languages = field_available_languages($this->entity_type, $this->field); foreach ($available_languages as $delta => $langcode) { if ($langcode != 'xx' && $langcode != 'en') { - $this->assertTrue(in_array($langcode, $enabled_languages), t('%language is an enabled language.', array('%language' => $langcode))); + $this->assertTrue(in_array($langcode, $enabled_languages), format_string('%language is an enabled language.', array('%language' => $langcode))); } } - $this->assertTrue(in_array('xx', $available_languages), t('%language was made available.', array('%language' => 'xx'))); - $this->assertFalse(in_array('en', $available_languages), t('%language was made unavailable.', array('%language' => 'en'))); + $this->assertTrue(in_array('xx', $available_languages), format_string('%language was made available.', array('%language' => 'xx'))); + $this->assertFalse(in_array('en', $available_languages), format_string('%language was made unavailable.', array('%language' => 'en'))); // Test field_available_languages() behavior for untranslatable fields. $this->field['translatable'] = FALSE; field_update_field($this->field); $available_languages = field_available_languages($this->entity_type, $this->field); - $this->assertTrue(count($available_languages) == 1 && $available_languages[0] === LANGUAGE_NONE, t('For untranslatable fields only LANGUAGE_NONE is available.')); + $this->assertTrue(count($available_languages) == 1 && $available_languages[0] === LANGUAGE_NONE, 'For untranslatable fields only LANGUAGE_NONE is available.'); } /** @@ -3092,10 +3092,10 @@ class FieldTranslationsTestCase extends FieldTestCase { $hash = hash('sha256', serialize(array($entity_type, $entity, $this->field_name, $langcode, $values[$langcode]))); // Check whether the parameters passed to _field_invoke() were correctly // forwarded to the callback function. - $this->assertEqual($hash, $result, t('The result for %language is correctly stored.', array('%language' => $langcode))); + $this->assertEqual($hash, $result, format_string('The result for %language is correctly stored.', array('%language' => $langcode))); } - $this->assertEqual(count($results), count($available_languages), t('No unavailable language has been processed.')); + $this->assertEqual(count($results), count($available_languages), 'No unavailable language has been processed.'); } /** @@ -3156,17 +3156,17 @@ class FieldTranslationsTestCase extends FieldTestCase { $hash = hash('sha256', serialize(array($entity_type, $entities[$id], $this->field_name, $langcode, $values[$id][$langcode]))); // Check whether the parameters passed to _field_invoke_multiple() // were correctly forwarded to the callback function. - $this->assertEqual($hash, $result, t('The result for entity %id/%language is correctly stored.', array('%id' => $id, '%language' => $langcode))); + $this->assertEqual($hash, $result, format_string('The result for entity %id/%language is correctly stored.', array('%id' => $id, '%language' => $langcode))); } } - $this->assertEqual(count($results), count($available_languages), t('No unavailable language has been processed for entity %id.', array('%id' => $id))); + $this->assertEqual(count($results), count($available_languages), format_string('No unavailable language has been processed for entity %id.', array('%id' => $id))); } $null = NULL; $grouped_results = _field_invoke_multiple('test_op_multiple', $entity_type, $entities, $null, $null, $options); foreach ($grouped_results as $id => $results) { foreach ($results as $langcode => $result) { - $this->assertTrue(isset($options['language'][$id]), t('The result language %language for entity %id was correctly suggested (display language: %display_language).', array('%id' => $id, '%language' => $langcode, '%display_language' => $display_language))); + $this->assertTrue(isset($options['language'][$id]), format_string('The result language %language for entity %id was correctly suggested (display language: %display_language).', array('%id' => $id, '%language' => $langcode, '%display_language' => $display_language))); } } } @@ -3178,7 +3178,7 @@ class FieldTranslationsTestCase extends FieldTestCase { // Enable field translations for nodes. field_test_entity_info_translatable('node', TRUE); $entity_info = entity_get_info('node'); - $this->assertTrue(count($entity_info['translation']), t('Nodes are translatable.')); + $this->assertTrue(count($entity_info['translation']), 'Nodes are translatable.'); // Prepare the field translations. field_test_entity_info_translatable('test_entity', TRUE); @@ -3187,7 +3187,7 @@ class FieldTranslationsTestCase extends FieldTestCase { $entity = field_test_create_stub_entity($eid, $evid, $this->instance['bundle']); $field_translations = array(); $available_languages = field_available_languages($entity_type, $this->field); - $this->assertTrue(count($available_languages) > 1, t('Field is translatable.')); + $this->assertTrue(count($available_languages) > 1, 'Field is translatable.'); foreach ($available_languages as $langcode) { $field_translations[$langcode] = $this->_generateTestFieldValues($this->field['cardinality']); } @@ -3204,7 +3204,7 @@ class FieldTranslationsTestCase extends FieldTestCase { foreach ($items as $delta => $item) { $result = $result && $item['value'] == $entity->{$this->field_name}[$langcode][$delta]['value']; } - $this->assertTrue($result, t('%language translation correctly handled.', array('%language' => $langcode))); + $this->assertTrue($result, format_string('%language translation correctly handled.', array('%language' => $langcode))); } } @@ -3260,7 +3260,7 @@ class FieldTranslationsTestCase extends FieldTestCase { $display_language = field_language($entity_type, $entity, NULL, $requested_language); foreach ($instances as $instance) { $field_name = $instance['field_name']; - $this->assertTrue($display_language[$field_name] == LANGUAGE_NONE, t('The display language for field %field_name is %language.', array('%field_name' => $field_name, '%language' => LANGUAGE_NONE))); + $this->assertTrue($display_language[$field_name] == LANGUAGE_NONE, format_string('The display language for field %field_name is %language.', array('%field_name' => $field_name, '%language' => LANGUAGE_NONE))); } // Test multiple-fields display languages for translatable entities. @@ -3274,20 +3274,20 @@ class FieldTranslationsTestCase extends FieldTestCase { // As the requested language was not assinged to any field, if the // returned language is defined for the current field, core fallback rules // were successfully applied. - $this->assertTrue(isset($entity->{$field_name}[$langcode]) && $langcode != $requested_language, t('The display language for the field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode))); + $this->assertTrue(isset($entity->{$field_name}[$langcode]) && $langcode != $requested_language, format_string('The display language for the field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode))); } // Test single-field display language. drupal_static_reset('field_language'); $langcode = field_language($entity_type, $entity, $this->field_name, $requested_language); - $this->assertTrue(isset($entity->{$this->field_name}[$langcode]) && $langcode != $requested_language, t('The display language for the (single) field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode))); + $this->assertTrue(isset($entity->{$this->field_name}[$langcode]) && $langcode != $requested_language, format_string('The display language for the (single) field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode))); // Test field_language() basic behavior without language fallback. variable_set('field_test_language_fallback', FALSE); $entity->{$this->field_name}[$requested_language] = mt_rand(1, 127); drupal_static_reset('field_language'); $display_language = field_language($entity_type, $entity, $this->field_name, $requested_language); - $this->assertEqual($display_language, $requested_language, t('Display language behave correctly when language fallback is disabled')); + $this->assertEqual($display_language, $requested_language, 'Display language behave correctly when language fallback is disabled'); } /** @@ -3331,7 +3331,7 @@ class FieldTranslationsTestCase extends FieldTestCase { $entity = field_test_entity_test_load($eid, $evid); foreach ($available_languages as $langcode => $value) { $passed = isset($entity->{$field_name}[$langcode]) && $entity->{$field_name}[$langcode][0]['value'] == $value + 1; - $this->assertTrue($passed, t('The @language translation for revision @revision was correctly stored', array('@language' => $langcode, '@revision' => $entity->ftvid))); + $this->assertTrue($passed, format_string('The @language translation for revision @revision was correctly stored', array('@language' => $langcode, '@revision' => $entity->ftvid))); } } } diff --git a/modules/field/tests/field_test.field.inc b/modules/field/tests/field_test.field.inc index cc76a998..1cab7739 100755 --- a/modules/field/tests/field_test.field.inc +++ b/modules/field/tests/field_test.field.inc @@ -28,7 +28,9 @@ function field_test_field_info() { 'shape' => array( 'label' => t('Shape'), 'description' => t('Another dummy field type.'), - 'settings' => array(), + 'settings' => array( + 'foreign_key_name' => 'shape', + ), 'instance_settings' => array(), 'default_widget' => 'test_field_widget', 'default_formatter' => 'field_test_default', diff --git a/modules/field/tests/field_test.info b/modules/field/tests/field_test.info index 2df6be5b..385a0534 100755 --- a/modules/field/tests/field_test.info +++ b/modules/field/tests/field_test.info @@ -6,8 +6,8 @@ files[] = field_test.entity.inc version = VERSION hidden = TRUE -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/field/tests/field_test.install b/modules/field/tests/field_test.install index 59575611..a224520b 100755 --- a/modules/field/tests/field_test.install +++ b/modules/field/tests/field_test.install @@ -132,6 +132,18 @@ function field_test_field_schema($field) { ); } else { + $foreign_keys = array(); + // The 'foreign keys' key is not always used in tests. + if (!empty($field['settings']['foreign_key_name'])) { + $foreign_keys['foreign keys'] = array( + // This is a dummy foreign key definition, references a table that + // doesn't exist, but that's not a problem. + $field['settings']['foreign_key_name'] => array( + 'table' => $field['settings']['foreign_key_name'], + 'columns' => array($field['settings']['foreign_key_name'] => 'id'), + ), + ); + } return array( 'columns' => array( 'shape' => array( @@ -145,6 +157,6 @@ function field_test_field_schema($field) { 'not null' => FALSE, ), ), - ); + ) + $foreign_keys; } } diff --git a/modules/field/tests/field_test.module b/modules/field/tests/field_test.module index 37ea7b1d..dc2023a7 100755 --- a/modules/field/tests/field_test.module +++ b/modules/field/tests/field_test.module @@ -204,10 +204,7 @@ function field_test_dummy_field_storage_query(EntityFieldQuery $query) { } /** - * Entity label callback. - * - * @param $entity - * The entity object. + * Implements callback_entity_info_label(). * * @return * The label of the entity prefixed with "label callback". diff --git a/modules/field_ui/field_ui.admin.inc b/modules/field_ui/field_ui.admin.inc index 43bb2027..5c6f5299 100755 --- a/modules/field_ui/field_ui.admin.inc +++ b/modules/field_ui/field_ui.admin.inc @@ -1558,8 +1558,8 @@ function field_ui_existing_field_options($entity_type, $bundle) { /** * Form constructor for the field settings edit page. * - * @see field_ui_settings_form_submit() - * @ingroups forms + * @see field_ui_field_settings_form_submit() + * @ingroup forms */ function field_ui_field_settings_form($form, &$form_state, $instance) { $bundle = $instance['bundle']; diff --git a/modules/field_ui/field_ui.info b/modules/field_ui/field_ui.info index bf5d3591..0b32314b 100755 --- a/modules/field_ui/field_ui.info +++ b/modules/field_ui/field_ui.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = field_ui.test -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/field_ui/field_ui.test b/modules/field_ui/field_ui.test index b67b70e2..21767d64 100755 --- a/modules/field_ui/field_ui.test +++ b/modules/field_ui/field_ui.test @@ -59,18 +59,18 @@ class FieldUITestCase extends DrupalWebTestCase { // First step : 'Add new field' on the 'Manage fields' page. $this->drupalPost("$bundle_path/fields", $initial_edit, t('Save')); - $this->assertRaw(t('These settings apply to the %label field everywhere it is used.', array('%label' => $label)), t('Field settings page was displayed.')); + $this->assertRaw(t('These settings apply to the %label field everywhere it is used.', array('%label' => $label)), 'Field settings page was displayed.'); // Second step : 'Field settings' form. $this->drupalPost(NULL, $field_edit, t('Save field settings')); - $this->assertRaw(t('Updated field %label field settings.', array('%label' => $label)), t('Redirected to instance and widget settings page.')); + $this->assertRaw(t('Updated field %label field settings.', array('%label' => $label)), 'Redirected to instance and widget settings page.'); // Third step : 'Instance settings' form. $this->drupalPost(NULL, $instance_edit, t('Save settings')); - $this->assertRaw(t('Saved %label configuration.', array('%label' => $label)), t('Redirected to "Manage fields" page.')); + $this->assertRaw(t('Saved %label configuration.', array('%label' => $label)), 'Redirected to "Manage fields" page.'); // Check that the field appears in the overview form. - $this->assertFieldByXPath('//table[@id="field-overview"]//td[1]', $label, t('Field was created and appears in the overview page.')); + $this->assertFieldByXPath('//table[@id="field-overview"]//td[1]', $label, 'Field was created and appears in the overview page.'); } /** @@ -98,10 +98,10 @@ class FieldUITestCase extends DrupalWebTestCase { // Second step : 'Instance settings' form. $this->drupalPost(NULL, $instance_edit, t('Save settings')); - $this->assertRaw(t('Saved %label configuration.', array('%label' => $label)), t('Redirected to "Manage fields" page.')); + $this->assertRaw(t('Saved %label configuration.', array('%label' => $label)), 'Redirected to "Manage fields" page.'); // Check that the field appears in the overview form. - $this->assertFieldByXPath('//table[@id="field-overview"]//td[1]', $label, t('Field was created and appears in the overview page.')); + $this->assertFieldByXPath('//table[@id="field-overview"]//td[1]', $label, 'Field was created and appears in the overview page.'); } /** @@ -119,14 +119,14 @@ class FieldUITestCase extends DrupalWebTestCase { function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_label) { // Display confirmation form. $this->drupalGet("$bundle_path/fields/$field_name/delete"); - $this->assertRaw(t('Are you sure you want to delete the field %label', array('%label' => $label)), t('Delete confirmation was found.')); + $this->assertRaw(t('Are you sure you want to delete the field %label', array('%label' => $label)), 'Delete confirmation was found.'); // Submit confirmation form. $this->drupalPost(NULL, array(), t('Delete')); - $this->assertRaw(t('The field %label has been deleted from the %type content type.', array('%label' => $label, '%type' => $bundle_label)), t('Delete message was found.')); + $this->assertRaw(t('The field %label has been deleted from the %type content type.', array('%label' => $label, '%type' => $bundle_label)), 'Delete message was found.'); // Check that the field does not appear in the overview form. - $this->assertNoFieldByXPath('//table[@id="field-overview"]//span[@class="label-field"]', $label, t('Field does not appear in the overview page.')); + $this->assertNoFieldByXPath('//table[@id="field-overview"]//span[@class="label-field"]', $label, 'Field does not appear in the overview page.'); } } @@ -179,13 +179,13 @@ class FieldUIManageFieldsTestCase extends FieldUITestCase { ); foreach ($table_headers as $table_header) { // We check that the label appear in the table headings. - $this->assertRaw($table_header . '', t('%table_header table header was found.', array('%table_header' => $table_header))); + $this->assertRaw($table_header . '', format_string('%table_header table header was found.', array('%table_header' => $table_header))); } // "Add new field" and "Add existing field" aren't a table heading so just // test the text. foreach (array('Add new field', 'Add existing field') as $element) { - $this->assertText($element, t('"@element" was found.', array('@element' => $element))); + $this->assertText($element, format_string('"@element" was found.', array('@element' => $element))); } } @@ -208,7 +208,7 @@ class FieldUIManageFieldsTestCase extends FieldUITestCase { // should also appear in the 'taxonomy term' entity. $vocabulary = taxonomy_vocabulary_load(1); $this->drupalGet('admin/structure/taxonomy/' . $vocabulary->machine_name . '/fields'); - $this->assertTrue($this->xpath('//select[@name="fields[_add_existing_field][field_name]"]//option[@value="' . $this->field_name . '"]'), t('Existing field was found in account settings.')); + $this->assertTrue($this->xpath('//select[@name="fields[_add_existing_field][field_name]"]//option[@value="' . $this->field_name . '"]'), 'Existing field was found in account settings.'); } /** @@ -231,7 +231,7 @@ class FieldUIManageFieldsTestCase extends FieldUITestCase { $this->assertFieldSettings($this->type, $this->field_name, $string); // Assert redirection back to the "manage fields" page. - $this->assertText(t('Saved @label configuration.', array('@label' => $this->field_label)), t('Redirected to "Manage fields" page.')); + $this->assertText(t('Saved @label configuration.', array('@label' => $this->field_label)), 'Redirected to "Manage fields" page.'); } /** @@ -240,12 +240,12 @@ class FieldUIManageFieldsTestCase extends FieldUITestCase { function addExistingField() { // Check "Add existing field" appears. $this->drupalGet('admin/structure/types/manage/page/fields'); - $this->assertRaw(t('Add existing field'), t('"Add existing field" was found.')); + $this->assertRaw(t('Add existing field'), '"Add existing field" was found.'); // Check that the list of options respects entity type restrictions on // fields. The 'comment' field is restricted to the 'comment' entity type // and should not appear in the list. - $this->assertFalse($this->xpath('//select[@id="edit-add-existing-field-field-name"]//option[@value="comment"]'), t('The list of options respects entity type restrictions.')); + $this->assertFalse($this->xpath('//select[@id="edit-add-existing-field-field-name"]//option[@value="comment"]'), 'The list of options respects entity type restrictions.'); // Add a new field based on an existing field. $edit = array( @@ -272,12 +272,12 @@ class FieldUIManageFieldsTestCase extends FieldUITestCase { field_info_cache_clear(); // Assert field settings. $field = field_info_field($field_name); - $this->assertTrue($field['settings']['test_field_setting'] == $string, t('Field settings were found.')); + $this->assertTrue($field['settings']['test_field_setting'] == $string, 'Field settings were found.'); // Assert instance and widget settings. $instance = field_info_instance($entity_type, $field_name, $bundle); - $this->assertTrue($instance['settings']['test_instance_setting'] == $string, t('Field instance settings were found.')); - $this->assertTrue($instance['widget']['settings']['test_widget_setting'] == $string, t('Field widget settings were found.')); + $this->assertTrue($instance['settings']['test_instance_setting'] == $string, 'Field instance settings were found.'); + $this->assertTrue($instance['widget']['settings']['test_widget_setting'] == $string, 'Field widget settings were found.'); } /** @@ -303,31 +303,31 @@ class FieldUIManageFieldsTestCase extends FieldUITestCase { $element_id = "edit-$field_name-$langcode-0-value"; $element_name = "{$field_name}[$langcode][0][value]"; $this->drupalGet($admin_path); - $this->assertFieldById($element_id, '', t('The default value widget was empty.')); + $this->assertFieldById($element_id, '', 'The default value widget was empty.'); // Check that invalid default values are rejected. $edit = array($element_name => '-1'); $this->drupalPost($admin_path, $edit, t('Save settings')); - $this->assertText("$field_name does not accept the value -1", t('Form vaildation failed.')); + $this->assertText("$field_name does not accept the value -1", 'Form vaildation failed.'); // Check that the default value is saved. $edit = array($element_name => '1'); $this->drupalPost($admin_path, $edit, t('Save settings')); - $this->assertText("Saved $field_name configuration", t('The form was successfully submitted.')); + $this->assertText("Saved $field_name configuration", 'The form was successfully submitted.'); $instance = field_info_instance('node', $field_name, $this->type); - $this->assertEqual($instance['default_value'], array(array('value' => 1)), t('The default value was correctly saved.')); + $this->assertEqual($instance['default_value'], array(array('value' => 1)), 'The default value was correctly saved.'); // Check that the default value shows up in the form $this->drupalGet($admin_path); - $this->assertFieldById($element_id, '1', t('The default value widget was displayed with the correct value.')); + $this->assertFieldById($element_id, '1', 'The default value widget was displayed with the correct value.'); // Check that the default value can be emptied. $edit = array($element_name => ''); $this->drupalPost(NULL, $edit, t('Save settings')); - $this->assertText("Saved $field_name configuration", t('The form was successfully submitted.')); + $this->assertText("Saved $field_name configuration", 'The form was successfully submitted.'); field_info_cache_clear(); $instance = field_info_instance('node', $field_name, $this->type); - $this->assertEqual($instance['default_value'], NULL, t('The default value was correctly saved.')); + $this->assertEqual($instance['default_value'], NULL, 'The default value was correctly saved.'); } /** @@ -362,9 +362,9 @@ class FieldUIManageFieldsTestCase extends FieldUITestCase { // Reset the fields info. field_info_cache_clear(); // Check that the field instance was deleted. - $this->assertNull(field_info_instance('node', $this->field_name, $this->type), t('Field instance was deleted.')); + $this->assertNull(field_info_instance('node', $this->field_name, $this->type), 'Field instance was deleted.'); // Check that the field was not deleted - $this->assertNotNull(field_info_field($this->field_name), t('Field was not deleted.')); + $this->assertNotNull(field_info_field($this->field_name), 'Field was not deleted.'); // Delete the second instance. $this->fieldUIDeleteField($bundle_path2, $this->field_name, $this->field_label, $type_name2); @@ -372,9 +372,9 @@ class FieldUIManageFieldsTestCase extends FieldUITestCase { // Reset the fields info. field_info_cache_clear(); // Check that the field instance was deleted. - $this->assertNull(field_info_instance('node', $this->field_name, $type_name2), t('Field instance was deleted.')); + $this->assertNull(field_info_instance('node', $this->field_name, $type_name2), 'Field instance was deleted.'); // Check that the field was deleted too. - $this->assertNull(field_info_field($this->field_name), t('Field was deleted.')); + $this->assertNull(field_info_field($this->field_name), 'Field was deleted.'); } /** @@ -385,7 +385,7 @@ class FieldUIManageFieldsTestCase extends FieldUITestCase { // Check that the field type is not available in the 'add new field' row. $this->drupalGet($bundle_path); - $this->assertFalse($this->xpath('//select[@id="edit-add-new-field-type"]//option[@value="hidden_test_field"]'), t("The 'add new field' select respects field types 'no_ui' property.")); + $this->assertFalse($this->xpath('//select[@id="edit-add-new-field-type"]//option[@value="hidden_test_field"]'), "The 'add new field' select respects field types 'no_ui' property."); // Create a field and an instance programmatically. $field_name = 'hidden_test_field'; @@ -398,18 +398,18 @@ class FieldUIManageFieldsTestCase extends FieldUITestCase { 'widget' => array('type' => 'test_field_widget'), ); field_create_instance($instance); - $this->assertTrue(field_read_instance('node', $field_name, $this->type), t('An instance of the field %field was created programmatically.', array('%field' => $field_name))); + $this->assertTrue(field_read_instance('node', $field_name, $this->type), format_string('An instance of the field %field was created programmatically.', array('%field' => $field_name))); // Check that the newly added instance appears on the 'Manage Fields' // screen. $this->drupalGet($bundle_path); - $this->assertFieldByXPath('//table[@id="field-overview"]//td[1]', $instance['label'], t('Field was created and appears in the overview page.')); + $this->assertFieldByXPath('//table[@id="field-overview"]//td[1]', $instance['label'], 'Field was created and appears in the overview page.'); // Check that the instance does not appear in the 'add existing field' row // on other bundles. $bundle_path = 'admin/structure/types/manage/article/fields/'; $this->drupalGet($bundle_path); - $this->assertFalse($this->xpath('//select[@id="edit-add-existing-field-field-name"]//option[@value=:field_name]', array(':field_name' => $field_name)), t("The 'add existing field' select respects field types 'no_ui' property.")); + $this->assertFalse($this->xpath('//select[@id="edit-add-existing-field-field-name"]//option[@value=:field_name]', array(':field_name' => $field_name)), "The 'add existing field' select respects field types 'no_ui' property."); } /** @@ -488,8 +488,8 @@ class FieldUIManageDisplayTestCase extends FieldUITestCase { // Display the "Manage display" screen and check that the expected formatter is // selected. $this->drupalGet($manage_display); - $this->assertFieldByName('fields[field_test][type]', $format, t('The expected formatter is selected.')); - $this->assertText("$setting_name: $setting_value", t('The expected summary is displayed.')); + $this->assertFieldByName('fields[field_test][type]', $format, 'The expected formatter is selected.'); + $this->assertText("$setting_name: $setting_value", 'The expected summary is displayed.'); // Change the formatter and check that the summary is updated. $edit = array('fields[field_test][type]' => 'field_test_multiple', 'refresh_rows' => 'field_test'); @@ -498,8 +498,8 @@ class FieldUIManageDisplayTestCase extends FieldUITestCase { $default_settings = field_info_formatter_settings($format); $setting_name = key($default_settings); $setting_value = $default_settings[$setting_name]; - $this->assertFieldByName('fields[field_test][type]', $format, t('The expected formatter is selected.')); - $this->assertText("$setting_name: $setting_value", t('The expected summary is displayed.')); + $this->assertFieldByName('fields[field_test][type]', $format, 'The expected formatter is selected.'); + $this->assertText("$setting_name: $setting_value", 'The expected summary is displayed.'); // Submit the form and check that the instance is updated. $this->drupalPost(NULL, array(), t('Save')); @@ -507,8 +507,8 @@ class FieldUIManageDisplayTestCase extends FieldUITestCase { $instance = field_info_instance('node', 'field_test', $this->type); $current_format = $instance['display']['default']['type']; $current_setting_value = $instance['display']['default']['settings'][$setting_name]; - $this->assertEqual($current_format, $format, t('The formatter was updated.')); - $this->assertEqual($current_setting_value, $setting_value, t('The setting was updated.')); + $this->assertEqual($current_format, $format, 'The formatter was updated.'); + $this->assertEqual($current_setting_value, $setting_value, 'The setting was updated.'); } /** @@ -540,8 +540,8 @@ class FieldUIManageDisplayTestCase extends FieldUITestCase { // Check that the field is displayed with the default formatter in 'rss' // mode (uses 'default'), and hidden in 'teaser' mode (uses custom settings). - $this->assertNodeViewText($node, 'rss', $output['field_test_default'], t("The field is displayed as expected in view modes that use 'default' settings.")); - $this->assertNodeViewNoText($node, 'teaser', $value, t("The field is hidden in view modes that use custom settings.")); + $this->assertNodeViewText($node, 'rss', $output['field_test_default'], "The field is displayed as expected in view modes that use 'default' settings."); + $this->assertNodeViewNoText($node, 'teaser', $value, "The field is hidden in view modes that use custom settings."); // Change fomatter for 'default' mode, check that the field is displayed // accordingly in 'rss' mode. @@ -549,14 +549,14 @@ class FieldUIManageDisplayTestCase extends FieldUITestCase { 'fields[field_test][type]' => 'field_test_with_prepare_view', ); $this->drupalPost('admin/structure/types/manage/' . $this->hyphen_type . '/display', $edit, t('Save')); - $this->assertNodeViewText($node, 'rss', $output['field_test_with_prepare_view'], t("The field is displayed as expected in view modes that use 'default' settings.")); + $this->assertNodeViewText($node, 'rss', $output['field_test_with_prepare_view'], "The field is displayed as expected in view modes that use 'default' settings."); // Specialize the 'rss' mode, check that the field is displayed the same. $edit = array( "view_modes_custom[rss]" => TRUE, ); $this->drupalPost('admin/structure/types/manage/' . $this->hyphen_type . '/display', $edit, t('Save')); - $this->assertNodeViewText($node, 'rss', $output['field_test_with_prepare_view'], t("The field is displayed as expected in newly specialized 'rss' mode.")); + $this->assertNodeViewText($node, 'rss', $output['field_test_with_prepare_view'], "The field is displayed as expected in newly specialized 'rss' mode."); // Set the field to 'hidden' in the view mode, check that the field is // hidden. @@ -564,7 +564,7 @@ class FieldUIManageDisplayTestCase extends FieldUITestCase { 'fields[field_test][type]' => 'hidden', ); $this->drupalPost('admin/structure/types/manage/' . $this->hyphen_type . '/display/rss', $edit, t('Save')); - $this->assertNodeViewNoText($node, 'rss', $value, t("The field is hidden in 'rss' mode.")); + $this->assertNodeViewNoText($node, 'rss', $value, "The field is hidden in 'rss' mode."); // Set the view mode back to 'default', check that the field is displayed // accordingly. @@ -572,7 +572,7 @@ class FieldUIManageDisplayTestCase extends FieldUITestCase { "view_modes_custom[rss]" => FALSE, ); $this->drupalPost('admin/structure/types/manage/' . $this->hyphen_type . '/display', $edit, t('Save')); - $this->assertNodeViewText($node, 'rss', $output['field_test_with_prepare_view'], t("The field is displayed as expected when 'rss' mode is set back to 'default' settings.")); + $this->assertNodeViewText($node, 'rss', $output['field_test_with_prepare_view'], "The field is displayed as expected when 'rss' mode is set back to 'default' settings."); // Specialize the view mode again. $edit = array( @@ -580,7 +580,7 @@ class FieldUIManageDisplayTestCase extends FieldUITestCase { ); $this->drupalPost('admin/structure/types/manage/' . $this->hyphen_type . '/display', $edit, t('Save')); // Check that the previous settings for the view mode have been kept. - $this->assertNodeViewNoText($node, 'rss', $value, t("The previous settings are kept when 'rss' mode is specialized again.")); + $this->assertNodeViewNoText($node, 'rss', $value, "The previous settings are kept when 'rss' mode is specialized again."); } /** diff --git a/modules/file/file.info b/modules/file/file.info index b4b3461d..972c15dd 100755 --- a/modules/file/file.info +++ b/modules/file/file.info @@ -6,8 +6,8 @@ core = 7.x dependencies[] = field files[] = tests/file.test -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/file/tests/file.test b/modules/file/tests/file.test index 76708a3c..69e711a3 100755 --- a/modules/file/tests/file.test +++ b/modules/file/tests/file.test @@ -139,7 +139,7 @@ class FileFieldTestCase extends DrupalWebTestCase { // Save at least one revision to better simulate a real site. $this->drupalCreateNode(get_object_vars($node)); $node = node_load($nid, NULL, TRUE); - $this->assertNotEqual($nid, $node->vid, t('Node revision exists.')); + $this->assertNotEqual($nid, $node->vid, 'Node revision exists.'); } // Attach a file to the node. @@ -180,7 +180,7 @@ class FileFieldTestCase extends DrupalWebTestCase { * Asserts that a file exists physically on disk. */ function assertFileExists($file, $message = NULL) { - $message = isset($message) ? $message : t('File %file exists on the disk.', array('%file' => $file->uri)); + $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->uri)); $this->assertTrue(is_file($file->uri), $message); } @@ -190,7 +190,7 @@ class FileFieldTestCase extends DrupalWebTestCase { function assertFileEntryExists($file, $message = NULL) { entity_get_controller('file')->resetCache(); $db_file = file_load($file->fid); - $message = isset($message) ? $message : t('File %file exists in database at the correct path.', array('%file' => $file->uri)); + $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->uri)); $this->assertEqual($db_file->uri, $file->uri, $message); } @@ -198,7 +198,7 @@ class FileFieldTestCase extends DrupalWebTestCase { * Asserts that a file does not exist on disk. */ function assertFileNotExists($file, $message = NULL) { - $message = isset($message) ? $message : t('File %file exists on the disk.', array('%file' => $file->uri)); + $message = isset($message) ? $message : format_string('File %file exists on the disk.', array('%file' => $file->uri)); $this->assertFalse(is_file($file->uri), $message); } @@ -207,7 +207,7 @@ class FileFieldTestCase extends DrupalWebTestCase { */ function assertFileEntryNotExists($file, $message) { entity_get_controller('file')->resetCache(); - $message = isset($message) ? $message : t('File %file exists in database at the correct path.', array('%file' => $file->uri)); + $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->uri)); $this->assertFalse(file_load($file->fid), $message); } @@ -215,7 +215,7 @@ class FileFieldTestCase extends DrupalWebTestCase { * Asserts that a file's status is set to permanent in the database. */ function assertFileIsPermanent($file, $message = NULL) { - $message = isset($message) ? $message : t('File %file is permanent.', array('%file' => $file->uri)); + $message = isset($message) ? $message : format_string('File %file is permanent.', array('%file' => $file->uri)); $this->assertTrue($file->status == FILE_STATUS_PERMANENT, $message); } } @@ -253,19 +253,19 @@ class FileManagedFileElementTestCase extends FileFieldTestCase { // Submit without a file. $this->drupalPost($path, array(), t('Save')); - $this->assertRaw(t('The file id is %fid.', array('%fid' => 0)), t('Submitted without a file.')); + $this->assertRaw(t('The file id is %fid.', array('%fid' => 0)), 'Submitted without a file.'); // Submit a new file, without using the Upload button. $last_fid_prior = $this->getLastFileId(); $edit = array('files[' . $input_base_name . ']' => drupal_realpath($test_file->uri)); $this->drupalPost($path, $edit, t('Save')); $last_fid = $this->getLastFileId(); - $this->assertTrue($last_fid > $last_fid_prior, t('New file got saved.')); - $this->assertRaw(t('The file id is %fid.', array('%fid' => $last_fid)), t('Submit handler has correct file info.')); + $this->assertTrue($last_fid > $last_fid_prior, 'New file got saved.'); + $this->assertRaw(t('The file id is %fid.', array('%fid' => $last_fid)), 'Submit handler has correct file info.'); // Submit no new input, but with a default file. $this->drupalPost($path . '/' . $last_fid, array(), t('Save')); - $this->assertRaw(t('The file id is %fid.', array('%fid' => $last_fid)), t('Empty submission did not change an existing file.')); + $this->assertRaw(t('The file id is %fid.', array('%fid' => $last_fid)), 'Empty submission did not change an existing file.'); // Now, test the Upload and Remove buttons, with and without Ajax. foreach (array(FALSE, TRUE) as $ajax) { @@ -280,9 +280,9 @@ class FileManagedFileElementTestCase extends FileFieldTestCase { $this->drupalPost(NULL, $edit, t('Upload')); } $last_fid = $this->getLastFileId(); - $this->assertTrue($last_fid > $last_fid_prior, t('New file got uploaded.')); + $this->assertTrue($last_fid > $last_fid_prior, 'New file got uploaded.'); $this->drupalPost(NULL, array(), t('Save')); - $this->assertRaw(t('The file id is %fid.', array('%fid' => $last_fid)), t('Submit handler has correct file info.')); + $this->assertRaw(t('The file id is %fid.', array('%fid' => $last_fid)), 'Submit handler has correct file info.'); // Remove, then Submit. $this->drupalGet($path . '/' . $last_fid); @@ -293,7 +293,7 @@ class FileManagedFileElementTestCase extends FileFieldTestCase { $this->drupalPost(NULL, array(), t('Remove')); } $this->drupalPost(NULL, array(), t('Save')); - $this->assertRaw(t('The file id is %fid.', array('%fid' => 0)), t('Submission after file removal was successful.')); + $this->assertRaw(t('The file id is %fid.', array('%fid' => 0)), 'Submission after file removal was successful.'); // Upload, then Remove, then Submit. $this->drupalGet($path); @@ -307,7 +307,7 @@ class FileManagedFileElementTestCase extends FileFieldTestCase { $this->drupalPost(NULL, array(), t('Remove')); } $this->drupalPost(NULL, array(), t('Save')); - $this->assertRaw(t('The file id is %fid.', array('%fid' => 0)), t('Submission after file upload and removal was successful.')); + $this->assertRaw(t('The file id is %fid.', array('%fid' => 0)), 'Submission after file upload and removal was successful.'); } } } @@ -350,16 +350,16 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('New file saved to disk on node creation.')); + $this->assertFileExists($node_file, 'New file saved to disk on node creation.'); // Ensure the file can be downloaded. $this->drupalGet(file_create_url($node_file->uri)); - $this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.')); + $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); // Ensure the edit page has a remove button instead of an upload button. $this->drupalGet("node/$nid/edit"); - $this->assertNoFieldByXPath('//input[@type="submit"]', t('Upload'), t('Node with file does not display the "Upload" button.')); - $this->assertFieldByXpath('//input[@type="submit"]', t('Remove'), t('Node with file displays the "Remove" button.')); + $this->assertNoFieldByXPath('//input[@type="submit"]', t('Upload'), 'Node with file does not display the "Upload" button.'); + $this->assertFieldByXpath('//input[@type="submit"]', t('Remove'), 'Node with file displays the "Remove" button.'); // "Click" the remove button (emulating either a nojs or js submission). switch ($type) { @@ -373,13 +373,13 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { } // Ensure the page now has an upload button instead of a remove button. - $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), t('After clicking the "Remove" button, it is no longer displayed.')); - $this->assertFieldByXpath('//input[@type="submit"]', t('Upload'), t('After clicking the "Remove" button, the "Upload" button is displayed.')); + $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), 'After clicking the "Remove" button, it is no longer displayed.'); + $this->assertFieldByXpath('//input[@type="submit"]', t('Upload'), 'After clicking the "Remove" button, the "Upload" button is displayed.'); // Save the node and ensure it does not have the file. $this->drupalPost(NULL, array(), t('Save')); $node = node_load($nid, NULL, TRUE); - $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NONE][0]['fid']), t('File was successfully removed from the node.')); + $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NONE][0]['fid']), 'File was successfully removed from the node.'); } } @@ -423,7 +423,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { $this->drupalPost(NULL, $edit, t('Upload')); } } - $this->assertNoFieldByXpath('//input[@type="submit"]', t('Upload'), t('After uploading 3 files for each field, the "Upload" button is no longer displayed.')); + $this->assertNoFieldByXpath('//input[@type="submit"]', t('Upload'), 'After uploading 3 files for each field, the "Upload" button is no longer displayed.'); $num_expected_remove_buttons = 6; @@ -440,7 +440,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { // Ensure we have the expected number of Remove buttons, and that they // are numbered sequentially. $buttons = $this->xpath('//input[@type="submit" and @value="Remove"]'); - $this->assertTrue(is_array($buttons) && count($buttons) === $num_expected_remove_buttons, t('There are %n "Remove" buttons displayed (JSMode=%type).', array('%n' => $num_expected_remove_buttons, '%type' => $type))); + $this->assertTrue(is_array($buttons) && count($buttons) === $num_expected_remove_buttons, format_string('There are %n "Remove" buttons displayed (JSMode=%type).', array('%n' => $num_expected_remove_buttons, '%type' => $type))); foreach ($buttons as $i => $button) { $key = $i >= $remaining ? $i - $remaining : $i; $check_field_name = $field_name2; @@ -482,17 +482,17 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { // correct name. $upload_button_name = $current_field_name . '_' . LANGUAGE_NONE . '_' . $remaining . '_upload_button'; $buttons = $this->xpath('//input[@type="submit" and @value="Upload" and @name=:name]', array(':name' => $upload_button_name)); - $this->assertTrue(is_array($buttons) && count($buttons) == 1, t('The upload button is displayed with the correct name (JSMode=%type).', array('%type' => $type))); + $this->assertTrue(is_array($buttons) && count($buttons) == 1, format_string('The upload button is displayed with the correct name (JSMode=%type).', array('%type' => $type))); // Ensure only at most one button per field is displayed. $buttons = $this->xpath('//input[@type="submit" and @value="Upload"]'); $expected = $current_field_name == $field_name ? 1 : 2; - $this->assertTrue(is_array($buttons) && count($buttons) == $expected, t('After removing a file, only one "Upload" button for each possible field is displayed (JSMode=%type).', array('%type' => $type))); + $this->assertTrue(is_array($buttons) && count($buttons) == $expected, format_string('After removing a file, only one "Upload" button for each possible field is displayed (JSMode=%type).', array('%type' => $type))); } } // Ensure the page now has no Remove buttons. - $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), t('After removing all files, there is no "Remove" button displayed (JSMode=%type).', array('%type' => $type))); + $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), format_string('After removing all files, there is no "Remove" button displayed (JSMode=%type).', array('%type' => $type))); // Save the node and ensure it does not have any files. $this->drupalPost(NULL, array('title' => $this->randomName()), t('Save')); @@ -500,7 +500,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { preg_match('/node\/([0-9]+)/', $this->getUrl(), $matches); $nid = $matches[1]; $node = node_load($nid, NULL, TRUE); - $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NONE][0]['fid']), t('Node was successfully saved without any files.')); + $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NONE][0]['fid']), 'Node was successfully saved without any files.'); } } @@ -526,21 +526,21 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('New file saved to disk on node creation.')); + $this->assertFileExists($node_file, 'New file saved to disk on node creation.'); // Ensure the private file is available to the user who uploaded it. $this->drupalGet(file_create_url($node_file->uri)); - $this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.')); + $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); // Ensure we can't change 'uri_scheme' field settings while there are some // entities with uploaded files. $this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_name"); - $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and @disabled="disabled"]', 'public', t('Upload destination setting disabled.')); + $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and @disabled="disabled"]', 'public', 'Upload destination setting disabled.'); // Delete node and confirm that setting could be changed. node_delete($nid); $this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_name"); - $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and not(@disabled)]', 'public', t('Upload destination setting enabled.')); + $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and not(@disabled)]', 'public', 'Upload destination setting enabled.'); } /** @@ -592,17 +592,17 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { $comment = comment_load($cid); $comment_file = (object) $comment->{'field_' . $name}[LANGUAGE_NONE][0]; - $this->assertFileExists($comment_file, t('New file saved to disk on node creation.')); + $this->assertFileExists($comment_file, 'New file saved to disk on node creation.'); // Test authenticated file download. $url = file_create_url($comment_file->uri); - $this->assertNotEqual($url, NULL, t('Confirmed that the URL is valid')); + $this->assertNotEqual($url, NULL, 'Confirmed that the URL is valid'); $this->drupalGet(file_create_url($comment_file->uri)); - $this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.')); + $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); // Test anonymous file download. $this->drupalLogout(); $this->drupalGet(file_create_url($comment_file->uri)); - $this->assertResponse(403, t('Confirmed that access is denied for the file without the needed permission.')); + $this->assertResponse(403, 'Confirmed that access is denied for the file without the needed permission.'); // Unpublishes node. $this->drupalLogin($this->admin_user); @@ -614,7 +614,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { // Ensures normal user can no longer download the file. $this->drupalLogin($user); $this->drupalGet(file_create_url($comment_file->uri)); - $this->assertResponse(403, t('Confirmed that access is denied for the file without the needed permission.')); + $this->assertResponse(403, 'Confirmed that access is denied for the file without the needed permission.'); } } @@ -661,25 +661,25 @@ class FileFieldRevisionTestCase extends FileFieldTestCase { $node = node_load($nid, NULL, TRUE); $node_file_r1 = (object) $node->{$field_name}[LANGUAGE_NONE][0]; $node_vid_r1 = $node->vid; - $this->assertFileExists($node_file_r1, t('New file saved to disk on node creation.')); - $this->assertFileEntryExists($node_file_r1, t('File entry exists in database on node creation.')); - $this->assertFileIsPermanent($node_file_r1, t('File is permanent.')); + $this->assertFileExists($node_file_r1, 'New file saved to disk on node creation.'); + $this->assertFileEntryExists($node_file_r1, 'File entry exists in database on node creation.'); + $this->assertFileIsPermanent($node_file_r1, 'File is permanent.'); // Upload another file to the same node in a new revision. $this->replaceNodeFile($test_file, $field_name, $nid); $node = node_load($nid, NULL, TRUE); $node_file_r2 = (object) $node->{$field_name}[LANGUAGE_NONE][0]; $node_vid_r2 = $node->vid; - $this->assertFileExists($node_file_r2, t('Replacement file exists on disk after creating new revision.')); - $this->assertFileEntryExists($node_file_r2, t('Replacement file entry exists in database after creating new revision.')); - $this->assertFileIsPermanent($node_file_r2, t('Replacement file is permanent.')); + $this->assertFileExists($node_file_r2, 'Replacement file exists on disk after creating new revision.'); + $this->assertFileEntryExists($node_file_r2, 'Replacement file entry exists in database after creating new revision.'); + $this->assertFileIsPermanent($node_file_r2, 'Replacement file is permanent.'); // Check that the original file is still in place on the first revision. $node = node_load($nid, $node_vid_r1, TRUE); - $this->assertEqual($node_file_r1, (object) $node->{$field_name}[LANGUAGE_NONE][0], t('Original file still in place after replacing file in new revision.')); - $this->assertFileExists($node_file_r1, t('Original file still in place after replacing file in new revision.')); - $this->assertFileEntryExists($node_file_r1, t('Original file entry still in place after replacing file in new revision')); - $this->assertFileIsPermanent($node_file_r1, t('Original file is still permanent.')); + $this->assertEqual($node_file_r1, (object) $node->{$field_name}[LANGUAGE_NONE][0], 'Original file still in place after replacing file in new revision.'); + $this->assertFileExists($node_file_r1, 'Original file still in place after replacing file in new revision.'); + $this->assertFileEntryExists($node_file_r1, 'Original file entry still in place after replacing file in new revision'); + $this->assertFileIsPermanent($node_file_r1, 'Original file is still permanent.'); // Save a new version of the node without any changes. // Check that the file is still the same as the previous revision. @@ -687,23 +687,23 @@ class FileFieldRevisionTestCase extends FileFieldTestCase { $node = node_load($nid, NULL, TRUE); $node_file_r3 = (object) $node->{$field_name}[LANGUAGE_NONE][0]; $node_vid_r3 = $node->vid; - $this->assertEqual($node_file_r2, $node_file_r3, t('Previous revision file still in place after creating a new revision without a new file.')); - $this->assertFileIsPermanent($node_file_r3, t('New revision file is permanent.')); + $this->assertEqual($node_file_r2, $node_file_r3, 'Previous revision file still in place after creating a new revision without a new file.'); + $this->assertFileIsPermanent($node_file_r3, 'New revision file is permanent.'); // Revert to the first revision and check that the original file is active. $this->drupalPost('node/' . $nid . '/revisions/' . $node_vid_r1 . '/revert', array(), t('Revert')); $node = node_load($nid, NULL, TRUE); $node_file_r4 = (object) $node->{$field_name}[LANGUAGE_NONE][0]; $node_vid_r4 = $node->vid; - $this->assertEqual($node_file_r1, $node_file_r4, t('Original revision file still in place after reverting to the original revision.')); - $this->assertFileIsPermanent($node_file_r4, t('Original revision file still permanent after reverting to the original revision.')); + $this->assertEqual($node_file_r1, $node_file_r4, 'Original revision file still in place after reverting to the original revision.'); + $this->assertFileIsPermanent($node_file_r4, 'Original revision file still permanent after reverting to the original revision.'); // Delete the second revision and check that the file is kept (since it is // still being used by the third revision). $this->drupalPost('node/' . $nid . '/revisions/' . $node_vid_r2 . '/delete', array(), t('Delete')); - $this->assertFileExists($node_file_r3, t('Second file is still available after deleting second revision, since it is being used by the third revision.')); - $this->assertFileEntryExists($node_file_r3, t('Second file entry is still available after deleting second revision, since it is being used by the third revision.')); - $this->assertFileIsPermanent($node_file_r3, t('Second file entry is still permanent after deleting second revision, since it is being used by the third revision.')); + $this->assertFileExists($node_file_r3, 'Second file is still available after deleting second revision, since it is being used by the third revision.'); + $this->assertFileEntryExists($node_file_r3, 'Second file entry is still available after deleting second revision, since it is being used by the third revision.'); + $this->assertFileIsPermanent($node_file_r3, 'Second file entry is still permanent after deleting second revision, since it is being used by the third revision.'); // Attach the second file to a user. $user = $this->drupalCreateUser(); @@ -714,9 +714,9 @@ class FileFieldRevisionTestCase extends FileFieldTestCase { // Delete the third revision and check that the file is not deleted yet. $this->drupalPost('node/' . $nid . '/revisions/' . $node_vid_r3 . '/delete', array(), t('Delete')); - $this->assertFileExists($node_file_r3, t('Second file is still available after deleting third revision, since it is being used by the user.')); - $this->assertFileEntryExists($node_file_r3, t('Second file entry is still available after deleting third revision, since it is being used by the user.')); - $this->assertFileIsPermanent($node_file_r3, t('Second file entry is still permanent after deleting third revision, since it is being used by the user.')); + $this->assertFileExists($node_file_r3, 'Second file is still available after deleting third revision, since it is being used by the user.'); + $this->assertFileEntryExists($node_file_r3, 'Second file entry is still available after deleting third revision, since it is being used by the user.'); + $this->assertFileIsPermanent($node_file_r3, 'Second file entry is still permanent after deleting third revision, since it is being used by the user.'); // Delete the user and check that the file is also deleted. user_delete($user->uid); @@ -724,13 +724,13 @@ class FileFieldRevisionTestCase extends FileFieldTestCase { // not be necessary here. The file really is deleted, but stream wrappers // doesn't seem to think so unless we clear the PHP file stat() cache. clearstatcache(); - $this->assertFileNotExists($node_file_r3, t('Second file is now deleted after deleting third revision, since it is no longer being used by any other nodes.')); - $this->assertFileEntryNotExists($node_file_r3, t('Second file entry is now deleted after deleting third revision, since it is no longer being used by any other nodes.')); + $this->assertFileNotExists($node_file_r3, 'Second file is now deleted after deleting third revision, since it is no longer being used by any other nodes.'); + $this->assertFileEntryNotExists($node_file_r3, 'Second file entry is now deleted after deleting third revision, since it is no longer being used by any other nodes.'); // Delete the entire node and check that the original file is deleted. $this->drupalPost('node/' . $nid . '/delete', array(), t('Delete')); - $this->assertFileNotExists($node_file_r1, t('Original file is deleted after deleting the entire node with two revisions remaining.')); - $this->assertFileEntryNotExists($node_file_r1, t('Original file entry is deleted after deleting the entire node with two revisions remaining.')); + $this->assertFileNotExists($node_file_r1, 'Original file is deleted after deleting the entire node with two revisions remaining.'); + $this->assertFileEntryNotExists($node_file_r1, 'Original file entry is deleted after deleting the entire node with two revisions remaining.'); } } @@ -774,7 +774,7 @@ class FileFieldDisplayTestCase extends FileFieldTestCase { ); $this->drupalPost("admin/structure/types/manage/$type_name/display", $edit, t('Save')); $this->drupalGet('node/' . $node->nid); - $this->assertNoText($field_name, t('Field label is hidden when no file attached for formatter %formatter', array('%formatter' => $formatter))); + $this->assertNoText($field_name, format_string('Field label is hidden when no file attached for formatter %formatter', array('%formatter' => $formatter))); } $test_file = $this->getTestFile('text'); @@ -787,13 +787,13 @@ class FileFieldDisplayTestCase extends FileFieldTestCase { $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; $default_output = theme('file_link', array('file' => $node_file)); - $this->assertRaw($default_output, t('Default formatter displaying correctly on full node view.')); + $this->assertRaw($default_output, 'Default formatter displaying correctly on full node view.'); // Turn the "display" option off and check that the file is no longer displayed. $edit = array($field_name . '[' . LANGUAGE_NONE . '][0][display]' => FALSE); $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save')); - $this->assertNoRaw($default_output, t('Field is hidden when "display" option is unchecked.')); + $this->assertNoRaw($default_output, 'Field is hidden when "display" option is unchecked.'); } } @@ -829,17 +829,17 @@ class FileFieldValidateTestCase extends FileFieldTestCase { $langcode = LANGUAGE_NONE; $edit = array("title" => $this->randomName()); $this->drupalPost('node/add/' . $type_name, $edit, t('Save')); - $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), t('Node save failed when required file field was empty.')); + $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), 'Node save failed when required file field was empty.'); // Create a new node with the uploaded file. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); - $this->assertTrue($nid !== FALSE, t('uploadNodeFile(@test_file, @field_name, @type_name) succeeded', array('@test_file' => $test_file->uri, '@field_name' => $field_name, '@type_name' => $type_name))); + $this->assertTrue($nid !== FALSE, format_string('uploadNodeFile(@test_file, @field_name, @type_name) succeeded', array('@test_file' => $test_file->uri, '@field_name' => $field_name, '@type_name' => $type_name))); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('File exists after uploading to the required field.')); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading to the required field.')); + $this->assertFileExists($node_file, 'File exists after uploading to the required field.'); + $this->assertFileEntryExists($node_file, 'File entry exists after uploading to the required field.'); // Try again with a multiple value field. field_delete_field($field_name); @@ -848,14 +848,14 @@ class FileFieldValidateTestCase extends FileFieldTestCase { // Try to post a new node without uploading a file in the multivalue field. $edit = array('title' => $this->randomName()); $this->drupalPost('node/add/' . $type_name, $edit, t('Save')); - $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), t('Node save failed when required multiple value file field was empty.')); + $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), 'Node save failed when required multiple value file field was empty.'); // Create a new node with the uploaded file into the multivalue field. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('File exists after uploading to the required multiple value field.')); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading to the required multipel value field.')); + $this->assertFileExists($node_file, 'File exists after uploading to the required multiple value field.'); + $this->assertFileEntryExists($node_file, 'File entry exists after uploading to the required multipel value field.'); // Remove our file field. field_delete_field($field_name); @@ -890,13 +890,13 @@ class FileFieldValidateTestCase extends FileFieldTestCase { $nid = $this->uploadNodeFile($small_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('File exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize))); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize))); + $this->assertFileExists($node_file, format_string('File exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize))); + $this->assertFileEntryExists($node_file, format_string('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize))); // Check that uploading the large file fails (1M limit). $nid = $this->uploadNodeFile($large_file, $field_name, $type_name); $error_message = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($large_file->filesize), '%maxsize' => format_size($file_limit))); - $this->assertRaw($error_message, t('Node save failed when file (%filesize) exceeded the max upload size (%maxsize).', array('%filesize' => format_size($large_file->filesize), '%maxsize' => $max_filesize))); + $this->assertRaw($error_message, format_string('Node save failed when file (%filesize) exceeded the max upload size (%maxsize).', array('%filesize' => format_size($large_file->filesize), '%maxsize' => $max_filesize))); } // Turn off the max filesize. @@ -906,8 +906,8 @@ class FileFieldValidateTestCase extends FileFieldTestCase { $nid = $this->uploadNodeFile($large_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('File exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize)))); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize)))); + $this->assertFileExists($node_file, format_string('File exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize)))); + $this->assertFileEntryExists($node_file, format_string('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize)))); // Remove our file field. field_delete_field($field_name); @@ -933,8 +933,8 @@ class FileFieldValidateTestCase extends FileFieldTestCase { $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('File exists after uploading a file with no extension checking.')); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file with no extension checking.')); + $this->assertFileExists($node_file, 'File exists after uploading a file with no extension checking.'); + $this->assertFileEntryExists($node_file, 'File entry exists after uploading a file with no extension checking.'); // Enable extension checking for text files. $this->updateFileField($field_name, $type_name, array('file_extensions' => 'txt')); @@ -942,7 +942,7 @@ class FileFieldValidateTestCase extends FileFieldTestCase { // Check that the file with the wrong extension cannot be uploaded. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $error_message = t('Only files with the following extensions are allowed: %files-allowed.', array('%files-allowed' => 'txt')); - $this->assertRaw($error_message, t('Node save failed when file uploaded with the wrong extension.')); + $this->assertRaw($error_message, 'Node save failed when file uploaded with the wrong extension.'); // Enable extension checking for text and image files. $this->updateFileField($field_name, $type_name, array('file_extensions' => "txt $test_file_extension")); @@ -951,8 +951,8 @@ class FileFieldValidateTestCase extends FileFieldTestCase { $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertFileExists($node_file, t('File exists after uploading a file with extension checking.')); - $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file with extension checking.')); + $this->assertFileExists($node_file, 'File exists after uploading a file with extension checking.'); + $this->assertFileEntryExists($node_file, 'File entry exists after uploading a file with extension checking.'); // Remove our file field. field_delete_field($field_name); @@ -986,7 +986,7 @@ class FileFieldPathTestCase extends FileFieldTestCase { // Check that the file was uploaded to the file root. $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertPathMatch('public://' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri))); + $this->assertPathMatch('public://' . $test_file->filename, $node_file->uri, format_string('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri))); // Change the path to contain multiple subdirectories. $field = $this->updateFileField($field_name, $type_name, array('file_directory' => 'foo/bar/baz')); @@ -997,7 +997,7 @@ class FileFieldPathTestCase extends FileFieldTestCase { // Check that the file was uploaded into the subdirectory. $node = node_load($nid, NULL, TRUE); $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; - $this->assertPathMatch('public://foo/bar/baz/' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri))); + $this->assertPathMatch('public://foo/bar/baz/' . $test_file->filename, $node_file->uri, format_string('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri))); // Check the path when used with tokens. // Change the path to contain multiple token directories. @@ -1013,7 +1013,7 @@ class FileFieldPathTestCase extends FileFieldTestCase { // the user running the test case. $data = array('user' => $this->admin_user); $subdirectory = token_replace('[user:uid]/[user:name]', $data); - $this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path with token replacements.', array('%file' => $node_file->uri))); + $this->assertPathMatch('public://' . $subdirectory . '/' . $test_file->filename, $node_file->uri, format_string('The file %file was uploaded to the correct path with token replacements.', array('%file' => $node_file->uri))); } /** @@ -1094,11 +1094,11 @@ class FileTokenReplaceTestCase extends FileFieldTestCase { $tests['[file:owner:uid]'] = $file->uid; // Test to make sure that we generated something for each token. - $this->assertFalse(in_array(0, array_map('strlen', $tests)), t('No empty tokens generated.')); + $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { $output = token_replace($input, array('file' => $file), array('language' => $language)); - $this->assertEqual($output, $expected, t('Sanitized file token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, format_string('Sanitized file token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. @@ -1109,7 +1109,7 @@ class FileTokenReplaceTestCase extends FileFieldTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('file' => $file), array('language' => $language, 'sanitize' => FALSE)); - $this->assertEqual($output, $expected, t('Unsanitized file token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, format_string('Unsanitized file token %token replaced.', array('%token' => $input))); } } } @@ -1154,10 +1154,10 @@ class FilePrivateTestCase extends FileFieldTestCase { $node_file = (object) $node->{$field_name}[LANGUAGE_NONE][0]; // Ensure the file can be downloaded. $this->drupalGet(file_create_url($node_file->uri)); - $this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.')); + $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.'); $this->drupalLogOut(); $this->drupalGet(file_create_url($node_file->uri)); - $this->assertResponse(403, t('Confirmed that access is denied for the file without the needed permission.')); + $this->assertResponse(403, 'Confirmed that access is denied for the file without the needed permission.'); // Test with the field that should deny access through field access. $this->drupalLogin($this->admin_user); @@ -1166,6 +1166,6 @@ class FilePrivateTestCase extends FileFieldTestCase { $node_file = (object) $node->{$no_access_field_name}[LANGUAGE_NONE][0]; // Ensure the file cannot be downloaded. $this->drupalGet(file_create_url($node_file->uri)); - $this->assertResponse(403, t('Confirmed that access is denied for the file without view field access permission.')); + $this->assertResponse(403, 'Confirmed that access is denied for the file without view field access permission.'); } } diff --git a/modules/file/tests/file_module_test.info b/modules/file/tests/file_module_test.info index 624aab65..a13b627b 100755 --- a/modules/file/tests/file_module_test.info +++ b/modules/file/tests/file_module_test.info @@ -5,8 +5,8 @@ version = VERSION core = 7.x hidden = TRUE -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/filter/filter.api.php b/modules/filter/filter.api.php index 6675e4af..2901eb95 100755 --- a/modules/filter/filter.api.php +++ b/modules/filter/filter.api.php @@ -57,20 +57,20 @@ * - description: Additional administrative information about the filter's * behavior, if needed for clarification. * - settings callback: The name of a function that returns configuration form - * elements for the filter. See hook_filter_FILTER_settings() for details. + * elements for the filter. See callback_filter_settings() for details. * - default settings: An associative array containing default settings for * the filter, to be applied when the filter has not been configured yet. * - prepare callback: The name of a function that escapes the content before - * the actual filtering happens. See hook_filter_FILTER_prepare() for + * the actual filtering happens. See callback_filter_prepare() for * details. * - process callback: (required) The name the function that performs the - * actual filtering. See hook_filter_FILTER_process() for details. + * actual filtering. See callback_filter_process() for details. * - cache (default TRUE): Specifies whether the filtered text can be cached. * Note that setting this to FALSE makes the entire text format not * cacheable, which may have an impact on the site's overall performance. * See filter_format_allowcache() for details. * - tips callback: The name of a function that returns end-user-facing filter - * usage guidelines for the filter. See hook_filter_FILTER_tips() for + * usage guidelines for the filter. See callback_filter_tips() for * details. * - weight: A default weight for the filter in new text formats. * @@ -122,11 +122,9 @@ function hook_filter_info_alter(&$info) { */ /** - * Settings callback for hook_filter_info(). + * Provide a settings form for filter settings. * - * Note: This is not really a hook. The function name is manually specified via - * 'settings callback' in hook_filter_info(), with this recommended callback - * name pattern. It is called from filter_admin_format_form(). + * Callback for hook_filter_info(). * * This callback function is used to provide a settings form for filter * settings, for filters that need settings on a per-text-format basis. This @@ -158,8 +156,10 @@ function hook_filter_info_alter(&$info) { * @return * An array of form elements defining settings for the filter. Array keys * should match the array keys in $filter->settings and $defaults. + * + * @ingroup callbacks */ -function hook_filter_FILTER_settings($form, &$form_state, $filter, $format, $defaults, $filters) { +function callback_filter_settings($form, &$form_state, $filter, $format, $defaults, $filters) { $filter->settings += $defaults; $elements = array(); @@ -172,11 +172,9 @@ function hook_filter_FILTER_settings($form, &$form_state, $filter, $format, $def } /** - * Prepare callback for hook_filter_info(). + * Provide prepared text with special characters escaped. * - * Note: This is not really a hook. The function name is manually specified via - * 'prepare callback' in hook_filter_info(), with this recommended callback - * name pattern. It is called from check_markup(). + * Callback for hook_filter_info(). * * See hook_filter_info() for a description of the filtering process. Filters * should not use the 'prepare callback' step for anything other than escaping, @@ -199,19 +197,19 @@ function hook_filter_FILTER_settings($form, &$form_state, $filter, $format, $def * * @return * The prepared, escaped text. + * + * @ingroup callbacks */ -function hook_filter_FILTER_prepare($text, $filter, $format, $langcode, $cache, $cache_id) { +function callback_filter_prepare($text, $filter, $format, $langcode, $cache, $cache_id) { // Escape and
tags.
$text = preg_replace('|(.+?)
|se', "[codefilter_code]$1[/codefilter_code]", $text);
return $text;
}
/**
- * Process callback for hook_filter_info().
+ * Provide text filtered to conform to the supplied format.
*
- * Note: This is not really a hook. The function name is manually specified via
- * 'process callback' in hook_filter_info(), with this recommended callback
- * name pattern. It is called from check_markup().
+ * Callback for hook_filter_info().
*
* See hook_filter_info() for a description of the filtering process. This step
* is where the filter actually transforms the text.
@@ -232,19 +230,19 @@ function hook_filter_FILTER_prepare($text, $filter, $format, $langcode, $cache,
*
* @return
* The filtered text.
+ *
+ * @ingroup callbacks
*/
-function hook_filter_FILTER_process($text, $filter, $format, $langcode, $cache, $cache_id) {
+function callback_filter_process($text, $filter, $format, $langcode, $cache, $cache_id) {
$text = preg_replace('|\[codefilter_code\](.+?)\[/codefilter_code\]|se', "$1", $text); return $text; } /** - * Tips callback for hook_filter_info(). + * Return help text for a filter. * - * Note: This is not really a hook. The function name is manually specified via - * 'tips callback' in hook_filter_info(), with this recommended callback - * name pattern. It is called from _filter_tips(). + * Callback for hook_filter_info(). * * A filter's tips should be informative and to the point. Short tips are * preferably one-liners. @@ -260,8 +258,10 @@ function hook_filter_FILTER_process($text, $filter, $format, $langcode, $cache, * * @return * Translated text to display as a tip. + * + * @ingroup callbacks */ -function hook_filter_FILTER_tips($filter, $format, $long) { +function callback_filter_tips($filter, $format, $long) { if ($long) { return t('Lines and paragraphs are automatically recognized. The <br /> line break, <p> paragraph and </p> close paragraph tags are inserted automatically. If paragraphs are not recognized simply add a couple blank lines.'); } diff --git a/modules/filter/filter.info b/modules/filter/filter.info index 33235878..c9390820 100755 --- a/modules/filter/filter.info +++ b/modules/filter/filter.info @@ -7,8 +7,8 @@ files[] = filter.test required = TRUE configure = admin/config/content/formats -; Information added by drupal.org packaging script on 2013-04-03 -version = "7.22" +; Information added by drupal.org packaging script on 2013-08-08 +version = "7.23" project = "drupal" -datestamp = "1365027012" +datestamp = "1375928238" diff --git a/modules/filter/filter.module b/modules/filter/filter.module index 182033fe..2afe901e 100755 --- a/modules/filter/filter.module +++ b/modules/filter/filter.module @@ -1256,10 +1256,9 @@ function filter_filter_info() { } /** - * Filter settings callback for the HTML content filter. + * Implements callback_filter_settings(). * - * See hook_filter_FILTER_settings() for documentation of parameters and return - * value. + * Filter settings callback for the HTML content filter. */ function _filter_html_settings($form, &$form_state, $filter, $format, $defaults) { $filter->settings += $defaults; @@ -1285,6 +1284,8 @@ function _filter_html_settings($form, &$form_state, $filter, $format, $defaults) } /** + * Implements callback_filter_process(). + * * Provides filtering of input into accepted HTML. */ function _filter_html($text, $filter) { @@ -1304,7 +1305,9 @@ function _filter_html($text, $filter) { } /** - * Filter tips callback: Provides help for the HTML filter. + * Implements callback_filter_tips(). + * + * Provides help for the HTML filter. * * @see filter_filter_info() */ @@ -1404,7 +1407,9 @@ function _filter_html_tips($filter, $format, $long = FALSE) { } /** - * Filter URL settings callback: Provides settings for the URL filter. + * Implements callback_filter_settings(). + * + * Provides settings for the URL filter. * * @see filter_filter_info() */ @@ -1425,6 +1430,8 @@ function _filter_url_settings($form, &$form_state, $filter, $format, $defaults) } /** + * Implements callback_filter_process(). + * * Converts text into hyperlinks automatically. * * This filter identifies and makes clickable three types of "links". @@ -1454,7 +1461,7 @@ function _filter_url($text, $filter) { // we cannot cleanly differ between protocols here without hard-coding MAILTO, // so '//' is optional for all protocols. // @see filter_xss_bad_protocol() - $protocols = variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal', 'rtsp')); + $protocols = variable_get('filter_allowed_protocols', array('ftp', 'http', 'https', 'irc', 'mailto', 'news', 'nntp', 'rtsp', 'sftp', 'ssh', 'tel', 'telnet', 'webcal')); $protocols = implode(':(?://)?|', $protocols) . ':(?://)?'; // Prepare domain name pattern. @@ -1650,7 +1657,9 @@ function _filter_url_trim($text, $length = NULL) { } /** - * Filter tips callback: Provides help for the URL filter. + * Implements callback_filter_tips(). + * + * Provides help for the URL filter. * * @see filter_filter_info() */ @@ -1659,6 +1668,8 @@ function _filter_url_tips($filter, $format, $long = FALSE) { } /** + * Implements callback_filter_process(). + * * Scans the input and makes sure that HTML tags are properly closed. */ function _filter_htmlcorrector($text) { @@ -1666,6 +1677,8 @@ function _filter_htmlcorrector($text) { } /** + * Implements callback_filter_process(). + * * Converts line breaks into
and ' . $source . " ' . $source . " ', array('p'));
- $this->assertNoNormalized($f, 'onmouseover', t('HTML filter attributes removal -- events, no evasion.'));
+ $this->assertNoNormalized($f, 'onmouseover', 'HTML filter attributes removal -- events, no evasion.');
$f = filter_xss(' \" style=\"background-image: url(javascript:alert(0));\"\xe0 ", array('p'));
- $this->assertNoNormalized($f, 'style', t('HTML filter -- invalid UTF-8.'));
+ $this->assertNoNormalized($f, 'style', 'HTML filter -- invalid UTF-8.');
$f = filter_xss("\xc0aaa");
- $this->assertEqual($f, '', t('HTML filter -- overlong UTF-8 sequences.'));
+ $this->assertEqual($f, '', 'HTML filter -- overlong UTF-8 sequences.');
$f = filter_xss("Who's Online");
- $this->assertNormalized($f, "who's online", t('HTML filter -- html entity number'));
+ $this->assertNormalized($f, "who's online", 'HTML filter -- html entity number');
$f = filter_xss("Who's Online");
- $this->assertNormalized($f, "who's online", t('HTML filter -- encoded html entity number'));
+ $this->assertNormalized($f, "who's online", 'HTML filter -- encoded html entity number');
$f = filter_xss("Who&#039; Online");
- $this->assertNormalized($f, "who' online", t('HTML filter -- double encoded html entity number'));
+ $this->assertNormalized($f, "who' online", 'HTML filter -- double encoded html entity number');
}
/**
@@ -1147,34 +1147,34 @@ class FilterUnitTestCase extends DrupalUnitTestCase {
// HTML filter is not able to secure some tags, these should never be
// allowed.
$f = _filter_html('', $filter);
- $this->assertNoNormalized($f, 'script', t('HTML filter should always remove script tags.'));
+ $this->assertNoNormalized($f, 'script', 'HTML filter should always remove script tags.');
$f = _filter_html('', $filter);
- $this->assertNoNormalized($f, 'iframe', t('HTML filter should always remove iframe tags.'));
+ $this->assertNoNormalized($f, 'iframe', 'HTML filter should always remove iframe tags.');
$f = _filter_html('', $filter);
- $this->assertNoNormalized($f, 'object', t('HTML filter should always remove object tags.'));
+ $this->assertNoNormalized($f, 'object', 'HTML filter should always remove object tags.');
$f = _filter_html('', $filter);
- $this->assertNoNormalized($f, 'style', t('HTML filter should always remove style tags.'));
+ $this->assertNoNormalized($f, 'style', 'HTML filter should always remove style tags.');
// Some tags make CSRF attacks easier, let the user take the risk herself.
$f = _filter_html(' text');
- $this->assertEqual($f, ' text text text text');
- $this->assertEqual($f, ' text text text text test test test test test test line1 line1 line1 line1 line1 line1 test test test test test test Line1 Line1 Line1 test\n test\n test\n دروبال');
- $this->assertEqual($f, ' دروبال دروبال ' . t('Help is available on the following items:') . ' ' . t('Help is available on the following items:') . '
in an intelligent fashion.
*
* Based on: http://photomatt.net/scripts/autop
@@ -1733,7 +1746,9 @@ function _filter_autop($text) {
}
/**
- * Filter tips callback: Provides help for the auto-paragraph filter.
+ * Implements callback_filter_tips().
+ *
+ * Provides help for the auto-paragraph filter.
*
* @see filter_filter_info()
*/
@@ -1747,6 +1762,8 @@ function _filter_autop_tips($filter, $format, $long = FALSE) {
}
/**
+ * Implements callback_filter_process().
+ *
* Escapes all HTML tags, so they will be visible instead of being effective.
*/
function _filter_html_escape($text) {
@@ -1754,7 +1771,9 @@ function _filter_html_escape($text) {
}
/**
- * Filter tips callback: Provides help for the HTML escaping filter.
+ * Implements callback_filter_tips().
+ *
+ * Provides help for the HTML escaping filter.
*
* @see filter_filter_info()
*/
diff --git a/modules/filter/filter.test b/modules/filter/filter.test
index 0c394951..cc0295b5 100755
--- a/modules/filter/filter.test
+++ b/modules/filter/filter.test
@@ -67,9 +67,9 @@ class FilterCRUDTestCase extends DrupalWebTestCase {
filter_format_disable($format);
$db_format = db_query("SELECT * FROM {filter_format} WHERE format = :format", array(':format' => $format->format))->fetchObject();
- $this->assertFalse($db_format->status, t('Database: Disabled text format is marked as disabled.'));
+ $this->assertFalse($db_format->status, 'Database: Disabled text format is marked as disabled.');
$formats = filter_formats();
- $this->assertTrue(!isset($formats[$format->format]), t('filter_formats: Disabled text format no longer exists.'));
+ $this->assertTrue(!isset($formats[$format->format]), 'filter_formats: Disabled text format no longer exists.');
}
/**
@@ -83,17 +83,17 @@ class FilterCRUDTestCase extends DrupalWebTestCase {
->condition('format', $format->format)
->execute()
->fetchObject();
- $this->assertEqual($db_format->format, $format->format, t('Database: Proper format id for text format %format.', $t_args));
- $this->assertEqual($db_format->name, $format->name, t('Database: Proper title for text format %format.', $t_args));
- $this->assertEqual($db_format->cache, $format->cache, t('Database: Proper cache indicator for text format %format.', $t_args));
- $this->assertEqual($db_format->weight, $format->weight, t('Database: Proper weight for text format %format.', $t_args));
+ $this->assertEqual($db_format->format, $format->format, format_string('Database: Proper format id for text format %format.', $t_args));
+ $this->assertEqual($db_format->name, $format->name, format_string('Database: Proper title for text format %format.', $t_args));
+ $this->assertEqual($db_format->cache, $format->cache, format_string('Database: Proper cache indicator for text format %format.', $t_args));
+ $this->assertEqual($db_format->weight, $format->weight, format_string('Database: Proper weight for text format %format.', $t_args));
// Verify filter_format_load().
$filter_format = filter_format_load($format->format);
- $this->assertEqual($filter_format->format, $format->format, t('filter_format_load: Proper format id for text format %format.', $t_args));
- $this->assertEqual($filter_format->name, $format->name, t('filter_format_load: Proper title for text format %format.', $t_args));
- $this->assertEqual($filter_format->cache, $format->cache, t('filter_format_load: Proper cache indicator for text format %format.', $t_args));
- $this->assertEqual($filter_format->weight, $format->weight, t('filter_format_load: Proper weight for text format %format.', $t_args));
+ $this->assertEqual($filter_format->format, $format->format, format_string('filter_format_load: Proper format id for text format %format.', $t_args));
+ $this->assertEqual($filter_format->name, $format->name, format_string('filter_format_load: Proper title for text format %format.', $t_args));
+ $this->assertEqual($filter_format->cache, $format->cache, format_string('filter_format_load: Proper cache indicator for text format %format.', $t_args));
+ $this->assertEqual($filter_format->weight, $format->weight, format_string('filter_format_load: Proper weight for text format %format.', $t_args));
// Verify the 'cache' text format property according to enabled filters.
$filter_info = filter_get_filters();
@@ -107,7 +107,7 @@ class FilterCRUDTestCase extends DrupalWebTestCase {
break;
}
}
- $this->assertEqual($filter_format->cache, $cacheable, t('Text format contains proper cache property.'));
+ $this->assertEqual($filter_format->cache, $cacheable, 'Text format contains proper cache property.');
}
/**
@@ -121,20 +121,20 @@ class FilterCRUDTestCase extends DrupalWebTestCase {
$t_args = array('%format' => $format->name, '%filter' => $name);
// Verify that filter status is properly stored.
- $this->assertEqual($filter->status, $format_filters[$name]['status'], t('Database: Proper status for %filter in text format %format.', $t_args));
+ $this->assertEqual($filter->status, $format_filters[$name]['status'], format_string('Database: Proper status for %filter in text format %format.', $t_args));
// Verify that filter settings were properly stored.
- $this->assertEqual(unserialize($filter->settings), isset($format_filters[$name]['settings']) ? $format_filters[$name]['settings'] : array(), t('Database: Proper filter settings for %filter in text format %format.', $t_args));
+ $this->assertEqual(unserialize($filter->settings), isset($format_filters[$name]['settings']) ? $format_filters[$name]['settings'] : array(), format_string('Database: Proper filter settings for %filter in text format %format.', $t_args));
// Verify that each filter has a module name assigned.
- $this->assertTrue(!empty($filter->module), t('Database: Proper module name for %filter in text format %format.', $t_args));
+ $this->assertTrue(!empty($filter->module), format_string('Database: Proper module name for %filter in text format %format.', $t_args));
// Remove the filter from the copy of saved $format to check whether all
// filters have been processed later.
unset($format_filters[$name]);
}
// Verify that all filters have been processed.
- $this->assertTrue(empty($format_filters), t('Database contains values for all filters in the saved format.'));
+ $this->assertTrue(empty($format_filters), 'Database contains values for all filters in the saved format.');
// Verify filter_list_format().
$filters = filter_list_format($format->format);
@@ -143,20 +143,20 @@ class FilterCRUDTestCase extends DrupalWebTestCase {
$t_args = array('%format' => $format->name, '%filter' => $name);
// Verify that filter status is properly stored.
- $this->assertEqual($filter->status, $format_filters[$name]['status'], t('filter_list_format: Proper status for %filter in text format %format.', $t_args));
+ $this->assertEqual($filter->status, $format_filters[$name]['status'], format_string('filter_list_format: Proper status for %filter in text format %format.', $t_args));
// Verify that filter settings were properly stored.
- $this->assertEqual($filter->settings, isset($format_filters[$name]['settings']) ? $format_filters[$name]['settings'] : array(), t('filter_list_format: Proper filter settings for %filter in text format %format.', $t_args));
+ $this->assertEqual($filter->settings, isset($format_filters[$name]['settings']) ? $format_filters[$name]['settings'] : array(), format_string('filter_list_format: Proper filter settings for %filter in text format %format.', $t_args));
// Verify that each filter has a module name assigned.
- $this->assertTrue(!empty($filter->module), t('filter_list_format: Proper module name for %filter in text format %format.', $t_args));
+ $this->assertTrue(!empty($filter->module), format_string('filter_list_format: Proper module name for %filter in text format %format.', $t_args));
// Remove the filter from the copy of saved $format to check whether all
// filters have been processed later.
unset($format_filters[$name]);
}
// Verify that all filters have been processed.
- $this->assertTrue(empty($format_filters), t('filter_list_format: Loaded filters contain values for all filters in the saved format.'));
+ $this->assertTrue(empty($format_filters), 'filter_list_format: Loaded filters contain values for all filters in the saved format.');
}
}
@@ -205,14 +205,14 @@ class FilterAdminTestCase extends DrupalWebTestCase {
// Verify default weight of the text format.
$this->drupalGet('admin/config/content/formats');
- $this->assertFieldByName("formats[$format_id][weight]", 0, t('Text format weight was saved.'));
+ $this->assertFieldByName("formats[$format_id][weight]", 0, 'Text format weight was saved.');
// Change the weight of the text format.
$edit = array(
"formats[$format_id][weight]" => 5,
);
$this->drupalPost('admin/config/content/formats', $edit, t('Save changes'));
- $this->assertFieldByName("formats[$format_id][weight]", 5, t('Text format weight was saved.'));
+ $this->assertFieldByName("formats[$format_id][weight]", 5, 'Text format weight was saved.');
// Edit text format.
$this->drupalGet('admin/config/content/formats');
@@ -222,7 +222,7 @@ class FilterAdminTestCase extends DrupalWebTestCase {
// Verify that the custom weight of the text format has been retained.
$this->drupalGet('admin/config/content/formats');
- $this->assertFieldByName("formats[$format_id][weight]", 5, t('Text format weight was retained.'));
+ $this->assertFieldByName("formats[$format_id][weight]", 5, 'Text format weight was retained.');
// Disable text format.
$this->assertLinkByHref('admin/config/content/formats/' . $format_id . '/disable');
@@ -231,7 +231,7 @@ class FilterAdminTestCase extends DrupalWebTestCase {
// Verify that disabled text format no longer exists.
$this->drupalGet('admin/config/content/formats/' . $format_id);
- $this->assertResponse(404, t('Disabled text format no longer exists.'));
+ $this->assertResponse(404, 'Disabled text format no longer exists.');
// Attempt to create a format of the same machine name as the disabled
// format but with a different human readable name.
@@ -268,44 +268,44 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$plain = 'plain_text';
// Check that the fallback format exists and cannot be disabled.
- $this->assertTrue($plain == filter_fallback_format(), t('The fallback format is set to plain text.'));
+ $this->assertTrue($plain == filter_fallback_format(), 'The fallback format is set to plain text.');
$this->drupalGet('admin/config/content/formats');
- $this->assertNoRaw('admin/config/content/formats/' . $plain . '/disable', t('Disable link for the fallback format not found.'));
+ $this->assertNoRaw('admin/config/content/formats/' . $plain . '/disable', 'Disable link for the fallback format not found.');
$this->drupalGet('admin/config/content/formats/' . $plain . '/disable');
- $this->assertResponse(403, t('The fallback format cannot be disabled.'));
+ $this->assertResponse(403, 'The fallback format cannot be disabled.');
// Verify access permissions to Full HTML format.
- $this->assertTrue(filter_access(filter_format_load($full), $this->admin_user), t('Admin user may use Full HTML.'));
- $this->assertFalse(filter_access(filter_format_load($full), $this->web_user), t('Web user may not use Full HTML.'));
+ $this->assertTrue(filter_access(filter_format_load($full), $this->admin_user), 'Admin user may use Full HTML.');
+ $this->assertFalse(filter_access(filter_format_load($full), $this->web_user), 'Web user may not use Full HTML.');
// Add an additional tag.
$edit = array();
$edit['filters[filter_html][settings][allowed_html]'] = '
';
$this->drupalPost('admin/config/content/formats/' . $filtered, $edit, t('Save configuration'));
- $this->assertFieldByName('filters[filter_html][settings][allowed_html]', $edit['filters[filter_html][settings][allowed_html]'], t('Allowed HTML tag added.'));
+ $this->assertFieldByName('filters[filter_html][settings][allowed_html]', $edit['filters[filter_html][settings][allowed_html]'], 'Allowed HTML tag added.');
$result = db_query('SELECT * FROM {cache_filter}')->fetchObject();
- $this->assertFalse($result, t('Cache cleared.'));
+ $this->assertFalse($result, 'Cache cleared.');
$elements = $this->xpath('//select[@name=:first]/following::select[@name=:second]', array(
':first' => 'filters[' . $first_filter . '][weight]',
':second' => 'filters[' . $second_filter . '][weight]',
));
- $this->assertTrue(!empty($elements), t('Order confirmed in admin interface.'));
+ $this->assertTrue(!empty($elements), 'Order confirmed in admin interface.');
// Reorder filters.
$edit = array();
$edit['filters[' . $second_filter . '][weight]'] = 1;
$edit['filters[' . $first_filter . '][weight]'] = 2;
$this->drupalPost(NULL, $edit, t('Save configuration'));
- $this->assertFieldByName('filters[' . $second_filter . '][weight]', 1, t('Order saved successfully.'));
- $this->assertFieldByName('filters[' . $first_filter . '][weight]', 2, t('Order saved successfully.'));
+ $this->assertFieldByName('filters[' . $second_filter . '][weight]', 1, 'Order saved successfully.');
+ $this->assertFieldByName('filters[' . $first_filter . '][weight]', 2, 'Order saved successfully.');
$elements = $this->xpath('//select[@name=:first]/following::select[@name=:second]', array(
':first' => 'filters[' . $second_filter . '][weight]',
':second' => 'filters[' . $first_filter . '][weight]',
));
- $this->assertTrue(!empty($elements), t('Reorder confirmed in admin interface.'));
+ $this->assertTrue(!empty($elements), 'Reorder confirmed in admin interface.');
$result = db_query('SELECT * FROM {filter} WHERE format = :format ORDER BY weight ASC', array(':format' => $filtered));
$filters = array();
@@ -314,7 +314,7 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$filters[] = $filter;
}
}
- $this->assertTrue(($filters[0]->name == $second_filter && $filters[1]->name == $first_filter), t('Order confirmed in database.'));
+ $this->assertTrue(($filters[0]->name == $second_filter && $filters[1]->name == $first_filter), 'Order confirmed in database.');
// Add format.
$edit = array();
@@ -324,19 +324,19 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$edit['filters[' . $second_filter . '][status]'] = TRUE;
$edit['filters[' . $first_filter . '][status]'] = TRUE;
$this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration'));
- $this->assertRaw(t('Added text format %format.', array('%format' => $edit['name'])), t('New filter created.'));
+ $this->assertRaw(t('Added text format %format.', array('%format' => $edit['name'])), 'New filter created.');
drupal_static_reset('filter_formats');
$format = filter_format_load($edit['format']);
- $this->assertNotNull($format, t('Format found in database.'));
+ $this->assertNotNull($format, 'Format found in database.');
- $this->assertFieldByName('roles[' . DRUPAL_AUTHENTICATED_RID . ']', '', t('Role found.'));
- $this->assertFieldByName('filters[' . $second_filter . '][status]', '', t('Line break filter found.'));
- $this->assertFieldByName('filters[' . $first_filter . '][status]', '', t('Url filter found.'));
+ $this->assertFieldByName('roles[' . DRUPAL_AUTHENTICATED_RID . ']', '', 'Role found.');
+ $this->assertFieldByName('filters[' . $second_filter . '][status]', '', 'Line break filter found.');
+ $this->assertFieldByName('filters[' . $first_filter . '][status]', '', 'Url filter found.');
// Disable new filter.
$this->drupalPost('admin/config/content/formats/' . $format->format . '/disable', array(), t('Disable'));
- $this->assertRaw(t('Disabled text format %format.', array('%format' => $edit['name'])), t('Format successfully disabled.'));
+ $this->assertRaw(t('Disabled text format %format.', array('%format' => $edit['name'])), 'Format successfully disabled.');
// Allow authenticated users on full HTML.
$format = filter_format_load($full);
@@ -344,14 +344,14 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$edit['roles[' . DRUPAL_ANONYMOUS_RID . ']'] = 0;
$edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = 1;
$this->drupalPost('admin/config/content/formats/' . $full, $edit, t('Save configuration'));
- $this->assertRaw(t('The text format %format has been updated.', array('%format' => $format->name)), t('Full HTML format successfully updated.'));
+ $this->assertRaw(t('The text format %format has been updated.', array('%format' => $format->name)), 'Full HTML format successfully updated.');
// Switch user.
$this->drupalLogout();
$this->drupalLogin($this->web_user);
$this->drupalGet('node/add/page');
- $this->assertRaw('', t('Full HTML filter accessible.'));
+ $this->assertRaw('', 'Full HTML filter accessible.');
// Use filtered HTML and see if it removes tags that are not allowed.
$body = '' . $this->randomName() . '';
@@ -364,20 +364,20 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$edit["body[$langcode][0][value]"] = $text;
$edit["body[$langcode][0][format]"] = $filtered;
$this->drupalPost('node/add/page', $edit, t('Save'));
- $this->assertRaw(t('Basic page %title has been created.', array('%title' => $edit["title"])), t('Filtered node created.'));
+ $this->assertRaw(t('Basic page %title has been created.', array('%title' => $edit["title"])), 'Filtered node created.');
$node = $this->drupalGetNodeByTitle($edit["title"]);
- $this->assertTrue($node, t('Node found in database.'));
+ $this->assertTrue($node, 'Node found in database.');
$this->drupalGet('node/' . $node->nid);
- $this->assertRaw($body . $extra_text, t('Filter removed invalid tag.'));
+ $this->assertRaw($body . $extra_text, 'Filter removed invalid tag.');
// Use plain text and see if it escapes all tags, whether allowed or not.
$edit = array();
$edit["body[$langcode][0][format]"] = $plain;
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
$this->drupalGet('node/' . $node->nid);
- $this->assertText(check_plain($text), t('The "Plain text" text format escapes all HTML tags.'));
+ $this->assertText(check_plain($text), 'The "Plain text" text format escapes all HTML tags.');
// Switch user.
$this->drupalLogout();
@@ -388,22 +388,22 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$edit = array();
$edit['filters[filter_html][settings][allowed_html]'] = '
\n" . $result);
}
@@ -953,172 +953,172 @@ class FilterUnitTestCase extends DrupalUnitTestCase {
function testFilterXSS() {
// Tag stripping, different ways to work around removal of HTML tags.
$f = filter_xss('');
- $this->assertNoNormalized($f, 'script', t('HTML tag stripping -- simple script without special characters.'));
+ $this->assertNoNormalized($f, 'script', 'HTML tag stripping -- simple script without special characters.');
$f = filter_xss('');
- $this->assertNoNormalized($f, 'script', t('HTML tag stripping -- empty script with source.'));
+ $this->assertNoNormalized($f, 'script', 'HTML tag stripping -- empty script with source.');
$f = filter_xss('');
- $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- non whitespace character after tag name.'));
+ $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- non whitespace character after tag name.');
$f = filter_xss('');
- $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- no space between tag and attribute.'));
+ $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- no space between tag and attribute.');
// Null between < and tag name works at least with IE6.
$f = filter_xss("<\0scr\0ipt>alert(0)");
- $this->assertNoNormalized($f, 'ipt', t('HTML tag stripping evasion -- breaking HTML with nulls.'));
+ $this->assertNoNormalized($f, 'ipt', 'HTML tag stripping evasion -- breaking HTML with nulls.');
$f = filter_xss("', array('img'));
- $this->assertNoNormalized($f, 'onerror', t('HTML filter attributes removal evasion -- spaces before equals sign.'));
+ $this->assertNoNormalized($f, 'onerror', 'HTML filter attributes removal evasion -- spaces before equals sign.');
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'onabort', t('HTML filter attributes removal evasion -- non alphanumeric characters before equals sign.'));
+ $this->assertNoNormalized($f, 'onabort', 'HTML filter attributes removal evasion -- non alphanumeric characters before equals sign.');
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'onmediaerror', t('HTML filter attributes removal evasion -- varying case.'));
+ $this->assertNoNormalized($f, 'onmediaerror', 'HTML filter attributes removal evasion -- varying case.');
// Works at least with IE6.
$f = filter_xss("
", array('img'));
- $this->assertNoNormalized($f, 'focus', t('HTML filter attributes removal evasion -- breaking with nulls.'));
+ $this->assertNoNormalized($f, 'focus', 'HTML filter attributes removal evasion -- breaking with nulls.');
// Only whitelisted scheme names allowed in attributes.
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing -- no evasion.'));
+ $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing -- no evasion.');
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- no quotes.'));
+ $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- no quotes.');
// A bit like CVE-2006-0070.
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- no alert ;)'));
+ $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- no alert ;)');
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- grave accents.'));
+ $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- grave accents.');
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing -- rare attribute.'));
+ $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing -- rare attribute.');
$f = filter_xss('
', array('table'));
- $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing -- another tag.'));
+ $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing -- another tag.');
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- varying case.'));
+ $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- varying case.');
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- UTF-8 decimal encoding.'));
+ $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- UTF-8 decimal encoding.');
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- long UTF-8 encoding.'));
+ $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- long UTF-8 encoding.');
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- UTF-8 hex encoding.'));
+ $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- UTF-8 hex encoding.');
$f = filter_xss("
", array('img'));
- $this->assertNoNormalized($f, 'script', t('HTML scheme clearing evasion -- an embedded tab.'));
+ $this->assertNoNormalized($f, 'script', 'HTML scheme clearing evasion -- an embedded tab.');
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'script', t('HTML scheme clearing evasion -- an encoded, embedded tab.'));
+ $this->assertNoNormalized($f, 'script', 'HTML scheme clearing evasion -- an encoded, embedded tab.');
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'script', t('HTML scheme clearing evasion -- an encoded, embedded newline.'));
+ $this->assertNoNormalized($f, 'script', 'HTML scheme clearing evasion -- an encoded, embedded newline.');
// With
this test would fail, but the entity gets turned into
// 
, so it's OK.
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'script', t('HTML scheme clearing evasion -- an encoded, embedded carriage return.'));
+ $this->assertNoNormalized($f, 'script', 'HTML scheme clearing evasion -- an encoded, embedded carriage return.');
$f = filter_xss("
", array('img'));
- $this->assertNoNormalized($f, 'cript', t('HTML scheme clearing evasion -- broken into many lines.'));
+ $this->assertNoNormalized($f, 'cript', 'HTML scheme clearing evasion -- broken into many lines.');
$f = filter_xss("
", array('img'));
- $this->assertNoNormalized($f, 'cript', t('HTML scheme clearing evasion -- embedded nulls.'));
+ $this->assertNoNormalized($f, 'cript', 'HTML scheme clearing evasion -- embedded nulls.');
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- spaces and metacharacters before scheme.'));
+ $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- spaces and metacharacters before scheme.');
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'vbscript', t('HTML scheme clearing evasion -- another scheme.'));
+ $this->assertNoNormalized($f, 'vbscript', 'HTML scheme clearing evasion -- another scheme.');
$f = filter_xss('
', array('img'));
- $this->assertNoNormalized($f, 'nosuchscheme', t('HTML scheme clearing evasion -- unknown scheme.'));
+ $this->assertNoNormalized($f, 'nosuchscheme', 'HTML scheme clearing evasion -- unknown scheme.');
// Netscape 4.x javascript entities.
$f = filter_xss('
', array('br'));
- $this->assertNoNormalized($f, 'alert', t('Netscape 4.x javascript entities.'));
+ $this->assertNoNormalized($f, 'alert', 'Netscape 4.x javascript entities.');
// DRUPAL-SA-2008-006: Invalid UTF-8, these only work as reflected XSS with
// Internet Explorer 6.
$f = filter_xss("', $filter);
- $this->assertNoNormalized($f, 'img', t('HTML filter should remove img tags on default.'));
+ $this->assertNoNormalized($f, 'img', 'HTML filter should remove img tags on default.');
$f = _filter_html('', $filter);
- $this->assertNoNormalized($f, 'img', t('HTML filter should remove input tags on default.'));
+ $this->assertNoNormalized($f, 'img', 'HTML filter should remove input tags on default.');
// Filtering content of some attributes is infeasible, these shouldn't be
// allowed too.
$f = _filter_html('
', $filter);
- $this->assertNoNormalized($f, 'onerror', t('HTML filter should remove empty on* attributes on default.'));
+ $this->assertNoNormalized($f, 'onerror', 'HTML filter should remove empty on* attributes on default.');
}
/**
@@ -1192,20 +1192,20 @@ class FilterUnitTestCase extends DrupalUnitTestCase {
// Test if the rel="nofollow" attribute is added, even if we try to prevent
// it.
$f = _filter_html('text', $filter);
- $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent -- no evasion.'));
+ $this->assertNormalized($f, 'rel="nofollow"', 'Spam deterrent -- no evasion.');
$f = _filter_html('text', $filter);
- $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- capital A.'));
+ $this->assertNormalized($f, 'rel="nofollow"', 'Spam deterrent evasion -- capital A.');
$f = _filter_html("text", $filter);
- $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- non whitespace character after tag name.'));
+ $this->assertNormalized($f, 'rel="nofollow"', 'Spam deterrent evasion -- non whitespace character after tag name.');
$f = _filter_html("<\0a\0 href=\"http://www.example.com/\">text", $filter);
- $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- some nulls.'));
+ $this->assertNormalized($f, 'rel="nofollow"', 'Spam deterrent evasion -- some nulls.');
$f = _filter_html('text', $filter);
- $this->assertNoNormalized($f, 'rel="follow"', t('Spam deterrent evasion -- with rel set - rel="follow" removed.'));
- $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- with rel set - rel="nofollow" added.'));
+ $this->assertNoNormalized($f, 'rel="follow"', 'Spam deterrent evasion -- with rel set - rel="follow" removed.');
+ $this->assertNormalized($f, 'rel="nofollow"', 'Spam deterrent evasion -- with rel set - rel="nofollow" added.');
}
/**
@@ -1214,13 +1214,13 @@ class FilterUnitTestCase extends DrupalUnitTestCase {
function testFilterXSSAdmin() {
// DRUPAL-SA-2008-044
$f = filter_xss_admin('');
- $this->assertNoNormalized($f, 'object', t('Admin HTML filter -- should not allow object tag.'));
+ $this->assertNoNormalized($f, 'object', 'Admin HTML filter -- should not allow object tag.');
$f = filter_xss_admin('');
- $this->assertNoNormalized($f, 'script', t('Admin HTML filter -- should not allow script tag.'));
+ $this->assertNoNormalized($f, 'script', 'Admin HTML filter -- should not allow script tag.');
$f = filter_xss_admin('
", t('HTML corrector -- unclosed list tags.'));
+ $this->assertEqual($f, "
", 'HTML corrector -- unclosed list tags.');
$f = _filter_htmlcorrector('
');
- $this->assertEqual($f, '
', t('HTML corrector -- XHTML closing slash.'));
+ $this->assertEqual($f, '
', 'HTML corrector -- XHTML closing slash.');
$f = _filter_htmlcorrector('
');
- $this->assertEqual($f, 'test
', t('HTML corrector -- Let proper XHTML pass through.'));
+ $this->assertEqual($f, 'test
', 'HTML corrector -- Let proper XHTML pass through.');
$f = _filter_htmlcorrector('test
');
- $this->assertEqual($f, 'test
', t('HTML corrector -- Let proper XHTML pass through, but ensure there is a single space before the closing slash.'));
+ $this->assertEqual($f, 'test
', 'HTML corrector -- Let proper XHTML pass through, but ensure there is a single space before the closing slash.');
$f = _filter_htmlcorrector('test
');
- $this->assertEqual($f, 'test
', t('HTML corrector -- Let proper XHTML pass through, but ensure there are not too many spaces before the closing slash.'));
+ $this->assertEqual($f, 'test
', 'HTML corrector -- Let proper XHTML pass through, but ensure there are not too many spaces before the closing slash.');
$f = _filter_htmlcorrector('');
- $this->assertEqual($f, '', t('HTML corrector -- Convert XHTML that is properly formed but that would not be compatible with typical HTML user agents.'));
+ $this->assertEqual($f, '', 'HTML corrector -- Convert XHTML that is properly formed but that would not be compatible with typical HTML user agents.');
$f = _filter_htmlcorrector('test1
test2');
- $this->assertEqual($f, 'test1
test2', t('HTML corrector -- Automatically close single tags.'));
+ $this->assertEqual($f, 'test1
test2', 'HTML corrector -- Automatically close single tags.');
$f = _filter_htmlcorrector('line1
line2');
- $this->assertEqual($f, 'line1
line2', t('HTML corrector -- Automatically close single tags.'));
+ $this->assertEqual($f, 'line1
line2', 'HTML corrector -- Automatically close single tags.');
$f = _filter_htmlcorrector('line1
line2');
- $this->assertEqual($f, 'line1
line2', t('HTML corrector -- Automatically close single tags.'));
+ $this->assertEqual($f, 'line1
line2', 'HTML corrector -- Automatically close single tags.');
$f = _filter_htmlcorrector('test');
- $this->assertEqual($f, '
test', t('HTML corrector -- Automatically close single tags.'));
+ $this->assertEqual($f, '
test', 'HTML corrector -- Automatically close single tags.');
$f = _filter_htmlcorrector('
');
- $this->assertEqual($f, '
', t("HTML corrector -- Transform empty tags to a single closed tag if the tag's content model is EMPTY."));
+ $this->assertEqual($f, '
', "HTML corrector -- Transform empty tags to a single closed tag if the tag's content model is EMPTY.");
$f = _filter_htmlcorrector('');
- $this->assertEqual($f, '', t("HTML corrector -- Do not transform empty tags to a single closed tag if the tag's content model is not EMPTY."));
+ $this->assertEqual($f, '', "HTML corrector -- Do not transform empty tags to a single closed tag if the tag's content model is not EMPTY.");
$f = _filter_htmlcorrector('
line2');
- $this->assertEqual($f, '
line2', t('HTML corrector -- Move non-inline elements outside of inline containers.'));
+ $this->assertEqual($f, '
line2', 'HTML corrector -- Move non-inline elements outside of inline containers.');
$f = _filter_htmlcorrector('
bold stuff');
- $this->assertEqual($f, '
bold stuff
bold stuff' . t('Help topics') . '
' . t('Help topics') . '
' . t($name) . '
', t('[' . $module . '] Heading was displayed'));
+ $this->assertTitle($name . ' | Drupal', format_string('%module title was displayed', array('%module' => $module)));
+ $this->assertRaw('' . t($name) . '
', format_string('%module heading was displayed', array('%module' => $module)));
}
}
}
@@ -132,6 +132,6 @@ class NoHelpTestCase extends DrupalWebTestCase {
$this->drupalLogin($this->big_user);
$this->drupalGet('admin/help');
- $this->assertNoText('Hook menu tests', t('Making sure the test module menu_test does not display a help link in admin/help'));
+ $this->assertNoText('Hook menu tests', 'Making sure the test module menu_test does not display a help link in admin/help');
}
}
diff --git a/modules/image/image.admin.inc b/modules/image/image.admin.inc
index 9f0fab25..7e626219 100755
--- a/modules/image/image.admin.inc
+++ b/modules/image/image.admin.inc
@@ -32,10 +32,9 @@ function image_style_list() {
* An image style array.
* @ingroup forms
* @see image_style_form_submit()
- * @see image_style_name_validate()
*/
function image_style_form($form, &$form_state, $style) {
- $title = t('Edit %name style', array('%name' => $style['name']));
+ $title = t('Edit %name style', array('%name' => $style['label']));
drupal_set_title($title, PASS_THROUGH);
// Adjust this form for styles that must be overridden to edit.
@@ -56,27 +55,31 @@ function image_style_form($form, &$form_state, $style) {
'#markup' => theme('image_style_preview', array('style' => $style)),
);
+ // Show the Image Style label.
+ $form['label'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Image style name'),
+ '#default_value' => $style['label'],
+ '#disabled' => !$editable,
+ '#required' => TRUE,
+ );
+
// Allow the name of the style to be changed, unless this style is
// provided by a module's hook_default_image_styles().
- if ($style['storage'] & IMAGE_STORAGE_MODULE) {
- $form['name'] = array(
- '#type' => 'item',
- '#title' => t('Image style name'),
- '#markup' => $style['name'],
- '#description' => t('This image style is being provided by %module module and may not be renamed.', array('%module' => $style['module'])),
- );
- }
- else {
- $form['name'] = array(
- '#type' => 'textfield',
- '#size' => '64',
- '#title' => t('Image style name'),
- '#default_value' => $style['name'],
- '#description' => t('The name is used in URLs for generated images. Use only lowercase alphanumeric characters, underscores (_), and hyphens (-).'),
- '#element_validate' => array('image_style_name_validate'),
- '#required' => TRUE,
- );
- }
+ $form['name'] = array(
+ '#type' => 'machine_name',
+ '#size' => '64',
+ '#default_value' => $style['name'],
+ '#disabled' => !$editable,
+ '#description' => t('The name is used in URLs for generated images. Use only lowercase alphanumeric characters, underscores (_), and hyphens (-).'),
+ '#required' => TRUE,
+ '#machine_name' => array(
+ 'exists' => 'image_style_load',
+ 'source' => array('label'),
+ 'replace_pattern' => '[^0-9a-z_\-]',
+ 'error' => t('Please only use lowercase alphanumeric characters, underscores (_), and hyphens (-) for style names.'),
+ ),
+ );
// Build the list of existing image effects for this image style.
$form['effects'] = array(
@@ -199,7 +202,7 @@ function image_style_form_add_submit($form, &$form_state) {
* Submit handler for overriding a module-defined style.
*/
function image_style_form_override_submit($form, &$form_state) {
- drupal_set_message(t('The %style style has been overridden, allowing you to change its settings.', array('%style' => $form_state['image_style']['name'])));
+ drupal_set_message(t('The %style style has been overridden, allowing you to change its settings.', array('%style' => $form_state['image_style']['label'])));
image_default_style_save($form_state['image_style']);
}
@@ -207,11 +210,10 @@ function image_style_form_override_submit($form, &$form_state) {
* Submit handler for saving an image style.
*/
function image_style_form_submit($form, &$form_state) {
- // Update the image style name if it has changed.
+ // Update the image style.
$style = $form_state['image_style'];
- if (isset($form_state['values']['name']) && $style['name'] != $form_state['values']['name']) {
- $style['name'] = $form_state['values']['name'];
- }
+ $style['name'] = $form_state['values']['name'];
+ $style['label'] = $form_state['values']['label'];
// Update image effect weights.
if (!empty($form_state['values']['effects'])) {
@@ -236,18 +238,26 @@ function image_style_form_submit($form, &$form_state) {
*
* @ingroup forms
* @see image_style_add_form_submit()
- * @see image_style_name_validate()
*/
function image_style_add_form($form, &$form_state) {
- $form['name'] = array(
+ $form['label'] = array(
'#type' => 'textfield',
- '#size' => '64',
'#title' => t('Style name'),
'#default_value' => '',
- '#description' => t('The name is used in URLs for generated images. Use only lowercase alphanumeric characters, underscores (_), and hyphens (-).'),
- '#element_validate' => array('image_style_name_validate'),
'#required' => TRUE,
);
+ $form['name'] = array(
+ '#type' => 'machine_name',
+ '#description' => t('The name is used in URLs for generated images. Use only lowercase alphanumeric characters, underscores (_), and hyphens (-).'),
+ '#size' => '64',
+ '#required' => TRUE,
+ '#machine_name' => array(
+ 'exists' => 'image_style_load',
+ 'source' => array('label'),
+ 'replace_pattern' => '[^0-9a-z_\-]',
+ 'error' => t('Please only use lowercase alphanumeric characters, underscores (_), and hyphens (-) for style names.'),
+ ),
+ );
$form['submit'] = array(
'#type' => 'submit',
@@ -261,14 +271,22 @@ function image_style_add_form($form, &$form_state) {
* Submit handler for adding a new image style.
*/
function image_style_add_form_submit($form, &$form_state) {
- $style = array('name' => $form_state['values']['name']);
+ $style = array(
+ 'name' => $form_state['values']['name'],
+ 'label' => $form_state['values']['label'],
+ );
$style = image_style_save($style);
- drupal_set_message(t('Style %name was created.', array('%name' => $style['name'])));
+ drupal_set_message(t('Style %name was created.', array('%name' => $style['label'])));
$form_state['redirect'] = 'admin/config/media/image-styles/edit/' . $style['name'];
}
/**
* Element validate function to ensure unique, URL safe style names.
+ *
+ * This function is no longer used in Drupal core since image style names are
+ * now validated using #machine_name functionality. It is kept for backwards
+ * compatibility (since non-core modules may be using it) and will be removed
+ * in Drupal 8.
*/
function image_style_name_validate($element, $form_state) {
// Check for duplicates.
@@ -295,7 +313,7 @@ function image_style_name_validate($element, $form_state) {
function image_style_delete_form($form, &$form_state, $style) {
$form_state['image_style'] = $style;
- $replacement_styles = array_diff_key(image_style_options(), array($style['name'] => ''));
+ $replacement_styles = array_diff_key(image_style_options(TRUE, PASS_THROUGH), array($style['name'] => ''));
$form['replacement'] = array(
'#title' => t('Replacement style'),
'#type' => 'select',
@@ -305,7 +323,7 @@ function image_style_delete_form($form, &$form_state, $style) {
return confirm_form(
$form,
- t('Optionally select a style before deleting %style', array('%style' => $style['name'])),
+ t('Optionally select a style before deleting %style', array('%style' => $style['label'])),
'admin/config/media/image-styles',
t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted.'),
t('Delete'), t('Cancel')
@@ -319,7 +337,7 @@ function image_style_delete_form_submit($form, &$form_state) {
$style = $form_state['image_style'];
image_style_delete($style, $form_state['values']['replacement']);
- drupal_set_message(t('Style %name was deleted.', array('%name' => $style['name'])));
+ drupal_set_message(t('Style %name was deleted.', array('%name' => $style['label'])));
$form_state['redirect'] = 'admin/config/media/image-styles';
}
@@ -331,7 +349,7 @@ function image_style_revert_form($form, &$form_state, $style) {
return confirm_form(
$form,
- t('Revert the %style style?', array('%style' => $style['name'])),
+ t('Revert the %style style?', array('%style' => $style['label'])),
'admin/config/media/image-styles',
t('Reverting this style will delete the customized settings and restore the defaults provided by the @module module.', array('@module' => $style['module'])),
t('Revert'), t('Cancel')
@@ -342,7 +360,7 @@ function image_style_revert_form($form, &$form_state, $style) {
* Submit handler to convert an overridden style to its default.
*/
function image_style_revert_form_submit($form, &$form_state) {
- drupal_set_message(t('The %style style has been reverted to its defaults.', array('%style' => $form_state['image_style']['name'])));
+ drupal_set_message(t('The %style style has been reverted to its defaults.', array('%style' => $form_state['image_style']['label'])));
image_default_style_revert($form_state['image_style']);
$form_state['redirect'] = 'admin/config/media/image-styles';
}
@@ -439,7 +457,7 @@ function image_effect_delete_form($form, &$form_state, $style, $effect) {
$form_state['image_style'] = $style;
$form_state['image_effect'] = $effect;
- $question = t('Are you sure you want to delete the @effect effect from the %style style?', array('%style' => $style['name'], '@effect' => $effect['label']));
+ $question = t('Are you sure you want to delete the @effect effect from the %style style?', array('%style' => $style['label'], '@effect' => $effect['label']));
return confirm_form($form, $question, 'admin/config/media/image-styles/edit/' . $style['name'], '', t('Delete'));
}
@@ -650,7 +668,7 @@ function theme_image_style_list($variables) {
$rows = array();
foreach ($styles as $style) {
$row = array();
- $row[] = l($style['name'], 'admin/config/media/image-styles/edit/' . $style['name']);
+ $row[] = l($style['label'], 'admin/config/media/image-styles/edit/' . $style['name']);
$link_attributes = array(
'attributes' => array(
'class' => array('image-style-link'),
@@ -805,7 +823,7 @@ function theme_image_style_preview($variables) {
// Build the preview of the image style.
$preview_url = file_create_url($preview_file) . '?cache_bypass=' . REQUEST_TIME;
$output .= '', t('Expected img tag was found.'));
- $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
+ $this->assertEqual($img_tag, '
', 'Expected img tag was found.');
+ $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url);
- $this->assertResponse(200, t('Image was generated at the URL.'));
- $this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.'));
+ $this->assertResponse(200, 'Image was generated at the URL.');
+ $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$image_info = image_get_info($generated_uri);
- $this->assertEqual($image_info['width'], 120, t('Expected width was found.'));
- $this->assertEqual($image_info['height'], 60, t('Expected height was found.'));
+ $this->assertEqual($image_info['width'], 120, 'Expected width was found.');
+ $this->assertEqual($image_info['height'], 60, 'Expected height was found.');
// Rotate 90 degrees anticlockwise.
$effect = array(
@@ -1161,14 +1172,14 @@ class ImageDimensionsTestCase extends DrupalWebTestCase {
image_effect_save($effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '
', t('Expected img tag was found.'));
- $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
+ $this->assertEqual($img_tag, '
', 'Expected img tag was found.');
+ $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url);
- $this->assertResponse(200, t('Image was generated at the URL.'));
- $this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.'));
+ $this->assertResponse(200, 'Image was generated at the URL.');
+ $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$image_info = image_get_info($generated_uri);
- $this->assertEqual($image_info['width'], 60, t('Expected width was found.'));
- $this->assertEqual($image_info['height'], 120, t('Expected height was found.'));
+ $this->assertEqual($image_info['width'], 60, 'Expected width was found.');
+ $this->assertEqual($image_info['height'], 120, 'Expected height was found.');
// Scale an image that is higher than it is wide (rotated by previous effect).
$effect = array(
@@ -1183,14 +1194,14 @@ class ImageDimensionsTestCase extends DrupalWebTestCase {
image_effect_save($effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '
', t('Expected img tag was found.'));
- $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
+ $this->assertEqual($img_tag, '
', 'Expected img tag was found.');
+ $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url);
- $this->assertResponse(200, t('Image was generated at the URL.'));
- $this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.'));
+ $this->assertResponse(200, 'Image was generated at the URL.');
+ $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$image_info = image_get_info($generated_uri);
- $this->assertEqual($image_info['width'], 45, t('Expected width was found.'));
- $this->assertEqual($image_info['height'], 90, t('Expected height was found.'));
+ $this->assertEqual($image_info['width'], 45, 'Expected width was found.');
+ $this->assertEqual($image_info['height'], 90, 'Expected height was found.');
// Test upscale disabled.
$effect = array(
@@ -1205,14 +1216,14 @@ class ImageDimensionsTestCase extends DrupalWebTestCase {
image_effect_save($effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '
', t('Expected img tag was found.'));
- $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
+ $this->assertEqual($img_tag, '
', 'Expected img tag was found.');
+ $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url);
- $this->assertResponse(200, t('Image was generated at the URL.'));
- $this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.'));
+ $this->assertResponse(200, 'Image was generated at the URL.');
+ $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$image_info = image_get_info($generated_uri);
- $this->assertEqual($image_info['width'], 45, t('Expected width was found.'));
- $this->assertEqual($image_info['height'], 90, t('Expected height was found.'));
+ $this->assertEqual($image_info['width'], 45, 'Expected width was found.');
+ $this->assertEqual($image_info['height'], 90, 'Expected height was found.');
// Add a desaturate effect.
$effect = array(
@@ -1223,14 +1234,14 @@ class ImageDimensionsTestCase extends DrupalWebTestCase {
image_effect_save($effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '
', t('Expected img tag was found.'));
- $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
+ $this->assertEqual($img_tag, '
', 'Expected img tag was found.');
+ $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url);
- $this->assertResponse(200, t('Image was generated at the URL.'));
- $this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.'));
+ $this->assertResponse(200, 'Image was generated at the URL.');
+ $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$image_info = image_get_info($generated_uri);
- $this->assertEqual($image_info['width'], 45, t('Expected width was found.'));
- $this->assertEqual($image_info['height'], 90, t('Expected height was found.'));
+ $this->assertEqual($image_info['width'], 45, 'Expected width was found.');
+ $this->assertEqual($image_info['height'], 90, 'Expected height was found.');
// Add a random rotate effect.
$effect = array(
@@ -1244,11 +1255,11 @@ class ImageDimensionsTestCase extends DrupalWebTestCase {
image_effect_save($effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '
', t('Expected img tag was found.'));
- $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
+ $this->assertEqual($img_tag, '
', 'Expected img tag was found.');
+ $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url);
- $this->assertResponse(200, t('Image was generated at the URL.'));
- $this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.'));
+ $this->assertResponse(200, 'Image was generated at the URL.');
+ $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
// Add a crop effect.
@@ -1264,14 +1275,14 @@ class ImageDimensionsTestCase extends DrupalWebTestCase {
image_effect_save($effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '
', t('Expected img tag was found.'));
- $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
+ $this->assertEqual($img_tag, '
', 'Expected img tag was found.');
+ $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url);
- $this->assertResponse(200, t('Image was generated at the URL.'));
- $this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.'));
+ $this->assertResponse(200, 'Image was generated at the URL.');
+ $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
$image_info = image_get_info($generated_uri);
- $this->assertEqual($image_info['width'], 30, t('Expected width was found.'));
- $this->assertEqual($image_info['height'], 30, t('Expected height was found.'));
+ $this->assertEqual($image_info['width'], 30, 'Expected width was found.');
+ $this->assertEqual($image_info['height'], 30, 'Expected height was found.');
// Rotate to a non-multiple of 90 degrees.
$effect = array(
@@ -1285,11 +1296,11 @@ class ImageDimensionsTestCase extends DrupalWebTestCase {
$effect = image_effect_save($effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '
', t('Expected img tag was found.'));
- $this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
+ $this->assertEqual($img_tag, '
', 'Expected img tag was found.');
+ $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
$this->drupalGet($url);
- $this->assertResponse(200, t('Image was generated at the URL.'));
- $this->assertTrue(file_exists($generated_uri), t('Generated file does exist after we accessed it.'));
+ $this->assertResponse(200, 'Image was generated at the URL.');
+ $this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
image_effect_delete($effect);
@@ -1303,7 +1314,7 @@ class ImageDimensionsTestCase extends DrupalWebTestCase {
image_effect_save($effect);
$img_tag = theme_image_style($variables);
- $this->assertEqual($img_tag, '
', t('Expected img tag was found.'));
+ $this->assertEqual($img_tag, '
', 'Expected img tag was found.');
}
}
@@ -1437,13 +1448,13 @@ class ImageDimensionsScaleTestCase extends DrupalUnitTestCase {
$return_value = image_dimensions_scale($test['input']['dimensions'], $test['input']['width'], $test['input']['height'], $test['input']['upscale']);
// Check the width.
- $this->assertEqual($test['output']['dimensions']['width'], $test['input']['dimensions']['width'], t('Computed width (@computed_width) equals expected width (@expected_width)', array('@computed_width' => $test['output']['dimensions']['width'], '@expected_width' => $test['input']['dimensions']['width'])));
+ $this->assertEqual($test['output']['dimensions']['width'], $test['input']['dimensions']['width'], format_string('Computed width (@computed_width) equals expected width (@expected_width)', array('@computed_width' => $test['output']['dimensions']['width'], '@expected_width' => $test['input']['dimensions']['width'])));
// Check the height.
- $this->assertEqual($test['output']['dimensions']['height'], $test['input']['dimensions']['height'], t('Computed height (@computed_height) equals expected height (@expected_height)', array('@computed_height' => $test['output']['dimensions']['height'], '@expected_height' => $test['input']['dimensions']['height'])));
+ $this->assertEqual($test['output']['dimensions']['height'], $test['input']['dimensions']['height'], format_string('Computed height (@computed_height) equals expected height (@expected_height)', array('@computed_height' => $test['output']['dimensions']['height'], '@expected_height' => $test['input']['dimensions']['height'])));
// Check the return value.
- $this->assertEqual($test['output']['return_value'], $return_value, t('Correct return value.'));
+ $this->assertEqual($test['output']['return_value'], $return_value, 'Correct return value.');
}
}
}
@@ -1704,7 +1715,7 @@ class ImageThemeFunctionWebTestCase extends DrupalWebTestCase {
$original_uri = file_unmanaged_copy($file->uri, 'public://', FILE_EXISTS_RENAME);
// Create a style.
- image_style_save(array('name' => 'test'));
+ image_style_save(array('name' => 'test', 'label' => 'Test'));
$url = image_style_url('test', $original_uri);
// Test using theme_image_formatter() without an image title, alt text, or
@@ -1737,3 +1748,108 @@ class ImageThemeFunctionWebTestCase extends DrupalWebTestCase {
}
}
+
+/**
+ * Tests flushing of image styles.
+ */
+class ImageStyleFlushTest extends ImageFieldTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Image style flushing',
+ 'description' => 'Tests flushing of image styles.',
+ 'group' => 'Image',
+ );
+ }
+
+ /**
+ * Given an image style and a wrapper, generate an image.
+ */
+ function createSampleImage($style, $wrapper) {
+ static $file;
+
+ if (!isset($file)) {
+ $files = $this->drupalGetTestFiles('image');
+ $file = reset($files);
+ }
+
+ // Make sure we have an image in our wrapper testing file directory.
+ $source_uri = file_unmanaged_copy($file->uri, $wrapper . '://');
+ // Build the derivative image.
+ $derivative_uri = image_style_path($style['name'], $source_uri);
+ $derivative = image_style_create_derivative($style, $source_uri, $derivative_uri);
+
+ return $derivative ? $derivative_uri : FALSE;
+ }
+
+ /**
+ * Count the number of images currently created for a style in a wrapper.
+ */
+ function getImageCount($style, $wrapper) {
+ return count(file_scan_directory($wrapper . '://styles/' . $style['name'], '/.*/'));
+ }
+
+ /**
+ * General test to flush a style.
+ */
+ function testFlush() {
+
+ // Setup a style to be created and effects to add to it.
+ $style_name = strtolower($this->randomName(10));
+ $style_label = $this->randomString();
+ $style_path = 'admin/config/media/image-styles/edit/' . $style_name;
+ $effect_edits = array(
+ 'image_resize' => array(
+ 'data[width]' => 100,
+ 'data[height]' => 101,
+ ),
+ 'image_scale' => array(
+ 'data[width]' => 110,
+ 'data[height]' => 111,
+ 'data[upscale]' => 1,
+ ),
+ );
+
+ // Add style form.
+ $edit = array(
+ 'name' => $style_name,
+ 'label' => $style_label,
+ );
+ $this->drupalPost('admin/config/media/image-styles/add', $edit, t('Create new style'));
+ // Add each sample effect to the style.
+ foreach ($effect_edits as $effect => $edit) {
+ // Add the effect.
+ $this->drupalPost($style_path, array('new' => $effect), t('Add'));
+ if (!empty($edit)) {
+ $this->drupalPost(NULL, $edit, t('Add effect'));
+ }
+ }
+
+ // Load the saved image style.
+ $style = image_style_load($style_name);
+
+ // Create an image for the 'public' wrapper.
+ $image_path = $this->createSampleImage($style, 'public');
+ // Expecting to find 2 images, one is the sample.png image shown in
+ // image style preview.
+ $this->assertEqual($this->getImageCount($style, 'public'), 2, format_string('Image style %style image %file successfully generated.', array('%style' => $style['name'], '%file' => $image_path)));
+
+ // Create an image for the 'private' wrapper.
+ $image_path = $this->createSampleImage($style, 'private');
+ $this->assertEqual($this->getImageCount($style, 'private'), 1, format_string('Image style %style image %file successfully generated.', array('%style' => $style['name'], '%file' => $image_path)));
+
+ // Remove the 'image_scale' effect and updates the style, which in turn
+ // forces an image style flush.
+ $effect = array_pop($style['effects']);
+ $this->drupalPost($style_path . '/effects/' . $effect['ieid'] . '/delete', array(), t('Delete'));
+ $this->assertResponse(200);
+ $this->drupalPost($style_path, array(), t('Update style'));
+ $this->assertResponse(200);
+
+ // Post flush, expected 1 image in the 'public' wrapper (sample.png).
+ $this->assertEqual($this->getImageCount($style, 'public'), 1, format_string('Image style %style flushed correctly for %wrapper wrapper.', array('%style' => $style['name'], '%wrapper' => 'public')));
+
+ // Post flush, expected no image in the 'private' wrapper.
+ $this->assertEqual($this->getImageCount($style, 'private'), 0, format_string('Image style %style flushed correctly for %wrapper wrapper.', array('%style' => $style['name'], '%wrapper' => 'private')));
+ }
+}
diff --git a/modules/image/tests/image_module_test.info b/modules/image/tests/image_module_test.info
index 3486df8c..16166783 100755
--- a/modules/image/tests/image_module_test.info
+++ b/modules/image/tests/image_module_test.info
@@ -6,8 +6,8 @@ core = 7.x
files[] = image_module_test.module
hidden = TRUE
-; Information added by drupal.org packaging script on 2013-04-03
-version = "7.22"
+; Information added by drupal.org packaging script on 2013-08-08
+version = "7.23"
project = "drupal"
-datestamp = "1365027012"
+datestamp = "1375928238"
diff --git a/modules/locale/locale.info b/modules/locale/locale.info
index 1ba12777..bc59c28e 100755
--- a/modules/locale/locale.info
+++ b/modules/locale/locale.info
@@ -6,8 +6,8 @@ core = 7.x
files[] = locale.test
configure = admin/config/regional/language
-; Information added by drupal.org packaging script on 2013-04-03
-version = "7.22"
+; Information added by drupal.org packaging script on 2013-08-08
+version = "7.23"
project = "drupal"
-datestamp = "1365027012"
+datestamp = "1375928238"
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index b60c5312..768fead6 100755
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -972,7 +972,7 @@ function locale_css_alter(&$css) {
// Replicate the same item, but with the RTL path and a little larger
// weight so that it appears directly after the original CSS file.
$item['data'] = $rtl_path;
- $item['weight'] += 0.01;
+ $item['weight'] += 0.0001;
$css[$rtl_path] = $item;
}
}
diff --git a/modules/locale/locale.test b/modules/locale/locale.test
index d88634e1..edf72e4d 100755
--- a/modules/locale/locale.test
+++ b/modules/locale/locale.test
@@ -52,8 +52,8 @@ class LocaleConfigurationTest extends DrupalWebTestCase {
'langcode' => 'fr',
);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
- $this->assertText('fr', t('Language added successfully.'));
- $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
+ $this->assertText('fr', 'Language added successfully.');
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
// Add custom language.
// Code for the language.
@@ -72,109 +72,109 @@ class LocaleConfigurationTest extends DrupalWebTestCase {
'direction' => '0',
);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
- $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
- $this->assertText($langcode, t('Language code found.'));
- $this->assertText($name, t('Name found.'));
- $this->assertText($native, t('Native found.'));
- $this->assertText($native, t('Test language added.'));
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
+ $this->assertText($langcode, 'Language code found.');
+ $this->assertText($name, 'Name found.');
+ $this->assertText($native, 'Native found.');
+ $this->assertText($native, 'Test language added.');
// Check if we can change the default language.
$path = 'admin/config/regional/language';
$this->drupalGet($path);
- $this->assertFieldChecked('edit-site-default-en', t('English is the default language.'));
+ $this->assertFieldChecked('edit-site-default-en', 'English is the default language.');
// Change the default language.
$edit = array(
'site_default' => $langcode,
);
$this->drupalPost(NULL, $edit, t('Save configuration'));
- $this->assertNoFieldChecked('edit-site-default-en', t('Default language updated.'));
- $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
+ $this->assertNoFieldChecked('edit-site-default-en', 'Default language updated.');
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
// Check if a valid language prefix is added after changing the default
// language.
$this->drupalGet('admin/config/regional/language/edit/en');
- $this->assertFieldByXPath('//input[@name="prefix"]', 'en', t('A valid path prefix has been added to the previous default language.'));
+ $this->assertFieldByXPath('//input[@name="prefix"]', 'en', 'A valid path prefix has been added to the previous default language.');
// Ensure we can't delete the default language.
$this->drupalGet('admin/config/regional/language/delete/' . $langcode);
- $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
- $this->assertText(t('The default language cannot be deleted.'), t('Failed to delete the default language.'));
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
+ $this->assertText(t('The default language cannot be deleted.'), 'Failed to delete the default language.');
// Check if we can disable a language.
$edit = array(
'enabled[en]' => FALSE,
);
$this->drupalPost($path, $edit, t('Save configuration'));
- $this->assertNoFieldChecked('edit-enabled-en', t('Language disabled.'));
+ $this->assertNoFieldChecked('edit-enabled-en', 'Language disabled.');
// Set disabled language to be the default and ensure it is re-enabled.
$edit = array(
'site_default' => 'en',
);
$this->drupalPost(NULL, $edit, t('Save configuration'));
- $this->assertFieldChecked('edit-enabled-en', t('Default language re-enabled.'));
+ $this->assertFieldChecked('edit-enabled-en', 'Default language re-enabled.');
// Ensure 'edit' link works.
$this->clickLink(t('edit'));
- $this->assertTitle(t('Edit language | Drupal'), t('Page title is "Edit language".'));
+ $this->assertTitle(t('Edit language | Drupal'), 'Page title is "Edit language".');
// Edit a language.
$name = $this->randomName(16);
$edit = array(
'name' => $name,
);
$this->drupalPost('admin/config/regional/language/edit/' . $langcode, $edit, t('Save language'));
- $this->assertRaw($name, t('The language has been updated.'));
- $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
+ $this->assertRaw($name, 'The language has been updated.');
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
// Ensure 'delete' link works.
$this->drupalGet('admin/config/regional/language');
$this->clickLink(t('delete'));
- $this->assertText(t('Are you sure you want to delete the language'), t('"delete" link is correct.'));
+ $this->assertText(t('Are you sure you want to delete the language'), '"delete" link is correct.');
// Delete an enabled language.
$this->drupalGet('admin/config/regional/language/delete/' . $langcode);
// First test the 'cancel' link.
$this->clickLink(t('Cancel'));
- $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
- $this->assertRaw($name, t('The language was not deleted.'));
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
+ $this->assertRaw($name, 'The language was not deleted.');
// Delete the language for real. This a confirm form, we do not need any
// fields changed.
$this->drupalPost('admin/config/regional/language/delete/' . $langcode, array(), t('Delete'));
// We need raw here because %locale will add HTML.
- $this->assertRaw(t('The language %locale has been removed.', array('%locale' => $name)), t('The test language has been removed.'));
- $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
+ $this->assertRaw(t('The language %locale has been removed.', array('%locale' => $name)), 'The test language has been removed.');
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
// Verify that language is no longer found.
$this->drupalGet('admin/config/regional/language/delete/' . $langcode);
- $this->assertResponse(404, t('Language no longer found.'));
+ $this->assertResponse(404, 'Language no longer found.');
// Make sure the "language_count" variable has been updated correctly.
drupal_static_reset('language_list');
$enabled = language_list('enabled');
- $this->assertEqual(variable_get('language_count', 1), count($enabled[1]), t('Language count is correct.'));
+ $this->assertEqual(variable_get('language_count', 1), count($enabled[1]), 'Language count is correct.');
// Delete a disabled language.
// Disable an enabled language.
$edit = array(
'enabled[fr]' => FALSE,
);
$this->drupalPost($path, $edit, t('Save configuration'));
- $this->assertNoFieldChecked('edit-enabled-fr', t('French language disabled.'));
+ $this->assertNoFieldChecked('edit-enabled-fr', 'French language disabled.');
// Get the count of enabled languages.
drupal_static_reset('language_list');
$enabled = language_list('enabled');
// Delete the disabled language.
$this->drupalPost('admin/config/regional/language/delete/fr', array(), t('Delete'));
// We need raw here because %locale will add HTML.
- $this->assertRaw(t('The language %locale has been removed.', array('%locale' => 'French')), t('Disabled language has been removed.'));
- $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
+ $this->assertRaw(t('The language %locale has been removed.', array('%locale' => 'French')), 'Disabled language has been removed.');
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
// Verify that language is no longer found.
$this->drupalGet('admin/config/regional/language/delete/fr');
- $this->assertResponse(404, t('Language no longer found.'));
+ $this->assertResponse(404, 'Language no longer found.');
// Make sure the "language_count" variable has not changed.
- $this->assertEqual(variable_get('language_count', 1), count($enabled[1]), t('Language count is correct.'));
+ $this->assertEqual(variable_get('language_count', 1), count($enabled[1]), 'Language count is correct.');
// Ensure we can't delete the English language.
$this->drupalGet('admin/config/regional/language/delete/en');
- $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
- $this->assertText(t('The English language cannot be deleted.'), t('Failed to delete English language.'));
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
+ $this->assertText(t('The English language cannot be deleted.'), 'Failed to delete English language.');
}
}
@@ -205,7 +205,7 @@ class LocaleLibraryInfoAlterTest extends DrupalWebTestCase {
public function testLibraryInfoAlter() {
drupal_add_library('system', 'ui.datepicker');
$scripts = drupal_get_js();
- $this->assertTrue(strpos($scripts, 'locale.datepicker.js'), t('locale.datepicker.js added to scripts.'));
+ $this->assertTrue(strpos($scripts, 'locale.datepicker.js'), 'locale.datepicker.js added to scripts.');
}
}
@@ -289,13 +289,13 @@ class LocaleJavascriptTranslationTest extends DrupalWebTestCase {
$args = array('%source' => $str, '%context' => $context);
// Make sure that the string was found in the file.
- $this->assertTrue(isset($source_strings[$str]), t("Found source string: %source", $args));
+ $this->assertTrue(isset($source_strings[$str]), format_string('Found source string: %source', $args));
// Make sure that the proper context was matched.
- $this->assertTrue(isset($source_strings[$str]) && $source_strings[$str] === $context, strlen($context) > 0 ? t("Context for %source is %context", $args) : t("Context for %source is blank", $args));
+ $this->assertTrue(isset($source_strings[$str]) && $source_strings[$str] === $context, strlen($context) > 0 ? format_string('Context for %source is %context', $args) : format_string('Context for %source is blank', $args));
}
- $this->assertEqual(count($source_strings), count($test_strings), t("Found correct number of source strings."));
+ $this->assertEqual(count($source_strings), count($test_strings), 'Found correct number of source strings.');
}
}
/**
@@ -352,12 +352,12 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
t($name, array(), array('langcode' => $langcode));
// Reset locale cache.
locale_reset();
- $this->assertText($langcode, t('Language code found.'));
- $this->assertText($name, t('Name found.'));
- $this->assertText($native, t('Native found.'));
+ $this->assertText($langcode, 'Language code found.');
+ $this->assertText($name, 'Name found.');
+ $this->assertText($native, 'Native found.');
// No t() here, we do not want to add this string to the database and it's
// surely not translated yet.
- $this->assertText($native, t('Test language added.'));
+ $this->assertText($native, 'Test language added.');
$this->drupalLogout();
// Search for the name and translate it.
@@ -372,8 +372,8 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
// assertText() seems to remove the input field where $name always could be
// found, so this is not a false assert. See how assertNoText succeeds
// later.
- $this->assertText($name, t('Search found the name.'));
- $this->assertRaw($language_indicator, t('Name is untranslated.'));
+ $this->assertText($name, 'Search found the name.');
+ $this->assertRaw($language_indicator, 'Name is untranslated.');
// Assume this is the only result, given the random name.
$this->clickLink(t('edit'));
// We save the lid from the path.
@@ -381,24 +381,24 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
preg_match('!admin/config/regional/translate/edit/(\d+)!', $this->getUrl(), $matches);
$lid = $matches[1];
// No t() here, it's surely not translated yet.
- $this->assertText($name, t('name found on edit screen.'));
+ $this->assertText($name, 'name found on edit screen.');
$edit = array(
"translations[$langcode]" => $translation,
);
$this->drupalPost(NULL, $edit, t('Save translations'));
- $this->assertText(t('The string has been saved.'), t('The string has been saved.'));
- $this->assertEqual($this->getUrl(), url('admin/config/regional/translate/translate', array('absolute' => TRUE)), t('Correct page redirection.'));
- $this->assertTrue($name != $translation && t($name, array(), array('langcode' => $langcode)) == $translation, t('t() works.'));
+ $this->assertText(t('The string has been saved.'), 'The string has been saved.');
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/translate/translate', array('absolute' => TRUE)), 'Correct page redirection.');
+ $this->assertTrue($name != $translation && t($name, array(), array('langcode' => $langcode)) == $translation, 't() works.');
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
// The indicator should not be here.
- $this->assertNoRaw($language_indicator, t('String is translated.'));
+ $this->assertNoRaw($language_indicator, 'String is translated.');
// Try to edit a non-existent string and ensure we're redirected correctly.
// Assuming we don't have 999,999 strings already.
$random_lid = 999999;
$this->drupalGet('admin/config/regional/translate/edit/' . $random_lid);
- $this->assertText(t('String not found'), t('String not found.'));
- $this->assertEqual($this->getUrl(), url('admin/config/regional/translate/translate', array('absolute' => TRUE)), t('Correct page redirection.'));
+ $this->assertText(t('String not found'), 'String not found.');
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/translate/translate', array('absolute' => TRUE)), 'Correct page redirection.');
$this->drupalLogout();
// Delete the language.
@@ -407,11 +407,11 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
// This a confirm form, we do not need any fields changed.
$this->drupalPost($path, array(), t('Delete'));
// We need raw here because %locale will add HTML.
- $this->assertRaw(t('The language %locale has been removed.', array('%locale' => $name)), t('The test language has been removed.'));
+ $this->assertRaw(t('The language %locale has been removed.', array('%locale' => $name)), 'The test language has been removed.');
// Reload to remove $name.
$this->drupalGet($path);
// Verify that language is no longer found.
- $this->assertResponse(404, t('Language no longer found.'));
+ $this->assertResponse(404, 'Language no longer found.');
$this->drupalLogout();
// Delete the string.
@@ -425,20 +425,20 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
// Assume this is the only result, given the random name.
$this->clickLink(t('delete'));
- $this->assertText(t('Are you sure you want to delete the string'), t('"delete" link is correct.'));
+ $this->assertText(t('Are you sure you want to delete the string'), '"delete" link is correct.');
// Delete the string.
$path = 'admin/config/regional/translate/delete/' . $lid;
$this->drupalGet($path);
// First test the 'cancel' link.
$this->clickLink(t('Cancel'));
- $this->assertEqual($this->getUrl(), url('admin/config/regional/translate/translate', array('absolute' => TRUE)), t('Correct page redirection.'));
- $this->assertRaw($name, t('The string was not deleted.'));
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/translate/translate', array('absolute' => TRUE)), 'Correct page redirection.');
+ $this->assertRaw($name, 'The string was not deleted.');
// Delete the name string.
$this->drupalPost('admin/config/regional/translate/delete/' . $lid, array(), t('Delete'));
- $this->assertText(t('The string has been removed.'), t('The string has been removed message.'));
- $this->assertEqual($this->getUrl(), url('admin/config/regional/translate/translate', array('absolute' => TRUE)), t('Correct page redirection.'));
+ $this->assertText(t('The string has been removed.'), 'The string has been removed message.');
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/translate/translate', array('absolute' => TRUE)), 'Correct page redirection.');
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
- $this->assertNoText($name, t('Search now can not find the name.'));
+ $this->assertNoText($name, 'Search now can not find the name.');
}
/*
@@ -494,14 +494,14 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
->execute()
->fetchObject();
$js_file = 'public://' . variable_get('locale_js_directory', 'languages') . '/' . $langcode . '_' . $file->javascript . '.js';
- $this->assertTrue($result = file_exists($js_file), t('JavaScript file created: %file', array('%file' => $result ? $js_file : t('not found'))));
+ $this->assertTrue($result = file_exists($js_file), format_string('JavaScript file created: %file', array('%file' => $result ? $js_file : 'not found')));
// Test JavaScript translation rebuilding.
file_unmanaged_delete($js_file);
- $this->assertTrue($result = !file_exists($js_file), t('JavaScript file deleted: %file', array('%file' => $result ? $js_file : t('found'))));
+ $this->assertTrue($result = !file_exists($js_file), format_string('JavaScript file deleted: %file', array('%file' => $result ? $js_file : 'found')));
cache_clear_all();
_locale_rebuild_js($langcode);
- $this->assertTrue($result = file_exists($js_file), t('JavaScript file rebuilt: %file', array('%file' => $result ? $js_file : t('not found'))));
+ $this->assertTrue($result = file_exists($js_file), format_string('JavaScript file rebuilt: %file', array('%file' => $result ? $js_file : 'not found')));
}
/**
@@ -554,7 +554,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
// Find the edit path.
$content = $this->drupalGetContent();
- $this->assertTrue(preg_match('@(admin/config/regional/translate/edit/[0-9]+)@', $content, $matches), t('Found the edit path.'));
+ $this->assertTrue(preg_match('@(admin/config/regional/translate/edit/[0-9]+)@', $content, $matches), 'Found the edit path.');
$path = $matches[0];
foreach ($bad_translations as $key => $translation) {
$edit = array(
@@ -563,8 +563,8 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
$this->drupalPost($path, $edit, t('Save translations'));
// Check for a form error on the textarea.
$form_class = $this->xpath('//form[@id="locale-translate-edit-form"]//textarea/@class');
- $this->assertNotIdentical(FALSE, strpos($form_class[0], 'error'), t('The string was rejected as unsafe.'));
- $this->assertNoText(t('The string has been saved.'), t('The string was not saved.'));
+ $this->assertNotIdentical(FALSE, strpos($form_class[0], 'error'), 'The string was rejected as unsafe.');
+ $this->assertNoText(t('The string has been saved.'), 'The string was not saved.');
}
}
@@ -621,7 +621,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
// assertText() seems to remove the input field where $name always could be
// found, so this is not a false assert. See how assertNoText succeeds
// later.
- $this->assertText($name, t('Search found the string.'));
+ $this->assertText($name, 'Search found the string.');
// Ensure untranslated string doesn't appear if searching on 'only
// translated strings'.
@@ -632,7 +632,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
- $this->assertText(t('No strings available.'), t("Search didn't find the string."));
+ $this->assertText(t('No strings available.'), "Search didn't find the string.");
// Ensure untranslated string appears if searching on 'only untranslated
// strings' in "all" (hasn't been translated to any language).
@@ -643,7 +643,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
- $this->assertNoText(t('No strings available.'), t('Search found the string.'));
+ $this->assertNoText(t('No strings available.'), 'Search found the string.');
// Ensure untranslated string appears if searching on 'only untranslated
// strings' in the custom language (hasn't been translated to that specific language).
@@ -654,7 +654,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
- $this->assertNoText(t('No strings available.'), t('Search found the string.'));
+ $this->assertNoText(t('No strings available.'), 'Search found the string.');
// Add translation.
// Assume this is the only result, given the random name.
@@ -677,7 +677,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
- $this->assertNoText(t('No strings available.'), t('Search found the translation.'));
+ $this->assertNoText(t('No strings available.'), 'Search found the translation.');
// Ensure translated source string doesn't appear if searching on 'only
// untranslated strings'.
@@ -688,7 +688,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
- $this->assertText(t('No strings available.'), t("Search didn't find the source string."));
+ $this->assertText(t('No strings available.'), "Search didn't find the source string.");
// Ensure translated string doesn't appear if searching on 'only
// untranslated strings'.
@@ -699,7 +699,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
- $this->assertText(t('No strings available.'), t("Search didn't find the translation."));
+ $this->assertText(t('No strings available.'), "Search didn't find the translation.");
// Ensure translated string does appear if searching on the custom language.
$search = array(
@@ -709,7 +709,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
- $this->assertNoText(t('No strings available.'), t('Search found the translation.'));
+ $this->assertNoText(t('No strings available.'), 'Search found the translation.');
// Ensure translated string doesn't appear if searching on English.
$search = array(
@@ -719,7 +719,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
- $this->assertText(t('No strings available.'), t("Search didn't find the translation."));
+ $this->assertText(t('No strings available.'), "Search didn't find the translation.");
// Search for a string that isn't in the system.
$unavailable_string = $this->randomName(16);
@@ -730,7 +730,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
- $this->assertText(t('No strings available.'), t("Search didn't find the invalid string."));
+ $this->assertText(t('No strings available.'), "Search didn't find the invalid string.");
}
}
@@ -898,16 +898,16 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
));
// The import should automatically create the corresponding language.
- $this->assertRaw(t('The language %language has been created.', array('%language' => 'French')), t('The language has been automatically created.'));
+ $this->assertRaw(t('The language %language has been created.', array('%language' => 'French')), 'The language has been automatically created.');
// The import should have created 7 strings.
- $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 9, '%update' => 0, '%delete' => 0)), t('The translation file was successfully imported.'));
+ $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 9, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.');
// This import should have saved plural forms to have 2 variants.
- $this->assert(db_query("SELECT plurals FROM {languages} WHERE language = 'fr'")->fetchField() == 2, t('Plural number initialized.'));
+ $this->assert(db_query("SELECT plurals FROM {languages} WHERE language = 'fr'")->fetchField() == 2, 'Plural number initialized.');
// Ensure we were redirected correctly.
- $this->assertEqual($this->getUrl(), url('admin/config/regional/translate', array('absolute' => TRUE)), t('Correct page redirection.'));
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/translate', array('absolute' => TRUE)), 'Correct page redirection.');
// Try importing a .po file with invalid tags in the default text group.
@@ -916,9 +916,9 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
));
// The import should have created 1 string and rejected 2.
- $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), t('The translation file was successfully imported.'));
+ $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.');
$skip_message = format_plural(2, 'One translation string was skipped because it contains disallowed HTML.', '@count translation strings were skipped because they contain disallowed HTML.');
- $this->assertRaw($skip_message, t('Unsafe strings were skipped.'));
+ $this->assertRaw($skip_message, 'Unsafe strings were skipped.');
// Try importing a .po file with invalid tags in a non default text group.
@@ -928,7 +928,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
));
// The import should have created 3 strings.
- $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 3, '%update' => 0, '%delete' => 0)), t('The translation file was successfully imported.'));
+ $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 3, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.');
// Try importing a .po file which doesn't exist.
@@ -938,8 +938,8 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
'files[file]' => $name,
'group' => 'custom',
), t('Import'));
- $this->assertEqual($this->getUrl(), url('admin/config/regional/translate/import', array('absolute' => TRUE)), t('Correct page redirection.'));
- $this->assertText(t('File to import not found.'), t('File to import not found message.'));
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/translate/import', array('absolute' => TRUE)), 'Correct page redirection.');
+ $this->assertText(t('File to import not found.'), 'File to import not found message.');
// Try importing a .po file with overriding strings, and ensure existing
@@ -950,7 +950,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
));
// The import should have created 1 string.
- $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), t('The translation file was successfully imported.'));
+ $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.');
// Ensure string wasn't overwritten.
$search = array(
'string' => 'Montag',
@@ -959,10 +959,10 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
- $this->assertText(t('No strings available.'), t('String not overwritten by imported string.'));
+ $this->assertText(t('No strings available.'), 'String not overwritten by imported string.');
// This import should not have changed number of plural forms.
- $this->assert(db_query("SELECT plurals FROM {languages} WHERE language = 'fr'")->fetchField() == 2, t('Plural numbers untouched.'));
+ $this->assert(db_query("SELECT plurals FROM {languages} WHERE language = 'fr'")->fetchField() == 2, 'Plural numbers untouched.');
$this->importPoFile($this->getPoFileWithBrokenPlural(), array(
'langcode' => 'fr',
@@ -971,7 +971,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
// Attempt to import broken .po file as well to prove that this
// will not overwrite the proper plural formula imported above.
- $this->assert(db_query("SELECT plurals FROM {languages} WHERE language = 'fr'")->fetchField() == 2, t('Broken plurals: plural numbers untouched.'));
+ $this->assert(db_query("SELECT plurals FROM {languages} WHERE language = 'fr'")->fetchField() == 2, 'Broken plurals: plural numbers untouched.');
$this->importPoFile($this->getPoFileWithMissingPlural(), array(
'langcode' => 'fr',
@@ -980,7 +980,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
// Attempt to import .po file which has no plurals and prove that this
// will not overwrite the proper plural formula imported above.
- $this->assert(db_query("SELECT plurals FROM {languages} WHERE language = 'fr'")->fetchField() == 2, t('No plurals: plural numbers untouched.'));
+ $this->assert(db_query("SELECT plurals FROM {languages} WHERE language = 'fr'")->fetchField() == 2, 'No plurals: plural numbers untouched.');
// Try importing a .po file with overriding strings, and ensure existing
@@ -991,7 +991,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
));
// The import should have updated 2 strings.
- $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 0, '%update' => 2, '%delete' => 0)), t('The translation file was successfully imported.'));
+ $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 0, '%update' => 2, '%delete' => 0)), 'The translation file was successfully imported.');
// Ensure string was overwritten.
$search = array(
'string' => 'Montag',
@@ -1000,9 +1000,9 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
- $this->assertNoText(t('No strings available.'), t('String overwritten by imported string.'));
+ $this->assertNoText(t('No strings available.'), 'String overwritten by imported string.');
// This import should have changed number of plural forms.
- $this->assert(db_query("SELECT plurals FROM {languages} WHERE language = 'fr'")->fetchField() == 3, t('Plural numbers changed.'));
+ $this->assert(db_query("SELECT plurals FROM {languages} WHERE language = 'fr'")->fetchField() == 3, 'Plural numbers changed.');
}
/**
@@ -1031,7 +1031,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
// Ensure the translation file was automatically imported when language was
// added.
- $this->assertText(t('One translation file imported for the enabled modules.'), t('Language file automatically imported.'));
+ $this->assertText(t('One translation file imported for the enabled modules.'), 'Language file automatically imported.');
// Ensure strings were successfully imported.
$search = array(
@@ -1041,7 +1041,7 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
'group' => 'all',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
- $this->assertNoText(t('No strings available.'), t('String successfully imported.'));
+ $this->assertNoText(t('No strings available.'), 'String successfully imported.');
}
/**
@@ -1053,8 +1053,8 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
'langcode' => 'hr',
));
- $this->assertIdentical(t('May', array(), array('langcode' => 'hr', 'context' => 'Long month name')), 'Svibanj', t('Long month name context is working.'));
- $this->assertIdentical(t('May', array(), array('langcode' => 'hr')), 'Svi.', t('Default context is working.'));
+ $this->assertIdentical(t('May', array(), array('langcode' => 'hr', 'context' => 'Long month name')), 'Svibanj', 'Long month name context is working.');
+ $this->assertIdentical(t('May', array(), array('langcode' => 'hr')), 'Svi.', 'Default context is working.');
}
/**
@@ -1068,15 +1068,15 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
'langcode' => $langcode,
));
- $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), t('The translation file was successfully imported.'));
- $this->assertIdentical(t('Operations', array(), array('langcode' => $langcode)), 'Műveletek', t('String imported and translated.'));
+ $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.');
+ $this->assertIdentical(t('Operations', array(), array('langcode' => $langcode)), 'Műveletek', 'String imported and translated.');
// Try importing a .po file.
$this->importPoFile($this->getPoFileWithEmptyMsgstr(), array(
'langcode' => $langcode,
'mode' => 0,
));
- $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 0, '%update' => 0, '%delete' => 1)), t('The translation file was successfully imported.'));
+ $this->assertRaw(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => 0, '%update' => 0, '%delete' => 1)), 'The translation file was successfully imported.');
// This is the language indicator on the translation search screen for
// untranslated strings. Copied straight from locale.inc.
$language_indicator = "$langcode ";
@@ -1090,8 +1090,8 @@ class LocaleImportFunctionalTest extends DrupalWebTestCase {
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
// assertText() seems to remove the input field where $str always could be
// found, so this is not a false assert.
- $this->assertText($str, t('Search found the string.'));
- $this->assertRaw($language_indicator, t('String is untranslated again.'));
+ $this->assertText($str, 'Search found the string.');
+ $this->assertRaw($language_indicator, 'String is untranslated again.');
}
/**
@@ -1344,9 +1344,9 @@ class LocaleExportFunctionalTest extends DrupalWebTestCase {
), t('Export'));
// Ensure we have a translation file.
- $this->assertRaw('# French translation of Drupal', t('Exported French translation file.'));
+ $this->assertRaw('# French translation of Drupal', 'Exported French translation file.');
// Ensure our imported translations exist in the file.
- $this->assertRaw('msgstr "lundi"', t('French translations present in exported file.'));
+ $this->assertRaw('msgstr "lundi"', 'French translations present in exported file.');
}
/**
@@ -1359,7 +1359,7 @@ class LocaleExportFunctionalTest extends DrupalWebTestCase {
// doesn't work.
$this->drupalPost('admin/config/regional/translate/export', array(), t('Export'));
// Ensure we have a translation file.
- $this->assertRaw('# LANGUAGE translation of PROJECT', t('Exported translation template file.'));
+ $this->assertRaw('# LANGUAGE translation of PROJECT', 'Exported translation template file.');
}
/**
@@ -1407,7 +1407,7 @@ class LocaleInstallTest extends DrupalWebTestCase {
function testFunctionSignatures() {
$reflector_t = new ReflectionFunction('t');
$reflector_st = new ReflectionFunction('st');
- $this->assertEqual($reflector_t->getParameters(), $reflector_st->getParameters(), t('Function signatures of t() and st() are equal.'));
+ $this->assertEqual($reflector_t->getParameters(), $reflector_st->getParameters(), 'Function signatures of t() and st() are equal.');
}
}
@@ -1446,7 +1446,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
// Check the UI language.
drupal_language_initialize();
global $language;
- $this->assertEqual($language->language, $this->language, t('Current language: %lang', array('%lang' => $language->language)));
+ $this->assertEqual($language->language, $this->language, format_string('Current language: %lang', array('%lang' => $language->language)));
// Enable multilingual workflow option for articles.
variable_set('language_content_type_article', 1);
@@ -1467,7 +1467,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
_locale_rebuild_js('fr');
$file = db_query('SELECT javascript FROM {languages} WHERE language = :language', array(':language' => 'fr'))->fetchObject();
$js_file = 'public://' . variable_get('locale_js_directory', 'languages') . '/fr_' . $file->javascript . '.js';
- $this->assertTrue($result = file_exists($js_file), t('JavaScript file created: %file', array('%file' => $result ? $js_file : t('none'))));
+ $this->assertTrue($result = file_exists($js_file), format_string('JavaScript file created: %file', array('%file' => $result ? $js_file : 'none')));
// Disable string caching.
variable_set('locale_cache_strings', 0);
@@ -1492,44 +1492,44 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase {
// Check the init language logic.
drupal_language_initialize();
- $this->assertEqual($language->language, 'en', t('Language after uninstall: %lang', array('%lang' => $language->language)));
+ $this->assertEqual($language->language, 'en', format_string('Language after uninstall: %lang', array('%lang' => $language->language)));
// Check JavaScript files deletion.
- $this->assertTrue($result = !file_exists($js_file), t('JavaScript file deleted: %file', array('%file' => $result ? $js_file : t('found'))));
+ $this->assertTrue($result = !file_exists($js_file), format_string('JavaScript file deleted: %file', array('%file' => $result ? $js_file : 'found')));
// Check language count.
$language_count = variable_get('language_count', 1);
- $this->assertEqual($language_count, 1, t('Language count: %count', array('%count' => $language_count)));
+ $this->assertEqual($language_count, 1, format_string('Language count: %count', array('%count' => $language_count)));
// Check language negotiation.
require_once DRUPAL_ROOT . '/includes/language.inc';
- $this->assertTrue(count(language_types()) == count(drupal_language_types()), t('Language types reset'));
+ $this->assertTrue(count(language_types()) == count(drupal_language_types()), 'Language types reset');
$language_negotiation = language_negotiation_get(LANGUAGE_TYPE_INTERFACE) == LANGUAGE_NEGOTIATION_DEFAULT;
- $this->assertTrue($language_negotiation, t('Interface language negotiation: %setting', array('%setting' => t($language_negotiation ? 'none' : 'set'))));
+ $this->assertTrue($language_negotiation, format_string('Interface language negotiation: %setting', array('%setting' => $language_negotiation ? 'none' : 'set')));
$language_negotiation = language_negotiation_get(LANGUAGE_TYPE_CONTENT) == LANGUAGE_NEGOTIATION_DEFAULT;
- $this->assertTrue($language_negotiation, t('Content language negotiation: %setting', array('%setting' => t($language_negotiation ? 'none' : 'set'))));
+ $this->assertTrue($language_negotiation, format_string('Content language negotiation: %setting', array('%setting' => $language_negotiation ? 'none' : 'set')));
$language_negotiation = language_negotiation_get(LANGUAGE_TYPE_URL) == LANGUAGE_NEGOTIATION_DEFAULT;
- $this->assertTrue($language_negotiation, t('URL language negotiation: %setting', array('%setting' => t($language_negotiation ? 'none' : 'set'))));
+ $this->assertTrue($language_negotiation, format_string('URL language negotiation: %setting', array('%setting' => $language_negotiation ? 'none' : 'set')));
// Check language providers settings.
- $this->assertFalse(variable_get('locale_language_negotiation_url_part', FALSE), t('URL language provider indicator settings cleared.'));
- $this->assertFalse(variable_get('locale_language_negotiation_session_param', FALSE), t('Visit language provider settings cleared.'));
+ $this->assertFalse(variable_get('locale_language_negotiation_url_part', FALSE), 'URL language provider indicator settings cleared.');
+ $this->assertFalse(variable_get('locale_language_negotiation_session_param', FALSE), 'Visit language provider settings cleared.');
// Check JavaScript parsed.
$javascript_parsed_count = count(variable_get('javascript_parsed', array()));
- $this->assertEqual($javascript_parsed_count, 0, t('JavaScript parsed count: %count', array('%count' => $javascript_parsed_count)));
+ $this->assertEqual($javascript_parsed_count, 0, format_string('JavaScript parsed count: %count', array('%count' => $javascript_parsed_count)));
// Check multilingual workflow option for articles.
$multilingual = variable_get('language_content_type_article', 0);
- $this->assertEqual($multilingual, 0, t('Multilingual workflow option: %status', array('%status' => t($multilingual ? 'enabled': 'disabled'))));
+ $this->assertEqual($multilingual, 0, format_string('Multilingual workflow option: %status', array('%status' => $multilingual ? 'enabled': 'disabled')));
// Check JavaScript translations directory.
$locale_js_directory = variable_get('locale_js_directory', 'languages');
- $this->assertEqual($locale_js_directory, 'languages', t('JavaScript translations directory: %dir', array('%dir' => $locale_js_directory)));
+ $this->assertEqual($locale_js_directory, 'languages', format_string('JavaScript translations directory: %dir', array('%dir' => $locale_js_directory)));
// Check string caching.
$locale_cache_strings = variable_get('locale_cache_strings', 1);
- $this->assertEqual($locale_cache_strings, 1, t('String caching: %status', array('%status' => t($locale_cache_strings ? 'enabled': 'disabled'))));
+ $this->assertEqual($locale_cache_strings, 1, format_string('String caching: %status', array('%status' => $locale_cache_strings ? 'enabled': 'disabled')));
}
}
@@ -1600,7 +1600,7 @@ class LocaleLanguageSwitchingFunctionalTest extends DrupalWebTestCase {
// Assert that the language switching block is displayed on the frontpage.
$this->drupalGet('');
- $this->assertText(t('Languages'), t('Language switcher block found.'));
+ $this->assertText(t('Languages'), 'Language switcher block found.');
// Assert that only the current language is marked as active.
list($language_switcher) = $this->xpath('//div[@id=:id]/div[@class="content"]', array(':id' => 'block-locale-' . $language_type));
@@ -1629,8 +1629,8 @@ class LocaleLanguageSwitchingFunctionalTest extends DrupalWebTestCase {
$anchors['inactive'][] = $language;
}
}
- $this->assertIdentical($links, array('active' => array('en'), 'inactive' => array('fr')), t('Only the current language list item is marked as active on the language switcher block.'));
- $this->assertIdentical($anchors, array('active' => array('en'), 'inactive' => array('fr')), t('Only the current language anchor is marked as active on the language switcher block.'));
+ $this->assertIdentical($links, array('active' => array('en'), 'inactive' => array('fr')), 'Only the current language list item is marked as active on the language switcher block.');
+ $this->assertIdentical($anchors, array('active' => array('en'), 'inactive' => array('fr')), 'Only the current language anchor is marked as active on the language switcher block.');
}
}
@@ -1749,7 +1749,7 @@ class LocaleBrowserDetectionTest extends DrupalUnitTestCase {
foreach ($test_cases as $accept_language => $expected_result) {
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = $accept_language;
$result = locale_language_from_browser($languages);
- $this->assertIdentical($result, $expected_result, t("Language selection '@accept-language' selects '@result', result = '@actual'", array('@accept-language' => $accept_language, '@result' => $expected_result, '@actual' => isset($result) ? $result : 'none')));
+ $this->assertIdentical($result, $expected_result, format_string("Language selection '@accept-language' selects '@result', result = '@actual'", array('@accept-language' => $accept_language, '@result' => $expected_result, '@actual' => isset($result) ? $result : 'none')));
}
}
}
@@ -1829,21 +1829,21 @@ class LocaleUserLanguageFunctionalTest extends DrupalWebTestCase {
$path = 'user/' . $web_user->uid . '/edit';
$this->drupalGet($path);
// Ensure language settings fieldset is available.
- $this->assertText(t('Language settings'), t('Language settings available.'));
+ $this->assertText(t('Language settings'), 'Language settings available.');
// Ensure custom language is present.
- $this->assertText($name, t('Language present on form.'));
+ $this->assertText($name, 'Language present on form.');
// Ensure disabled language isn't present.
- $this->assertNoText($name_disabled, t('Disabled language not present on form.'));
+ $this->assertNoText($name_disabled, 'Disabled language not present on form.');
// Switch to our custom language.
$edit = array(
'language' => $langcode,
);
$this->drupalPost($path, $edit, t('Save'));
// Ensure form was submitted successfully.
- $this->assertText(t('The changes have been saved.'), t('Changes were saved.'));
+ $this->assertText(t('The changes have been saved.'), 'Changes were saved.');
// Check if language was changed.
$elements = $this->xpath('//input[@id=:id]', array(':id' => 'edit-language-' . $langcode));
- $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), t('Default language successfully updated.'));
+ $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), 'Default language successfully updated.');
$this->drupalLogout();
}
@@ -1881,20 +1881,20 @@ class LocaleUserCreationTest extends DrupalWebTestCase {
'langcode' => 'fr',
);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
- $this->assertText($langcode, t('Language added successfully.'));
- $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
+ $this->assertText($langcode, 'Language added successfully.');
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Correct page redirection.');
// Set language negotiation.
$edit = array(
'language[enabled][locale-url]' => TRUE,
);
$this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
- $this->assertText(t('Language negotiation configuration saved.'), t('Set language negotiation.'));
+ $this->assertText(t('Language negotiation configuration saved.'), 'Set language negotiation.');
// Check if the language selector is available on admin/people/create and
// set to the currently active language.
$this->drupalGet($langcode . '/admin/people/create');
- $this->assertFieldChecked("edit-language-$langcode", t('Global language set in the language selector.'));
+ $this->assertFieldChecked("edit-language-$langcode", 'Global language set in the language selector.');
// Create a user with the admin/people/create form and check if the correct
// language is set.
@@ -1909,13 +1909,13 @@ class LocaleUserCreationTest extends DrupalWebTestCase {
$this->drupalPost($langcode . '/admin/people/create', $edit, t('Create new account'));
$user = user_load_by_name($username);
- $this->assertEqual($user->language, $langcode, t('New user has correct language set.'));
+ $this->assertEqual($user->language, $langcode, 'New user has correct language set.');
// Register a new user and check if the language selector is hidden.
$this->drupalLogout();
$this->drupalGet($langcode . '/user/register');
- $this->assertNoFieldByName('language[fr]', t('Language selector is not accessible.'));
+ $this->assertNoFieldByName('language[fr]', 'Language selector is not accessible.');
$username = $this->randomName(10);
$edit = array(
@@ -1926,7 +1926,7 @@ class LocaleUserCreationTest extends DrupalWebTestCase {
$this->drupalPost($langcode . '/user/register', $edit, t('Create new account'));
$user = user_load_by_name($username);
- $this->assertEqual($user->language, $langcode, t('New user has correct language set.'));
+ $this->assertEqual($user->language, $langcode, 'New user has correct language set.');
// Test if the admin can use the language selector and if the
// correct language is was saved.
@@ -1934,7 +1934,7 @@ class LocaleUserCreationTest extends DrupalWebTestCase {
$this->drupalLogin($admin_user);
$this->drupalGet($user_edit);
- $this->assertFieldChecked("edit-language-$langcode", t('Language selector is accessible and correct language is selected.'));
+ $this->assertFieldChecked("edit-language-$langcode", 'Language selector is accessible and correct language is selected.');
// Set pass_raw so we can login the new user.
$user->pass_raw = $this->randomName(10);
@@ -1947,7 +1947,7 @@ class LocaleUserCreationTest extends DrupalWebTestCase {
$this->drupalLogin($user);
$this->drupalGet($user_edit);
- $this->assertFieldChecked("edit-language-$langcode", t('Language selector is accessible and correct language is selected.'));
+ $this->assertFieldChecked("edit-language-$langcode", 'Language selector is accessible and correct language is selected.');
}
}
@@ -1999,7 +1999,7 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
// not enabled yet.
$this->drupalPost('admin/config/regional/language/configure', array(), t('Save settings'));
$this->drupalGet($prefix);
- $this->assertResponse(404, t('The "xx" front page is not available yet.'));
+ $this->assertResponse(404, 'The "xx" front page is not available yet.');
// Enable URL language detection and selection.
$edit = array('language[enabled][locale-url]' => 1);
@@ -2029,11 +2029,11 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
// Confirm English language path alias works.
$this->drupalGet($english_path);
- $this->assertText($node->title, t('English alias works.'));
+ $this->assertText($node->title, 'English alias works.');
// Confirm custom language path alias works.
$this->drupalGet($prefix . '/' . $custom_language_path);
- $this->assertText($node->title, t('Custom language alias works.'));
+ $this->assertText($node->title, 'Custom language alias works.');
// Create a custom path.
$custom_path = $this->randomName(8);
@@ -2046,10 +2046,10 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
);
path_save($edit);
$lookup_path = drupal_lookup_path('alias', 'node/' . $node->nid, 'en');
- $this->assertEqual($english_path, $lookup_path, t('English language alias has priority.'));
+ $this->assertEqual($english_path, $lookup_path, 'English language alias has priority.');
// Same check for language 'xx'.
$lookup_path = drupal_lookup_path('alias', 'node/' . $node->nid, $prefix);
- $this->assertEqual($custom_language_path, $lookup_path, t('Custom language alias has priority.'));
+ $this->assertEqual($custom_language_path, $lookup_path, 'Custom language alias has priority.');
path_delete($edit);
// Create language nodes to check priority of aliases.
@@ -2076,17 +2076,17 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
$this->drupalGet('