Index: modules/simpletest/drupal_web_test_case.php =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v retrieving revision 1.237 diff -u -p -r1.237 drupal_web_test_case.php --- modules/simpletest/drupal_web_test_case.php 25 Sep 2010 01:50:07 -0000 1.237 +++ modules/simpletest/drupal_web_test_case.php 26 Sep 2010 15:49:16 -0000 @@ -912,6 +912,32 @@ class DrupalWebTestCase extends DrupalTe } /** + * Creates a default configuration from the standard installation profile. + * + * @param $module + * The name of a module, for which a corresponding _standard_install_MODULE + * function exists in the standard installation profile. For example, pass + * "node" to invoke the corresponding function _standard_install_node(). + * The corresponding function must exist in standard.install. + * Note that some default configurations depend on other, and potential + * dependencies have to be created manually; e.g., pass "node" before "rdf". + * + * @see standard.install + */ + protected function drupalCreateStandardConfiguration($module) { + require_once DRUPAL_ROOT . '/' . drupal_get_path('profile', 'standard') . '/standard.install'; + $function = '_standard_install_' . $module; + $function(); + + // Update the menu router information. + menu_rebuild(); + // Reset permissions to catch any new. + $this->checkPermissions(array(), TRUE); + + $this->pass(t('Created standard installation profile configuration for %module.', array('%module' => $module))); + } + + /** * Get a list files that can be used in tests. * * @param $type @@ -982,16 +1008,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 26 Sep 2010 16:04:23 -0000 @@ -68,10 +68,12 @@ class ActionsConfigurationTestCase exten * Test actions executing in a potential loop, and make sure they abort properly. */ class ActionLoopTestCase 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/form.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/form.test,v retrieving revision 1.68 diff -u -p -r1.68 form.test --- modules/simpletest/tests/form.test 24 Sep 2010 21:36:22 -0000 1.68 +++ modules/simpletest/tests/form.test 26 Sep 2010 16:19:39 -0000 @@ -7,6 +7,7 @@ */ class FormsTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; public static function getInfo() { return array( @@ -17,7 +18,8 @@ class FormsTestCase extends DrupalWebTes } function setUp() { - parent::setUp('form_test'); + parent::setUp(array('form_test', 'file')); + $this->drupalCreateStandardConfiguration('filter'); } /** @@ -370,6 +372,8 @@ 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', @@ -379,7 +383,7 @@ class FormAlterTestCase extends DrupalWe } function setUp() { - parent::setUp('form_test'); + parent::setUp('form_test', 'block'); } /** @@ -404,6 +408,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', @@ -484,6 +490,7 @@ 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( @@ -557,6 +564,7 @@ class FormsElementsLabelsTestCase extend * Test the tableselect form element for expected behavior. */ class FormsElementsTableSelectFunctionalTest extends DrupalWebTestCase { + protected $profile = 'testing'; public static function getInfo() { return array( @@ -764,6 +772,7 @@ 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( @@ -914,6 +923,8 @@ 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', @@ -940,6 +951,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', @@ -1082,6 +1095,7 @@ class FormsRebuildTestCase extends Drupa * Test the programmatic form submission behavior. */ class FormsProgrammaticTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; public static function getInfo() { return array( @@ -1162,6 +1176,7 @@ 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( @@ -1326,6 +1341,7 @@ class FormsArbitraryRebuildTestCase exte * Tests form API file inclusion. */ class FormsFileInclusionTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; public static function getInfo() { return array( @@ -1340,17 +1356,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 26 Sep 2010 15:49:16 -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'); }