diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-03-17 23:26:33 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-03-17 23:26:33 +0000 |
commit | ee2e63d7f9064ae57b3fb91007c53ceddf31ae48 (patch) | |
tree | 9536e30197339acf0902133e2096ee205f6b7b1a /modules/simpletest/tests | |
parent | 16dcae23519b3ad5a1b6c287f69d2f049b2f8841 (diff) | |
download | brdo-ee2e63d7f9064ae57b3fb91007c53ceddf31ae48.tar.gz brdo-ee2e63d7f9064ae57b3fb91007c53ceddf31ae48.tar.bz2 |
#402804 by roychri and Damien Tournoud: Add assertions to check if text was found only once or more than once.
Diffstat (limited to 'modules/simpletest/tests')
-rw-r--r-- | modules/simpletest/tests/form.test | 29 | ||||
-rw-r--r-- | modules/simpletest/tests/form_test.module | 29 |
2 files changed, 58 insertions, 0 deletions
diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test index b51c116d0..9dfa7cf8c 100644 --- a/modules/simpletest/tests/form.test +++ b/modules/simpletest/tests/form.test @@ -315,3 +315,32 @@ class FormsElementsTableSelectFunctionalTest extends DrupalWebTestCase { } +/** + * Test the form_clean_id() for expected behavior. + */ +class FormsFormCleanIdFunctionalTest extends DrupalWebTestCase { + + function getInfo() { + return array( + 'name' => t('form_clean_id() test'), + 'description' => t('Test the function form_clean_id() for expected behavior'), + 'group' => t('Form API'), + ); + } + + function setUp() { + parent::setUp('form_test'); + } + + /** + * Test the uniqueness of the form_clean_id() function. + */ + function testFormCleanId() { + $this->drupalGet('form_test/form_clean_id'); + $this->assertNoUniqueText('form-test-form-clean-id-presence'); + $this->assertUniqueText('form-test-form-clean-id-presence-1'); + $this->assertUniqueText('form-test-form-clean-id-presence-2'); + $this->assertNoUniqueText('Test Textfield'); + } + +} diff --git a/modules/simpletest/tests/form_test.module b/modules/simpletest/tests/form_test.module index a1eee25b2..057046caf 100644 --- a/modules/simpletest/tests/form_test.module +++ b/modules/simpletest/tests/form_test.module @@ -44,10 +44,39 @@ function form_test_menu() { 'type' => MENU_CALLBACK, ); + $items['form_test/form_clean_id'] = array( + 'title' => 'form_clean_id test', + 'page callback' => 'form_test_form_clean_id_page', + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); + return $items; } /** + * Generate a page with three form, to test the clean_id generation. + */ +function form_test_form_clean_id_page() { + $output = drupal_get_form('form_test_test_form'); + $output .= drupal_get_form('form_test_test_form'); + $output .= drupal_get_form('form_test_test_form'); + return $output; +} + +/** + * A simple form to test clean_id generation. + */ +function form_test_test_form(&$form_state) { + $form['input'] = array( + '#type' => 'item', + '#title' => 'Test Textfield', + '#markup' => form_clean_id('form_test_form_clean_id_presence'), + ); + return $form; +} + +/** * Create a header and options array. Helper function for callbacks. */ function _form_test_tableselect_get_data() { |