Index: modules/simpletest/drupal_web_test_case.php =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v retrieving revision 1.235 diff -u -p -r1.235 drupal_web_test_case.php --- modules/simpletest/drupal_web_test_case.php 19 Sep 2010 18:39:18 -0000 1.235 +++ modules/simpletest/drupal_web_test_case.php 21 Sep 2010 20:02:01 -0000 @@ -908,6 +908,24 @@ class DrupalWebTestCase extends DrupalTe } /** + * Creates a default configuration from the Standard installation profile. + * + * @param $module + * The name of module to invoke the default configuration from the Standard + * installation profile; e.g., "node" to invoke _standad_install_node(). + * + * @see standard.install + */ + protected function drupalCreateStandard($module) { + require_once DRUPAL_ROOT . '/' . drupal_get_path('profile', 'standard') . '/standard.install'; + $function = '_standard_install_' . $module; + $function(); + + // Reset permissions to catch any new. + $this->checkPermissions(array(), TRUE); + } + + /** * Get a list files that can be used in tests. * * @param $type @@ -978,16 +996,18 @@ class DrupalWebTestCase extends DrupalTe } /** - * Create a user with a given set of permissions. The permissions correspond to the - * names given on the privileges page. + * Create a user with a given set of permissions. * * @param $permissions - * Array of permission names to assign to user. + * Array of permission names to assign to the user. Note that the user + * always has the default permissions derived from the + * "authenticated users" role. + * * @return * A fully loaded user object with pass_raw property, or FALSE if account * creation fails. */ - protected function drupalCreateUser($permissions = array('access comments', 'access content', 'post comments', 'post comments without approval')) { + protected function drupalCreateUser(array $permissions = array()) { // Create a role with the given permission set. if (!($rid = $this->drupalCreateRole($permissions))) { return FALSE; Index: modules/simpletest/tests/actions.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/actions.test,v retrieving revision 1.18 diff -u -p -r1.18 actions.test --- modules/simpletest/tests/actions.test 5 Aug 2010 23:53:38 -0000 1.18 +++ modules/simpletest/tests/actions.test 21 Sep 2010 19:25:57 -0000 @@ -67,11 +67,13 @@ class ActionsConfigurationTestCase exten /** * Test actions executing in a potential loop, and make sure they abort properly. */ -class ActionLoopTestCase extends DrupalWebTestCase { +class ActionsLoopTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; + public static function getInfo() { return array( - 'name' => 'Actions executing in a potentially infinite loop', - 'description' => 'Tests actions executing in a loop, and makes sure they abort properly.', + 'name' => 'Actions infinite loop', + 'description' => 'Tests actions executing in an infinite loop, and makes sure they abort properly.', 'group' => 'Actions', ); } Index: modules/simpletest/tests/ajax_forms_test.module =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/ajax_forms_test.module,v retrieving revision 1.7 diff -u -p -r1.7 ajax_forms_test.module --- modules/simpletest/tests/ajax_forms_test.module 6 May 2010 05:59:31 -0000 1.7 +++ modules/simpletest/tests/ajax_forms_test.module 21 Sep 2010 19:25:57 -0000 @@ -38,7 +38,6 @@ function ajax_forms_test_menu() { * A basic form used to test form_state['values'] during callback. */ function ajax_forms_test_simple_form($form, &$form_state) { - $form = array(); $form['select'] = array( '#type' => 'select', '#options' => array( Index: modules/simpletest/tests/form.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/form.test,v retrieving revision 1.67 diff -u -p -r1.67 form.test --- modules/simpletest/tests/form.test 19 Sep 2010 18:39:18 -0000 1.67 +++ modules/simpletest/tests/form.test 21 Sep 2010 19:54:46 -0000 @@ -7,17 +7,19 @@ */ class FormsTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; public static function getInfo() { return array( - 'name' => 'Form element validation', + 'name' => 'Element validation', 'description' => 'Tests various form element validation mechanisms.', 'group' => 'Form API', ); } function setUp() { - parent::setUp('form_test'); + parent::setUp('form_test', 'file'); + $this->drupalCreateStandard('filter'); } /** @@ -309,16 +311,18 @@ class FormsTestCase extends DrupalWebTes * Test form alter hooks. */ class FormAlterTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; + public static function getInfo() { return array( - 'name' => 'Form alter hooks', + 'name' => 'Alter hooks', 'description' => 'Tests hook_form_alter() and hook_form_FORM_ID_alter().', 'group' => 'Form API', ); } function setUp() { - parent::setUp('form_test'); + parent::setUp('form_test', 'block'); } /** @@ -343,6 +347,8 @@ class FormAlterTestCase extends DrupalWe * Test form validation handlers. */ class FormValidationTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; + public static function getInfo() { return array( 'name' => 'Form validation handlers', @@ -423,10 +429,11 @@ class FormValidationTestCase extends Dru * Test form element labels, required markers and associated output. */ class FormsElementsLabelsTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; public static function getInfo() { return array( - 'name' => 'Form element and label output test', + 'name' => 'Labels and markers', 'description' => 'Test form element labels, required markers and associated output.', 'group' => 'Form API', ); @@ -496,10 +503,11 @@ class FormsElementsLabelsTestCase extend * Test the tableselect form element for expected behavior. */ class FormsElementsTableSelectFunctionalTest extends DrupalWebTestCase { + protected $profile = 'testing'; public static function getInfo() { return array( - 'name' => 'Tableselect form element type test', + 'name' => 'Tableselect', 'description' => 'Test the tableselect element for expected behavior', 'group' => 'Form API', ); @@ -509,14 +517,11 @@ class FormsElementsTableSelectFunctional parent::setUp('form_test'); } - /** * Test the display of checkboxes when #multiple is TRUE. */ function testMultipleTrue() { - $this->drupalGet('form_test/tableselect/multiple-true'); - $this->assertNoText(t('Empty text.'), t('Empty text should not be displayed.')); // Test for the presence of the Select all rows tableheader. @@ -533,7 +538,6 @@ class FormsElementsTableSelectFunctional */ function testMultipleFalse() { $this->drupalGet('form_test/tableselect/multiple-false'); - $this->assertNoText(t('Empty text.'), t('Empty text should not be displayed.')); // Test for the absence of the Select all rows tableheader. @@ -557,9 +561,7 @@ class FormsElementsTableSelectFunctional * Test the submission of single and multiple values when #multiple is TRUE. */ function testMultipleTrueSubmit() { - // Test a submission with one checkbox checked. - $edit = array(); $edit['tableselect[row1]'] = TRUE; $this->drupalPost('form_test/tableselect/multiple-true', $edit, 'Submit'); @@ -575,7 +577,6 @@ class FormsElementsTableSelectFunctional $this->assertText(t('Submitted: row1 = row1'), t('Checked checkbox row1.')); $this->assertText(t('Submitted: row2 = 0'), t('Unchecked checkbox row2.')); $this->assertText(t('Submitted: row3 = row3'), t('Checked checkbox row3.')); - } /** @@ -607,14 +608,11 @@ class FormsElementsTableSelectFunctional $this->assertNoFieldByXPath('//th[@class="select-all"]', NULL, t('Do not display a "Select all" checkbox when #multiple is FALSE, even when #js_select is TRUE.')); } - /** * Test the whether the option checker gives an error on invalid tableselect values for checkboxes. */ function testMultipleTrueOptionchecker() { - list($header, $options) = _form_test_tableselect_get_data(); - $form['tableselect'] = array( '#type' => 'tableselect', '#header' => $header, @@ -631,14 +629,11 @@ class FormsElementsTableSelectFunctional } - /** * Test the whether the option checker gives an error on invalid tableselect values for radios. */ function testMultipleFalseOptionchecker() { - list($header, $options) = _form_test_tableselect_get_data(); - $form['tableselect'] = array( '#type' => 'tableselect', '#header' => $header, @@ -655,7 +650,6 @@ class FormsElementsTableSelectFunctional $this->assertTrue(isset($errors['tableselect']), t('Option checker disallows invalid values for radio buttons.')); } - /** * Helper function for the option check test to submit a form while collecting errors. * @@ -677,9 +671,7 @@ class FormsElementsTableSelectFunctional $form_state['input']['form_id'] = $form_id; drupal_prepare_form($form_id, $form, $form_state); - drupal_process_form($form_id, $form, $form_state); - $errors = form_get_errors(); // Clear errors and messages. @@ -690,7 +682,6 @@ class FormsElementsTableSelectFunctional // to allow the caller lowlevel access to the form. return array($form, $form_state, $errors); } - } /** @@ -703,11 +694,12 @@ class FormsElementsTableSelectFunctional * values aren't lost due to a wrong form rebuild. */ class FormsFormStorageTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; public static function getInfo() { return array( - 'name' => 'Multistep form using form storage', - 'description' => 'Tests a multistep form using form storage and makes sure validation and caching works right.', + 'name' => 'Multistep form storage', + 'description' => 'Tests a multistep form using form storage and makes sure validation and caching works right.', 'group' => 'Form API', ); } @@ -853,9 +845,11 @@ class FormsFormStorageTestCase extends D * Test wrapper form callbacks. */ class FormsFormWrapperTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; + public static function getInfo() { return array( - 'name' => 'Form wrapper callback', + 'name' => 'Wrapper callback', 'description' => 'Tests form wrapper callbacks to pass a prebuilt form to form builder functions.', 'group' => 'Form API', ); @@ -879,6 +873,8 @@ class FormsFormWrapperTestCase extends D * Test $form_state clearance. */ class FormStateValuesCleanTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; + public static function getInfo() { return array( 'name' => 'Form state values clearance', @@ -931,7 +927,7 @@ class FormStateValuesCleanTestCase exten class FormsRebuildTestCase extends DrupalWebTestCase { public static function getInfo() { return array( - 'name' => 'Form rebuilding', + 'name' => 'Rebuild', 'description' => 'Tests functionality of drupal_rebuild_form().', 'group' => 'Form API', ); @@ -1021,10 +1017,11 @@ class FormsRebuildTestCase extends Drupa * Test the programmatic form submission behavior. */ class FormsProgrammaticTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; public static function getInfo() { return array( - 'name' => 'Programmatic form submissions', + 'name' => 'Programmed submissions', 'description' => 'Test the programmatic form submission behavior.', 'group' => 'Form API', ); @@ -1101,10 +1098,11 @@ class FormsProgrammaticTestCase extends * Test that FAPI correctly determines $form_state['triggering_element']. */ class FormsTriggeringElementTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; public static function getInfo() { return array( - 'name' => 'Form triggering element determination', + 'name' => 'Triggering element', 'description' => 'Test the determination of $form_state[\'triggering_element\'].', 'group' => 'Form API', ); @@ -1265,10 +1263,11 @@ class FormsArbitraryRebuildTestCase exte * Tests form API file inclusion. */ class FormsFileInclusionTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; public static function getInfo() { return array( - 'name' => 'Form API file inclusion', + 'name' => 'Include files', 'description' => 'Tests form API file inclusion.', 'group' => 'Form API', ); @@ -1279,17 +1278,14 @@ class FormsFileInclusionTestCase extends } /** - * Tests loading an include specified in hook_menu(). + * Tests form state file inclusion. */ function testLoadMenuInclude() { + // Verify loading an include specified in hook_menu(). $this->drupalPostAJAX('form-test/load-include-menu', array(), array('op' => t('Save')), 'system/ajax', array(), array(), 'form-test-load-include-menu'); $this->assertText('Submit callback called.'); - } - /** - * Tests loading a custom specified inlcude. - */ - function testLoadCustomInclude() { + // Verify loading a custom specified include. $this->drupalPost('form-test/load-include-custom', array(), t('Save')); $this->assertText('Submit callback called.'); } Index: profiles/standard/standard.install =================================================================== RCS file: /cvs/drupal/drupal/profiles/standard/standard.install,v retrieving revision 1.23 diff -u -p -r1.23 standard.install --- profiles/standard/standard.install 7 Sep 2010 18:01:32 -0000 1.23 +++ profiles/standard/standard.install 21 Sep 2010 20:04:28 -0000 @@ -8,6 +8,55 @@ */ function standard_install() { // Add text formats. + _standard_install_filter(); + + // Enable some standard blocks. + _standard_install_block(); + + // Insert default pre-defined node types into the database. + _standard_install_node(); + + // Insert default pre-defined RDF mapping into the database. + _standard_install_rdf(); + + // Configure default comment settings. + _standard_install_comment(); + + // Configure default user settings. + _standard_install_user(); + + // Create a default vocabulary named "Tags", enabled for the 'article' content + // type. + _standard_install_taxonomy(); + + // Create an image field named "Image", enabled for the 'article' content type. + _standard_install_image(); + + // Create a Home link in the main menu. + $item = array( + 'link_title' => 'Home', + 'link_path' => '', + 'menu_name' => 'main-menu', + ); + menu_link_save($item); + + // Update the menu router information. + menu_rebuild(); + + // Enable the admin theme. + db_update('system') + ->fields(array('status' => 1)) + ->condition('type', 'theme') + ->condition('name', 'seven') + ->execute(); + variable_set('admin_theme', 'seven'); + variable_set('node_admin_theme', '1'); +} + +/** + * Configures default text formats. + */ +function _standard_install_filter() { $filtered_html_format = array( 'name' => 'Filtered HTML', 'weight' => 0, @@ -61,7 +110,16 @@ function standard_install() { $full_html_format = (object) $full_html_format; filter_format_save($full_html_format); - // Enable some standard blocks. + // Grant default permissions. + $filtered_html_permission = filter_permission_name($filtered_html_format); + user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array($filtered_html_permission)); + user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array($filtered_html_permission)); +} + +/** + * Configures default blocks. + */ +function _standard_install_block() { $default_theme = variable_get('theme_default', 'bartik'); $admin_theme = 'seven'; $values = array( @@ -196,15 +254,21 @@ function standard_install() { 'cache' => -1, ), ); - $query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache')); + $query = db_insert('block') + ->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache')); foreach ($values as $record) { $query->values($record); } $query->execute(); +} - // Insert default pre-defined node types into the database. For a complete - // list of available node type attributes, refer to the node type API - // documentation at: http://api.drupal.org/api/HEAD/function/hook_node_info. +/** + * Confgures default node types. + */ +function _standard_install_node() { + // For a complete list of available node type attributes, refer to the node + // type API documentation. + // @see http://api.drupal.org/api/HEAD/function/hook_node_info $types = array( array( 'type' => 'page', @@ -225,14 +289,26 @@ function standard_install() { 'locked' => 0, ), ); - foreach ($types as $type) { $type = node_type_set_defaults($type); node_type_save($type); node_add_body_field($type); } - // Insert default pre-defined RDF mapping into the database. + // Default "Basic page" to not be promoted and do not display date and author + // information for it. + variable_set('node_options_page', array('status')); + variable_set('node_submitted_page', FALSE); + + // Grant default permissions. + user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content')); + user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content')); +} + +/** + * Configures default RDF mappings. + */ +function _standard_install_rdf() { $rdf_mappings = array( array( 'type' => 'node', @@ -260,14 +336,24 @@ function standard_install() { foreach ($rdf_mappings as $rdf_mapping) { rdf_mapping_save($rdf_mapping); } +} - // Default "Basic page" to not be promoted and have comments disabled. - variable_set('node_options_page', array('status')); +/** + * Configures default comment settings. + */ +function _standard_install_comment() { + // Default "Basic page" to have comments disabled. variable_set('comment_page', COMMENT_NODE_HIDDEN); - // Don't display date and author information for "Basic page" nodes by default. - variable_set('node_submitted_page', FALSE); + // Grant default permissions. + user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access comments')); + user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access comments', 'post comments', 'post comments without approval')); +} +/** + * Configures default user settings. + */ +function _standard_install_user() { // Enable user picture support and set the default to a square thumbnail option. variable_set('user_pictures', '1'); variable_set('user_picture_dimensions', '1024x1024'); @@ -277,7 +363,27 @@ function standard_install() { // Allow visitor account creation with administrative approval. variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL); - // Create a default vocabulary named "Tags", enabled for the 'article' content type. + // Create a default role for site administrators, with all available + // permissions assigned. + $admin_role = new stdClass(); + $admin_role->name = 'administrator'; + $admin_role->weight = 2; + user_role_save($admin_role); + user_role_grant_permissions($admin_role->rid, array_keys(module_invoke_all('permission'))); + + // Set this as the administrator role. + variable_set('user_admin_role', $admin_role->rid); + + // Assign user 1 the "administrator" role. + db_insert('users_roles') + ->fields(array('uid' => 1, 'rid' => $admin_role->rid)) + ->execute(); +} + +/** + * Configures default taxonomy vocabularies and fields. + */ +function _standard_install_taxonomy() { $description = st('Use tags to group articles on similar topics into categories.'); $help = st('Enter a comma-separated list of words to describe your content.'); $vocabulary = (object) array( @@ -327,12 +433,15 @@ function standard_install() { ), ); field_create_instance($instance); +} - - // Create an image field named "Image", enabled for the 'article' content type. - // Many of the following values will be defaulted, they're included here as an illustrative examples. - // See http://api.drupal.org/api/function/field_create_field/7 - +/** + * Configures default image fields. + */ +function _standard_install_image() { + // Many of the following values will be defaulted, they're included here as + // illustrative examples. + // @see http://api.drupal.org/api/function/field_create_field/7 $field = array( 'field_name' => 'field_image', 'type' => 'image', @@ -351,9 +460,9 @@ function standard_install() { ); field_create_field($field); - - // Many of the following values will be defaulted, they're included here as an illustrative examples. - // See http://api.drupal.org/api/function/field_create_instance/7 + // Many of the following values will be defaulted, they're included here as + // illustrative examples. + // @see http://api.drupal.org/api/function/field_create_instance/7 $instance = array( 'field_name' => 'field_image', 'entity_type' => 'node', @@ -361,7 +470,6 @@ function standard_install() { 'bundle' => 'article', 'description' => st('Upload an image to go with this article.'), 'required' => FALSE, - 'settings' => array( 'file_directory' => 'field/image', 'file_extensions' => 'png gif jpg jpeg', @@ -371,7 +479,6 @@ function standard_install() { 'alt_field' => TRUE, 'title_field' => '', ), - 'widget' => array( 'type' => 'image_image', 'settings' => array( @@ -380,7 +487,6 @@ function standard_install() { ), 'weight' => -1, ), - 'display' => array( 'default' => array( 'label' => 'hidden', @@ -397,43 +503,4 @@ function standard_install() { ), ); field_create_instance($instance); - - // Enable default permissions for system roles. - $filtered_html_permission = filter_permission_name($filtered_html_format); - user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content', 'access comments', $filtered_html_permission)); - user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content', 'access comments', 'post comments', 'post comments without approval', $filtered_html_permission)); - - // Create a default role for site administrators, with all available permissions assigned. - $admin_role = new stdClass(); - $admin_role->name = 'administrator'; - $admin_role->weight = 2; - user_role_save($admin_role); - user_role_grant_permissions($admin_role->rid, array_keys(module_invoke_all('permission'))); - // Set this as the administrator role. - variable_set('user_admin_role', $admin_role->rid); - - // Assign user 1 the "administrator" role. - db_insert('users_roles') - ->fields(array('uid' => 1, 'rid' => $admin_role->rid)) - ->execute(); - - // Create a Home link in the main menu. - $item = array( - 'link_title' => 'Home', - 'link_path' => '', - 'menu_name' => 'main-menu', - ); - menu_link_save($item); - - // Update the menu router information. - menu_rebuild(); - - // Enable the admin theme. - db_update('system') - ->fields(array('status' => 1)) - ->condition('type', 'theme') - ->condition('name', 'seven') - ->execute(); - variable_set('admin_theme', 'seven'); - variable_set('node_admin_theme', '1'); }