update to drupal 7.23
This commit is contained in:
parent
db5f70501a
commit
e539e701f8
@ -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
|
||||
|
@ -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)));
|
||||
}
|
||||
|
@ -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']));
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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".
|
||||
|
@ -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().
|
||||
*/
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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']);
|
||||
|
@ -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
|
||||
|
@ -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'])) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) {
|
||||
$('<li></li>')
|
||||
.html($('<div></div>').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)
|
||||
|
@ -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.'),
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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 <a href="@url">PHP documentation</a> 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 <a href="@url">PHP documentation</a> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
|
||||
|
@ -152,7 +152,7 @@ function comment_node_type_load($name) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity URI callback.
|
||||
* Implements callback_entity_info_uri().
|
||||
*/
|
||||
function comment_uri($comment) {
|
||||
return array(
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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('<div class="customize clearfix"><ul class="action-links"><li><a href="#">' + Drupal.t('Customize dashboard') + '</a></li></ul><div class="canvas"></div></div>');
|
||||
$('.customize .action-links a', this).click(Drupal.behaviors.dashboard.enterCustomizeMode);
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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();
|
||||
|
@ -128,7 +128,7 @@ function field_schema() {
|
||||
'not null' => TRUE,
|
||||
'default' => ''
|
||||
),
|
||||
'entity_type' => array(
|
||||
'entity_type' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 32,
|
||||
'not null' => TRUE,
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @file
|
||||
* Tests for options.module.
|
||||
*/
|
||||
|
||||
@ -85,7 +85,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
$this->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 <strong>markup</strong>', t('Option text was properly filtered.'));
|
||||
$this->assertRaw('Some dangerous & unescaped <strong>markup</strong>', '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 <strong>markup</strong>', t('Option text was properly filtered.'));
|
||||
$this->assertRaw('Some dangerous & unescaped <strong>markup</strong>', '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 <strong>markup</strong>', t('Option text was properly filtered.'));
|
||||
$this->assertRaw('Some dangerous & unescaped <strong>markup</strong>', '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'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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 = '<em>' . $this->randomName() . '</em>';
|
||||
@ -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)));
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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',
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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".
|
||||
|
@ -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'];
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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 . '</th>', t('%table_header table header was found.', array('%table_header' => $table_header)));
|
||||
$this->assertRaw($table_header . '</th>', 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.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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.');
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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 <code> and </code> tags.
|
||||
$text = preg_replace('|<code>(.+?)</code>|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', "<pre>$1</pre>", $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.');
|
||||
}
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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 <p> and <br> 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()
|
||||
*/
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,8 +9,8 @@ files[] = forum.test
|
||||
configure = admin/structure/forum
|
||||
stylesheets[all][] = forum.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"
|
||||
|
||||
|
@ -233,6 +233,8 @@ function forum_entity_info_alter(&$info) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_entity_info_uri().
|
||||
*
|
||||
* Entity URI callback used in forum_entity_info_alter().
|
||||
*/
|
||||
function forum_uri($forum) {
|
||||
|
@ -94,18 +94,18 @@ class ForumTestCase extends DrupalWebTestCase {
|
||||
$edit = array();
|
||||
$edit['modules[Core][forum][enable]'] = FALSE;
|
||||
$this->drupalPost('admin/modules', $edit, t('Save configuration'));
|
||||
$this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.'));
|
||||
$this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
|
||||
module_list(TRUE);
|
||||
$this->assertFalse(module_exists('forum'), t('Forum module is not enabled.'));
|
||||
$this->assertFalse(module_exists('forum'), 'Forum module is not enabled.');
|
||||
|
||||
// Attempt to re-enable the Forum module and ensure it does not try to
|
||||
// recreate the taxonomy_forums field.
|
||||
$edit = array();
|
||||
$edit['modules[Core][forum][enable]'] = 'forum';
|
||||
$this->drupalPost('admin/modules', $edit, t('Save configuration'));
|
||||
$this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.'));
|
||||
$this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
|
||||
module_list(TRUE);
|
||||
$this->assertTrue(module_exists('forum'), t('Forum module is enabled.'));
|
||||
$this->assertTrue(module_exists('forum'), 'Forum module is enabled.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -166,17 +166,17 @@ class ForumTestCase extends DrupalWebTestCase {
|
||||
$xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="topics"]', $forum_arg);
|
||||
$topics = $this->xpath($xpath);
|
||||
$topics = trim($topics[0]);
|
||||
$this->assertEqual($topics, '6', t('Number of topics found.'));
|
||||
$this->assertEqual($topics, '6', 'Number of topics found.');
|
||||
|
||||
// Verify the number of unread topics.
|
||||
$unread_topics = _forum_topics_unread($this->forum['tid'], $this->edit_any_topics_user->uid);
|
||||
$unread_topics = format_plural($unread_topics, '1 new', '@count new');
|
||||
$xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="topics"]//a', $forum_arg);
|
||||
$this->assertFieldByXPath($xpath, $unread_topics, t('Number of unread topics found.'));
|
||||
$this->assertFieldByXPath($xpath, $unread_topics, 'Number of unread topics found.');
|
||||
|
||||
// Verify total number of posts in forum.
|
||||
$xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="posts"]', $forum_arg);
|
||||
$this->assertFieldByXPath($xpath, '6', t('Number of posts found.'));
|
||||
$this->assertFieldByXPath($xpath, '6', 'Number of posts found.');
|
||||
|
||||
// Test loading multiple forum nodes on the front page.
|
||||
$this->drupalLogin($this->drupalCreateUser(array('administer content types', 'create forum content')));
|
||||
@ -226,7 +226,7 @@ class ForumTestCase extends DrupalWebTestCase {
|
||||
$this->drupalPost('node/add/forum', array('title' => $this->randomName(10), 'body[' . LANGUAGE_NONE .'][0][value]' => $this->randomName(120)), t('Save'));
|
||||
|
||||
$nid_count = db_query('SELECT COUNT(nid) FROM {node}')->fetchField();
|
||||
$this->assertEqual(0, $nid_count, t('A forum node was not created when missing a forum vocabulary.'));
|
||||
$this->assertEqual(0, $nid_count, 'A forum node was not created when missing a forum vocabulary.');
|
||||
|
||||
// Reset the defaults for future tests.
|
||||
module_enable(array('forum'));
|
||||
@ -247,14 +247,14 @@ class ForumTestCase extends DrupalWebTestCase {
|
||||
$edit['blocks[forum_active][region]'] = 'sidebar_second';
|
||||
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
|
||||
$this->assertResponse(200);
|
||||
$this->assertText(t('The block settings have been updated.'), t('Active forum topics forum block was enabled'));
|
||||
$this->assertText(t('The block settings have been updated.'), 'Active forum topics forum block was enabled');
|
||||
|
||||
// Enable the new forum block.
|
||||
$edit = array();
|
||||
$edit['blocks[forum_new][region]'] = 'sidebar_second';
|
||||
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
|
||||
$this->assertResponse(200);
|
||||
$this->assertText(t('The block settings have been updated.'), t('[New forum topics] Forum block was enabled'));
|
||||
$this->assertText(t('The block settings have been updated.'), '[New forum topics] Forum block was enabled');
|
||||
|
||||
// Retrieve forum menu id.
|
||||
$mlid = db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = 'forum' AND menu_name = 'navigation' AND module = 'system' ORDER BY mlid ASC", 0, 1)->fetchField();
|
||||
@ -272,13 +272,13 @@ class ForumTestCase extends DrupalWebTestCase {
|
||||
// Verify "edit container" link exists and functions correctly.
|
||||
$this->drupalGet('admin/structure/forum');
|
||||
$this->clickLink('edit container');
|
||||
$this->assertRaw('Edit container', t('Followed the link to edit the container'));
|
||||
$this->assertRaw('Edit container', 'Followed the link to edit the container');
|
||||
// Create forum inside the forum container.
|
||||
$this->forum = $this->createForum('forum', $this->container['tid']);
|
||||
// Verify the "edit forum" link exists and functions correctly.
|
||||
$this->drupalGet('admin/structure/forum');
|
||||
$this->clickLink('edit forum');
|
||||
$this->assertRaw('Edit forum', t('Followed the link to edit the forum'));
|
||||
$this->assertRaw('Edit forum', 'Followed the link to edit the forum');
|
||||
// Navigate back to forum structure page.
|
||||
$this->drupalGet('admin/structure/forum');
|
||||
// Create second forum in container.
|
||||
@ -334,15 +334,15 @@ class ForumTestCase extends DrupalWebTestCase {
|
||||
// Edit the vocabulary.
|
||||
$this->drupalPost('admin/structure/taxonomy/' . $original_settings->machine_name . '/edit', $edit, t('Save'));
|
||||
$this->assertResponse(200);
|
||||
$this->assertRaw(t('Updated vocabulary %name.', array('%name' => $title)), t('Vocabulary was edited'));
|
||||
$this->assertRaw(t('Updated vocabulary %name.', array('%name' => $title)), 'Vocabulary was edited');
|
||||
|
||||
// Grab the newly edited vocabulary.
|
||||
entity_get_controller('taxonomy_vocabulary')->resetCache();
|
||||
$current_settings = taxonomy_vocabulary_load($vid);
|
||||
|
||||
// Make sure we actually edited the vocabulary properly.
|
||||
$this->assertEqual($current_settings->name, $title, t('The name was updated'));
|
||||
$this->assertEqual($current_settings->description, $description, t('The description was updated'));
|
||||
$this->assertEqual($current_settings->name, $title, 'The name was updated');
|
||||
$this->assertEqual($current_settings->description, $description, 'The description was updated');
|
||||
|
||||
// Restore the original vocabulary.
|
||||
taxonomy_vocabulary_save($original_settings);
|
||||
@ -379,7 +379,7 @@ class ForumTestCase extends DrupalWebTestCase {
|
||||
$this->drupalPost('admin/structure/forum/add/' . $type, $edit, t('Save'));
|
||||
$this->assertResponse(200);
|
||||
$type = ($type == 'container') ? 'forum container' : 'forum';
|
||||
$this->assertRaw(t('Created new @type %term.', array('%term' => $name, '@type' => t($type))), t(ucfirst($type) . ' was created'));
|
||||
$this->assertRaw(t('Created new @type %term.', array('%term' => $name, '@type' => t($type))), format_string('@type was created', array('@type' => ucfirst($type))));
|
||||
|
||||
// Verify forum.
|
||||
$term = db_query("SELECT * FROM {taxonomy_term_data} t WHERE t.vid = :vid AND t.name = :name AND t.description = :desc", array(':vid' => variable_get('forum_nav_vocabulary', ''), ':name' => $name, ':desc' => $description))->fetchAssoc();
|
||||
@ -461,24 +461,24 @@ class ForumTestCase extends DrupalWebTestCase {
|
||||
|
||||
$type = t('Forum topic');
|
||||
if ($container) {
|
||||
$this->assertNoRaw(t('@type %title has been created.', array('@type' => $type, '%title' => $title)), t('Forum topic was not created'));
|
||||
$this->assertRaw(t('The item %title is a forum container, not a forum.', array('%title' => $forum['name'])), t('Error message was shown'));
|
||||
$this->assertNoRaw(t('@type %title has been created.', array('@type' => $type, '%title' => $title)), 'Forum topic was not created');
|
||||
$this->assertRaw(t('The item %title is a forum container, not a forum.', array('%title' => $forum['name'])), 'Error message was shown');
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$this->assertRaw(t('@type %title has been created.', array('@type' => $type, '%title' => $title)), t('Forum topic was created'));
|
||||
$this->assertNoRaw(t('The item %title is a forum container, not a forum.', array('%title' => $forum['name'])), t('No error message was shown'));
|
||||
$this->assertRaw(t('@type %title has been created.', array('@type' => $type, '%title' => $title)), 'Forum topic was created');
|
||||
$this->assertNoRaw(t('The item %title is a forum container, not a forum.', array('%title' => $forum['name'])), 'No error message was shown');
|
||||
}
|
||||
|
||||
// Retrieve node object, ensure that the topic was created and in the proper forum.
|
||||
$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)));
|
||||
$this->assertEqual($node->taxonomy_forums[LANGUAGE_NONE][0]['tid'], $tid, 'Saved forum topic was in the expected forum');
|
||||
|
||||
// View forum topic.
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertRaw($title, t('Subject was found'));
|
||||
$this->assertRaw($body, t('Body was found'));
|
||||
$this->assertRaw($title, 'Subject was found');
|
||||
$this->assertRaw($body, 'Body was found');
|
||||
|
||||
return $node;
|
||||
}
|
||||
@ -502,14 +502,14 @@ class ForumTestCase extends DrupalWebTestCase {
|
||||
$this->drupalGet('admin/help/forum');
|
||||
$this->assertResponse($response2);
|
||||
if ($response2 == 200) {
|
||||
$this->assertTitle(t('Forum | Drupal'), t('Forum help title was displayed'));
|
||||
$this->assertText(t('Forum'), t('Forum help node was displayed'));
|
||||
$this->assertTitle(t('Forum | Drupal'), 'Forum help title was displayed');
|
||||
$this->assertText(t('Forum'), 'Forum help node was displayed');
|
||||
}
|
||||
|
||||
// Verify the forum blocks were displayed.
|
||||
$this->drupalGet('');
|
||||
$this->assertResponse(200);
|
||||
$this->assertText(t('New forum topics'), t('[New forum topics] Forum block was displayed'));
|
||||
$this->assertText(t('New forum topics'), '[New forum topics] Forum block was displayed');
|
||||
|
||||
// View forum container page.
|
||||
$this->verifyForumView($this->container);
|
||||
@ -521,20 +521,20 @@ class ForumTestCase extends DrupalWebTestCase {
|
||||
// View forum node.
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertResponse(200);
|
||||
$this->assertTitle($node->title . ' | Drupal', t('Forum node was displayed'));
|
||||
$this->assertTitle($node->title . ' | Drupal', 'Forum node was displayed');
|
||||
$breadcrumb = array(
|
||||
l(t('Home'), NULL),
|
||||
l(t('Forums'), 'forum'),
|
||||
l($this->container['name'], 'forum/' . $this->container['tid']),
|
||||
l($this->forum['name'], 'forum/' . $this->forum['tid']),
|
||||
);
|
||||
$this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)), t('Breadcrumbs were displayed'));
|
||||
$this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)), 'Breadcrumbs were displayed');
|
||||
|
||||
// View forum edit node.
|
||||
$this->drupalGet('node/' . $node->nid . '/edit');
|
||||
$this->assertResponse($response);
|
||||
if ($response == 200) {
|
||||
$this->assertTitle('Edit Forum topic ' . $node->title . ' | Drupal', t('Forum edit node was displayed'));
|
||||
$this->assertTitle('Edit Forum topic ' . $node->title . ' | Drupal', 'Forum edit node was displayed');
|
||||
}
|
||||
|
||||
if ($response == 200) {
|
||||
@ -547,7 +547,7 @@ class ForumTestCase extends DrupalWebTestCase {
|
||||
$edit["taxonomy_forums[$langcode]"] = $this->root_forum['tid'];
|
||||
$edit['shadow'] = TRUE;
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
||||
$this->assertRaw(t('Forum topic %title has been updated.', array('%title' => $edit["title"])), t('Forum node was edited'));
|
||||
$this->assertRaw(t('Forum topic %title has been updated.', array('%title' => $edit["title"])), 'Forum node was edited');
|
||||
|
||||
// Verify topic was moved to a different forum.
|
||||
$forum_tid = db_query("SELECT tid FROM {forum} WHERE nid = :nid AND vid = :vid", array(
|
||||
@ -559,7 +559,7 @@ class ForumTestCase extends DrupalWebTestCase {
|
||||
// Delete forum node.
|
||||
$this->drupalPost('node/' . $node->nid . '/delete', array(), t('Delete'));
|
||||
$this->assertResponse($response);
|
||||
$this->assertRaw(t('Forum topic %title has been deleted.', array('%title' => $edit['title'])), t('Forum node was deleted'));
|
||||
$this->assertRaw(t('Forum topic %title has been deleted.', array('%title' => $edit['title'])), 'Forum node was deleted');
|
||||
}
|
||||
}
|
||||
|
||||
@ -575,7 +575,7 @@ class ForumTestCase extends DrupalWebTestCase {
|
||||
// View forum page.
|
||||
$this->drupalGet('forum/' . $forum['tid']);
|
||||
$this->assertResponse(200);
|
||||
$this->assertTitle($forum['name'] . ' | Drupal', t('Forum name was displayed'));
|
||||
$this->assertTitle($forum['name'] . ' | Drupal', 'Forum name was displayed');
|
||||
|
||||
$breadcrumb = array(
|
||||
l(t('Home'), NULL),
|
||||
@ -585,7 +585,7 @@ class ForumTestCase extends DrupalWebTestCase {
|
||||
$breadcrumb[] = l($parent['name'], 'forum/' . $parent['tid']);
|
||||
}
|
||||
|
||||
$this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)), t('Breadcrumbs were displayed'));
|
||||
$this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)), 'Breadcrumbs were displayed');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
files[] = help.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"
|
||||
|
||||
|
@ -52,17 +52,17 @@ class HelpTestCase extends DrupalWebTestCase {
|
||||
// Check for css on admin/help.
|
||||
$this->drupalLogin($this->big_user);
|
||||
$this->drupalGet('admin/help');
|
||||
$this->assertRaw(drupal_get_path('module', 'help') . '/help.css', t('The help.css file is present in the HTML.'));
|
||||
$this->assertRaw(drupal_get_path('module', 'help') . '/help.css', 'The help.css file is present in the HTML.');
|
||||
|
||||
// Verify that introductory help text exists, goes for 100% module coverage.
|
||||
$this->assertRaw(t('For more information, refer to the specific topics listed in the next section or to the <a href="@drupal">online Drupal handbooks</a>.', array('@drupal' => 'http://drupal.org/documentation')), 'Help intro text correctly appears.');
|
||||
|
||||
// Verify that help topics text appears.
|
||||
$this->assertRaw('<h2>' . t('Help topics') . '</h2><p>' . t('Help is available on the following items:') . '</p>', t('Help topics text correctly appears.'));
|
||||
$this->assertRaw('<h2>' . t('Help topics') . '</h2><p>' . t('Help is available on the following items:') . '</p>', 'Help topics text correctly appears.');
|
||||
|
||||
// Make sure links are properly added for modules implementing hook_help().
|
||||
foreach ($this->modules as $module => $name) {
|
||||
$this->assertLink($name, 0, t('Link properly added to @name (admin/help/@module)', array('@module' => $module, '@name' => $name)));
|
||||
$this->assertLink($name, 0, format_string('Link properly added to @name (admin/help/@module)', array('@module' => $module, '@name' => $name)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,8 +78,8 @@ class HelpTestCase extends DrupalWebTestCase {
|
||||
$this->drupalGet('admin/help/' . $module);
|
||||
$this->assertResponse($response);
|
||||
if ($response == 200) {
|
||||
$this->assertTitle($name . ' | Drupal', t('[' . $module . '] Title was displayed'));
|
||||
$this->assertRaw('<h1 class="page-title">' . t($name) . '</h1>', t('[' . $module . '] Heading was displayed'));
|
||||
$this->assertTitle($name . ' | Drupal', format_string('%module title was displayed', array('%module' => $module)));
|
||||
$this->assertRaw('<h1 class="page-title">' . t($name) . '</h1>', 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');
|
||||
}
|
||||
}
|
||||
|
@ -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 .= '<div class="preview-image-wrapper">';
|
||||
$output .= check_plain($style['name']) . ' (' . l(t('view actual size'), file_create_url($preview_file) . '?' . time()) . ')';
|
||||
$output .= check_plain($style['label']) . ' (' . l(t('view actual size'), file_create_url($preview_file) . '?' . time()) . ')';
|
||||
$output .= '<div class="preview-image modified-image" style="' . $preview_attributes['style'] . '">';
|
||||
$output .= '<a href="' . file_create_url($preview_file) . '?' . time() . '">' . theme('image', array('path' => $preview_url, 'alt' => t('Sample modified image'), 'title' => '', 'attributes' => $preview_attributes)) . '</a>';
|
||||
$output .= '<div class="height" style="height: ' . $preview_height . 'px"><span>' . $preview_image['height'] . 'px</span></div>';
|
||||
|
@ -177,6 +177,7 @@ function hook_image_default_styles() {
|
||||
$styles = array();
|
||||
|
||||
$styles['mymodule_preview'] = array(
|
||||
'label' => 'My module preview',
|
||||
'effects' => array(
|
||||
array(
|
||||
'name' => 'image_scale',
|
||||
|
@ -311,7 +311,7 @@ function image_field_widget_settings_form($field, $instance) {
|
||||
$form['preview_image_style'] = array(
|
||||
'#title' => t('Preview image style'),
|
||||
'#type' => 'select',
|
||||
'#options' => image_style_options(FALSE),
|
||||
'#options' => image_style_options(FALSE, PASS_THROUGH),
|
||||
'#empty_option' => '<' . t('no preview') . '>',
|
||||
'#default_value' => $settings['preview_image_style'],
|
||||
'#description' => t('The preview image will be shown while editing the content.'),
|
||||
@ -495,7 +495,7 @@ function image_field_formatter_settings_form($field, $instance, $view_mode, $for
|
||||
$display = $instance['display'][$view_mode];
|
||||
$settings = $display['settings'];
|
||||
|
||||
$image_styles = image_style_options(FALSE);
|
||||
$image_styles = image_style_options(FALSE, PASS_THROUGH);
|
||||
$element['image_style'] = array(
|
||||
'#title' => t('Image style'),
|
||||
'#type' => 'select',
|
||||
@ -528,7 +528,7 @@ function image_field_formatter_settings_summary($field, $instance, $view_mode) {
|
||||
|
||||
$summary = array();
|
||||
|
||||
$image_styles = image_style_options(FALSE);
|
||||
$image_styles = image_style_options(FALSE, PASS_THROUGH);
|
||||
// Unset possible 'No defined styles' option.
|
||||
unset($image_styles['']);
|
||||
// Styles could be lost because of enabled/disabled modules that defines
|
||||
|
@ -7,8 +7,8 @@ dependencies[] = file
|
||||
files[] = image.test
|
||||
configure = admin/config/media/image-styles
|
||||
|
||||
; 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"
|
||||
|
||||
|
@ -41,11 +41,18 @@ function image_schema() {
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => 'The style name.',
|
||||
'description' => 'The style machine name.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'label' => array(
|
||||
'description' => 'The style administrative name.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
),
|
||||
'primary key' => array('isid'),
|
||||
'unique keys' => array(
|
||||
@ -448,6 +455,30 @@ function image_update_7004() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a column to the 'image_style' table to store administrative labels.
|
||||
*/
|
||||
function image_update_7005() {
|
||||
$field = array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
'description' => 'The style administrative name.',
|
||||
);
|
||||
db_add_field('image_styles', 'label', $field);
|
||||
|
||||
// Do a direct query here, rather than calling image_styles(),
|
||||
// in case Image module is disabled.
|
||||
$styles = db_query('SELECT name FROM {image_styles}')->fetchCol();
|
||||
foreach ($styles as $style) {
|
||||
db_update('image_styles')
|
||||
->fields(array('label' => $style))
|
||||
->condition('name', $style)
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup updates-7.x-extra".
|
||||
*/
|
||||
|
@ -347,6 +347,7 @@ function image_image_default_styles() {
|
||||
$styles = array();
|
||||
|
||||
$styles['thumbnail'] = array(
|
||||
'label' => 'Thumbnail (100x100)',
|
||||
'effects' => array(
|
||||
array(
|
||||
'name' => 'image_scale',
|
||||
@ -357,6 +358,7 @@ function image_image_default_styles() {
|
||||
);
|
||||
|
||||
$styles['medium'] = array(
|
||||
'label' => 'Medium (220x220)',
|
||||
'effects' => array(
|
||||
array(
|
||||
'name' => 'image_scale',
|
||||
@ -367,6 +369,7 @@ function image_image_default_styles() {
|
||||
);
|
||||
|
||||
$styles['large'] = array(
|
||||
'label' => 'Large (480x480)',
|
||||
'effects' => array(
|
||||
array(
|
||||
'name' => 'image_scale',
|
||||
@ -575,6 +578,7 @@ function image_styles() {
|
||||
$module_styles = module_invoke($module, 'image_default_styles');
|
||||
foreach ($module_styles as $style_name => $style) {
|
||||
$style['name'] = $style_name;
|
||||
$style['label'] = empty($style['label']) ? $style_name : $style['label'];
|
||||
$style['module'] = $module;
|
||||
$style['storage'] = IMAGE_STORAGE_DEFAULT;
|
||||
foreach ($style['effects'] as $key => $effect) {
|
||||
@ -689,6 +693,10 @@ function image_style_save($style) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Add a default label when not given.
|
||||
if (empty($style['label'])) {
|
||||
$style['label'] = $style['name'];
|
||||
}
|
||||
drupal_write_record('image_styles', $style);
|
||||
$style['is_new'] = TRUE;
|
||||
}
|
||||
@ -758,20 +766,28 @@ function image_style_effects($style) {
|
||||
*
|
||||
* @param $include_empty
|
||||
* If TRUE a <none> option will be inserted in the options array.
|
||||
* @param $output
|
||||
* Optional flag determining how the options will be sanitized on output.
|
||||
* Leave this at the default (CHECK_PLAIN) if you are using the output of
|
||||
* this function directly in an HTML context, such as for checkbox or radio
|
||||
* button labels, and do not plan to sanitize it on your own. If using the
|
||||
* output of this function as select list options (its primary use case), you
|
||||
* should instead set this flag to PASS_THROUGH to avoid double-escaping of
|
||||
* the output (the form API sanitizes select list options by default).
|
||||
*
|
||||
* @return
|
||||
* Array of image styles both key and value are set to style name.
|
||||
* Array of image styles with the machine name as key and the label as value.
|
||||
*/
|
||||
function image_style_options($include_empty = TRUE) {
|
||||
function image_style_options($include_empty = TRUE, $output = CHECK_PLAIN) {
|
||||
$styles = image_styles();
|
||||
$options = array();
|
||||
if ($include_empty && !empty($styles)) {
|
||||
$options[''] = t('<none>');
|
||||
}
|
||||
// Use the array concatenation operator '+' here instead of array_merge(),
|
||||
// because the latter loses the datatype of the array keys, turning
|
||||
// associative string keys into numeric ones without warning.
|
||||
$options = $options + drupal_map_assoc(array_keys($styles));
|
||||
foreach ($styles as $name => $style) {
|
||||
$options[$name] = ($output == PASS_THROUGH) ? $style['label'] : check_plain($style['label']);
|
||||
}
|
||||
|
||||
if (empty($options)) {
|
||||
$options[''] = t('No defined styles');
|
||||
}
|
||||
@ -953,9 +969,10 @@ function image_style_transform_dimensions($style_name, array &$dimensions) {
|
||||
* An image style array.
|
||||
*/
|
||||
function image_style_flush($style) {
|
||||
$style_directory = drupal_realpath(file_default_scheme() . '://styles/' . $style['name']);
|
||||
if (is_dir($style_directory)) {
|
||||
file_unmanaged_delete_recursive($style_directory);
|
||||
// Delete the style directory in each registered wrapper.
|
||||
$wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE);
|
||||
foreach ($wrappers as $wrapper => $wrapper_data) {
|
||||
file_unmanaged_delete_recursive($wrapper . '://styles/' . $style['name']);
|
||||
}
|
||||
|
||||
// Let other modules update as necessary on flush.
|
||||
|
@ -17,7 +17,6 @@
|
||||
* image_style_save()
|
||||
* image_style_delete()
|
||||
* image_style_options()
|
||||
* image_style_flush()
|
||||
* image_effect_definition_load()
|
||||
* image_effect_load()
|
||||
* image_effect_save()
|
||||
@ -122,7 +121,7 @@ class ImageStylesPathAndUrlTestCase extends DrupalWebTestCase {
|
||||
parent::setUp('image_module_test');
|
||||
|
||||
$this->style_name = 'style_foo';
|
||||
image_style_save(array('name' => $this->style_name));
|
||||
image_style_save(array('name' => $this->style_name, 'label' => $this->randomString()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,11 +131,11 @@ class ImageStylesPathAndUrlTestCase extends DrupalWebTestCase {
|
||||
$scheme = 'public';
|
||||
$actual = image_style_path($this->style_name, "$scheme://foo/bar.gif");
|
||||
$expected = "$scheme://styles/" . $this->style_name . "/$scheme/foo/bar.gif";
|
||||
$this->assertEqual($actual, $expected, t('Got the path for a file URI.'));
|
||||
$this->assertEqual($actual, $expected, 'Got the path for a file URI.');
|
||||
|
||||
$actual = image_style_path($this->style_name, 'foo/bar.gif');
|
||||
$expected = "$scheme://styles/" . $this->style_name . "/$scheme/foo/bar.gif";
|
||||
$this->assertEqual($actual, $expected, t('Got the path for a relative file path.'));
|
||||
$this->assertEqual($actual, $expected, 'Got the path for a relative file path.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,7 +185,7 @@ class ImageStylesPathAndUrlTestCase extends DrupalWebTestCase {
|
||||
// Create the directories for the styles.
|
||||
$directory = $scheme . '://styles/' . $this->style_name;
|
||||
$status = file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
|
||||
$this->assertNotIdentical(FALSE, $status, t('Created the directory for the generated images for the test style.'));
|
||||
$this->assertNotIdentical(FALSE, $status, 'Created the directory for the generated images for the test style.');
|
||||
|
||||
// Create a working copy of the file.
|
||||
$files = $this->drupalGetTestFiles('image');
|
||||
@ -196,11 +195,11 @@ class ImageStylesPathAndUrlTestCase extends DrupalWebTestCase {
|
||||
// Let the image_module_test module know about this file, so it can claim
|
||||
// ownership in hook_file_download().
|
||||
variable_set('image_module_test_file_download', $original_uri);
|
||||
$this->assertNotIdentical(FALSE, $original_uri, t('Created the generated image file.'));
|
||||
$this->assertNotIdentical(FALSE, $original_uri, 'Created the generated image file.');
|
||||
|
||||
// Get the URL of a file that has not been generated and try to create it.
|
||||
$generated_uri = image_style_path($this->style_name, $original_uri);
|
||||
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
|
||||
$this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.');
|
||||
$generate_url = image_style_url($this->style_name, $original_uri);
|
||||
|
||||
// Ensure that the tests still pass when the file is generated by accessing
|
||||
@ -224,21 +223,21 @@ class ImageStylesPathAndUrlTestCase extends DrupalWebTestCase {
|
||||
|
||||
// Fetch the URL that generates the file.
|
||||
$this->drupalGet($generate_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->assertRaw(file_get_contents($generated_uri), t('URL returns expected file.'));
|
||||
$this->assertResponse(200, 'Image was generated at the URL.');
|
||||
$this->assertTrue(file_exists($generated_uri), 'Generated file does exist after we accessed it.');
|
||||
$this->assertRaw(file_get_contents($generated_uri), 'URL returns expected file.');
|
||||
$generated_image_info = image_get_info($generated_uri);
|
||||
$this->assertEqual($this->drupalGetHeader('Content-Type'), $generated_image_info['mime_type'], t('Expected Content-Type was reported.'));
|
||||
$this->assertEqual($this->drupalGetHeader('Content-Length'), $generated_image_info['file_size'], t('Expected Content-Length was reported.'));
|
||||
$this->assertEqual($this->drupalGetHeader('Content-Type'), $generated_image_info['mime_type'], 'Expected Content-Type was reported.');
|
||||
$this->assertEqual($this->drupalGetHeader('Content-Length'), $generated_image_info['file_size'], 'Expected Content-Length was reported.');
|
||||
if ($scheme == 'private') {
|
||||
$this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', t('Expires header was sent.'));
|
||||
$this->assertEqual($this->drupalGetHeader('Cache-Control'), 'no-cache, must-revalidate, post-check=0, pre-check=0', t('Cache-Control header was set to prevent caching.'));
|
||||
$this->assertEqual($this->drupalGetHeader('X-Image-Owned-By'), 'image_module_test', t('Expected custom header has been added.'));
|
||||
$this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.');
|
||||
$this->assertEqual($this->drupalGetHeader('Cache-Control'), 'no-cache, must-revalidate, post-check=0, pre-check=0', 'Cache-Control header was set to prevent caching.');
|
||||
$this->assertEqual($this->drupalGetHeader('X-Image-Owned-By'), 'image_module_test', 'Expected custom header has been added.');
|
||||
|
||||
// Make sure that a second request to the already existing derivate works
|
||||
// too.
|
||||
$this->drupalGet($generate_url);
|
||||
$this->assertResponse(200, t('Image was generated at the URL.'));
|
||||
$this->assertResponse(200, 'Image was generated at the URL.');
|
||||
|
||||
// Make sure that access is denied for existing style files if we do not
|
||||
// have access.
|
||||
@ -251,11 +250,11 @@ class ImageStylesPathAndUrlTestCase extends DrupalWebTestCase {
|
||||
$file_noaccess = array_shift($files);
|
||||
$original_uri_noaccess = file_unmanaged_copy($file_noaccess->uri, $scheme . '://', FILE_EXISTS_RENAME);
|
||||
$generated_uri_noaccess = $scheme . '://styles/' . $this->style_name . '/' . $scheme . '/'. drupal_basename($original_uri_noaccess);
|
||||
$this->assertFalse(file_exists($generated_uri_noaccess), t('Generated file does not exist.'));
|
||||
$this->assertFalse(file_exists($generated_uri_noaccess), 'Generated file does not exist.');
|
||||
$generate_url_noaccess = image_style_url($this->style_name, $original_uri_noaccess);
|
||||
|
||||
$this->drupalGet($generate_url_noaccess);
|
||||
$this->assertResponse(403, t('Confirmed that access is denied for the private image style.') );
|
||||
$this->assertResponse(403, 'Confirmed that access is denied for the private image style.');
|
||||
// Verify that images are not appended to the response. Currently this test only uses PNG images.
|
||||
if (strpos($generate_url, '.png') === FALSE ) {
|
||||
$this->fail('Confirming that private image styles are not appended require PNG file.');
|
||||
@ -341,13 +340,13 @@ class ImageEffectsUnitTest extends ImageToolkitTestCase {
|
||||
* Test the image_resize_effect() function.
|
||||
*/
|
||||
function testResizeEffect() {
|
||||
$this->assertTrue(image_resize_effect($this->image, array('width' => 1, 'height' => 2)), t('Function returned the expected value.'));
|
||||
$this->assertTrue(image_resize_effect($this->image, array('width' => 1, 'height' => 2)), 'Function returned the expected value.');
|
||||
$this->assertToolkitOperationsCalled(array('resize'));
|
||||
|
||||
// Check the parameters.
|
||||
$calls = image_test_get_all_calls();
|
||||
$this->assertEqual($calls['resize'][0][1], 1, t('Width was passed correctly'));
|
||||
$this->assertEqual($calls['resize'][0][2], 2, t('Height was passed correctly'));
|
||||
$this->assertEqual($calls['resize'][0][1], 1, 'Width was passed correctly');
|
||||
$this->assertEqual($calls['resize'][0][2], 2, 'Height was passed correctly');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -355,13 +354,13 @@ class ImageEffectsUnitTest extends ImageToolkitTestCase {
|
||||
*/
|
||||
function testScaleEffect() {
|
||||
// @todo: need to test upscaling.
|
||||
$this->assertTrue(image_scale_effect($this->image, array('width' => 10, 'height' => 10)), t('Function returned the expected value.'));
|
||||
$this->assertTrue(image_scale_effect($this->image, array('width' => 10, 'height' => 10)), 'Function returned the expected value.');
|
||||
$this->assertToolkitOperationsCalled(array('resize'));
|
||||
|
||||
// Check the parameters.
|
||||
$calls = image_test_get_all_calls();
|
||||
$this->assertEqual($calls['resize'][0][1], 10, t('Width was passed correctly'));
|
||||
$this->assertEqual($calls['resize'][0][2], 5, t('Height was based off aspect ratio and passed correctly'));
|
||||
$this->assertEqual($calls['resize'][0][1], 10, 'Width was passed correctly');
|
||||
$this->assertEqual($calls['resize'][0][2], 5, 'Height was based off aspect ratio and passed correctly');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -369,42 +368,42 @@ class ImageEffectsUnitTest extends ImageToolkitTestCase {
|
||||
*/
|
||||
function testCropEffect() {
|
||||
// @todo should test the keyword offsets.
|
||||
$this->assertTrue(image_crop_effect($this->image, array('anchor' => 'top-1', 'width' => 3, 'height' => 4)), t('Function returned the expected value.'));
|
||||
$this->assertTrue(image_crop_effect($this->image, array('anchor' => 'top-1', 'width' => 3, 'height' => 4)), 'Function returned the expected value.');
|
||||
$this->assertToolkitOperationsCalled(array('crop'));
|
||||
|
||||
// Check the parameters.
|
||||
$calls = image_test_get_all_calls();
|
||||
$this->assertEqual($calls['crop'][0][1], 0, t('X was passed correctly'));
|
||||
$this->assertEqual($calls['crop'][0][2], 1, t('Y was passed correctly'));
|
||||
$this->assertEqual($calls['crop'][0][3], 3, t('Width was passed correctly'));
|
||||
$this->assertEqual($calls['crop'][0][4], 4, t('Height was passed correctly'));
|
||||
$this->assertEqual($calls['crop'][0][1], 0, 'X was passed correctly');
|
||||
$this->assertEqual($calls['crop'][0][2], 1, 'Y was passed correctly');
|
||||
$this->assertEqual($calls['crop'][0][3], 3, 'Width was passed correctly');
|
||||
$this->assertEqual($calls['crop'][0][4], 4, 'Height was passed correctly');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the image_scale_and_crop_effect() function.
|
||||
*/
|
||||
function testScaleAndCropEffect() {
|
||||
$this->assertTrue(image_scale_and_crop_effect($this->image, array('width' => 5, 'height' => 10)), t('Function returned the expected value.'));
|
||||
$this->assertTrue(image_scale_and_crop_effect($this->image, array('width' => 5, 'height' => 10)), 'Function returned the expected value.');
|
||||
$this->assertToolkitOperationsCalled(array('resize', 'crop'));
|
||||
|
||||
// Check the parameters.
|
||||
$calls = image_test_get_all_calls();
|
||||
$this->assertEqual($calls['crop'][0][1], 7.5, t('X was computed and passed correctly'));
|
||||
$this->assertEqual($calls['crop'][0][2], 0, t('Y was computed and passed correctly'));
|
||||
$this->assertEqual($calls['crop'][0][3], 5, t('Width was computed and passed correctly'));
|
||||
$this->assertEqual($calls['crop'][0][4], 10, t('Height was computed and passed correctly'));
|
||||
$this->assertEqual($calls['crop'][0][1], 7.5, 'X was computed and passed correctly');
|
||||
$this->assertEqual($calls['crop'][0][2], 0, 'Y was computed and passed correctly');
|
||||
$this->assertEqual($calls['crop'][0][3], 5, 'Width was computed and passed correctly');
|
||||
$this->assertEqual($calls['crop'][0][4], 10, 'Height was computed and passed correctly');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the image_desaturate_effect() function.
|
||||
*/
|
||||
function testDesaturateEffect() {
|
||||
$this->assertTrue(image_desaturate_effect($this->image, array()), t('Function returned the expected value.'));
|
||||
$this->assertTrue(image_desaturate_effect($this->image, array()), 'Function returned the expected value.');
|
||||
$this->assertToolkitOperationsCalled(array('desaturate'));
|
||||
|
||||
// Check the parameters.
|
||||
$calls = image_test_get_all_calls();
|
||||
$this->assertEqual(count($calls['desaturate'][0]), 1, t('Only the image was passed.'));
|
||||
$this->assertEqual(count($calls['desaturate'][0]), 1, 'Only the image was passed.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -412,13 +411,13 @@ class ImageEffectsUnitTest extends ImageToolkitTestCase {
|
||||
*/
|
||||
function testRotateEffect() {
|
||||
// @todo: need to test with 'random' => TRUE
|
||||
$this->assertTrue(image_rotate_effect($this->image, array('degrees' => 90, 'bgcolor' => '#fff')), t('Function returned the expected value.'));
|
||||
$this->assertTrue(image_rotate_effect($this->image, array('degrees' => 90, 'bgcolor' => '#fff')), 'Function returned the expected value.');
|
||||
$this->assertToolkitOperationsCalled(array('rotate'));
|
||||
|
||||
// Check the parameters.
|
||||
$calls = image_test_get_all_calls();
|
||||
$this->assertEqual($calls['rotate'][0][1], 90, t('Degrees were passed correctly'));
|
||||
$this->assertEqual($calls['rotate'][0][2], 0xffffff, t('Background color was passed correctly'));
|
||||
$this->assertEqual($calls['rotate'][0][1], 90, 'Degrees were passed correctly');
|
||||
$this->assertEqual($calls['rotate'][0][2], 0xffffff, 'Background color was passed correctly');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -484,13 +483,15 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
|
||||
*/
|
||||
function testNumericStyleName() {
|
||||
$style_name = rand();
|
||||
$style_label = $this->randomString();
|
||||
$edit = array(
|
||||
'name' => $style_name,
|
||||
'label' => $style_label,
|
||||
);
|
||||
$this->drupalPost('admin/config/media/image-styles/add', $edit, t('Create new style'));
|
||||
$this->assertRaw(t('Style %name was created.', array('%name' => $style_name)), t('Image style successfully created.'));
|
||||
$this->assertRaw(t('Style %name was created.', array('%name' => $style_label)), 'Image style successfully created.');
|
||||
$options = image_style_options();
|
||||
$this->assertTrue(array_key_exists($style_name, $options), t('Array key %key exists.', array('%key' => $style_name)));
|
||||
$this->assertTrue(array_key_exists($style_name, $options), format_string('Array key %key exists.', array('%key' => $style_name)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -499,6 +500,7 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
|
||||
function testStyle() {
|
||||
// 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(
|
||||
@ -533,9 +535,10 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
|
||||
|
||||
$edit = array(
|
||||
'name' => $style_name,
|
||||
'label' => $style_label,
|
||||
);
|
||||
$this->drupalPost('admin/config/media/image-styles/add', $edit, t('Create new style'));
|
||||
$this->assertRaw(t('Style %name was created.', array('%name' => $style_name)), t('Image style successfully created.'));
|
||||
$this->assertRaw(t('Style %name was created.', array('%name' => $style_label)), 'Image style successfully created.');
|
||||
|
||||
// Add effect form.
|
||||
|
||||
@ -557,7 +560,7 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
|
||||
foreach ($style['effects'] as $ieid => $effect) {
|
||||
$this->drupalGet($style_path . '/effects/' . $ieid);
|
||||
foreach ($effect_edits[$effect['name']] as $field => $value) {
|
||||
$this->assertFieldByName($field, $value, t('The %field field in the %effect effect has the correct value of %value.', array('%field' => $field, '%effect' => $effect['name'], '%value' => $value)));
|
||||
$this->assertFieldByName($field, $value, format_string('The %field field in the %effect effect has the correct value of %value.', array('%field' => $field, '%effect' => $effect['name'], '%value' => $value)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -573,14 +576,16 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
|
||||
$order_correct = FALSE;
|
||||
}
|
||||
}
|
||||
$this->assertTrue($order_correct, t('The order of the effects is correctly set by default.'));
|
||||
$this->assertTrue($order_correct, 'The order of the effects is correctly set by default.');
|
||||
|
||||
// Test the style overview form.
|
||||
// Change the name of the style and adjust the weights of effects.
|
||||
$style_name = strtolower($this->randomName(10));
|
||||
$style_label = $this->randomString();
|
||||
$weight = count($effect_edits);
|
||||
$edit = array(
|
||||
'name' => $style_name,
|
||||
'label' => $style_label,
|
||||
);
|
||||
foreach ($style['effects'] as $ieid => $effect) {
|
||||
$edit['effects[' . $ieid . '][weight]'] = $weight;
|
||||
@ -589,7 +594,7 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
|
||||
|
||||
// Create an image to make sure it gets flushed after saving.
|
||||
$image_path = $this->createSampleImage($style);
|
||||
$this->assertEqual($this->getImageCount($style), 1, t('Image style %style image %file successfully generated.', array('%style' => $style['name'], '%file' => $image_path)));
|
||||
$this->assertEqual($this->getImageCount($style), 1, format_string('Image style %style image %file successfully generated.', array('%style' => $style['label'], '%file' => $image_path)));
|
||||
|
||||
$this->drupalPost($style_path, $edit, t('Update style'));
|
||||
|
||||
@ -598,12 +603,12 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
|
||||
|
||||
// Check that the URL was updated.
|
||||
$this->drupalGet($style_path);
|
||||
$this->assertResponse(200, t('Image style %original renamed to %new', array('%original' => $style['name'], '%new' => $style_name)));
|
||||
$this->assertResponse(200, format_string('Image style %original renamed to %new', array('%original' => $style['label'], '%new' => $style_label)));
|
||||
|
||||
// Check that the image was flushed after updating the style.
|
||||
// This is especially important when renaming the style. Make sure that
|
||||
// the old image directory has been deleted.
|
||||
$this->assertEqual($this->getImageCount($style), 0, t('Image style %style was flushed after renaming the style and updating the order of effects.', array('%style' => $style['name'])));
|
||||
$this->assertEqual($this->getImageCount($style), 0, format_string('Image style %style was flushed after renaming the style and updating the order of effects.', array('%style' => $style['label'])));
|
||||
|
||||
// Load the style by the new name with the new weights.
|
||||
drupal_static_reset('image_styles');
|
||||
@ -618,18 +623,18 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
|
||||
$order_correct = FALSE;
|
||||
}
|
||||
}
|
||||
$this->assertTrue($order_correct, t('The order of the effects is correctly set by default.'));
|
||||
$this->assertTrue($order_correct, 'The order of the effects is correctly set by default.');
|
||||
|
||||
// Image effect deletion form.
|
||||
|
||||
// Create an image to make sure it gets flushed after deleting an effect.
|
||||
$image_path = $this->createSampleImage($style);
|
||||
$this->assertEqual($this->getImageCount($style), 1, t('Image style %style image %file successfully generated.', array('%style' => $style['name'], '%file' => $image_path)));
|
||||
$this->assertEqual($this->getImageCount($style), 1, format_string('Image style %style image %file successfully generated.', array('%style' => $style['label'], '%file' => $image_path)));
|
||||
|
||||
// Test effect deletion form.
|
||||
$effect = array_pop($style['effects']);
|
||||
$this->drupalPost($style_path . '/effects/' . $effect['ieid'] . '/delete', array(), t('Delete'));
|
||||
$this->assertRaw(t('The image effect %name has been deleted.', array('%name' => $effect['label'])), t('Image effect deleted.'));
|
||||
$this->assertRaw(t('The image effect %name has been deleted.', array('%name' => $effect['label'])), 'Image effect deleted.');
|
||||
|
||||
// Style deletion form.
|
||||
|
||||
@ -638,10 +643,10 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
|
||||
|
||||
// Confirm the style directory has been removed.
|
||||
$directory = file_default_scheme() . '://styles/' . $style_name;
|
||||
$this->assertFalse(is_dir($directory), t('Image style %style directory removed on style deletion.', array('%style' => $style['name'])));
|
||||
$this->assertFalse(is_dir($directory), format_string('Image style %style directory removed on style deletion.', array('%style' => $style['label'])));
|
||||
|
||||
drupal_static_reset('image_styles');
|
||||
$this->assertFalse(image_style_load($style_name), t('Image style %style successfully deleted.', array('%style' => $style['name'])));
|
||||
$this->assertFalse(image_style_load($style_name), format_string('Image style %style successfully deleted.', array('%style' => $style['label'])));
|
||||
|
||||
}
|
||||
|
||||
@ -651,34 +656,36 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
|
||||
function testDefaultStyle() {
|
||||
// Setup a style to be created and effects to add to it.
|
||||
$style_name = 'thumbnail';
|
||||
$style_label = 'Thumbnail (100x100)';
|
||||
$edit_path = 'admin/config/media/image-styles/edit/' . $style_name;
|
||||
$delete_path = 'admin/config/media/image-styles/delete/' . $style_name;
|
||||
$revert_path = 'admin/config/media/image-styles/revert/' . $style_name;
|
||||
|
||||
// Ensure deleting a default is not possible.
|
||||
$this->drupalGet($delete_path);
|
||||
$this->assertText(t('Page not found'), t('Default styles may not be deleted.'));
|
||||
$this->assertText(t('Page not found'), 'Default styles may not be deleted.');
|
||||
|
||||
// Ensure that editing a default is not possible (without overriding).
|
||||
$this->drupalGet($edit_path);
|
||||
$this->assertNoField('edit-name', t('Default styles may not be renamed.'));
|
||||
$this->assertNoField('edit-submit', t('Default styles may not be edited.'));
|
||||
$this->assertNoField('edit-add', t('Default styles may not have new effects added.'));
|
||||
$disabled_field = $this->xpath('//input[@id=:id and @disabled="disabled"]', array(':id' => 'edit-name'));
|
||||
$this->assertTrue($disabled_field, 'Default styles may not be renamed.');
|
||||
$this->assertNoField('edit-submit', 'Default styles may not be edited.');
|
||||
$this->assertNoField('edit-add', 'Default styles may not have new effects added.');
|
||||
|
||||
// Create an image to make sure the default works before overriding.
|
||||
drupal_static_reset('image_styles');
|
||||
$style = image_style_load($style_name);
|
||||
$image_path = $this->createSampleImage($style);
|
||||
$this->assertEqual($this->getImageCount($style), 1, t('Image style %style image %file successfully generated.', array('%style' => $style['name'], '%file' => $image_path)));
|
||||
$this->assertEqual($this->getImageCount($style), 1, format_string('Image style %style image %file successfully generated.', array('%style' => $style['name'], '%file' => $image_path)));
|
||||
|
||||
// Verify that effects attached to a default style do not have an ieid key.
|
||||
foreach ($style['effects'] as $effect) {
|
||||
$this->assertFalse(isset($effect['ieid']), t('The %effect effect does not have an ieid.', array('%effect' => $effect['name'])));
|
||||
$this->assertFalse(isset($effect['ieid']), format_string('The %effect effect does not have an ieid.', array('%effect' => $effect['name'])));
|
||||
}
|
||||
|
||||
// Override the default.
|
||||
$this->drupalPost($edit_path, array(), t('Override defaults'));
|
||||
$this->assertRaw(t('The %style style has been overridden, allowing you to change its settings.', array('%style' => $style_name)), t('Default image style may be overridden.'));
|
||||
$this->assertRaw(t('The %style style has been overridden, allowing you to change its settings.', array('%style' => $style_label)), 'Default image style may be overridden.');
|
||||
|
||||
// Add sample effect to the overridden style.
|
||||
$this->drupalPost($edit_path, array('new' => 'image_desaturate'), t('Add'));
|
||||
@ -687,22 +694,23 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
|
||||
|
||||
// Verify that effects attached to the style have an ieid now.
|
||||
foreach ($style['effects'] as $effect) {
|
||||
$this->assertTrue(isset($effect['ieid']), t('The %effect effect has an ieid.', array('%effect' => $effect['name'])));
|
||||
$this->assertTrue(isset($effect['ieid']), format_string('The %effect effect has an ieid.', array('%effect' => $effect['name'])));
|
||||
}
|
||||
|
||||
// The style should now have 2 effect, the original scale provided by core
|
||||
// and the desaturate effect we added in the override.
|
||||
$effects = array_values($style['effects']);
|
||||
$this->assertEqual($effects[0]['name'], 'image_scale', t('The default effect still exists in the overridden style.'));
|
||||
$this->assertEqual($effects[1]['name'], 'image_desaturate', t('The added effect exists in the overridden style.'));
|
||||
$this->assertEqual($effects[0]['name'], 'image_scale', 'The default effect still exists in the overridden style.');
|
||||
$this->assertEqual($effects[1]['name'], 'image_desaturate', 'The added effect exists in the overridden style.');
|
||||
|
||||
// Check that we are unable to rename an overridden style.
|
||||
// Check that we are able to rename an overridden style.
|
||||
$this->drupalGet($edit_path);
|
||||
$this->assertNoField('edit-name', t('Overridden styles may not be renamed.'));
|
||||
$disabled_field = $this->xpath('//input[@id=:id and @disabled="disabled"]', array(':id' => 'edit-name'));
|
||||
$this->assertFalse($disabled_field, 'Overridden styles may be renamed.');
|
||||
|
||||
// Create an image to ensure the override works properly.
|
||||
$image_path = $this->createSampleImage($style);
|
||||
$this->assertEqual($this->getImageCount($style), 1, t('Image style %style image %file successfully generated.', array('%style' => $style['name'], '%file' => $image_path)));
|
||||
$this->assertEqual($this->getImageCount($style), 1, format_string('Image style %style image %file successfully generated.', array('%style' => $style['label'], '%file' => $image_path)));
|
||||
|
||||
// Revert the image style.
|
||||
$this->drupalPost($revert_path, array(), t('Revert'));
|
||||
@ -711,8 +719,8 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
|
||||
|
||||
// The style should now have the single effect for scale.
|
||||
$effects = array_values($style['effects']);
|
||||
$this->assertEqual($effects[0]['name'], 'image_scale', t('The default effect still exists in the reverted style.'));
|
||||
$this->assertFalse(array_key_exists(1, $effects), t('The added effect has been removed in the reverted style.'));
|
||||
$this->assertEqual($effects[0]['name'], 'image_scale', 'The default effect still exists in the reverted style.');
|
||||
$this->assertFalse(array_key_exists(1, $effects), 'The added effect has been removed in the reverted style.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -721,7 +729,8 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
|
||||
function testStyleReplacement() {
|
||||
// Create a new style.
|
||||
$style_name = strtolower($this->randomName(10));
|
||||
image_style_save(array('name' => $style_name));
|
||||
$style_label = $this->randomString();
|
||||
image_style_save(array('name' => $style_name, 'label' => $style_label));
|
||||
$style_path = 'admin/config/media/image-styles/edit/' . $style_name;
|
||||
|
||||
// Create an image field that uses the new style.
|
||||
@ -739,28 +748,30 @@ class ImageAdminStylesUnitTest extends ImageFieldTestCase {
|
||||
|
||||
// Test that image is displayed using newly created style.
|
||||
$this->drupalGet('node/' . $nid);
|
||||
$this->assertRaw(check_plain(image_style_url($style_name, $node->{$field_name}[LANGUAGE_NONE][0]['uri'])), t('Image displayed using style @style.', array('@style' => $style_name)));
|
||||
$this->assertRaw(check_plain(image_style_url($style_name, $node->{$field_name}[LANGUAGE_NONE][0]['uri'])), format_string('Image displayed using style @style.', array('@style' => $style_name)));
|
||||
|
||||
// Rename the style and make sure the image field is updated.
|
||||
$new_style_name = strtolower($this->randomName(10));
|
||||
$new_style_label = $this->randomString();
|
||||
$edit = array(
|
||||
'name' => $new_style_name,
|
||||
'label' => $new_style_label,
|
||||
);
|
||||
$this->drupalPost('admin/config/media/image-styles/edit/' . $style_name, $edit, t('Update style'));
|
||||
$this->assertText(t('Changes to the style have been saved.'), t('Style %name was renamed to %new_name.', array('%name' => $style_name, '%new_name' => $new_style_name)));
|
||||
$this->assertText(t('Changes to the style have been saved.'), format_string('Style %name was renamed to %new_name.', array('%name' => $style_name, '%new_name' => $new_style_name)));
|
||||
$this->drupalGet('node/' . $nid);
|
||||
$this->assertRaw(check_plain(image_style_url($new_style_name, $node->{$field_name}[LANGUAGE_NONE][0]['uri'])), t('Image displayed using style replacement style.'));
|
||||
$this->assertRaw(check_plain(image_style_url($new_style_name, $node->{$field_name}[LANGUAGE_NONE][0]['uri'])), format_string('Image displayed using style replacement style.'));
|
||||
|
||||
// Delete the style and choose a replacement style.
|
||||
$edit = array(
|
||||
'replacement' => 'thumbnail',
|
||||
);
|
||||
$this->drupalPost('admin/config/media/image-styles/delete/' . $new_style_name, $edit, t('Delete'));
|
||||
$message = t('Style %name was deleted.', array('%name' => $new_style_name));
|
||||
$message = t('Style %name was deleted.', array('%name' => $new_style_label));
|
||||
$this->assertRaw($message, $message);
|
||||
|
||||
$this->drupalGet('node/' . $nid);
|
||||
$this->assertRaw(check_plain(image_style_url('thumbnail', $node->{$field_name}[LANGUAGE_NONE][0]['uri'])), t('Image displayed using style replacement style.'));
|
||||
$this->assertRaw(check_plain(image_style_url('thumbnail', $node->{$field_name}[LANGUAGE_NONE][0]['uri'])), format_string('Image displayed using style replacement style.'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -811,7 +822,7 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
|
||||
'height' => 20,
|
||||
);
|
||||
$default_output = theme('image', $image_info);
|
||||
$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.');
|
||||
|
||||
// Test the image linked to file formatter.
|
||||
$instance = field_info_instance('node', $field_name, 'article');
|
||||
@ -820,19 +831,19 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
|
||||
field_update_instance($instance);
|
||||
$default_output = l(theme('image', $image_info), file_create_url($image_uri), array('html' => TRUE));
|
||||
$this->drupalGet('node/' . $nid);
|
||||
$this->assertRaw($default_output, t('Image linked to file formatter displaying correctly on full node view.'));
|
||||
$this->assertRaw($default_output, 'Image linked to file formatter displaying correctly on full node view.');
|
||||
// Verify that the image can be downloaded.
|
||||
$this->assertEqual(file_get_contents($test_image->uri), $this->drupalGet(file_create_url($image_uri)), t('File was downloaded successfully.'));
|
||||
$this->assertEqual(file_get_contents($test_image->uri), $this->drupalGet(file_create_url($image_uri)), 'File was downloaded successfully.');
|
||||
if ($scheme == 'private') {
|
||||
// Only verify HTTP headers when using private scheme and the headers are
|
||||
// sent by Drupal.
|
||||
$this->assertEqual($this->drupalGetHeader('Content-Type'), 'image/png', t('Content-Type header was sent.'));
|
||||
$this->assertEqual($this->drupalGetHeader('Cache-Control'), 'private', t('Cache-Control header was sent.'));
|
||||
$this->assertEqual($this->drupalGetHeader('Content-Type'), 'image/png', 'Content-Type header was sent.');
|
||||
$this->assertEqual($this->drupalGetHeader('Cache-Control'), 'private', 'Cache-Control header was sent.');
|
||||
|
||||
// Log out and try to access the file.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet(file_create_url($image_uri));
|
||||
$this->assertResponse('403', t('Access denied to original image as anonymous user.'));
|
||||
$this->assertResponse('403', 'Access denied to original image as anonymous user.');
|
||||
|
||||
// Log in again.
|
||||
$this->drupalLogin($this->admin_user);
|
||||
@ -843,7 +854,7 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
|
||||
field_update_instance($instance);
|
||||
$default_output = l(theme('image', $image_info), 'node/' . $nid, array('html' => TRUE, 'attributes' => array('class' => 'active')));
|
||||
$this->drupalGet('node/' . $nid);
|
||||
$this->assertRaw($default_output, t('Image linked to content formatter displaying correctly on full node view.'));
|
||||
$this->assertRaw($default_output, 'Image linked to content formatter displaying correctly on full node view.');
|
||||
|
||||
// Test the image style 'thumbnail' formatter.
|
||||
$instance['display']['default']['settings']['image_link'] = '';
|
||||
@ -859,13 +870,13 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
|
||||
$image_info['height'] = 50;
|
||||
$default_output = theme('image', $image_info);
|
||||
$this->drupalGet('node/' . $nid);
|
||||
$this->assertRaw($default_output, t('Image style thumbnail formatter displaying correctly on full node view.'));
|
||||
$this->assertRaw($default_output, 'Image style thumbnail formatter displaying correctly on full node view.');
|
||||
|
||||
if ($scheme == 'private') {
|
||||
// Log out and try to access the file.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet(image_style_url('thumbnail', $image_uri));
|
||||
$this->assertResponse('403', t('Access denied to image style thumbnail as anonymous user.'));
|
||||
$this->assertResponse('403', 'Access denied to image style thumbnail as anonymous user.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -894,16 +905,16 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
|
||||
$instance = field_info_instance('node', $field_name, 'article');
|
||||
|
||||
$this->drupalGet('node/add/article');
|
||||
$this->assertText(t('Files must be less than 50 KB.'), t('Image widget max file size is displayed on article form.'));
|
||||
$this->assertText(t('Allowed file types: ' . $test_image_extension . '.'), t('Image widget allowed file types displayed on article form.'));
|
||||
$this->assertText(t('Images must be between 10x10 and 100x100 pixels.'), t('Image widget allowed resolution displayed on article form.'));
|
||||
$this->assertText(t('Files must be less than 50 KB.'), 'Image widget max file size is displayed on article form.');
|
||||
$this->assertText(t('Allowed file types: ' . $test_image_extension . '.'), 'Image widget allowed file types displayed on article form.');
|
||||
$this->assertText(t('Images must be between 10x10 and 100x100 pixels.'), 'Image widget allowed resolution displayed on article form.');
|
||||
|
||||
// We have to create the article first and then edit it because the alt
|
||||
// and title fields do not display until the image has been attached.
|
||||
$nid = $this->uploadNodeImage($test_image, $field_name, 'article');
|
||||
$this->drupalGet('node/' . $nid . '/edit');
|
||||
$this->assertFieldByName($field_name . '[' . LANGUAGE_NONE . '][0][alt]', '', t('Alt field displayed on article form.'));
|
||||
$this->assertFieldByName($field_name . '[' . LANGUAGE_NONE . '][0][title]', '', t('Title field displayed on article form.'));
|
||||
$this->assertFieldByName($field_name . '[' . LANGUAGE_NONE . '][0][alt]', '', 'Alt field displayed on article form.');
|
||||
$this->assertFieldByName($field_name . '[' . LANGUAGE_NONE . '][0][title]', '', 'Title field displayed on article form.');
|
||||
// Verify that the attached image is being previewed using the 'medium'
|
||||
// style.
|
||||
$node = node_load($nid, NULL, TRUE);
|
||||
@ -913,7 +924,7 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
|
||||
'height' => 110,
|
||||
);
|
||||
$default_output = theme('image', $image_info);
|
||||
$this->assertRaw($default_output, t("Preview image is displayed using 'medium' style."));
|
||||
$this->assertRaw($default_output, "Preview image is displayed using 'medium' style.");
|
||||
|
||||
// Add alt/title fields to the image and verify that they are displayed.
|
||||
$image_info = array(
|
||||
@ -929,7 +940,7 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
|
||||
);
|
||||
$this->drupalPost('node/' . $nid . '/edit', $edit, t('Save'));
|
||||
$default_output = theme('image', $image_info);
|
||||
$this->assertRaw($default_output, t('Image displayed using user supplied alt and title attributes.'));
|
||||
$this->assertRaw($default_output, 'Image displayed using user supplied alt and title attributes.');
|
||||
|
||||
// Verify that alt/title longer than allowed results in a validation error.
|
||||
$test_size = 2000;
|
||||
@ -962,7 +973,7 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
|
||||
'title' => t('Image field formatter'),
|
||||
),
|
||||
));
|
||||
$this->assertTrue(stripos($image, 'testFound') > 0, t('Image field formatters can have attributes.'));
|
||||
$this->assertTrue(stripos($image, 'testFound') > 0, 'Image field formatters can have attributes.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -979,7 +990,7 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
// Verify that no image is displayed on the page by checking for the class
|
||||
// that would be used on the image field.
|
||||
$this->assertNoPattern('<div class="(.*?)field-name-' . strtr($field_name, '_', '-') . '(.*?)">', t('No image displayed when no image is attached and no default image specified.'));
|
||||
$this->assertNoPattern('<div class="(.*?)field-name-' . strtr($field_name, '_', '-') . '(.*?)">', 'No image displayed when no image is attached and no default image specified.');
|
||||
|
||||
// Add a default image to the public imagefield instance.
|
||||
$images = $this->drupalGetTestFiles('image');
|
||||
@ -991,10 +1002,10 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
|
||||
field_info_cache_clear();
|
||||
$field = field_info_field($field_name);
|
||||
$image = file_load($field['settings']['default_image']);
|
||||
$this->assertTrue($image->status == FILE_STATUS_PERMANENT, t('The default image status is permanent.'));
|
||||
$this->assertTrue($image->status == FILE_STATUS_PERMANENT, 'The default image status is permanent.');
|
||||
$default_output = theme('image', array('path' => $image->uri));
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertRaw($default_output, t('Default image displayed when no user supplied image is present.'));
|
||||
$this->assertRaw($default_output, 'Default image displayed when no user supplied image is present.');
|
||||
|
||||
// Create a node with an image attached and ensure that the default image
|
||||
// is not displayed.
|
||||
@ -1007,8 +1018,8 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
|
||||
);
|
||||
$image_output = theme('image', $image_info);
|
||||
$this->drupalGet('node/' . $nid);
|
||||
$this->assertNoRaw($default_output, t('Default image is not displayed when user supplied image is present.'));
|
||||
$this->assertRaw($image_output, t('User supplied image is displayed.'));
|
||||
$this->assertNoRaw($default_output, 'Default image is not displayed when user supplied image is present.');
|
||||
$this->assertRaw($image_output, 'User supplied image is displayed.');
|
||||
|
||||
// Remove default image from the field and make sure it is no longer used.
|
||||
$edit = array(
|
||||
@ -1018,7 +1029,7 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
|
||||
// Clear field info cache so the new default image is detected.
|
||||
field_info_cache_clear();
|
||||
$field = field_info_field($field_name);
|
||||
$this->assertFalse($field['settings']['default_image'], t('Default image removed from field.'));
|
||||
$this->assertFalse($field['settings']['default_image'], 'Default image removed from field.');
|
||||
// Create an image field that uses the private:// scheme and test that the
|
||||
// default image works as expected.
|
||||
$private_field_name = strtolower($this->randomName());
|
||||
@ -1030,14 +1041,14 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
|
||||
$this->drupalPost('admin/structure/types/manage/article/fields/' . $private_field_name, $edit, t('Save settings'));
|
||||
$private_field = field_info_field($private_field_name);
|
||||
$image = file_load($private_field['settings']['default_image']);
|
||||
$this->assertEqual('private', file_uri_scheme($image->uri), t('Default image uses private:// scheme.'));
|
||||
$this->assertTrue($image->status == FILE_STATUS_PERMANENT, t('The default image status is permanent.'));
|
||||
$this->assertEqual('private', file_uri_scheme($image->uri), 'Default image uses private:// scheme.');
|
||||
$this->assertTrue($image->status == FILE_STATUS_PERMANENT, 'The default image status is permanent.');
|
||||
// Create a new node with no image attached and ensure that default private
|
||||
// image is displayed.
|
||||
$node = $this->drupalCreateNode(array('type' => 'article'));
|
||||
$default_output = theme('image', array('path' => $image->uri));
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertRaw($default_output, t('Default private image displayed when no user supplied image is present.'));
|
||||
$this->assertRaw($default_output, 'Default private image displayed when no user supplied image is present.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1083,9 +1094,9 @@ class ImageFieldValidateTestCase extends ImageFieldTestCase {
|
||||
}
|
||||
}
|
||||
$nid = $this->uploadNodeImage($image_that_is_too_small, $field_name, 'article');
|
||||
$this->assertText(t('The specified file ' . $image_that_is_too_small->filename . ' could not be uploaded. The image is too small; the minimum dimensions are 50x50 pixels.'), t('Node save failed when minimum image resolution was not met.'));
|
||||
$this->assertText(t('The specified file ' . $image_that_is_too_small->filename . ' could not be uploaded. The image is too small; the minimum dimensions are 50x50 pixels.'), 'Node save failed when minimum image resolution was not met.');
|
||||
$nid = $this->uploadNodeImage($image_that_is_too_big, $field_name, 'article');
|
||||
$this->assertText(t('The image was resized to fit within the maximum allowed dimensions of 100x100 pixels.'), t('Image exceeding max resolution was properly resized.'));
|
||||
$this->assertText(t('The image was resized to fit within the maximum allowed dimensions of 100x100 pixels.'), 'Image exceeding max resolution was properly resized.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1116,7 +1127,7 @@ class ImageDimensionsTestCase extends DrupalWebTestCase {
|
||||
$original_uri = file_unmanaged_copy($file->uri, 'public://', FILE_EXISTS_RENAME);
|
||||
|
||||
// Create a style.
|
||||
$style = image_style_save(array('name' => 'test'));
|
||||
$style = image_style_save(array('name' => 'test', 'label' => 'Test'));
|
||||
$generated_uri = 'public://styles/test/public/'. drupal_basename($original_uri);
|
||||
$url = image_style_url('test', $original_uri);
|
||||
|
||||
@ -1140,14 +1151,14 @@ class ImageDimensionsTestCase extends DrupalWebTestCase {
|
||||
|
||||
image_effect_save($effect);
|
||||
$img_tag = theme_image_style($variables);
|
||||
$this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . check_plain($url) . '" width="120" height="60" alt="" />', t('Expected img tag was found.'));
|
||||
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
|
||||
$this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . check_plain($url) . '" width="120" height="60" alt="" />', '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, '<img typeof="foaf:Image" src="' . check_plain($url) . '" width="60" height="120" alt="" />', t('Expected img tag was found.'));
|
||||
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
|
||||
$this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . check_plain($url) . '" width="60" height="120" alt="" />', '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, '<img typeof="foaf:Image" src="' . check_plain($url) . '" width="45" height="90" alt="" />', t('Expected img tag was found.'));
|
||||
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
|
||||
$this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . check_plain($url) . '" width="45" height="90" alt="" />', '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, '<img typeof="foaf:Image" src="' . check_plain($url) . '" width="45" height="90" alt="" />', t('Expected img tag was found.'));
|
||||
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
|
||||
$this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . check_plain($url) . '" width="45" height="90" alt="" />', '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, '<img typeof="foaf:Image" src="' . check_plain($url) . '" width="45" height="90" alt="" />', t('Expected img tag was found.'));
|
||||
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
|
||||
$this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . check_plain($url) . '" width="45" height="90" alt="" />', '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, '<img typeof="foaf:Image" src="' . check_plain($url) . '" alt="" />', t('Expected img tag was found.'));
|
||||
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
|
||||
$this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . check_plain($url) . '" alt="" />', '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, '<img typeof="foaf:Image" src="' . check_plain($url) . '" width="30" height="30" alt="" />', t('Expected img tag was found.'));
|
||||
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
|
||||
$this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . check_plain($url) . '" width="30" height="30" alt="" />', '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, '<img typeof="foaf:Image" src="' . check_plain($url) . '" alt="" />', t('Expected img tag was found.'));
|
||||
$this->assertFalse(file_exists($generated_uri), t('Generated file does not exist.'));
|
||||
$this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . check_plain($url) . '" alt="" />', '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, '<img typeof="foaf:Image" src="' . check_plain($url) . '" alt="" />', t('Expected img tag was found.'));
|
||||
$this->assertEqual($img_tag, '<img typeof="foaf:Image" src="' . check_plain($url) . '" alt="" />', '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')));
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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"
|
||||
|
||||
|
@ -6,8 +6,8 @@ core = 7.x
|
||||
files[] = menu.test
|
||||
configure = admin/structure/menu
|
||||
|
||||
; 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"
|
||||
|
||||
|
@ -70,7 +70,7 @@ class MenuTestCase extends DrupalWebTestCase {
|
||||
$item['options']['attributes']['title'] = $description;
|
||||
menu_link_save($item);
|
||||
$saved_item = menu_link_load($item['mlid']);
|
||||
$this->assertEqual($description, $saved_item['options']['attributes']['title'], t('Saving an existing link updates the description (title attribute)'));
|
||||
$this->assertEqual($description, $saved_item['options']['attributes']['title'], 'Saving an existing link updates the description (title attribute)');
|
||||
$this->resetMenuLink($item, $old_title);
|
||||
}
|
||||
|
||||
@ -111,14 +111,14 @@ class MenuTestCase extends DrupalWebTestCase {
|
||||
|
||||
// Assert the new menu.
|
||||
$this->drupalGet('admin/structure/menu/manage/' . $menu_name . '/edit');
|
||||
$this->assertRaw($title, t('Custom menu was added.'));
|
||||
$this->assertRaw($title, 'Custom menu was added.');
|
||||
|
||||
// Edit the menu.
|
||||
$new_title = $this->randomName(16);
|
||||
$menu['title'] = $new_title;
|
||||
menu_save($menu);
|
||||
$this->drupalGet('admin/structure/menu/manage/' . $menu_name . '/edit');
|
||||
$this->assertRaw($new_title, t('Custom menu was edited.'));
|
||||
$this->assertRaw($new_title, 'Custom menu was edited.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,7 +167,7 @@ class MenuTestCase extends DrupalWebTestCase {
|
||||
$edit['blocks[menu_' . $menu_name . '][region]'] = 'sidebar_first';
|
||||
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
|
||||
$this->assertResponse(200);
|
||||
$this->assertText(t('The block settings have been updated.'), t('Custom menu block was enabled'));
|
||||
$this->assertText(t('The block settings have been updated.'), 'Custom menu block was enabled');
|
||||
|
||||
return menu_load($menu_name);
|
||||
}
|
||||
@ -184,11 +184,11 @@ class MenuTestCase extends DrupalWebTestCase {
|
||||
// Delete custom menu.
|
||||
$this->drupalPost("admin/structure/menu/manage/$menu_name/delete", array(), t('Delete'));
|
||||
$this->assertResponse(200);
|
||||
$this->assertRaw(t('The custom menu %title has been deleted.', array('%title' => $title)), t('Custom menu was deleted'));
|
||||
$this->assertRaw(t('The custom menu %title has been deleted.', array('%title' => $title)), 'Custom menu was deleted');
|
||||
$this->assertFalse(menu_load($menu_name), 'Custom menu was deleted');
|
||||
// Test if all menu links associated to the menu were removed from database.
|
||||
$result = db_query("SELECT menu_name FROM {menu_links} WHERE menu_name = :menu_name", array(':menu_name' => $menu_name))->fetchField();
|
||||
$this->assertFalse($result, t('All menu links associated to the custom menu were deleted.'));
|
||||
$this->assertFalse($result, 'All menu links associated to the custom menu were deleted.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -266,13 +266,13 @@ class MenuTestCase extends DrupalWebTestCase {
|
||||
$item = $this->addMenuLink(0, $path);
|
||||
|
||||
$this->drupalGet('admin/structure/menu/item/' . $item['mlid'] . '/edit');
|
||||
$this->assertFieldByName('link_path', $path, t('Path is found with both query and fragment.'));
|
||||
$this->assertFieldByName('link_path', $path, 'Path is found with both query and fragment.');
|
||||
|
||||
// Now change the path to something without query and fragment.
|
||||
$path = 'node';
|
||||
$this->drupalPost('admin/structure/menu/item/' . $item['mlid'] . '/edit', array('link_path' => $path), t('Save'));
|
||||
$this->drupalGet('admin/structure/menu/item/' . $item['mlid'] . '/edit');
|
||||
$this->assertFieldByName('link_path', $path, t('Path no longer has query or fragment.'));
|
||||
$this->assertFieldByName('link_path', $path, 'Path no longer has query or fragment.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -350,7 +350,7 @@ class MenuTestCase extends DrupalWebTestCase {
|
||||
// Verify menu link link.
|
||||
$this->clickLink($title);
|
||||
$title = $parent_node->title;
|
||||
$this->assertTitle(t("@title | Drupal", array('@title' => $title)), t('Parent menu link link target was correct'));
|
||||
$this->assertTitle(t("@title | Drupal", array('@title' => $title)), 'Parent menu link link target was correct');
|
||||
}
|
||||
|
||||
// Verify menu link.
|
||||
@ -360,7 +360,7 @@ class MenuTestCase extends DrupalWebTestCase {
|
||||
// Verify menu link link.
|
||||
$this->clickLink($title);
|
||||
$title = $item_node->title;
|
||||
$this->assertTitle(t("@title | Drupal", array('@title' => $title)), t('Menu link link target was correct'));
|
||||
$this->assertTitle(t("@title | Drupal", array('@title' => $title)), 'Menu link link target was correct');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -412,7 +412,7 @@ class MenuTestCase extends DrupalWebTestCase {
|
||||
// Reset menu link.
|
||||
$this->drupalPost("admin/structure/menu/item/$mlid/reset", array(), t('Reset'));
|
||||
$this->assertResponse(200);
|
||||
$this->assertRaw(t('The menu link was reset to its default settings.'), t('Menu link was reset'));
|
||||
$this->assertRaw(t('The menu link was reset to its default settings.'), 'Menu link was reset');
|
||||
|
||||
// Verify menu link.
|
||||
$this->drupalGet('');
|
||||
@ -432,7 +432,7 @@ class MenuTestCase extends DrupalWebTestCase {
|
||||
// Delete menu link.
|
||||
$this->drupalPost("admin/structure/menu/item/$mlid/delete", array(), t('Confirm'));
|
||||
$this->assertResponse(200);
|
||||
$this->assertRaw(t('The menu link %title has been deleted.', array('%title' => $title)), t('Menu link was deleted'));
|
||||
$this->assertRaw(t('The menu link %title has been deleted.', array('%title' => $title)), 'Menu link was deleted');
|
||||
|
||||
// Verify deletion.
|
||||
$this->drupalGet('');
|
||||
@ -509,7 +509,7 @@ class MenuTestCase extends DrupalWebTestCase {
|
||||
$item['link_path'] .= '#' . $options['fragment'];
|
||||
}
|
||||
foreach ($expected_item as $key => $value) {
|
||||
$this->assertEqual($item[$key], $value, t('Parameter %key had expected value.', array('%key' => $key)));
|
||||
$this->assertEqual($item[$key], $value, format_string('Parameter %key had expected value.', array('%key' => $key)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -537,21 +537,21 @@ class MenuTestCase extends DrupalWebTestCase {
|
||||
$this->drupalGet('admin/help/menu');
|
||||
$this->assertResponse($response);
|
||||
if ($response == 200) {
|
||||
$this->assertText(t('Menu'), t('Menu help was displayed'));
|
||||
$this->assertText(t('Menu'), 'Menu help was displayed');
|
||||
}
|
||||
|
||||
// View menu build overview node.
|
||||
$this->drupalGet('admin/structure/menu');
|
||||
$this->assertResponse($response);
|
||||
if ($response == 200) {
|
||||
$this->assertText(t('Menus'), t('Menu build overview node was displayed'));
|
||||
$this->assertText(t('Menus'), 'Menu build overview node was displayed');
|
||||
}
|
||||
|
||||
// View navigation menu customization node.
|
||||
$this->drupalGet('admin/structure/menu/manage/navigation');
|
||||
$this->assertResponse($response);
|
||||
if ($response == 200) {
|
||||
$this->assertText(t('Navigation'), t('Navigation menu node was displayed'));
|
||||
$this->assertText(t('Navigation'), 'Navigation menu node was displayed');
|
||||
}
|
||||
|
||||
// View menu edit node.
|
||||
@ -559,21 +559,21 @@ class MenuTestCase extends DrupalWebTestCase {
|
||||
$this->drupalGet('admin/structure/menu/item/' . $item['mlid'] . '/edit');
|
||||
$this->assertResponse($response);
|
||||
if ($response == 200) {
|
||||
$this->assertText(t('Edit menu item'), t('Menu edit node was displayed'));
|
||||
$this->assertText(t('Edit menu item'), 'Menu edit node was displayed');
|
||||
}
|
||||
|
||||
// View menu settings node.
|
||||
$this->drupalGet('admin/structure/menu/settings');
|
||||
$this->assertResponse($response);
|
||||
if ($response == 200) {
|
||||
$this->assertText(t('Menus'), t('Menu settings node was displayed'));
|
||||
$this->assertText(t('Menus'), 'Menu settings node was displayed');
|
||||
}
|
||||
|
||||
// View add menu node.
|
||||
$this->drupalGet('admin/structure/menu/add');
|
||||
$this->assertResponse($response);
|
||||
if ($response == 200) {
|
||||
$this->assertText(t('Menus'), t('Add menu node was displayed'));
|
||||
$this->assertText(t('Menus'), 'Add menu node was displayed');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -654,7 +654,7 @@ class MenuNodeTestCase extends DrupalWebTestCase {
|
||||
$this->assertLink($node_title);
|
||||
|
||||
$this->drupalGet('node/' . $node->nid . '/edit');
|
||||
$this->assertOptionSelected('edit-menu-weight', 17, t('Menu weight correct in edit form'));
|
||||
$this->assertOptionSelected('edit-menu-weight', 17, 'Menu weight correct in edit form');
|
||||
|
||||
// Edit the node and remove the menu link.
|
||||
$edit = array(
|
||||
@ -675,11 +675,11 @@ class MenuNodeTestCase extends DrupalWebTestCase {
|
||||
|
||||
// Assert that disabled Management menu is not shown on the node/$nid/edit page.
|
||||
$this->drupalGet('node/' . $node->nid . '/edit');
|
||||
$this->assertText('Provide a menu link', t('Link in not allowed menu not shown in node edit form'));
|
||||
$this->assertText('Provide a menu link', 'Link in not allowed menu not shown in node edit form');
|
||||
// Assert that the link is still in the management menu after save.
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
||||
$link = menu_link_load($item['mlid']);
|
||||
$this->assertTrue($link, t('Link in not allowed menu still exists after saving node'));
|
||||
$this->assertTrue($link, 'Link in not allowed menu still exists after saving node');
|
||||
|
||||
// Move the menu link back to the Navigation menu.
|
||||
$item['menu_name'] = 'navigation';
|
||||
|
@ -9,8 +9,8 @@ required = TRUE
|
||||
configure = admin/structure/types
|
||||
stylesheets[all][] = node.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"
|
||||
|
||||
|
@ -244,13 +244,7 @@ function node_field_display_node_alter(&$display, $context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity URI callback.
|
||||
*
|
||||
* @param $node
|
||||
* A node entity.
|
||||
*
|
||||
* @return array
|
||||
* An array with 'path' as the key and the path to the node as its value.
|
||||
* Implements callback_entity_info_uri().
|
||||
*/
|
||||
function node_uri($node) {
|
||||
return array(
|
||||
@ -1593,6 +1587,9 @@ function node_permission() {
|
||||
),
|
||||
'access content overview' => array(
|
||||
'title' => t('Access the content overview page'),
|
||||
'description' => user_access('access content overview')
|
||||
? t('Get an overview of <a href="@url">all content</a>.', array('@url' => url('admin/content')))
|
||||
: t('Get an overview of all content.'),
|
||||
),
|
||||
'access content' => array(
|
||||
'title' => t('View published content'),
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
@ -5,8 +5,8 @@ package = Core
|
||||
core = 7.x
|
||||
files[] = openid.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"
|
||||
|
||||
|
@ -6,8 +6,8 @@ core = 7.x
|
||||
dependencies[] = openid
|
||||
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"
|
||||
|
||||
|
@ -4,8 +4,8 @@ package = Core
|
||||
version = VERSION
|
||||
core = 7.x
|
||||
|
||||
; 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"
|
||||
|
||||
|
@ -6,8 +6,8 @@ core = 7.x
|
||||
files[] = path.test
|
||||
configure = admin/config/search/path
|
||||
|
||||
; 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"
|
||||
|
||||
|
@ -42,12 +42,12 @@ class PathTestCase extends DrupalWebTestCase {
|
||||
// created.
|
||||
cache_clear_all('*', 'cache_path', TRUE);
|
||||
$this->drupalGet($edit['source']);
|
||||
$this->assertTrue(cache_get($edit['source'], 'cache_path'), t('Cache entry was created.'));
|
||||
$this->assertTrue(cache_get($edit['source'], 'cache_path'), 'Cache entry was created.');
|
||||
|
||||
// Visit the alias for the node and confirm a cache entry is created.
|
||||
cache_clear_all('*', 'cache_path', TRUE);
|
||||
$this->drupalGet($edit['alias']);
|
||||
$this->assertTrue(cache_get($edit['source'], 'cache_path'), t('Cache entry was created.'));
|
||||
$this->assertTrue(cache_get($edit['source'], 'cache_path'), 'Cache entry was created.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -334,7 +334,7 @@ class PathLanguageTestCase extends DrupalWebTestCase {
|
||||
drupal_static_reset('locale_url_outbound_alter');
|
||||
$languages = language_list();
|
||||
$url = url('node/' . $french_node->nid, array('language' => $languages[$french_node->language]));
|
||||
$this->assertTrue(strpos($url, $edit['path[alias]']), t('URL contains the path alias.'));
|
||||
$this->assertTrue(strpos($url, $edit['path[alias]']), 'URL contains the path alias.');
|
||||
|
||||
// Confirm that the alias works even when changing language negotiation
|
||||
// options. Enable User language detection and selection over URL one.
|
||||
@ -378,23 +378,23 @@ class PathLanguageTestCase extends DrupalWebTestCase {
|
||||
// situation only aliases in the default language and language neutral ones
|
||||
// should keep working.
|
||||
$this->drupalGet($french_alias);
|
||||
$this->assertResponse(404, t('Alias for French translation is unavailable when URL language negotiation is disabled.'));
|
||||
$this->assertResponse(404, 'Alias for French translation is unavailable when URL language negotiation is disabled.');
|
||||
|
||||
// drupal_lookup_path() has an internal static cache. Check to see that
|
||||
// it has the appropriate contents at this point.
|
||||
drupal_lookup_path('wipe');
|
||||
$french_node_path = drupal_lookup_path('source', $french_alias, $french_node->language);
|
||||
$this->assertEqual($french_node_path, 'node/' . $french_node->nid, t('Normal path works.'));
|
||||
$this->assertEqual($french_node_path, 'node/' . $french_node->nid, 'Normal path works.');
|
||||
// Second call should return the same path.
|
||||
$french_node_path = drupal_lookup_path('source', $french_alias, $french_node->language);
|
||||
$this->assertEqual($french_node_path, 'node/' . $french_node->nid, t('Normal path is the same.'));
|
||||
$this->assertEqual($french_node_path, 'node/' . $french_node->nid, 'Normal path is the same.');
|
||||
|
||||
// Confirm that the alias works.
|
||||
$french_node_alias = drupal_lookup_path('alias', 'node/' . $french_node->nid, $french_node->language);
|
||||
$this->assertEqual($french_node_alias, $french_alias, t('Alias works.'));
|
||||
$this->assertEqual($french_node_alias, $french_alias, 'Alias works.');
|
||||
// Second call should return the same alias.
|
||||
$french_node_alias = drupal_lookup_path('alias', 'node/' . $french_node->nid, $french_node->language);
|
||||
$this->assertEqual($french_node_alias, $french_alias, t('Alias is the same.'));
|
||||
$this->assertEqual($french_node_alias, $french_alias, 'Alias is the same.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -508,8 +508,8 @@ class PathMonolingualTestCase extends DrupalWebTestCase {
|
||||
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
|
||||
|
||||
// Verify that French is the only language.
|
||||
$this->assertFalse(drupal_multilingual(), t('Site is mono-lingual'));
|
||||
$this->assertEqual(language_default('language'), 'fr', t('French is the default language'));
|
||||
$this->assertFalse(drupal_multilingual(), 'Site is mono-lingual');
|
||||
$this->assertEqual(language_default('language'), 'fr', 'French is the default language');
|
||||
|
||||
// Set language detection to URL.
|
||||
$edit = array('language[enabled][locale-url]' => TRUE);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user