summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/image/image.module4
-rw-r--r--modules/simpletest/tests/common.test40
-rw-r--r--modules/user/user.module4
3 files changed, 44 insertions, 4 deletions
diff --git a/modules/image/image.module b/modules/image/image.module
index a979e6e5f..394bd5df5 100644
--- a/modules/image/image.module
+++ b/modules/image/image.module
@@ -29,7 +29,7 @@ function image_menu() {
function image_theme() {
return array(
'image_style' => array(
- 'arguments' => array('style' => NULL, 'path' => NULL, 'alt' => '', 'title' => '', 'attributes' => NULL, 'getsize' => TRUE),
+ 'arguments' => array('style' => NULL, 'path' => NULL, 'alt' => '', 'title' => '', 'attributes' => array(), 'getsize' => TRUE),
),
);
}
@@ -666,7 +666,7 @@ function image_effect_apply(&$image, $effect) {
* A string containing the image tag.
* @ingroup themeable
*/
-function theme_image_style($style_name, $path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) {
+function theme_image_style($style_name, $path, $alt = '', $title = '', $attributes = array(), $getsize = TRUE) {
// theme_image() can only honor the $getsize parameter with local file paths.
// The derivative image is not created until it has been requested so the file
// may not yet exist, in this case we just fallback to the URL.
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index b2ae4a3dc..c396e9120 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -1074,3 +1074,43 @@ class FormatDateUnitTest extends DrupalWebTestCase {
drupal_save_session(TRUE);
}
}
+
+/**
+ * Tests for the format_date() function.
+ */
+class DrupalAttributesUnitTest extends DrupalUnitTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => t('HTML Attributes'),
+ 'description' => t('Perform unit tests on the drupal_attributes() function.'),
+ 'group' => t('System')
+ );
+ }
+
+ /**
+ * Tests that drupal_css_class() cleans the class name properly.
+ */
+ function testDrupalAttributes() {
+ // Verify that special characters are HTML encoded.
+ $this->assertIdentical(drupal_attributes(array('title' => '&"\'<>')), ' title="&amp;&quot;&#039;&lt;&gt;"', t('HTML encode attribute values.'));
+
+ // Verify multi-value attributes are concatenated with spaces.
+ $attributes = array('class' => array('first', 'last'));
+ $this->assertIdentical(drupal_attributes(array('class' => array('first', 'last'))), ' class="first last"', t('Concatenate multi-value attributes.'));
+
+ // Verify empty attribute values are rendered.
+ $this->assertIdentical(drupal_attributes(array('alt' => '')), ' alt=""', t('Empty attribute value #1.'));
+ $this->assertIdentical(drupal_attributes(array('alt' => NULL)), ' alt=""', t('Empty attribute value #2.'));
+
+ // Verify multiple attributes are rendered.
+ $attributes = array(
+ 'id' => 'id-test',
+ 'class' => array('first', 'last'),
+ 'alt' => 'Alternate',
+ );
+ $this->assertIdentical(drupal_attributes($attributes), ' id="id-test" class="first last" alt="Alternate"', t('Multiple attributes.'));
+
+ // Verify empty attributes array is rendered.
+ $this->assertIdentical(drupal_attributes(array()), '', t('Empty attributes array.'));
+ }
+}
diff --git a/modules/user/user.module b/modules/user/user.module
index ac7f6cbff..f3d188791 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -1177,10 +1177,10 @@ function template_preprocess_user_picture(&$variables) {
if (isset($filepath)) {
$alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
if (module_exists('image') && $style = variable_get('user_picture_style', '')) {
- $variables['picture'] = theme('image_style', $style, $filepath, $alt, $alt, NULL, FALSE);
+ $variables['picture'] = theme('image_style', $style, $filepath, $alt, $alt, array(), FALSE);
}
else {
- $variables['picture'] = theme('image', $filepath, $alt, $alt, NULL, FALSE);
+ $variables['picture'] = theme('image', $filepath, $alt, $alt, array(), FALSE);
}
if (!empty($account->uid) && user_access('access user profiles')) {
$attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE);