Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.252
diff -u -p -r1.252 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php 29 Nov 2010 04:45:11 -0000 1.252
+++ modules/simpletest/drupal_web_test_case.php 29 Nov 2010 14:04:49 -0000
@@ -925,6 +925,32 @@ class DrupalWebTestCase extends DrupalTe
}
/**
+ * Creates a default configuration from the testing installation profile.
+ *
+ * @param $module
+ * The name of a module, for which a corresponding _testing_install_MODULE
+ * function exists in the testing installation profile. For example, pass
+ * "node" to invoke the corresponding function _testing_install_node().
+ * The corresponding function must exist in testing.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 drupalCreateTestConfiguration($module) {
+ require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'testing') . '/testing.install';
+ $function = '_testing_install_' . $module;
+ $function();
+
+ // Update the menu router information.
+ menu_rebuild();
+ // Reset permissions to catch any new.
+ $this->checkPermissions(array(), TRUE);
+
+ $this->pass(t('Created test configuration for %module.', array('%module' => $module)));
+ }
+
+ /**
* Get a list files that can be used in tests.
*
* @param $type
@@ -995,26 +1021,32 @@ 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 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', 'skip comment approval')) {
- // Create a role with the given permission set.
- if (!($rid = $this->drupalCreateRole($permissions))) {
- return FALSE;
+ protected function drupalCreateUser(array $permissions = array()) {
+ // Create a role with the given permission set, if any.
+ $rid = FALSE;
+ if ($permissions) {
+ $rid = $this->drupalCreateRole($permissions);
+ if (!$rid) {
+ return FALSE;
+ }
}
// Create a user assigned to that role.
$edit = array();
$edit['name'] = $this->randomName();
$edit['mail'] = $edit['name'] . '@example.com';
- $edit['roles'] = array($rid => $rid);
+ if ($rid) {
+ $edit['roles'] = array($rid => $rid);
+ }
$edit['pass'] = user_password();
$edit['status'] = 1;
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 29 Nov 2010 13:59:47 -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.76
diff -u -p -r1.76 form.test
--- modules/simpletest/tests/form.test 21 Nov 2010 10:14:25 -0000 1.76
+++ modules/simpletest/tests/form.test 29 Nov 2010 13:59:47 -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('form_test', 'file');
+ $this->drupalCreateTestConfiguration('filter');
}
/**
@@ -433,6 +435,8 @@ class FormElementTestCase extends Drupal
* Test form alter hooks.
*/
class FormAlterTestCase extends DrupalWebTestCase {
+ protected $profile = 'testing';
+
public static function getInfo() {
return array(
'name' => 'Form alter hooks',
@@ -442,7 +446,7 @@ class FormAlterTestCase extends DrupalWe
}
function setUp() {
- parent::setUp('form_test');
+ parent::setUp('form_test', 'block');
}
/**
@@ -467,6 +471,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',
@@ -564,6 +570,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(
@@ -637,6 +644,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(
@@ -844,6 +852,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(
@@ -988,6 +997,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',
@@ -1014,6 +1025,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',
@@ -1156,6 +1169,7 @@ class FormsRebuildTestCase extends Drupa
* Test the programmatic form submission behavior.
*/
class FormsProgrammaticTestCase extends DrupalWebTestCase {
+ protected $profile = 'testing';
public static function getInfo() {
return array(
@@ -1236,6 +1250,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(
@@ -1400,6 +1415,7 @@ class FormsArbitraryRebuildTestCase exte
* Tests form API file inclusion.
*/
class FormsFileInclusionTestCase extends DrupalWebTestCase {
+ protected $profile = 'testing';
public static function getInfo() {
return array(
@@ -1414,17 +1430,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/testing/testing.install
===================================================================
RCS file: /cvs/drupal/drupal/profiles/testing/testing.install,v
retrieving revision 1.2
diff -u -p -r1.2 testing.install
--- profiles/testing/testing.install 27 Aug 2010 12:36:53 -0000 1.2
+++ profiles/testing/testing.install 29 Nov 2010 13:59:47 -0000
@@ -14,3 +14,455 @@ function testing_install() {
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content'));
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content'));
}
+
+/**
+ * Configures default text formats.
+ */
+function _testing_install_filter() {
+ $filtered_html_format = array(
+ 'name' => 'Filtered HTML',
+ 'weight' => 0,
+ 'filters' => array(
+ // URL filter.
+ 'filter_url' => array(
+ 'weight' => 0,
+ 'status' => 1,
+ ),
+ // HTML filter.
+ 'filter_html' => array(
+ 'weight' => 1,
+ 'status' => 1,
+ ),
+ // Line break filter.
+ 'filter_autop' => array(
+ 'weight' => 2,
+ 'status' => 1,
+ ),
+ // HTML corrector filter.
+ 'filter_htmlcorrector' => array(
+ 'weight' => 10,
+ 'status' => 1,
+ ),
+ ),
+ );
+ $filtered_html_format = (object) $filtered_html_format;
+ filter_format_save($filtered_html_format);
+
+ $full_html_format = array(
+ 'name' => 'Full HTML',
+ 'weight' => 1,
+ 'filters' => array(
+ // URL filter.
+ 'filter_url' => array(
+ 'weight' => 0,
+ 'status' => 1,
+ ),
+ // Line break filter.
+ 'filter_autop' => array(
+ 'weight' => 1,
+ 'status' => 1,
+ ),
+ // HTML corrector filter.
+ 'filter_htmlcorrector' => array(
+ 'weight' => 10,
+ 'status' => 1,
+ ),
+ ),
+ );
+ $full_html_format = (object) $full_html_format;
+ filter_format_save($full_html_format);
+
+ // 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 _testing_install_block() {
+ $default_theme = variable_get('theme_default', 'bartik');
+ $admin_theme = 'seven';
+ $values = array(
+ array(
+ 'module' => 'system',
+ 'delta' => 'main',
+ 'theme' => $default_theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'content',
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'search',
+ 'delta' => 'form',
+ 'theme' => $default_theme,
+ 'status' => 1,
+ 'weight' => -1,
+ 'region' => 'sidebar_first',
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'node',
+ 'delta' => 'recent',
+ 'theme' => $admin_theme,
+ 'status' => 1,
+ 'weight' => 10,
+ 'region' => 'dashboard_main',
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'user',
+ 'delta' => 'login',
+ 'theme' => $default_theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'sidebar_first',
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'system',
+ 'delta' => 'navigation',
+ 'theme' => $default_theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'sidebar_first',
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'system',
+ 'delta' => 'management',
+ 'theme' => $default_theme,
+ 'status' => 1,
+ 'weight' => 1,
+ 'region' => 'sidebar_first',
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'system',
+ 'delta' => 'powered-by',
+ 'theme' => $default_theme,
+ 'status' => 1,
+ 'weight' => 10,
+ 'region' => 'footer',
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'system',
+ 'delta' => 'help',
+ 'theme' => $default_theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'help',
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'system',
+ 'delta' => 'main',
+ 'theme' => $admin_theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'content',
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'system',
+ 'delta' => 'help',
+ 'theme' => $admin_theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'help',
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'user',
+ 'delta' => 'login',
+ 'theme' => $admin_theme,
+ 'status' => 1,
+ 'weight' => 10,
+ 'region' => 'content',
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'user',
+ 'delta' => 'new',
+ 'theme' => $admin_theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'dashboard_sidebar',
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'search',
+ 'delta' => 'form',
+ 'theme' => $admin_theme,
+ 'status' => 1,
+ 'weight' => -10,
+ 'region' => 'dashboard_sidebar',
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ );
+ $query = db_insert('block')
+ ->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
+ foreach ($values as $record) {
+ $query->values($record);
+ }
+ $query->execute();
+}
+
+/**
+ * Confgures default node types.
+ */
+function _testing_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',
+ 'name' => st('Basic page'),
+ 'base' => 'node_content',
+ 'description' => st("Use basic pages for your static content, such as an 'About us' page."),
+ 'custom' => 1,
+ 'modified' => 1,
+ 'locked' => 0,
+ ),
+ array(
+ 'type' => 'article',
+ 'name' => st('Article'),
+ 'base' => 'node_content',
+ 'description' => st('Use articles for time-sensitive content like news, press releases or blog posts.'),
+ 'custom' => 1,
+ 'modified' => 1,
+ 'locked' => 0,
+ ),
+ );
+ foreach ($types as $type) {
+ $type = node_type_set_defaults($type);
+ node_type_save($type);
+ node_add_body_field($type);
+ }
+
+ // 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 _testing_install_rdf() {
+ $rdf_mappings = array(
+ array(
+ 'type' => 'node',
+ 'bundle' => 'page',
+ 'mapping' => array(
+ 'rdftype' => array('foaf:Document'),
+ ),
+ ),
+ array(
+ 'type' => 'node',
+ 'bundle' => 'article',
+ 'mapping' => array(
+ 'rdftype' => array('sioc:Item', 'foaf:Document'),
+ 'field_image' => array(
+ 'predicates' => array('og:image', 'rdfs:seeAlso'),
+ 'type' => 'rel',
+ ),
+ 'field_tags' => array(
+ 'predicates' => array('dc:subject'),
+ 'type' => 'rel',
+ ),
+ ),
+ ),
+ );
+ foreach ($rdf_mappings as $rdf_mapping) {
+ rdf_mapping_save($rdf_mapping);
+ }
+}
+
+/**
+ * Configures default comment settings.
+ */
+function _testing_install_comment() {
+ // Default "Basic page" to have comments disabled.
+ variable_set('comment_page', COMMENT_NODE_HIDDEN);
+
+ // 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 _testing_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');
+ variable_set('user_picture_file_size', '800');
+ variable_set('user_picture_style', 'thumbnail');
+
+ // Allow visitor account creation with administrative approval.
+ variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
+
+ // 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 _testing_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(
+ 'name' => 'Tags',
+ 'description' => $description,
+ 'machine_name' => 'tags',
+ 'help' => $help,
+
+ );
+ taxonomy_vocabulary_save($vocabulary);
+
+ $field = array(
+ 'field_name' => 'field_' . $vocabulary->machine_name,
+ 'type' => 'taxonomy_term_reference',
+ // Set cardinality to unlimited for tagging.
+ 'cardinality' => FIELD_CARDINALITY_UNLIMITED,
+ 'settings' => array(
+ 'allowed_values' => array(
+ array(
+ 'vid' => $vocabulary->vid,
+ 'parent' => 0,
+ ),
+ ),
+ ),
+ );
+ field_create_field($field);
+
+ $instance = array(
+ 'field_name' => 'field_' . $vocabulary->machine_name,
+ 'entity_type' => 'node',
+ 'label' => $vocabulary->name,
+ 'bundle' => 'article',
+ 'description' => $vocabulary->help,
+ 'widget' => array(
+ 'type' => 'taxonomy_autocomplete',
+ 'weight' => -4,
+ ),
+ 'display' => array(
+ 'default' => array(
+ 'type' => 'taxonomy_term_reference_link',
+ 'weight' => 10,
+ ),
+ 'teaser' => array(
+ 'type' => 'taxonomy_term_reference_link',
+ 'weight' => 10,
+ ),
+ ),
+ );
+ field_create_instance($instance);
+}
+
+/**
+ * Configures default image fields.
+ */
+function _testing_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',
+ 'cardinality' => 1,
+ 'translatable' => TRUE,
+ 'locked' => FALSE,
+ 'indexes' => array('fid' => array('fid')),
+ 'settings' => array(
+ 'uri_scheme' => 'public',
+ 'default_image' => FALSE,
+ ),
+ 'storage' => array(
+ 'type' => 'field_sql_storage',
+ 'settings' => array(),
+ ),
+ );
+ field_create_field($field);
+
+ // 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',
+ 'label' => 'Image',
+ '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',
+ 'max_filesize' => '',
+ 'max_resolution' => '',
+ 'min_resolution' => '',
+ 'alt_field' => TRUE,
+ 'title_field' => '',
+ ),
+ 'widget' => array(
+ 'type' => 'image_image',
+ 'settings' => array(
+ 'progress_indicator' => 'throbber',
+ 'preview_image_style' => 'thumbnail',
+ ),
+ 'weight' => -1,
+ ),
+ 'display' => array(
+ 'default' => array(
+ 'label' => 'hidden',
+ 'type' => 'image',
+ 'settings' => array('image_style' => 'large', 'image_link' => ''),
+ 'weight' => -1,
+ ),
+ 'teaser' => array(
+ 'label' => 'hidden',
+ 'type' => 'image',
+ 'settings' => array('image_style' => 'medium', 'image_link' => 'content'),
+ 'weight' => -1,
+ ),
+ ),
+ );
+ field_create_instance($instance);
+}