diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-07-15 17:40:18 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-07-15 17:40:18 +0000 |
commit | 5a8452c55b9e6d7fcef921a7b56c23ef29eec3a9 (patch) | |
tree | 7285272f52d423a3a49b2a8ac3a596fb5939c49d /modules/simpletest | |
parent | b692036962b8d2c5c2b12749cf662d537a889375 (diff) | |
download | brdo-5a8452c55b9e6d7fcef921a7b56c23ef29eec3a9.tar.gz brdo-5a8452c55b9e6d7fcef921a7b56c23ef29eec3a9.tar.bz2 |
- Patch #493746 by JohnAlbin, ultimateboy, moshe weitzman: Enhance drupal_attributes() for multiple valued values.
Diffstat (limited to 'modules/simpletest')
-rw-r--r-- | modules/simpletest/tests/common.test | 40 |
1 files changed, 40 insertions, 0 deletions
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="&"'<>"', 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.')); + } +} |