diff options
Diffstat (limited to 'modules/system/system.test')
-rw-r--r-- | modules/system/system.test | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/modules/system/system.test b/modules/system/system.test index 3773af13c..d9577f669 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -718,3 +718,82 @@ class SystemBlockTestCase extends DrupalWebTestCase { } +class SystemSettingsForm extends DrupalWebTestCase { + /** + * Implementation of getInfo(). + */ + function getInfo() { + return array( + 'name' => t('System setting forms'), + 'description' => t('Tests correctness of system_settings_form() processing.'), + 'group' => t('System') + ); + } + + /** + * Implementation of setUp(). + */ + function setUp() { + parent::setUp(); + + variable_set('system_settings_form_test', TRUE); + variable_set('system_settings_form_test_4', TRUE); + } + + /** + * Reset page title. + */ + function tearDown() { + variable_del('system_settings_form_test'); + variable_del('system_settings_form_test_4'); + + parent::tearDown(); + } + + /** + * Tests the handling of automatic defaults in systems_settings_form(). + */ + function testAutomaticDefaults() { + $form = array(); + + $form['system_settings_form_test'] = array( + '#type' => 'checkbox', + '#default_value' => FALSE, + ); + + $form['system_settings_form_test_2'] = array( + '#type' => 'checkbox', + '#default_value' => FALSE, + ); + + $form['system_settings_form_test_3'] = array( + '#type' => 'checkbox', + '#default_value' => TRUE, + ); + + $form['has_children']['system_settings_form_test_4'] = array( + '#type' => 'checkbox', + '#default_value' => FALSE, + ); + + $form['has_children']['system_settings_form_test_5'] = array( + '#type' => 'checkbox', + '#default_value' => TRUE, + ); + + $automatic = system_settings_form($form, FALSE); + $this->assertFalse($automatic['system_settings_form_test']['#default_value']); + $this->assertFalse($automatic['system_settings_form_test_2']['#default_value']); + $this->assertTrue($automatic['system_settings_form_test_3']['#default_value']); + $this->assertFalse($automatic['has_children']['system_settings_form_test_4']['#default_value']); + $this->assertTrue($automatic['has_children']['system_settings_form_test_5']['#default_value']); + + + $no_automatic = system_settings_form($form); + $this->assertTrue($no_automatic['system_settings_form_test']['#default_value']); + $this->assertFalse($no_automatic['system_settings_form_test_2']['#default_value']); + $this->assertTrue($no_automatic['system_settings_form_test_3']['#default_value']); + $this->assertTrue($no_automatic['has_children']['system_settings_form_test_4']['#default_value']); + $this->assertTrue($no_automatic['has_children']['system_settings_form_test_5']['#default_value']); + } +} |