From ff9635f70d624e0e75391684ced8eea008fd7f76 Mon Sep 17 00:00:00 2001 From: Attila Vasas <8567234+VasasA@users.noreply.github.com> Date: Fri, 25 Feb 2022 19:00:19 +0100 Subject: [PATCH] Issue #35: Port cleanup work. By @VasasA. Progress towards completing the port. Work in progress. --- README.md | 36 ++ config/og.settings.json | 20 +- og.api.php | 4 +- og.install | 61 ++- og.module | 24 +- og_access/config/og_access.settings.json | 4 + og_access/og_access.install | 31 +- og_access/og_access.module | 17 +- og_access/og_access.test | 154 ++++---- og_context/config/og_context.settings.json | 11 +- og_context/og_context.install | 34 +- og_context/og_context.module | 2 +- og_context/og_context.test | 22 +- og_field_access/og_field_access.test | 58 ++- og_ui/config/og_ui.settings.json | 4 +- og_ui/og_ui.admin.inc | 32 +- og_ui/og_ui.install | 10 +- og_ui/og_ui.module | 11 + og_ui/og_ui.test | 258 +++---------- og_ui/og_ui.tests.info | 6 - tests/og.test | 423 +-------------------- tests/og.tests.info | 12 - tests/og_test.module | 2 +- 23 files changed, 350 insertions(+), 886 deletions(-) create mode 100644 og_access/config/og_access.settings.json diff --git a/README.md b/README.md index 815bcae6..b51fb1c5 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,42 @@ or moderated. - [Organic Groups Terms, Definitions](https://github.com/backdrop-contrib/og/wiki/2.-Organic-Groups-Terms,-Definitions) - [For Developers and Site Builders](https://github.com/backdrop-contrib/og/wiki/3.-For-Developers-and-Site-Builders) +## Upgrading Organic Groups from Drupal 7 + +If you are upgrading an existing Organic Groups installation from Drupal 7 (or upgrading a Drupal 7 module that requires Organic Groups), there are some steps you can (should) take to ensure that your upgraded installation is fully enabled at the end of the process. + +#### Stub Modules + +Backdrop Organic Groups relies on two modules that don't exist in Drupal: + +- Entity UI (`entity_ui`), needed for the Backdrop version of Organic Groups; +- Entity Plus (`entity_plus`), also needed for the Backdrop version of Organic Groups. + +When the Backdrop version of `update.php` runs, if those modules are not present and enabled, then the update will disable all of the Backdrop modules that depend on them, which includes Organic Groups, plus any further modules that depend on Organic Groups. + +So the solution is to install "stub" modules in the Drupal installation prior to generating the database from which the Backdrop upgrade will take place. + +#### Upgrade Process + +Assuming you are following [the official upgrade instructions](https://backdropcms.org/upgrade-from-drupal) or something similar [like this](https://packweb.eu/blog/migrating-drupal-7-backdrop-cms), do the following: + +1. Download and unzip these two modules, which are Drupal "stub" modules: + - [entity_plus.zip](https://github.com/backdrop-contrib/rules/wiki/files/entity_plus.zip) + - [entity_ui.zip](https://github.com/backdrop-contrib/rules/wiki/files/entity_ui.zip) + +2. In Step 2, "Prepare your Drupal site for upgrade", prior to substep 9 ("Make a second backup...calling it backdrop-ready.sql"), + + - Install those two modules into `sites/all/modules` of your Drupal installation; + - Enable those two modules. (They don't do anything. This just makes your database know that they exist, or rather, that they will be forthcoming.) + +3. Continue with substep 9: make your second backup of the database to be used for Backdrop, e.g., backdrop-ready.sql. + +4. Once you have made that second backup, you can uninstall and remove the two stub modules from your Drupal installation. + +5. Continue with the rest of the migration/upgrade process. + +Of course, make sure that you've already installed the Backdrop versions of Organic Groups, Entity Plus, and Entity UI in your Backdrop contrib folder prior to running `update.php`, or all of the above will be for naught. + ## Issues - Bugs and Feature requests should be reported in the diff --git a/config/og.settings.json b/config/og.settings.json index dec7e894..cea3f1a1 100644 --- a/config/og.settings.json +++ b/config/og.settings.json @@ -1,15 +1,11 @@ { "_config_name": "og.settings", - "og_7000_add_field": "FALSE", - "og_content_type_usage_typetype": "dynamic variable in file /og/includes/migrate/7000/og_add_fields.inc line 27", - "og_7200_ogur_roles": "FALSE", - "og_user_roles_roles_typetype": "dynamic variable in file /og/includes/migrate/7000/og_ogur_roles.migrate.inc line 37", - "og_node_access_strict": "TRUE", - "og_use_queue": "FALSE", - "og_orphans_delete": "FALSE", - "og_is_group__entity_type__bundle": "dynamic variable in file /og/og.module line 1839", - "og_group_manager_full_access": "TRUE", - "og_is_group_default_access__group_type__bundle": "dynamic variable in file /og/og.module line 2617", - "og_maintain_overridden_roles": "TRUE", - "og_features_ignore_og_fields": "FALSE" + "og_7000_add_field": false, + "og_7200_ogur_roles": false, + "og_node_access_strict": true, + "og_use_queue": false, + "og_orphans_delete": false, + "og_group_manager_full_access": true, + "og_maintain_overridden_roles": true, + "og_features_ignore_og_fields": false } \ No newline at end of file diff --git a/og.api.php b/og.api.php index 4f58d71b..cba9512e 100644 --- a/og.api.php +++ b/og.api.php @@ -155,7 +155,7 @@ function hook_og_role_revoke($entity_type, $gid, $uid, $rid) { */ function hook_og_role_change_permissions($role, $grant, $revoke) { if (!$role->gid) { - drupal_set_message(t('Global group permissions granted for @role users: @permissions', array('@role' => $role->name, '@permissions' => implode(', ', $grant)))); + backdrop_set_message(t('Global group permissions granted for @role users: @permissions', array('@role' => $role->name, '@permissions' => implode(', ', $grant)))); } } @@ -233,7 +233,7 @@ function hook_og_invalidate_cache($gids = array()) { ); foreach ($caches as $cache) { - drupal_static_reset($cache); + backdrop_static_reset($cache); } } diff --git a/og.install b/og.install index 3cb285cb..47bdb70f 100644 --- a/og.install +++ b/og.install @@ -41,29 +41,6 @@ function og_install() { * Implements hook_uninstall(). */ function og_uninstall() { - db_delete('variable') - ->condition('name', 'og_group_manager_default_rids_%', 'LIKE') - ->execute(); - - db_delete('variable') - ->condition('name', 'og_is_group_default_access__%__%', 'LIKE') - ->execute(); - - $vars = array( - 'og_context', - 'og_group_manager_full_access', - 'og_skip_access', - 'og_update_batch_size', - 'og_upgrade_7001', - 'og_node_access_strict', - 'og_features_ignore_og_fields', - 'og_maintain_overridden_roles', - ); - foreach ($vars as $var) { - // TODO This variable was probably removed in Backdrop without replacement. - variable_del($var); - } - // Delete OG-core fields. $og_fields = array( 'group_group', @@ -434,27 +411,49 @@ function og_update_last_removed() { function og_update_1000() { $config = config('og.settings'); $config->set('og_7000_add_field', update_variable_get('og_7000_add_field', 'FALSE')); - $config->set('og_content_type_usage_typetype', update_variable_get('og_content_type_usage_typetype', 'dynamic variable in file /og/includes/migrate/7000/og_add_fields.inc line 27')); $config->set('og_7200_ogur_roles', update_variable_get('og_7200_ogur_roles', 'FALSE')); - $config->set('og_user_roles_roles_typetype', update_variable_get('og_user_roles_roles_typetype', 'dynamic variable in file /og/includes/migrate/7000/og_ogur_roles.migrate.inc line 37')); $config->set('og_node_access_strict', update_variable_get('og_node_access_strict', 'TRUE')); $config->set('og_use_queue', update_variable_get('og_use_queue', 'FALSE')); $config->set('og_orphans_delete', update_variable_get('og_orphans_delete', 'FALSE')); - $config->set('og_is_group__entity_type__bundle', update_variable_get('og_is_group__entity_type__bundle', 'dynamic variable in file /og/og.module line 1839')); $config->set('og_group_manager_full_access', update_variable_get('og_group_manager_full_access', 'TRUE')); - $config->set('og_is_group_default_access__group_type__bundle', update_variable_get('og_is_group_default_access__group_type__bundle', 'dynamic variable in file /og/og.module line 2617')); $config->set('og_maintain_overridden_roles', update_variable_get('og_maintain_overridden_roles', 'TRUE')); $config->set('og_features_ignore_og_fields', update_variable_get('og_features_ignore_og_fields', 'FALSE')); + $config->save(); update_variable_del('og_7000_add_field'); - update_variable_del('og_content_type_usage_typetype'); update_variable_del('og_7200_ogur_roles'); - update_variable_del('og_user_roles_roles_typetype'); update_variable_del('og_node_access_strict'); update_variable_del('og_use_queue'); update_variable_del('og_orphans_delete'); - update_variable_del('og_is_group__entity_type__bundle'); update_variable_del('og_group_manager_full_access'); - update_variable_del('og_is_group_default_access__group_type__bundle'); update_variable_del('og_maintain_overridden_roles'); update_variable_del('og_features_ignore_og_fields'); + + $result = db_select('variable', 'v') + ->fields('v', array('name')) + ->condition('name', 'og_group_manager_default_rids_%', 'LIKE') + ->execute() + ->fetchCol(); + foreach($result as $name) { + $config->set($name, update_variable_get($name, array())); + update_variable_del($name); + } + $result = db_select('variable', 'v') + ->fields('v', array('name')) + ->condition('name', 'og_is_group_default_access__%__%', 'LIKE') + ->execute() + ->fetchCol(); + foreach($result as $name) { + $config->set($name, update_variable_get($name, 'TRUE')); + update_variable_del($name); + } + $result = db_select('variable', 'v') + ->fields('v', array('name')) + ->condition('name', 'og_is_group__%__%', 'LIKE') + ->execute() + ->fetchCol(); + foreach($result as $name) { + $config->set($name, update_variable_get($name, 'FALSE')); + update_variable_del($name); + } + $config->save(); } diff --git a/og.module b/og.module index 70b98054..c79649d0 100644 --- a/og.module +++ b/og.module @@ -506,7 +506,7 @@ function og_og_default_roles() { */ function og_config_info() { $prefixes['og.settings'] = array( - 'label' => t('Module name settings'), + 'label' => t('Organic groups settings'), 'group' => t('Configuration'), ); } @@ -889,8 +889,7 @@ function og_entity_insert($entity, $entity_type) { og_group($entity_type, $id, array('entity' => $entity->uid)); // Assign roles to group manager. $name = 'og_group_manager_default_rids_' . $entity_type . '_' . $bundle; - // TODO This variable was probably removed in Backdrop without replacement. - if ($rids = variable_get($name)) { + if ($rids = config_get('og.settings', $name)) { foreach ($rids as $rid) { og_role_grant($entity_type, $id, $entity->uid, $rid); } @@ -916,8 +915,7 @@ function og_entity_update($entity, $entity_type) { og_group($entity_type, $id, array('entity' => $entity->uid)); // Assign roles to group manager. $name = 'og_group_manager_default_rids_' . $entity_type . '_' . $bundle; - // TODO This variable was probably removed in Backdrop without replacement. - if ($rids = variable_get($name)) { + if ($rids = config_get('og.settings', $name)) { foreach ($rids as $rid) { og_role_grant($entity_type, $id, $entity->uid, $rid); } @@ -1876,7 +1874,13 @@ function og_is_group($entity_type, $entity) { } list(, , $bundle) = entity_extract_ids($entity_type, $entity); if (!field_info_instance($entity_type, OG_GROUP_FIELD, $bundle)) { - return config_get('og.settings', "og_is_group__{$entity_type}__{$bundle}"); + $config = config('og.settings'); + $variable = "og_is_group__{$entity_type}__{$bundle}"; + if ($config->get($variable) === NULL) { + $config->set($variable, FALSE); + $config->save(); + } + return $config->get($variable); } $items = field_get_items($entity_type, $entity, OG_GROUP_FIELD); @@ -2654,7 +2658,13 @@ function og_is_group_default_access($group_type, $gid) { $bundle = $wrapper->getBundle(); if (!field_info_instance($group_type, OG_DEFAULT_ACCESS_FIELD, $bundle)) { - return config_get('og.settings', "og_is_group_default_access__{$group_type}__{$bundle}"); + $config = config('og.settings'); + $variable = "og_is_group_default_access__{$group_type}__{$bundle}"; + if ($config->get($variable) === NULL) { + $config->set($variable, TRUE); + $config->save(); + } + return $config->get($variable); } if (empty($wrapper->{OG_DEFAULT_ACCESS_FIELD})) { diff --git a/og_access/config/og_access.settings.json b/og_access/config/og_access.settings.json new file mode 100644 index 00000000..22423fbb --- /dev/null +++ b/og_access/config/og_access.settings.json @@ -0,0 +1,4 @@ +{ + "_config_name": "og_access.settings", + "og_access_privacy_change_batch_processing": true +} \ No newline at end of file diff --git a/og_access/og_access.install b/og_access/og_access.install index c534cee5..eab04eb5 100644 --- a/og_access/og_access.install +++ b/og_access/og_access.install @@ -10,29 +10,22 @@ * Implements hook_uninstall(). */ function og_access_uninstall() { - $vars = array( - 'og_access_strict_private', - ); - foreach ($vars as $var) { - // TODO This variable was probably removed in Backdrop without replacement. - variable_del($var); - } - // TODO This variable was probably removed in Backdrop without replacement. - variable_del(OG_ACCESS_PRIVACY_CHANGE_BATCH_PROCESSING); } /** - * Implements hook_schema();(). + * Implements hook_update_N(). */ -function og_access_schema() { - if (db_table_exists('og_access_post')) { - db_rename_table('og_access_post', 'd6_og_access_post'); - } +function og_access_update_1000() { + $config = config('og_access.settings'); + $config->set('og_access_privacy_change_batch_processing', update_variable_get('og_access_privacy_change_batch_processing', 'TRUE')); + $config->save(); + update_variable_del('og_access_privacy_change_batch_processing'); } -// TODO The old hook_update_N functions cannot be applied to Backdrop. -function og_access_update_7000(&$sandbox) { } - -// TODO The old hook_update_N functions cannot be applied to Backdrop. -function og_access_update_7200(&$sandbox) { } +/** + * Implements hook_update_last_removed(). + */ +function og_access_update_last_removed() { + return 7200; +} diff --git a/og_access/og_access.module b/og_access/og_access.module index d4d272d2..a7dfb3ba 100644 --- a/og_access/og_access.module +++ b/og_access/og_access.module @@ -303,8 +303,7 @@ function og_access_og_access_invoke_node_access_acquire_grants($context) { */ function og_access_check_node_access_grants_is_needed($entity, $entity_type) { // Check whether group privacy change batch processing is needed. - // TODO This variable was probably removed in Backdrop without replacement. - if (!variable_get(OG_ACCESS_PRIVACY_CHANGE_BATCH_PROCESSING, TRUE)) { + if (!config_get('og_access.settings', OG_ACCESS_PRIVACY_CHANGE_BATCH_PROCESSING)) { return FALSE; } @@ -427,12 +426,11 @@ function og_access_invoke_node_access_acquire_grants($group_type, $group_id, &$c * Implements hook_form_FORM_ID_alter(). */ function og_access_form_og_ui_admin_settings_alter(&$form, &$form_state) { - // TODO This variable was probably removed in Backdrop without replacement. $form[OG_ACCESS_PRIVACY_CHANGE_BATCH_PROCESSING] = array( '#type' => 'checkbox', '#title' => t('Update group content privacy'), '#description' => t('Upon group privacy change, create batch operation to update group content.'), - '#default_value' => variable_get(OG_ACCESS_PRIVACY_CHANGE_BATCH_PROCESSING, TRUE), + '#default_value' => config_get('og_access.settings', OG_ACCESS_PRIVACY_CHANGE_BATCH_PROCESSING), ); } @@ -443,3 +441,14 @@ function og_access_autoload_info() { return array( ); } + +/** + * Implements hook_config_info(). + */ +function og_access_config_info() { + $prefixes['og_access.settings'] = array( + 'label' => t('Organic groups access control settings'), + 'group' => t('Configuration'), + ); + return $prefixes; +} diff --git a/og_access/og_access.test b/og_access/og_access.test index e7f01044..c2ac4624 100644 --- a/og_access/og_access.test +++ b/og_access/og_access.test @@ -8,31 +8,23 @@ /** * Test OG access. */ -class OgAccessTestCase extends DrupalWebTestCase { - - public static function getInfo() { - return array( - 'name' => 'OG access', - 'description' => 'Test the visibility of nodes that are handled by OG access.', - 'group' => 'Organic groups access', - ); - } +class OgAccessTestCase extends BackdropWebTestCase { function setUp() { parent::setUp('og_access'); node_access_rebuild(); - $this->user1 = $this->drupalCreateUser(); - $this->user2 = $this->drupalCreateUser(array( + $this->user1 = $this->backdropCreateUser(); + $this->user2 = $this->backdropCreateUser(array( 'access content', )); // Create group and group content node types. - $this->group_type = $this->drupalCreateContentType()->type; + $this->group_type = $this->backdropCreateContentType()->type; og_create_field(OG_GROUP_FIELD, 'node', $this->group_type); og_create_field(OG_ACCESS_FIELD, 'node', $this->group_type); - $this->group_content_type = $this->drupalCreateContentType()->type; + $this->group_content_type = $this->backdropCreateContentType()->type; og_create_field(OG_AUDIENCE_FIELD, 'node', $this->group_content_type); // Create a group node and enable access. @@ -41,7 +33,7 @@ class OgAccessTestCase extends DrupalWebTestCase { $settings[OG_GROUP_FIELD][LANGUAGE_NONE][0]['value'] = 1; $settings[OG_ACCESS_FIELD][LANGUAGE_NONE][0]['value'] = 1; $settings['uid'] = $this->user1->uid; - $this->group_node = $this->drupalCreateNode($settings); + $this->group_node = $this->backdropCreateNode($settings); } /** @@ -54,7 +46,7 @@ class OgAccessTestCase extends DrupalWebTestCase { ); // Create group content. - $node1 = $this->drupalCreateNode($settings); + $node1 = $this->backdropCreateNode($settings); $values = array( 'entity_type' => 'node', 'entity' => $node1, @@ -66,28 +58,28 @@ class OgAccessTestCase extends DrupalWebTestCase { $this->assertFalse(node_access('view', $this->group_node, $this->user2), 'Other user should not see the group'); // Group is private. We are changing it to public. - $this->drupalLogin($this->user1); + $this->backdropLogin($this->user1); $edit = array( 'group_access[und]' => 0, ); - $this->drupalPost('node/' . $this->group_node->nid . '/edit', $edit, 'Save'); + $this->backdropPost('node/' . $this->group_node->nid . '/edit', $edit, 'Save'); - drupal_static_reset(); + backdrop_static_reset(); $this->assertTrue(node_access('view', $node1, $this->user2), 'Other user should be able to see the node'); $this->assertTrue(node_access('view', $this->group_node, $this->user2), 'Other user should be able to see the group'); // Group is public. We are changing it to private. - $this->drupalLogin($this->user1); + $this->backdropLogin($this->user1); $edit = array( 'group_access[und]' => 1, ); - $this->drupalPost('node/' . $this->group_node->nid . '/edit', $edit, 'Save'); + $this->backdropPost('node/' . $this->group_node->nid . '/edit', $edit, 'Save'); $this->group_node = node_load($this->group_node->nid); - drupal_static_reset(); + backdrop_static_reset(); $this->assertFalse(node_access('view', $node1, $this->user2), 'Other user should not see the node'); $this->assertFalse(node_access('view', $this->group_node, $this->user2), 'Other user should not see the group'); } @@ -99,7 +91,7 @@ class OgAccessTestCase extends DrupalWebTestCase { * groups are accessible, even for members. */ function testSubGroupContentAccess() { - $subgroup_content_type = $this->drupalCreateContentType()->type; + $subgroup_content_type = $this->backdropCreateContentType()->type; og_create_field(OG_AUDIENCE_FIELD, 'node', $subgroup_content_type); og_create_field(OG_GROUP_FIELD, 'node', $subgroup_content_type); og_create_field(OG_ACCESS_FIELD, 'node', $subgroup_content_type); @@ -113,24 +105,24 @@ class OgAccessTestCase extends DrupalWebTestCase { $settings[OG_ACCESS_FIELD][LANGUAGE_NONE][0]['value'] = 1; $settings[OG_AUDIENCE_FIELD][LANGUAGE_NONE][0]['target_id'] = $this->group_node->nid; $settings[OG_CONTENT_ACCESS_FIELD][LANGUAGE_NONE][0]['value'] = OG_CONTENT_ACCESS_DEFAULT; - $subgroup_node = $this->drupalCreateNode($settings); + $subgroup_node = $this->backdropCreateNode($settings); // Add another user to group. og_group('node', $this->group_node->nid, array('entity' => $this->user2)); - $this->drupalLogin($this->user1); + $this->backdropLogin($this->user1); // Assert the user can view the group. // Assert the user is a group member. $this->assertTrue(og_is_member('node', $this->group_node->nid, 'user', $this->user1), 'User is a group member.'); - $this->drupalGet('node/' . $subgroup_node->nid); + $this->backdropGet('node/' . $subgroup_node->nid); $this->assertResponse('200', 'Group member can view subgroup.'); // Assert another user is a group member. - $this->drupalLogin($this->user2); + $this->backdropLogin($this->user2); $this->assertTrue(og_is_member('node', $this->group_node->nid, 'user', $this->user2), 'User is a group member.'); // Assert the member can see the subgroup. - $this->drupalGet('node/' . $subgroup_node->nid); + $this->backdropGet('node/' . $subgroup_node->nid); $this->assertResponse('200', 'Group member can view subgroup.'); } @@ -138,22 +130,22 @@ class OgAccessTestCase extends DrupalWebTestCase { * Group with access field. */ function testGroupAccess() { - $this->drupalLogin($this->user1); + $this->backdropLogin($this->user1); $nid = $this->group_node->nid; // Assert the user is a group member. $this->assertTrue(og_is_member('node', $nid, 'user', $this->user1), t('User is a group member.')); // Assert the user can view the group. - $this->drupalGet('node/' . $nid); + $this->backdropGet('node/' . $nid); $this->assertResponse('200', t('Group member can view group node.')); // Assert another user is not a group member. - $this->drupalLogin($this->user2); + $this->backdropLogin($this->user2); $this->assertFalse(og_is_member('node', $nid, 'user', $this->user2), t('User is not a group member.')); // Assert non-member can't view the group. - $this->drupalGet('node/' . $nid); + $this->backdropGet('node/' . $nid); $this->assertResponse('403', t('Non group member can not view group node.')); } @@ -163,7 +155,7 @@ class OgAccessTestCase extends DrupalWebTestCase { function testGroupContentAccessDefault() { og_create_field(OG_CONTENT_ACCESS_FIELD, 'node', $this->group_content_type); - $this->drupalLogin($this->user1); + $this->backdropLogin($this->user1); $nid = $this->group_node->nid; // Create a group content node and set default access. @@ -171,20 +163,20 @@ class OgAccessTestCase extends DrupalWebTestCase { $settings['type'] = $this->group_content_type; $settings[OG_AUDIENCE_FIELD][LANGUAGE_NONE][0]['target_id'] = $nid; $settings[OG_CONTENT_ACCESS_FIELD][LANGUAGE_NONE][0]['value'] = OG_CONTENT_ACCESS_DEFAULT; - $group_content_node = $this->drupalCreateNode($settings); + $group_content_node = $this->backdropCreateNode($settings); // Assert the user can view the group. // Assert the user is a group member. $this->assertTrue(og_is_member('node', $nid, 'user', $this->user1), t('User is a group member.')); - $this->drupalGet('node/' . $group_content_node->nid); + $this->backdropGet('node/' . $group_content_node->nid); $this->assertResponse('200', t('Group member can view group node.')); // Assert another user is not a group member. - $this->drupalLogin($this->user2); + $this->backdropLogin($this->user2); $this->assertFalse(og_is_member('node', $nid, 'user', $this->user2), t('User is not a group member.')); // Assert non-member can't view the group. - $this->drupalGet('node/' . $group_content_node->nid); + $this->backdropGet('node/' . $group_content_node->nid); $this->assertResponse('403', t('Non group member can not view group node.')); } @@ -199,13 +191,13 @@ class OgAccessTestCase extends DrupalWebTestCase { // public, and one time set to private. foreach (array(0, 1) as $state) { // Make sure user1 is logged in. - $this->drupalLogin($this->user1); + $this->backdropLogin($this->user1); // Create a group node and enable access. $settings = array(); $settings['type'] = $this->group_type; $settings[OG_GROUP_FIELD][LANGUAGE_NONE][0]['value'] = 1; $settings[OG_ACCESS_FIELD][LANGUAGE_NONE][0]['value'] = $state; - $group_node = $this->drupalCreateNode($settings); + $group_node = $this->backdropCreateNode($settings); $nid = $group_node->nid; @@ -214,27 +206,27 @@ class OgAccessTestCase extends DrupalWebTestCase { $settings['type'] = $this->group_content_type; $settings[OG_AUDIENCE_FIELD][LANGUAGE_NONE][0]['target_id'] = $nid; $settings[OG_CONTENT_ACCESS_FIELD][LANGUAGE_NONE][0]['value'] = OG_CONTENT_ACCESS_PUBLIC; - $public_node = $this->drupalCreateNode($settings); + $public_node = $this->backdropCreateNode($settings); // Create a group content node and set private access. $settings[OG_CONTENT_ACCESS_FIELD][LANGUAGE_NONE][0]['value'] = OG_CONTENT_ACCESS_PRIVATE; - $private_node = $this->drupalCreateNode($settings); + $private_node = $this->backdropCreateNode($settings); // Assert the user can view the group. $this->assertTrue(og_is_member('node', $nid, 'user', $this->user1), t('User is a group member.')); - $this->drupalGet('node/' . $public_node->nid); + $this->backdropGet('node/' . $public_node->nid); $this->assertResponse('200', t('Group member can view public group content node.')); - $this->drupalGet('node/' . $private_node->nid); + $this->backdropGet('node/' . $private_node->nid); $this->assertResponse('200', t('Group member can view private group content node.')); // Assert another user is not a group member. - $this->drupalLogin($this->user2); + $this->backdropLogin($this->user2); $this->assertFalse(og_is_member('node', $nid, 'user', $this->user2), t('User is not a group member.')); // Assert non-member can't view the group. - $this->drupalGet('node/' . $public_node->nid); + $this->backdropGet('node/' . $public_node->nid); $this->assertResponse('200', t('Non group member can view public group content node.')); - $this->drupalGet('node/' . $private_node->nid); + $this->backdropGet('node/' . $private_node->nid); $this->assertResponse('403', t('Non group member can not view private group content node.')); } } @@ -243,27 +235,27 @@ class OgAccessTestCase extends DrupalWebTestCase { * Test group content without access field. */ function testGroupContentAccessNotExist() { - $this->drupalLogin($this->user1); + $this->backdropLogin($this->user1); $nid = $this->group_node->nid; // Create a group content node and set default access. $settings = array(); $settings['type'] = $this->group_content_type; $settings[OG_AUDIENCE_FIELD][LANGUAGE_NONE][0]['target_id'] = $nid; - $group_content_node = $this->drupalCreateNode($settings); + $group_content_node = $this->backdropCreateNode($settings); // Assert the user can view the group. // Assert the user is a group member. $this->assertTrue(og_is_member('node', $nid, 'user', $this->user1), t('User is a group member.')); - $this->drupalGet('node/' . $group_content_node->nid); + $this->backdropGet('node/' . $group_content_node->nid); $this->assertResponse('200', t('Group member can view group node.')); // Assert another user is not a group member. - $this->drupalLogin($this->user2); + $this->backdropLogin($this->user2); $this->assertFalse(og_is_member('node', $nid, 'user', $this->user2), t('User is not a group member.')); // Assert non-member can't view the group. - $this->drupalGet('node/' . $group_content_node->nid); + $this->backdropGet('node/' . $group_content_node->nid); $this->assertResponse('403', t('Non group member can not view group node.')); } @@ -272,18 +264,18 @@ class OgAccessTestCase extends DrupalWebTestCase { * results in a private group content. */ function testOgStrictPrivate() { - $this->drupalLogin($this->user1); + $this->backdropLogin($this->user1); // Create a group node and set as private. $settings = array(); $settings['type'] = $this->group_type; $settings[OG_GROUP_FIELD][LANGUAGE_NONE][0]['value'] = 1; $settings[OG_ACCESS_FIELD][LANGUAGE_NONE][0]['value'] = 1; - $group_node1 = $this->drupalCreateNode($settings); + $group_node1 = $this->backdropCreateNode($settings); // Create a group node and set as public. $settings[OG_ACCESS_FIELD][LANGUAGE_NONE][0]['value'] = 0; - $group_node2 = $this->drupalCreateNode($settings); + $group_node2 = $this->backdropCreateNode($settings); // Create a group content node and set default access. $settings = array(); @@ -291,18 +283,18 @@ class OgAccessTestCase extends DrupalWebTestCase { $settings[OG_AUDIENCE_FIELD][LANGUAGE_NONE][0]['target_id'] = $group_node1->nid; $settings[OG_AUDIENCE_FIELD][LANGUAGE_NONE][1]['target_id'] = $group_node2->nid; $settings[OG_CONTENT_ACCESS_FIELD][LANGUAGE_NONE][0]['value'] = OG_CONTENT_ACCESS_DEFAULT; - $node = $this->drupalCreateNode($settings); + $node = $this->backdropCreateNode($settings); // Assert the user can view the group. $this->assertTrue(og_is_member('node', $group_node1->nid, 'user', $this->user1), t('User is a group member.')); - $this->drupalGet('node/' . $node->nid); + $this->backdropGet('node/' . $node->nid); $this->assertResponse('200', t('Group member can view public group node.')); // Assert another user is not a group member. - $this->drupalLogin($this->user2); + $this->backdropLogin($this->user2); $this->assertFalse(og_is_member('node', $group_node1->nid, 'user', $this->user2), t('User is not a group member.')); - $this->drupalGet('node/' . $node->nid); + $this->backdropGet('node/' . $node->nid); $this->assertResponse('403', t('Non group member can not view group content node.')); // Assert all groups were registered in {node_access}. @@ -319,20 +311,20 @@ class OgAccessTestCase extends DrupalWebTestCase { function testUnpublishedNode() { $user1 = $this->user1; $user2 = $this->user2; - $this->drupalLogin($user1); + $this->backdropLogin($user1); // Create a group node and set as private. $settings = array(); $settings['type'] = $this->group_type; $settings[OG_GROUP_FIELD][LANGUAGE_NONE][0]['value'] = 1; $settings[OG_ACCESS_FIELD][LANGUAGE_NONE][0]['value'] = 1; - $group_node1 = $this->drupalCreateNode($settings); + $group_node1 = $this->backdropCreateNode($settings); // Create a group content node and set default access. $settings = array(); $settings['type'] = $this->group_content_type; $settings[OG_AUDIENCE_FIELD][LANGUAGE_NONE][0]['target_id'] = $group_node1->nid; - $node = $this->drupalCreateNode($settings); + $node = $this->backdropCreateNode($settings); // Add another user to group. og_group('node', $group_node1->nid, array('entity' => $user2)); @@ -341,7 +333,7 @@ class OgAccessTestCase extends DrupalWebTestCase { $node->status = NODE_NOT_PUBLISHED; node_save($node); - drupal_static_reset('node_access'); + backdrop_static_reset('node_access'); $this->assertFalse(node_access('view', $node, $user2), 'Group member can not view unpublished node.'); } @@ -352,25 +344,17 @@ class OgAccessTestCase extends DrupalWebTestCase { /** * Test "Use group defaults". */ -class OgAccessUseGroupDefaultsTestCase extends DrupalWebTestCase { - - public static function getInfo() { - return array( - 'name' => 'Use group defaults', - 'description' => "Verify for an exception when OG access field is missing from the group, but exists on the group content.", - 'group' => 'Organic groups access', - ); - } +class OgAccessUseGroupDefaultsTestCase extends BackdropWebTestCase { function setUp() { parent::setUp('og_access'); node_access_rebuild(); // Create group and group content node types. - $this->group_type = $this->drupalCreateContentType()->type; + $this->group_type = $this->backdropCreateContentType()->type; og_create_field(OG_GROUP_FIELD, 'node', $this->group_type); - $this->group_content_type = $this->drupalCreateContentType()->type; + $this->group_content_type = $this->backdropCreateContentType()->type; og_create_field(OG_AUDIENCE_FIELD, 'node', $this->group_content_type); og_create_field(OG_CONTENT_ACCESS_FIELD, 'node', $this->group_content_type); @@ -379,7 +363,7 @@ class OgAccessUseGroupDefaultsTestCase extends DrupalWebTestCase { $settings['type'] = $this->group_type; $settings[OG_GROUP_FIELD][LANGUAGE_NONE][0]['value'] = TRUE; $settings['uid'] = 1; - $this->group_node = $this->drupalCreateNode($settings); + $this->group_node = $this->backdropCreateNode($settings); } /** @@ -392,7 +376,7 @@ class OgAccessUseGroupDefaultsTestCase extends DrupalWebTestCase { $settings[OG_CONTENT_ACCESS_FIELD][LANGUAGE_NONE][0]['value'] = OG_CONTENT_ACCESS_DEFAULT; try { - $this->drupalCreateNode($settings); + $this->backdropCreateNode($settings); $this->fail("Can set node visibility when access field is missing from the group."); } catch (OgException $e) { @@ -402,7 +386,7 @@ class OgAccessUseGroupDefaultsTestCase extends DrupalWebTestCase { // Attach the OG access field to the group bundle and try to create a // group content. og_create_field(OG_ACCESS_FIELD, 'node', $this->group_type); - $node = $this->drupalCreateNode($settings); + $node = $this->backdropCreateNode($settings); $this->assertTrue($node, 'A group content has been created successfully.'); } @@ -411,47 +395,39 @@ class OgAccessUseGroupDefaultsTestCase extends DrupalWebTestCase { /** * Tests moderated group memberships. */ -class OgAccessModeratedGroup extends DrupalWebTestCase { - - public static function getInfo() { - return array( - 'name' => 'OG moderated group membership', - 'description' => 'Test groups that require membership approval.', - 'group' => 'Organic groups access', - ); - } +class OgAccessModeratedGroup extends BackdropWebTestCase { public function setUp() { parent::setUp(array('og', 'og_access', 'og_ui')); node_access_rebuild(); // Creating the content type and the necessary fields for this test. - $content_type = $this->drupalCreateContentType(); + $content_type = $this->backdropCreateContentType(); og_create_field(OG_GROUP_FIELD, 'node', $content_type->type); og_create_field(OG_ACCESS_FIELD, 'node', $content_type->type); // Creating a private group, and a user. - $this->group = $this->drupalCreateNode(array('type' => $content_type->type)); + $this->group = $this->backdropCreateNode(array('type' => $content_type->type)); $wrapper = entity_metadata_wrapper('node', $this->group); $wrapper->{OG_GROUP_FIELD}->set(TRUE); $wrapper->{OG_ACCESS_FIELD}->set(1); $wrapper->save(); - $this->user = $this->drupalCreateUser(); + $this->user = $this->backdropCreateUser(); // Remove ability to apply without approval, but still allow them to subscribe. $roles = og_roles('node', $this->group->type); og_role_revoke_permissions(array_search(OG_ANONYMOUS_ROLE, $roles), array('subscribe without approval')); og_role_grant_permissions(array_search(OG_ANONYMOUS_ROLE, $roles), array('subscribe')); - $this->drupalLogin($this->user); + $this->backdropLogin($this->user); } /** * Test membership creation attempt made via direct API calls, by non-admins. */ public function testMembershipRequest() { - // The call of drupalLogin() in setUp() is not effective for API calls, + // The call of backdropLogin() in setUp() is not effective for API calls, // switching users here to test the permission check. global $user; $current_user = $user; diff --git a/og_context/config/og_context.settings.json b/og_context/config/og_context.settings.json index fdb32c6c..0b607acf 100644 --- a/og_context/config/og_context.settings.json +++ b/og_context/config/og_context.settings.json @@ -1,6 +1,11 @@ { "_config_name": "og_context.settings", - "og_context_negotiation_type": "dynamic variable in file /og/og_context/og_context.admin.inc line 49", - "og_context_providers_weight_type": "dynamic variable in file /og/og_context/og_context.admin.inc line 50", - "og_context_negotiation_group_context": "dynamic value in file /og/og_context/og_context.module line 410" + "og_context_negotiation_group_context": { + "url": -5, + "node": -4 + }, + "og_context_providers_weight_group_context": { + "url": -5, + "node": -4 + } } \ No newline at end of file diff --git a/og_context/og_context.install b/og_context/og_context.install index eab1dfd7..170220cf 100644 --- a/og_context/og_context.install +++ b/og_context/og_context.install @@ -10,14 +10,7 @@ * Implements hook_uninstall(). */ function og_context_uninstall() { - $vars = array( - 'og_context_negotiation_group_context', - 'og_context_providers_weight_group_context', - ); - foreach ($vars as $var) { - // TODO This variable was probably removed in Backdrop without replacement. - variable_del($var); - } + } /** @@ -25,20 +18,15 @@ function og_context_uninstall() { */ function og_context_update_1000() { $config = config('og_context.settings'); - $config->set('og_context_negotiation_type', update_variable_get('og_context_negotiation_type', 'dynamic variable in file /og/og_context/og_context.admin.inc line 49')); - $config->set('og_context_providers_weight_type', update_variable_get('og_context_providers_weight_type', 'dynamic variable in file /og/og_context/og_context.admin.inc line 50')); - $config->set('og_context_negotiation_group_context', update_variable_get('og_context_negotiation_group_context', 'dynamic value in file /og/og_context/og_context.module line 410')); - update_variable_del('og_context_negotiation_type'); - update_variable_del('og_context_providers_weight_type'); + $config->set('og_context_negotiation_group_context', update_variable_get('og_context_negotiation_group_context', array( + 'url' => -5, + 'node' => -4, + ))); + $config->set('og_context_providers_weight_group_context', update_variable_get('og_context_providers_weight_group_context', array( + 'url' => -5, + 'node' => -4, + ))); + $config->save(); + update_variable_del('og_context_providers_weight_group_context'); update_variable_del('og_context_negotiation_group_context'); } - -/** - * Implements hook_install(). - */ -function og_context_install() { - // Dynamically generated variable data was detected. - // /og/og_context/og_context.admin.inc line 49 - // /og/og_context/og_context.admin.inc line 50 - // /og/og_context/og_context.module line 410 -} diff --git a/og_context/og_context.module b/og_context/og_context.module index c0421c2e..432c9eeb 100644 --- a/og_context/og_context.module +++ b/og_context/og_context.module @@ -404,7 +404,7 @@ function og_context_provider_weight($provider) { */ function og_context_config_info() { $prefixes['og_context.settings'] = array( - 'label' => t('Module name settings'), + 'label' => t('Organic groups context settings'), 'group' => t('Configuration'), ); } diff --git a/og_context/og_context.test b/og_context/og_context.test index 8c9a7b12..aa324459 100644 --- a/og_context/og_context.test +++ b/og_context/og_context.test @@ -8,29 +8,21 @@ /** * Test OG access. */ -class OgContextTestCase extends DrupalWebTestCase { - - public static function getInfo() { - return array( - 'name' => 'OG context', - 'description' => 'Check if context is returning only if user has right permissions.', - 'group' => 'Organic groups context', - ); - } +class OgContextTestCase extends BackdropWebTestCase { function setUp() { parent::setUp('og_context', 'og_access'); node_access_rebuild(); - $this->user1 = $this->drupalCreateUser(); - $this->user2 = $this->drupalCreateUser(); + $this->user1 = $this->backdropCreateUser(); + $this->user2 = $this->backdropCreateUser(); // Create group and group content node types. - $this->group_type = $this->drupalCreateContentType()->type; + $this->group_type = $this->backdropCreateContentType()->type; og_create_field(OG_GROUP_FIELD, 'node', $this->group_type); og_create_field(OG_ACCESS_FIELD, 'node', $this->group_type); - $this->group_content_type = $this->drupalCreateContentType()->type; + $this->group_content_type = $this->backdropCreateContentType()->type; og_create_field(OG_AUDIENCE_FIELD, 'node', $this->group_content_type); // Create a group node and enable access. @@ -39,7 +31,7 @@ class OgContextTestCase extends DrupalWebTestCase { $settings[OG_GROUP_FIELD][LANGUAGE_NONE][0]['value'] = 1; $settings[OG_ACCESS_FIELD][LANGUAGE_NONE][0]['value'] = 1; $settings['uid'] = $this->user1->uid; - $this->group_node = $this->drupalCreateNode($settings); + $this->group_node = $this->backdropCreateNode($settings); } /** @@ -47,7 +39,7 @@ class OgContextTestCase extends DrupalWebTestCase { * has permissions and NULL if he doesn't. */ function testGettingGroupContext() { - $this->drupalLogin($this->user1); + $this->backdropLogin($this->user1); // User can get the group context. $this->assertTrue(og_context('node', $this->group_node)); diff --git a/og_field_access/og_field_access.test b/og_field_access/og_field_access.test index 15a9c095..798ccc90 100644 --- a/og_field_access/og_field_access.test +++ b/og_field_access/og_field_access.test @@ -9,15 +9,7 @@ /** * Test OG access. */ -class OgFieldAccessTestCase extends DrupalWebTestCase { - - public static function getInfo() { - return array( - 'name' => 'Organic groups field access', - 'description' => 'Test the access control on fields.', - 'group' => 'Organic groups field access', - ); - } +class OgFieldAccessTestCase extends BackdropWebTestCase { function setUp() { parent::setUp('og_field_access'); @@ -27,15 +19,15 @@ class OgFieldAccessTestCase extends DrupalWebTestCase { * Group with access field. */ function testOgFieldAccess() { - $user1 = $this->drupalCreateUser(); - $user2 = $this->drupalCreateUser(); - $this->drupalLogin($user1); + $user1 = $this->backdropCreateUser(); + $user2 = $this->backdropCreateUser(); + $this->backdropLogin($user1); // Create group and group content node types. - $group_type = $this->drupalCreateContentType(); + $group_type = $this->backdropCreateContentType(); og_create_field(OG_GROUP_FIELD, 'node', $group_type->type); - $group_content_type = $this->drupalCreateContentType(); + $group_content_type = $this->backdropCreateContentType(); og_create_field(OG_AUDIENCE_FIELD, 'node', $group_content_type->type); $og_roles = og_roles('node', $group_type->type); @@ -50,39 +42,39 @@ class OgFieldAccessTestCase extends DrupalWebTestCase { ); og_role_change_permissions($anon_rid, $permissions); - $this->drupalLogin($user1); + $this->backdropLogin($user1); // Create a group node. $settings = array(); $settings['type'] = $group_type->type; $settings[OG_GROUP_FIELD][LANGUAGE_NONE][0]['value'] = 1; $settings['body'][LANGUAGE_NONE][0]['value'] = $this->randomName(); - $node = $this->drupalCreateNode($settings); + $node = $this->backdropCreateNode($settings); // Assert another user is not a group member. - $this->drupalLogin($user2); + $this->backdropLogin($user2); $this->assertFalse(og_is_member('node', $node->nid, 'user', $user2), t('User is not a group member.')); // Assert user can't view the field. - $this->drupalGet('node/' . $node->nid); + $this->backdropGet('node/' . $node->nid); $this->assertResponse('200', t('Non group member can view node.')); $this->assertNoText($node->body[LANGUAGE_NONE][0]['value'], t('Non group member can not view field.')); // Change permissions and assert user can view the field. $permissions['view body field'] = 1; og_role_change_permissions($anon_rid, $permissions); - $this->drupalGet('node/' . $node->nid); + $this->backdropGet('node/' . $node->nid); $this->assertText($node->body[LANGUAGE_NONE][0]['value'], t('Non group member can now view field.')); // Assert user can't edit the field. - $this->drupalGet('node/' . $node->nid . '/edit'); + $this->backdropGet('node/' . $node->nid . '/edit'); $this->assertResponse('200', t('Non group member can edit node.')); $this->assertNoText($node->body[LANGUAGE_NONE][0]['value'], t('Non group member can not edit field.')); // Change permissions and assert user can view the field. $permissions['update body field'] = 1; og_role_change_permissions($anon_rid, $permissions); - $this->drupalGet('node/' . $node->nid . '/edit'); + $this->backdropGet('node/' . $node->nid . '/edit'); $langcode = LANGUAGE_NONE; $this->assertFieldByName("body[$langcode][0][value]", $node->body[LANGUAGE_NONE][0]['value'], t('Non group member can now edit field.')); @@ -95,38 +87,38 @@ class OgFieldAccessTestCase extends DrupalWebTestCase { $settings['type'] = $group_content_type->type; $settings[OG_AUDIENCE_FIELD][LANGUAGE_NONE][0]['target_id'] = $node->nid; $settings['body'][LANGUAGE_NONE][0]['value'] = $this->randomName(); - $node = $this->drupalCreateNode($settings); + $node = $this->backdropCreateNode($settings); - $this->drupalLogin($user1); - $this->drupalGet('node/' . $node->nid); + $this->backdropLogin($user1); + $this->backdropGet('node/' . $node->nid); $this->assertText($node->body[LANGUAGE_NONE][0]['value'], t('Group member can view field of a group content.')); - $this->drupalLogin($user2); - $this->drupalGet('node/' . $node->nid); + $this->backdropLogin($user2); + $this->backdropGet('node/' . $node->nid); $this->assertNoText($node->body[LANGUAGE_NONE][0]['value'], t('Non member can not view field of a group content.')); // Assert field permissions on orphan group content. $settings = array(); $settings['type'] = $group_content_type->type; $settings['uid'] = $user1->uid; - $node = $this->drupalCreateNode($settings); + $node = $this->backdropCreateNode($settings); - $this->drupalGet('node/' . $node->nid); + $this->backdropGet('node/' . $node->nid); $this->assertText($node->body[LANGUAGE_NONE][0]['value'], t('Non member can view field of an orphan group content.')); // Assert fields of nodes not related to OG are not being restricted. - $user3 = $this->drupalCreateUser(array( + $user3 = $this->backdropCreateUser(array( 'access content', 'create page content', 'edit any page content', )); - $this->drupalLogin($user3); + $this->backdropLogin($user3); - $node = $this->drupalCreateNode(); - $this->drupalGet('node/' . $node->nid); + $node = $this->backdropCreateNode(); + $this->backdropGet('node/' . $node->nid); $this->assertText($node->body[LANGUAGE_NONE][0]['value'], t('User can view field of content not related to Organic groups.')); - $this->drupalGet('node/' . $node->nid . '/edit'); + $this->backdropGet('node/' . $node->nid . '/edit'); $this->assertText($node->body[LANGUAGE_NONE][0]['value'], t('User can edit field of content not related to Organic groups.')); } } diff --git a/og_ui/config/og_ui.settings.json b/og_ui/config/og_ui.settings.json index eaaf48ae..348833bc 100644 --- a/og_ui/config/og_ui.settings.json +++ b/og_ui/config/og_ui.settings.json @@ -1,6 +1,6 @@ { "_config_name": "og_ui.settings", - "og_ui_7000_add_field": "FALSE", + "og_ui_7000_add_field": false, "og_ui_admin_people_view": "og_members_admin:default", - "og_ui_deny_subscribe_without_approval": "TRUE" + "og_ui_deny_subscribe_without_approval": true } \ No newline at end of file diff --git a/og_ui/og_ui.admin.inc b/og_ui/og_ui.admin.inc index 14719d47..3780e580 100644 --- a/og_ui/og_ui.admin.inc +++ b/og_ui/og_ui.admin.inc @@ -10,25 +10,29 @@ */ function og_ui_admin_settings($form_state) { $form = array(); - $form['#config'] = 'og_ui.settings'; + $config = config('og.settings'); + $form['#config'] = 'og.settings'; - // TODO This variable was probably removed in Backdrop without replacement. $form['og_group_manager_full_access'] = array( '#type' => 'checkbox', '#title' => t('Group manager full permissions'), '#description' => t('When enabled the group manager will have all the permissions in the group.'), - '#default_value' => variable_get('og_group_manager_full_access', TRUE), + '#default_value' => $config->get('og_group_manager_full_access'), ); - // TODO This variable was probably removed in Backdrop without replacement. $form['og_node_access_strict'] = array( '#type' => 'checkbox', '#title' => t('Strict node access permissions'), '#description' => t('When enabled Organic groups will restrict permissions for creating, updating and deleting according to the Organic groups access settings. Example: A content editor with the Edit any page content permission who is not a member of a group would be denied access to modifying page content in that group. (For restricting view access use the Organic groups access control module.)'), - '#default_value' => variable_get('og_node_access_strict', TRUE), + '#default_value' => $config->get('og_node_access_strict'), ); - $form['og_ui_admin_people_view'] = array( + $form['og_ui'] = array( + '#type' => 'fieldset', + '#config' => 'og_ui.settings', + ); + + $form['og_ui']['og_ui_admin_people_view'] = array( '#type' => 'select', '#title' => t('Admin people View'), '#description' => t('Select the View that should be used to show and control the people in the group.'), @@ -57,41 +61,41 @@ function og_ui_admin_settings($form_state) { ); $name = 'og_group_manager_default_rids_' . $entity_type . '_' . $bundle_name; - // TODO This variable was probably removed in Backdrop without replacement. + if ($config->get($name) === NULL) { + $config->set($name, array()); + $config->save(); + } $form['og_group_manager_rids'][$name] = array( '#type' => 'select', '#title' => t('Roles in @entity-label - @bundle-label', $params), '#options' => $og_roles, '#multiple' => TRUE, - '#default_value' => variable_get($name, array()), + '#default_value' => $config->get($name), ); } } } - // TODO This variable was probably removed in Backdrop without replacement. $form['og_features_ignore_og_fields'] = array( '#type' => 'checkbox', '#title' => t('Prevent "Features" export piping'), '#description' => t('When exporting using Features module a content-type, this will prevent from OG related fields to be exported.'), - '#default_value' => variable_get('og_features_ignore_og_fields', FALSE), + '#default_value' => $config->get('og_features_ignore_og_fields'), '#access' => module_exists('features'), ); - // TODO This variable was probably removed in Backdrop without replacement. $form['og_use_queue'] = array( '#type' => 'checkbox', '#title' => t('Use queue'), '#description' => t("Use the core's queue process to operations such as deleting memberships when groups are deleted."), - '#default_value' => variable_get('og_use_queue', FALSE), + '#default_value' => $config->get('og_use_queue'), ); - // TODO This variable was probably removed in Backdrop without replacement. $form['og_orphans_delete'] = array( '#type' => 'checkbox', '#title' => t('Delete orphans'), '#description' => t('Delete "Orphan" group-content (not including useres), when the group is deleted.'), - '#default_value' => variable_get('og_orphans_delete', FALSE), + '#default_value' => $config->get('og_orphans_delete'), '#states' => array( 'visible' => array( ':input[name="og_use_queue"]' => array('checked' => TRUE), diff --git a/og_ui/og_ui.install b/og_ui/og_ui.install index 19efe990..483f607e 100644 --- a/og_ui/og_ui.install +++ b/og_ui/og_ui.install @@ -10,14 +10,7 @@ * Implements hook_uninstall(). */ function og_ui_uninstall() { - $vars = array( - 'og_ui_admin_people_view', - 'og_ui_deny_subscribe_without_approval', - ); - foreach ($vars as $var) { - // TODO This variable was probably removed in Backdrop without replacement. - variable_del($var); - } + } /** @@ -35,6 +28,7 @@ function og_ui_update_1000() { $config->set('og_ui_7000_add_field', update_variable_get('og_ui_7000_add_field', 'FALSE')); $config->set('og_ui_admin_people_view', update_variable_get('og_ui_admin_people_view', 'og_members_admin:default')); $config->set('og_ui_deny_subscribe_without_approval', update_variable_get('og_ui_deny_subscribe_without_approval', 'TRUE')); + $config->save(); update_variable_del('og_ui_7000_add_field'); update_variable_del('og_ui_admin_people_view'); update_variable_del('og_ui_deny_subscribe_without_approval'); diff --git a/og_ui/og_ui.module b/og_ui/og_ui.module index 86caade2..8e9e20b2 100644 --- a/og_ui/og_ui.module +++ b/og_ui/og_ui.module @@ -1237,3 +1237,14 @@ function og_ui_autoload_info() { 'og_ui_handler_area_og_membership_overview' => 'includes/views/handlers/og_ui_handler_area_og_membership_overview.inc', ); } + +/** + * Implements hook_config_info(). + */ +function og_ui_config_info() { + $prefixes['og_ui.settings'] = array( + 'label' => t('Organic groups UI settings'), + 'group' => t('Configuration'), + ); + return $prefixes; +} diff --git a/og_ui/og_ui.test b/og_ui/og_ui.test index 7beb30cc..6f14a0cd 100644 --- a/og_ui/og_ui.test +++ b/og_ui/og_ui.test @@ -1,14 +1,7 @@ 'OG UI role permissions', - 'description' => 'Verify that role permissions can be added and removed via the permissions page of the group.', - 'group' => 'Organic groups UI' - ); - } +class OgUiUserPermissionsTestCase extends BackdropWebTestCase { function setUp() { parent::setUp('og_ui', 'entity_feature'); @@ -26,9 +19,9 @@ class OgUiUserPermissionsTestCase extends DrupalWebTestCase { 'administer content types', 'administer group', ); - $admin_user = $this->drupalCreateUser($permissions); - $web_user = $this->drupalCreateUser(); - $this->drupalLogin($admin_user); + $admin_user = $this->backdropCreateUser($permissions); + $web_user = $this->backdropCreateUser(); + $this->backdropLogin($admin_user); // Create a group. $entity1 = entity_create('entity_test', array('name' => 'main', 'uid' => $admin_user->uid)); @@ -39,7 +32,7 @@ class OgUiUserPermissionsTestCase extends DrupalWebTestCase { $this->assertTrue(og_user_access('entity_test', $entity1->pid, 'subscribe', $web_user), t('User has "subscribe" permission.')); // Remove a permission. - $this->drupalPost('admin/config/group/permissions/entity_test/main', array('1[subscribe]' => FALSE), t('Save permissions')); + $this->backdropPost('admin/config/group/permissions/entity_test/main', array('1[subscribe]' => FALSE), t('Save permissions')); $this->assertText(t('The changes have been saved.'), t('Successful save message displayed.')); // FIXME: There is an og_invalidate_cache() on permissions granting @@ -49,7 +42,7 @@ class OgUiUserPermissionsTestCase extends DrupalWebTestCase { $this->assertFalse(og_user_access('entity_test', $entity1->pid, 'subscribe', $web_user), t('User now does not have "subscribe" permission.')); // Re-add permission. - $this->drupalPost('admin/config/group/permissions/entity_test/main', array('1[subscribe]' => TRUE), t('Save permissions')); + $this->backdropPost('admin/config/group/permissions/entity_test/main', array('1[subscribe]' => TRUE), t('Save permissions')); // FIXME: There is an og_invalidate_cache() on permissions granting // and revoking, but somehow, we need to do it manually here. @@ -58,14 +51,7 @@ class OgUiUserPermissionsTestCase extends DrupalWebTestCase { } } -class OgUiAdminPermissionsTestCase extends DrupalWebTestCase { - public static function getInfo() { - return array( - 'name' => 'OG UI admin section', - 'description' => 'Verify that only users with group admin permissions can see the admin tabs.', - 'group' => 'Organic groups UI' - ); - } +class OgUiAdminPermissionsTestCase extends BackdropWebTestCase { function setUp() { parent::setUp('og_ui'); @@ -78,19 +64,19 @@ class OgUiAdminPermissionsTestCase extends DrupalWebTestCase { * Check access permissions to the group admin tab. */ function testOgUiAdminTabAccess() { - $user1 = $this->drupalCreateUser(); - $user2 = $this->drupalCreateUser(); + $user1 = $this->backdropCreateUser(); + $user2 = $this->backdropCreateUser(); $settings = array(); $settings['uid'] = $user1->uid; $settings['type'] = 'article'; $settings[OG_GROUP_FIELD][LANGUAGE_NONE][0]['value'] = 1; - $node = $this->drupalCreateNode($settings); + $node = $this->backdropCreateNode($settings); - $this->drupalLogin($user2); + $this->backdropLogin($user2); // User does not have any access permissions. - $this->drupalGet('node/' . $node->nid . '/group'); + $this->backdropGet('node/' . $node->nid . '/group'); $this->assertResponse(403, t('User without privileges can not access group admin tabs.')); $perms = array( @@ -105,7 +91,7 @@ class OgUiAdminPermissionsTestCase extends DrupalWebTestCase { foreach ($perms as $perm) { // Add an admin permission to allow the user to access to the admin tabs. og_role_grant_permissions($auth_rid, array($perm)); - $this->drupalGet('node/' . $node->nid . '/group'); + $this->backdropGet('node/' . $node->nid . '/group'); $this->assertResponse(200, t('User with "@perm" privilege can access group admin tabs.', array('@perm' => $perm))); // Remove the admin permission to restrict user access to the admin tabs. // User is left without admin permissions for the next loop. @@ -117,16 +103,16 @@ class OgUiAdminPermissionsTestCase extends DrupalWebTestCase { * Check access to restricted permissions on the permissions edit page. */ function testOgUiAdminPermissionsAccess() { - $user1 = $this->drupalCreateUser(); - $user2 = $this->drupalCreateUser(); + $user1 = $this->backdropCreateUser(); + $user2 = $this->backdropCreateUser(); $settings = array(); $settings['uid'] = $user1->uid; $settings['type'] = 'article'; $settings[OG_GROUP_FIELD][LANGUAGE_NONE][0]['value'] = 1; - $node = $this->drupalCreateNode($settings); + $node = $this->backdropCreateNode($settings); - $this->drupalLogin($user2); + $this->backdropLogin($user2); $roles = og_roles('node', 'article'); $auth_rid = array_search(OG_ANONYMOUS_ROLE, $roles); $text = t('Warning: Give to trusted roles only; this permission has security implications in the group context.'); @@ -134,26 +120,19 @@ class OgUiAdminPermissionsTestCase extends DrupalWebTestCase { // Check that restricted permissions are not displayed to the user with // manage permissions but not administer group. og_role_grant_permissions($auth_rid, array('manage permissions')); - $this->drupalGet('group/node/' . $node->nid . '/admin/permissions'); + $this->backdropGet('group/node/' . $node->nid . '/admin/permissions'); $this->assertNoText($text, t('Restricted permissions are not displayed to the unprivileged user.')); // Check that restricted permissions are displayed to a user with administer // group. og_role_revoke_permissions($auth_rid, array('manage permissions')); og_role_grant_permissions($auth_rid, array('administer group')); - $this->drupalGet('group/node/' . $node->nid . '/admin/permissions'); + $this->backdropGet('group/node/' . $node->nid . '/admin/permissions'); $this->assertText($text, t('Restricted permissions are displayed to the privileged user.')); } } -class OgUiSubscribeTestCase extends DrupalWebTestCase { - public static function getInfo() { - return array( - 'name' => 'OG UI subscribe', - 'description' => 'Verify the subscribe and unsubsribe functionality.', - 'group' => 'Organic groups UI' - ); - } +class OgUiSubscribeTestCase extends BackdropWebTestCase { function setUp() { parent::setUp('og_ui', 'entity_feature'); @@ -165,23 +144,23 @@ class OgUiSubscribeTestCase extends DrupalWebTestCase { * Test subscribing to group. */ function testOgUiSubscribe() { - $user1 = $this->drupalCreateUser(); - $user2 = $this->drupalCreateUser(); - $this->drupalLogin($user1); + $user1 = $this->backdropCreateUser(); + $user2 = $this->backdropCreateUser(); + $this->backdropLogin($user1); // Create a group. $settings = array(); $settings['type'] = 'article'; $settings['uid'] = $user1->uid; $settings[OG_GROUP_FIELD][LANGUAGE_NONE][0]['value'] = 1; - $node = $this->drupalCreateNode($settings); + $node = $this->backdropCreateNode($settings); - $this->drupalGet('node/' . $node->nid); + $this->backdropGet('node/' . $node->nid); $this->assertText(t('You are the group manager'), t('Group manager gets correct text.')); - $this->drupalLogin($user2); - $this->drupalGet('node/' . $node->nid); + $this->backdropLogin($user2); + $this->backdropGet('node/' . $node->nid); $this->assertText(t('Request group membership'), t('Non-member without "subscribe without approval" gets correct text.')); $this->clickLink(t('Request group membership')); @@ -190,16 +169,16 @@ class OgUiSubscribeTestCase extends DrupalWebTestCase { $request = $this->randomString(); $edit = array(); $edit['og_membership_request[und][0][value]'] = $request; - $this->drupalPost(NULL, $edit , t('Join')); + $this->backdropPost(NULL, $edit , t('Join')); $og_membership = og_get_membership('node', $node->nid, 'user', $user2->uid); $wrapper = entity_metadata_wrapper('og_membership', $og_membership); $this->assertEqual($request, $wrapper->og_membership_request->value(), t('User request was saved in group membership.')); - $this->drupalGet('node/' . $node->nid); + $this->backdropGet('node/' . $node->nid); $this->assertText(t('Unsubscribe from group'), t('Member gets correct unsubscribe text.')); $this->clickLink(t('Unsubscribe from group')); - $this->drupalPost(NULL, array() , t('Unsubscribe')); + $this->backdropPost(NULL, array() , t('Unsubscribe')); $this->assertFalse(og_is_member('node', $node->nid, 'user', $user2, array(OG_STATE_ACTIVE, OG_STATE_PENDING)), t('User unsubscribed from group.')); @@ -208,37 +187,29 @@ class OgUiSubscribeTestCase extends DrupalWebTestCase { $rid = array_search(OG_ANONYMOUS_ROLE, $og_roles); og_role_change_permissions($rid, array('subscribe without approval' => 1)); - $this->drupalGet('node/' . $node->nid); + $this->backdropGet('node/' . $node->nid); $this->assertText(t('Subscribe to group'), t('Non-member with "subscribe without approval" gets correct text.')); $this->clickLink(t('Subscribe to group')); $this->assertNoText('Request message', t('Request message does not appear.')); - $this->drupalPost(NULL, array() , t('Join')); + $this->backdropPost(NULL, array() , t('Join')); $this->assertTrue(og_is_member('node', $node->nid, 'user', $user2), t('User subscribed to group')); } } -class OgUiManagePeopleTestCase extends DrupalWebTestCase { +class OgUiManagePeopleTestCase extends BackdropWebTestCase { public $user1; public $user2; public $entity; - public static function getInfo() { - return array( - 'name' => 'OG UI manage people', - 'description' => 'Verify the people management functionality.', - 'group' => 'Organic groups UI' - ); - } - function setUp() { parent::setUp('og_ui', 'entity_feature'); // Add OG group field. og_create_field(OG_GROUP_FIELD, 'entity_test', 'test'); // Create users. - $this->user1 = $this->drupalCreateUser(); - $this->user2 = $this->drupalCreateUser(); + $this->user1 = $this->backdropCreateUser(); + $this->user2 = $this->backdropCreateUser(); // Create a group. $this->entity = entity_create('entity_test', array('name' => 'test', 'uid' => $this->user1->uid)); @@ -252,26 +223,26 @@ class OgUiManagePeopleTestCase extends DrupalWebTestCase { * Test adding people via group/[entity_type]/[etid]/admin/people/add-user. */ function testOgUiAddPeople() { - $this->drupalLogin($this->user1); + $this->backdropLogin($this->user1); // Add user2 to the group. $this->assertFalse(og_is_member('entity_test', $this->entity->pid, 'user', $this->user2), 'User is not a group member'); $edit = array(); $edit['name'] = $this->user2->name; - $this->drupalPost('group/entity_test/' . $this->entity->pid . '/admin/people/add-user', $edit, t('Add users')); + $this->backdropPost('group/entity_test/' . $this->entity->pid . '/admin/people/add-user', $edit, t('Add users')); // Reload user. og_invalidate_cache(); $this->assertTrue(og_is_member('entity_test', $this->entity->pid, 'user', $this->user2), 'User was added to the group.'); // Add the same user twice. - $this->drupalPost('group/entity_test/' . $this->entity->pid . '/admin/people/add-user', $edit, t('Add users')); - $this->assertText(t('User @name is already subscribed to group.', array('@name' => format_username($this->user2))), 'User can not be added twice.'); + $this->backdropPost('group/entity_test/' . $this->entity->pid . '/admin/people/add-user', $edit, t('Add users')); + $this->assertText(t('User @name is already subscribed to group.', array('@name' => user_format_name($this->user2))), 'User can not be added twice.'); // Add non-existing user. $edit = array(); $edit['name'] = $this->randomName(); - $this->drupalPost('group/entity_test/' . $this->entity->pid . '/admin/people/add-user', $edit, t('Add users')); + $this->backdropPost('group/entity_test/' . $this->entity->pid . '/admin/people/add-user', $edit, t('Add users')); $this->assertText(t('You have entered an invalid user name.'), t('Invalid user name not added to group.')); } @@ -279,7 +250,7 @@ class OgUiManagePeopleTestCase extends DrupalWebTestCase { * Change membership status for a single group user. */ function testOgUiEditMembershipStatus() { - $this->drupalLogin($this->user1); + $this->backdropLogin($this->user1); // Group the user to the group. $membership = og_group('entity_test', $this->entity->pid, array('entity' => $this->user2)); @@ -287,10 +258,10 @@ class OgUiManagePeopleTestCase extends DrupalWebTestCase { // Updating the state status. $states = og_group_content_states(); foreach ($states as $state => $title) { - $this->drupalPost('group/entity_test/' . $this->entity->pid . '/admin/people/edit-membership/' . $membership->id, array('state' => $state), t('Update membership')); + $this->backdropPost('group/entity_test/' . $this->entity->pid . '/admin/people/edit-membership/' . $membership->id, array('state' => $state), t('Update membership')); // Reset the static cache for a fresh OG membership object. - drupal_static_reset(); + backdrop_static_reset(); $membership = og_membership_load($membership->id); // Verify the membership has updates successfully. @@ -302,11 +273,11 @@ class OgUiManagePeopleTestCase extends DrupalWebTestCase { * Delete a single user's membership from group. */ function testOgUiDeleteMembership() { - $this->drupalLogin($this->user1); + $this->backdropLogin($this->user1); // Group the user to the group. $membership = og_group('entity_test', $this->entity->pid, array('entity' => $this->user2)); - $this->drupalPost('group/entity_test/' . $this->entity->pid . '/admin/people/delete-membership/' . $membership->id, array(), t('Remove')); + $this->backdropPost('group/entity_test/' . $this->entity->pid . '/admin/people/delete-membership/' . $membership->id, array(), t('Remove')); // Verify the membership was removed. $this->assertText('The membership was removed.'); @@ -316,8 +287,8 @@ class OgUiManagePeopleTestCase extends DrupalWebTestCase { * Test that only the correct group audience fields are shown. */ function testOgUiAddPeopleMultipleAudienceFields() { - $user1 = $this->drupalCreateUser(); - $this->drupalLogin($user1); + $user1 = $this->backdropCreateUser(); + $this->backdropLogin($user1); // Delete the default group audience field field_delete_field('og_user_entity_test'); @@ -387,14 +358,14 @@ class OgUiManagePeopleTestCase extends DrupalWebTestCase { // Because only one of the three fields applies to this entity type and // bundle, no select box should be shown. - $this->drupalGet('group/entity_test/' . $entity->pid . '/admin/people/add-user'); + $this->backdropGet('group/entity_test/' . $entity->pid . '/admin/people/add-user'); $this->assertNoField('edit-field-name'); // Temporarily change the second field to apply to this bundle. Now the // select box should be shown. $field['group_audience_entity_test_test2']['settings']['handler_settings']['target_bundles'] = array('test'); field_update_field($field['group_audience_entity_test_test2']); - $this->drupalGet('group/entity_test/' . $entity->pid . '/admin/people/add-user'); + $this->backdropGet('group/entity_test/' . $entity->pid . '/admin/people/add-user'); $this->assertField('edit-field-name'); $elements = $this->xpath('//select[@id="edit-field-name"]//option'); $this->assertEqual(count($elements), 2, '2 options available for selection'); @@ -406,14 +377,14 @@ class OgUiManagePeopleTestCase extends DrupalWebTestCase { // Revert the field settings to the previous state. $field['group_audience_entity_test_test2']['settings']['handler_settings']['target_bundles'] = array('test2'); field_update_field($field['group_audience_entity_test_test2']); - $this->drupalGet('group/entity_test/' . $entity->pid . '/admin/people/add-user'); + $this->backdropGet('group/entity_test/' . $entity->pid . '/admin/people/add-user'); $this->assertNoField('edit-field-name'); // Change the third field to apply to this entity type. In this case the // select box should be shown, as well. $field['group_audience_entity_test2']['settings']['target_type'] = 'entity_test'; field_update_field($field['group_audience_entity_test2']); - $this->drupalGet('group/entity_test/' . $entity->pid . '/admin/people/add-user'); + $this->backdropGet('group/entity_test/' . $entity->pid . '/admin/people/add-user'); $this->assertField('edit-field-name'); $elements = $this->xpath('//select[@id="edit-field-name"]//option'); $this->assertEqual(count($elements), 2, '2 options available for selection'); @@ -427,150 +398,47 @@ class OgUiManagePeopleTestCase extends DrupalWebTestCase { * Tests that invalid group IDs in the menu path do not cause exceptions. */ public function testOgUiPath() { - $this->drupalGet('entity_test/' . $this->entity->pid . 'invalid/group'); + $this->backdropGet('entity_test/' . $this->entity->pid . 'invalid/group'); $this->assertResponse(403); // Numeric values that are not consist of decimal characters are forbidden. // 0x1 for instance is equivalent to 1 // http://php.net/manual/en/language.types.integer.php - $this->drupalGet('entity_test/0x' . $this->entity->pid . '/group'); + $this->backdropGet('entity_test/0x' . $this->entity->pid . '/group'); $this->assertResponse(403); // Non-existing groups return 404 however. - $this->drupalGet('entity_test/666'); + $this->backdropGet('entity_test/666'); $this->assertResponse(404); // For the same, admin area returns 403. - $this->drupalGet('entity_test/666/group'); + $this->backdropGet('entity_test/666/group'); $this->assertResponse(403); } } -/** - * Upgrade 7000 test. - * - * Load a filled installation of Drupal 6 and run the upgrade process on it. - */ -class OgUiMigrate7000TestCase extends UpgradePathTestCase { - public static function getInfo() { - return array( - 'name' => 'OG UI upgrade path', - 'description' => 'Tests the upgrade path of Organic groups UI.', - 'group' => 'Organic groups UI', - 'dependencies' => array('migrate'), - ); - } - - public function setUp() { - // Path to the database dump. - $this->databaseDumpFiles = array( - drupal_get_path('module', 'og_ui') . '/tests/drupal-6.og-ui.database.php', - ); - parent::setUp(); - $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.'); - - // spl_autoload_register() wasn't called, so we do it here, to allow - // classes to be auto-loaded. - spl_autoload_register('drupal_autoload_class'); - spl_autoload_register('drupal_autoload_interface'); - - module_enable(array('og_ui', 'migrate')); - - foreach (migrate_migrations() as $migration) { - $machine_name = $migration->getMachineName(); - $result = $migration->processImport(); - $this->assertEqual($result, Migration::RESULT_COMPLETED, format_string('Migration @name executed.', array('@name' => $machine_name))); - } - } - - /** - * Test a successful upgrade. - */ - public function testUpgrade() { - // Assert according to the scenario Drupal 6's test table dump was created. - $nodes_info = array( - // Open group. - 1 => array( - 'name' => t('open'), - 'anon' => array( - 'subscribe' => FALSE, - 'subscribe without approval' => TRUE, - ), - ), - // Moderated group. - 2 => array( - 'name' => t('moderated'), - 'anon' => array( - 'subscribe' => TRUE, - 'subscribe without approval' => FALSE, - ), - ), - // Invite only group. - 3 => array( - 'name' => t('invite only'), - 'anon' => array( - 'subscribe' => FALSE, - 'subscribe without approval' => FALSE, - ), - ), - // Closed group. - 4 => array( - 'name' => t('closed'), - 'anon' => array( - 'subscribe' => FALSE, - 'subscribe without approval' => FALSE, - ), - 'auth' => array('unsubscribe' => FALSE), - ), - ); - - foreach ($nodes_info as $nid => $node_info) { - // Set default values. - $node_info += array('auth' => array('unsubscribe' => TRUE)); - - $og_roles = og_roles('node', 'test_group', $nid, TRUE); - $permissions = og_role_permissions($og_roles); - - $anon_rid = array_search(OG_ANONYMOUS_ROLE, $og_roles); - $auth_rid = array_search(OG_AUTHENTICATED_ROLE, $og_roles); - - // Assert permissions for non-member and member roles. - $this->assertEqual($permissions[$anon_rid], array_filter($node_info['anon']), t('Correct permissions were set for non-member role in @type group.', array('@type' => $node_info['name']))); - $this->assertEqual($permissions[$auth_rid], array_filter($node_info['auth']), t('Correct permissions were set for member role in @type group.', array('@type' => $node_info['name']))); - } - } -} - /** * Joining to a private group status. */ -class OgUiPrivateGroupStatus extends DrupalWebTestCase { +class OgUiPrivateGroupStatus extends BackdropWebTestCase { public $user; public $group; - public static function getInfo() { - return array( - 'name' => 'Subscribe to private groups', - 'description' => 'Testing the automatic approval of a membership request for a private group.', - 'group' => 'Organic groups UI', - ); - } - public function setUp() { parent::setUp(array('og', 'og_access', 'og_ui')); node_access_rebuild(); // Creating the content type and the necessary fields for this test. - $content_type = $this->drupalCreateContentType(); + $content_type = $this->backdropCreateContentType(); og_create_field(OG_GROUP_FIELD, 'node', $content_type->type); og_create_field(OG_ACCESS_FIELD, 'node', $content_type->type); // Creating a private group, and a user. - $this->group = $this->drupalCreateNode(array('type' => $content_type->type)); + $this->group = $this->backdropCreateNode(array('type' => $content_type->type)); $wrapper = entity_metadata_wrapper('node', $this->group); $wrapper->{OG_GROUP_FIELD}->set(TRUE); $wrapper->{OG_ACCESS_FIELD}->set(1); $wrapper->save(); - $this->user = $this->drupalCreateUser(); + $this->user = $this->backdropCreateUser(); } /** @@ -584,11 +452,11 @@ class OgUiPrivateGroupStatus extends DrupalWebTestCase { * approved automatically. */ public function testMemberShipRequestStatus() { - $this->drupalLogin($this->user); + $this->backdropLogin($this->user); // When the user ask to join a private group we need to verify that the // membership will be pending. - $this->drupalPost('group/node/' . $this->group->nid . '/subscribe/og_user_node', array(), t('Join')); + $this->backdropPost('group/node/' . $this->group->nid . '/subscribe/og_user_node', array(), t('Join')); $this->assertTrue(og_is_member('node', $this->group->nid, 'user', $this->user, array(OG_STATE_PENDING)), 'The user membership request is pending.'); // Delete the membership. @@ -605,10 +473,10 @@ class OgUiPrivateGroupStatus extends DrupalWebTestCase { // Change the approval variable and ask to join the private group. $roles = og_roles('node', $this->group->type); og_role_grant_permissions(array_search(OG_ANONYMOUS_ROLE, $roles), array('subscribe without approval')); - variable_set('og_ui_deny_subscribe_without_approval', FALSE); + config_set('og_ui.settings', 'og_ui_deny_subscribe_without_approval', FALSE); // Verify the user membership is approved automatically. - $this->drupalPost('group/node/' . $this->group->nid . '/subscribe/og_user_node', array(), t('Join')); + $this->backdropPost('group/node/' . $this->group->nid . '/subscribe/og_user_node', array(), t('Join')); $this->assertTrue(og_is_member('node', $this->group->nid, 'user', $this->user, array(OG_STATE_ACTIVE)), 'The user membership request is active.'); } } diff --git a/og_ui/og_ui.tests.info b/og_ui/og_ui.tests.info index 68194d5c..9e4bb290 100644 --- a/og_ui/og_ui.tests.info +++ b/og_ui/og_ui.tests.info @@ -22,12 +22,6 @@ description = Verify the people management functionality. group = Organic groups UI file = og_ui.test -[OgUiMigrate7000TestCase] -name = OG UI upgrade path -description = Tests the upgrade path of Organic groups UI. -group = Organic groups UI -file = og_ui.test - [OgUiPrivateGroupStatus] name = Subscribe to private groups description = Testing the automatic approval of a membership request for a private group. diff --git a/tests/og.test b/tests/og.test index 48297070..16f8d251 100644 --- a/tests/og.test +++ b/tests/og.test @@ -33,14 +33,6 @@ class OgTestBase extends BackdropWebTestCase { class OgAccess extends OgTestBase { - public static function getInfo() { - return array( - 'name' => 'OG entity access', - 'description' => 'Test the access provided by OG API.', - 'group' => 'Organic groups', - ); - } - function setUp() { parent::setUp('og', 'og_entity_test'); } @@ -143,14 +135,6 @@ class OgAccess extends OgTestBase { */ class OgNodeAccess extends OgTestBase { - public static function getInfo() { - return array( - 'name' => 'OG node access', - 'description' => 'Test strict node access permissions for group nodes and group content.', - 'group' => 'Organic groups', - ); - } - function setUp() { parent::setUp('og'); @@ -194,7 +178,7 @@ class OgNodeAccess extends OgTestBase { */ function testStrictAccessNodeUpdate() { // Set Node access strict variable. - variable_set('og_node_access_strict', TRUE); + config_set('og.settings', 'og_node_access_strict', TRUE); // Login as editor and try to change the group node and group content. $this->backdropLogin($this->editor_user); @@ -220,7 +204,7 @@ class OgNodeAccess extends OgTestBase { */ function testStrictAccessNodeCreate() { // Set Node access strict variable. - variable_set('og_node_access_strict', TRUE); + config_set('og.settings', 'og_node_access_strict', TRUE); $editor_user = $this->editor_user; $this->backdropLogin($editor_user); @@ -267,7 +251,7 @@ class OgNodeAccess extends OgTestBase { */ function testNoStrictAccessNodeUpdate() { // Set Node access strict variable. - variable_set('og_node_access_strict', FALSE); + config_set('og.settings', 'og_node_access_strict', FALSE); // Login as editor and try to change the group node and group content. $this->backdropLogin($this->editor_user); @@ -296,7 +280,7 @@ class OgNodeAccess extends OgTestBase { */ function testNoStrictAccessNodeCreate() { // Set Node access strict variable. - variable_set('og_node_access_strict', FALSE); + config_set('og.settings', 'og_node_access_strict', FALSE); $this->group_editor_user = $this->backdropCreateUser(array('access content')); $this->backdropLogin($this->group_editor_user); @@ -322,7 +306,7 @@ class OgNodeAccess extends OgTestBase { */ function testNodeUpdateAudienceField() { // Set Node access strict variable. - variable_set('og_node_access_strict', TRUE); + config_set('og.settings', 'og_node_access_strict', TRUE); $editor_user = $this->editor_user; // Add editor to a single groups. @@ -376,14 +360,6 @@ class OgNodeAccess extends OgTestBase { */ class OgMetaData extends OgTestBase { - public static function getInfo() { - return array( - 'name' => 'OG metadata', - 'description' => 'Test the metadata properties.', - 'group' => 'Organic groups', - ); - } - function setUp() { parent::setUp('og', 'og_entity_test'); } @@ -470,14 +446,6 @@ class OgMetaData extends OgTestBase { */ class OgGroupAndUngroup extends OgTestBase { - public static function getInfo() { - return array( - 'name' => 'OG group and ungroup', - 'description' => 'Test the group and ungrouping of content with a group.', - 'group' => 'Organic groups', - ); - } - function setUp() { parent::setUp('og', 'og_entity_test'); @@ -669,7 +637,7 @@ class OgGroupAndUngroup extends OgTestBase { function testGroupManagerDefaultRoles() { // Get only the admin role. $og_roles = og_roles('og_entity_test', 'main', 0, FALSE, FALSE); - variable_set('og_group_manager_default_rids_og_entity_test_main', array_keys($og_roles)); + config_set('og.settings', 'og_group_manager_default_rids_og_entity_test_main', array_keys($og_roles)); $user1 = $this->backdropCreateUser(); $entity1 = entity_create('og_entity_test', array('name' => 'main', 'uid' => $user1->uid)); @@ -718,13 +686,6 @@ class OgGroupAndUngroup extends OgTestBase { } class OgPermissionsTestCase extends OgTestBase { - public static function getInfo() { - return array( - 'name' => 'OG permissions', - 'description' => 'Verify that permissions can be added and removed via API.', - 'group' => 'Organic groups' - ); - } function setUp() { parent::setUp('og', 'og_entity_test'); @@ -860,13 +821,6 @@ class OgPermissionsTestCase extends OgTestBase { } class OgDefaultAccessFieldTestCase extends OgTestBase { - public static function getInfo() { - return array( - 'name' => 'OG default access field', - 'description' => 'Test groups with default access field.', - 'group' => 'Organic groups' - ); - } function setUp() { parent::setUp('og', 'og_entity_test'); @@ -920,7 +874,7 @@ class OgDefaultAccessFieldTestCase extends OgTestBase { $this->assertTrue(array_search(OG_ADMINISTRATOR_ROLE, $user_roles), t('User has overriden "admin" role.')); // Disable existing group's default access field. - variable_set('og_maintain_overridden_roles', TRUE); + config_set('og.settings', 'og_maintain_overridden_roles', TRUE); $wrapper->{OG_DEFAULT_ACCESS_FIELD}->set(0); $wrapper->save(); $this->assertEqual($og_roles, og_roles('og_entity_test', 'main', $entity->pid), t('Group with enabled default access field that was disabled is assigned to the global roles and permissions settings.')); @@ -934,7 +888,7 @@ class OgDefaultAccessFieldTestCase extends OgTestBase { $wrapper->save(); // Assert admin role was not maintained from the overriden group. - variable_set('og_maintain_overridden_roles', FALSE); + config_set('og.settings', 'og_maintain_overridden_roles', FALSE); $wrapper->{OG_DEFAULT_ACCESS_FIELD}->set(0); $wrapper->save(); @@ -943,186 +897,11 @@ class OgDefaultAccessFieldTestCase extends OgTestBase { } } -/** - * Upgrade 7000 test. - * - * Load a filled installation of Backdrop 6 and run the upgrade on it. - * - * TODO: We have to use $this->backdropGet('node/' . $nid); to proerly load - * the node data, otherwise. We should understand why this is needed, and - * remove it. - */ -/* class OgMigrate7000TestCase extends UpgradePathTestCase { - public static function getInfo() { - return array( - 'name' => 'OG migrate - 7000', - 'description' => 'Tests the upgrade path of OG from Backdrop 6.', - 'group' => 'Organic groups', - // TODO: Why do we need to enable Views?! - otherwise we get WSOD. - 'dependencies' => array('migrate', 'views'), - ); - } - */ -/* public function setUp() { - // Path to the database dump. - $this->databaseDumpFiles = array( - backdrop_get_path('module', 'og') . '/tests/backdrop-6.og.database.php', - ); - parent::setUp(); - $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.')); - - // spl_autoload_register() wasn't called, so we do it here, to allow - // classes to be auto-loaded. - spl_autoload_register('backdrop_autoload_class'); - spl_autoload_register('backdrop_autoload_interface'); - - // TODO: Why do we need to enable Views?! - module_enable(array('og', 'views', 'migrate')); - - $class_names = array( - 'OgMigrateAddFields', - 'OgMigrateUser', - 'OgMigrateContent', - ); - - // FIXME: migrate_flush_caches() crashes, so we register manually. - foreach ($class_names as $class_name) { - MigrationBase::registerMigration($class_name); - } - - // Register a dynamic migration. - MigrationBase::registerMigration('OgMigrateGroup', 'OgMigrateGroupTest_group', array('bundle' => 'test_group')); - - $migration = Migration::getInstance('OgMigrateAddFields'); - $result = $migration->processImport(); - $this->assertEqual($result, Migration::RESULT_COMPLETED, 'Migration OgMigrateAddFields executed.'); - - $migration = Migration::getInstance('OgMigrateGroupTest_group', 'OgMigrateGroup', array('bundle' => 'test_group')); - $result = $migration->processImport(); - $this->assertEqual($result, Migration::RESULT_COMPLETED, 'Migration OgMigrateGroupTest_group executed.'); - - $migration = Migration::getInstance('OgMigrateUser'); - $result = $migration->processImport(); - $this->assertEqual($result, Migration::RESULT_COMPLETED, 'Migration OgMigrateUser executed.'); - - $migration = Migration::getInstance('OgMigrateContent'); - $result = $migration->processImport(); - $this->assertEqual($result, Migration::RESULT_COMPLETED, 'Migration OgMigrateContent executed.'); - } - */ - /** - * Test a successful group upgrade. - * - * @see og_7000_group() - */ -/* public function testGroup() { - // Assert according to the scenario Backdrop 6's test table dump was created. - foreach (array(1, 2) as $nid) { - $this->backdropGet('node/' . $nid); - $node = node_load($nid); - $this->assertTrue($node->{OG_GROUP_FIELD}[LANGUAGE_NONE][0]['value'], t('Node ID @nid is an active group.', array('@nid' => $nid))); - } - - // Test group content with NID 3 - 5 belong to the group with NID 2. - foreach (range(3, 5) as $nid) { - $this->backdropGet('node/' . $nid); - $node = node_load($nid); - $this->assertTrue(og_is_member('node', 2, 'node', $node), t('Node ID @nid is a group content of Node ID 2', array('@nid' => $nid))); - } - - // Orphan group content (i.e. not attached to a group). - $node = node_load(6); - $this->assertFalse(og_get_entity_groups('node', $node), t('Node ID 6 is not associated with any group.')); - - // Group content that shares the same group. - $node = node_load(9); - foreach (array(7, 8) as $nid) { - $this->assertTrue(og_is_member('node', $nid, 'node', $node), t('Node ID @nid is as group content associated with multiple groups.', array('@nid' => $node->nid))); - } - } - */ - /** - * Test user upgrade. - * - * @see og_7000_user() - */ -/* public function testUser() { - // Assert users. - $values = array( - // Uid 3 is the group manager, so in OG6 it was marked as admin. - 3 => array('admin' => TRUE), - 4 => array('active' => FALSE), - 5 => array(), - 6 => array('active' => FALSE, 'admin' => TRUE), - 7 => array('admin' => TRUE), - ); - - $og_roles = og_roles('node', 'test_group'); - - foreach ($values as $uid => $value) { - $account = user_load($uid); - - // Set default values. - $value += array('active' => TRUE, 'admin' => FALSE); - $roles = array(); - - if ($value['active']) { - $op = 'active'; - $states = array(OG_STATE_ACTIVE); - $rid = array_search(OG_AUTHENTICATED_ROLE, $og_roles); - } - else { - $op = 'pending'; - $states = array(OG_STATE_PENDING); - // If the member is pending then they have the anonymous role. - $rid = array_search(OG_ANONYMOUS_ROLE, $og_roles); - } - - $roles[$rid] = TRUE; - - if ($value['admin']) { - // OG_ADMINISTRATOR_ROLE - $rid = array_search(OG_ADMINISTRATOR_ROLE, $og_roles); - $roles[$rid] = TRUE; - } - - $this->assertTrue(og_is_member('node', 10, 'user', $account, $states), format_string('User @uid is @op member in group.', array('@uid' => $uid, '@op' => $op))); - // Pass also pending state, so we make sure that even if the user - // isn't active they are considered members, to check they get the - // correct role. - $this->assertEqual(array_keys(og_get_user_roles('node', 10, $uid, TRUE, FALSE)), array_keys($roles), format_string('User @uid has the correct roles in group.', array('@uid' => $uid))); - } - } - */ - /** - * Test group description upgrade. - * - * @see og_7000_group() - */ -/* public function testGroupDescription() { - // Assert description was converted to a field. - foreach (array(1, 2, 7, 8, 10) as $nid) { - $this->backdropGet('node/' . $nid); - $node = node_load($nid); - $this->assertTrue($node->og_description[LANGUAGE_NONE][0]['value'], t('Description fields has correct data.')); - } - } -} - */ - /** * Test the complex widget. */ class OgFieldWidgetTestCase extends OgTestBase { - public static function getInfo() { - return array( - 'name' => 'OG reference widget', - 'description' => 'Test the OG reference widget behavior.', - 'group' => 'Organic groups', - ); - } - function setUp() { parent::setUp('og'); @@ -1301,14 +1080,6 @@ class OgFieldWidgetTestCase extends OgTestBase { */ class OgRoleRevoke extends OgTestBase { - public static function getInfo() { - return array( - 'name' => 'OG roles revoke', - 'description' => 'Test the revocation of group roles', - 'group' => 'Organic groups', - ); - } - function setUp() { parent::setUp('og', 'og_entity_test'); } @@ -1358,96 +1129,11 @@ class OgRoleRevoke extends OgTestBase { } } -/** - * Test Upgrade from branch 1.x to 2.x. - */ -/* class OgMigrate7200TestCase extends UpdatePathTestCase { - - public static function getInfo() { - return array( - 'name' => 'OG migrate 7.x-2.x', - 'description' => 'Test the upgrade from 7.x-1.x to 7.x-2.x branch.', - 'group' => 'Organic groups', - 'dependencies' => array('migrate'), - ); - } - - function setUp() { - // Path to the database dump files. - $this->databaseDumpFiles = array( - backdrop_get_path('module', 'og') . '/tests/og-7.x-1.x.database.php', - ); - - parent::setUp(); - - // FIXME: Since the DB dump holds group-audience field instances, - // we need to delete them, otherwise this will create notices in - // resulting from OG no longer defining hook_field_info(). - // Deleting using field_delete_instance() didn't work. - db_delete('field_config_instance') - ->condition('field_name', 'group_audience') - ->execute(); - } - - function testUpgrade() { - $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.')); - - $this->assertFalse(field_info_field('group_audience'), 'Group audience field was deleted.'); - - // spl_autoload_register() wasn't called, so we do it here, to allow - // classes to be auto-loaded. - spl_autoload_register('backdrop_autoload_class'); - spl_autoload_register('backdrop_autoload_interface'); - - module_enable(array('og', 'migrate')); - - // FIXME: migrate_flush_caches() crashes, so we register manually. - MigrationBase::registerMigration('OgMigrateMembership'); - MigrationBase::registerMigration('OgMigrateRoles'); - MigrationBase::registerMigration('OgMigrateUserRoles'); - - $migration = Migration::getInstance('OgMigrateMembership'); - $result = $migration->processImport(); - $this->assertEqual($result, Migration::RESULT_COMPLETED, 'OgMigrateMembership returned RESULT_COMPLETED'); - - $migration = Migration::getInstance('OgMigrateRoles'); - $result = $migration->processImport(); - $this->assertEqual($result, Migration::RESULT_COMPLETED, 'OgMigrateRoles returned RESULT_COMPLETED'); - - $migration = Migration::getInstance('OgMigrateUserRoles'); - $result = $migration->processImport(); - $this->assertEqual($result, Migration::RESULT_COMPLETED, 'OgMigrateUserRoles returned RESULT_COMPLETED'); - - // Assert group roles. - $roles = array( - 'non-member', - 'member', - 'administrator member', - ); - $this->assertEqual(array_values(og_roles('node', 'school', 1)), $roles, 'Returned expected roles group first group.'); - - $roles[] = 'new role'; - $this->assertEqual(array_values(og_roles('node', 'school', 2)), $roles, 'Returned expected roles group second group.'); - - // Assert field name was registered in the OG membership. - $og_membership = entity_load('og_membership', 1); - $this->assertTrue($og_membership->field_name, 'Field name was registered in the OG membership.'); - } -} - */ /** * Test queying group-audience fields using entityFieldQuery. */ class OgEntityFieldQueryTestCase extends OgTestBase { - public static function getInfo() { - return array( - 'name' => 'OG audience fields query', - 'description' => 'Test querying group-audience fields using entityFieldQuery.', - 'group' => 'Organic groups', - ); - } - function setUp() { parent::setUp('og', 'entity', 'og_entity_test', 'entity_plus', 'entity_ui'); @@ -1672,14 +1358,6 @@ class OgEntityFieldQueryTestCase extends OgTestBase { */ class OgEntityFieldQueryFieldConditionTestCase extends OgTestBase { - public static function getInfo() { - return array( - 'name' => 'OG field condition query', - 'description' => 'Test querying field condition fields using entityFieldQuery.', - 'group' => 'Organic groups', - ); - } - function setUp() { parent::setUp('og', 'og_entity_test'); @@ -1839,14 +1517,6 @@ class OgEntityFieldQueryFieldConditionTestCase extends OgTestBase { */ class OgAudienceFieldAutoCreateTestCase extends OgTestBase { - public static function getInfo() { - return array( - 'name' => 'OG audience fields auto-create', - 'description' => 'Test auto attaching a group-audience field to the user entity, if needed, upon adding a new group field.', - 'group' => 'Organic groups', - ); - } - function setUp() { parent::setUp('og'); } @@ -1874,16 +1544,7 @@ class OgAudienceFieldAutoCreateTestCase extends OgTestBase { } } - -class OgBehaviorHandlerTestCase extends OgTestBase { - - public static function getInfo() { - return array( - 'name' => 'OG widget behavior', - 'description' => 'Test the widget behavior of group-audience fields.', - 'group' => 'Organic groups', - ); - } +class OgBehaviorHandlerTestCase extends OgTestBase { function setUp() { parent::setUp('og_test', 'og_entity_test'); @@ -2022,14 +1683,6 @@ class OgDeleteOrphansTestCase extends OgTestBase { public $group_type; public $node_type; - public static function getInfo() { - return array( - 'name' => 'OG orphan delete', - 'description' => 'Verifying for deleting orphan group content.', - 'group' => 'Organic groups', - ); - } - function setUp() { parent::setUp('og_test'); @@ -2048,8 +1701,8 @@ class OgDeleteOrphansTestCase extends OgTestBase { og_create_field(OG_AUDIENCE_FIELD, 'node', $type->type, $og_field); // Set the setting for delete a group content when deleting group. - variable_set('og_orphans_delete', TRUE); - variable_set('og_use_queue', TRUE); + config_set('og.settings', 'og_orphans_delete', TRUE); + config_set('og.settings', 'og_use_queue', TRUE); } /** @@ -2158,7 +1811,7 @@ class OgDeleteOrphansTestCase extends OgTestBase { */ public function testGroupContentNodeAccessAfterDeletingGroupAndWhenUsingQueue() { // Configure OG to use queue for deleting pending content. - variable_set('og_use_queue', TRUE); + config_set('og.settings', 'og_use_queue', TRUE); $account = $this->backdropCreateUser(array('access content', 'edit own ' . $this->node_type . ' content')); $this->backdropLogin($account); @@ -2201,15 +1854,6 @@ class OgNonMembersPublishingContentTestCase extends OgTestBase { public $user; public $adminUser; - public static function getInfo() { - return array( - 'name' => 'OG non members publishing', - 'description' => 'Grant access to non members users publishing content with the group passed in the query string.', - 'group' => 'Organic groups', - 'dependencies' => array('entityreference_prepopulate'), - ); - } - public function setUp() { parent::setUp('og_test', 'entityreference_prepopulate'); @@ -2291,19 +1935,12 @@ class OgNonMembersPublishingContentTestCase extends OgTestBase { * */ class OgUserCanPublishGroupContentTypeOnlyInGroup extends OgTestBase { + public $group; public $site_user; public $group_user; public $group_content; - public static function getInfo() { - return array( - 'name' => 'User can publish group content only inside group', - 'description' => "User with permission to create a group content only in a group can't publish outside of a group.", - 'group' => 'Organic groups', - ); - } - public function setUp() { parent::setUp('og'); @@ -2390,7 +2027,7 @@ class OgUserCanPublishGroupContentTypeOnlyInGroup extends OgTestBase { $this->backdropLogin($this->site_user); // Set node access strict variable to FALSE for posting outside groups. - variable_set('og_node_access_strict', FALSE); + config_set('og.settings', 'og_node_access_strict', FALSE); // Verify that the user can publish group content outside a group. $node_title = $this->randomName(); @@ -2431,14 +2068,6 @@ class OgAutoCompleteAccessibleGroupsValidation extends OgTestBase { var $group_owner; var $group_member; - public static function getInfo() { - return array( - 'name' => 'Auto complete for non accessible groups', - 'description' => "Verify the user cannot fill in the auto complete field with the name of a un-accessible group name.", - 'group' => 'Organic groups', - ); - } - function setUp() { parent::setUp('og', 'entity_plus', 'entity_ui', 'entityreference'); debug('pass'); @@ -2514,14 +2143,6 @@ class OgAutoCompleteAccessibleGroupsValidation extends OgTestBase { */ class OgSelectAccessibleGroupsValidation extends OgTestBase { - public static function getInfo() { - return array( - 'name' => 'Select widget for non accessible groups', - 'description' => "Verify the user cannot fill in the select field with the name of a un-accessible group name.", - 'group' => 'Organic groups', - ); - } - function setUp() { parent::setUp('og'); @@ -2589,14 +2210,6 @@ class OgSelectAccessibleGroupsValidation extends OgTestBase { */ class OgAudienceFieldAccessOverrideTestCase extends OgTestBase { - public static function getInfo() { - return array( - 'name' => 'OG audience field access settings', - 'description' => 'Test the ability to use entity access instead of field access for the audience field.', - 'group' => 'Organic groups', - ); - } - function setUp() { parent::setUp('og'); } @@ -2637,14 +2250,6 @@ class OgAudienceFieldAccessOverrideTestCase extends OgTestBase { */ class OgAudienceFieldDeltaTestCase extends OgTestBase { - public static function getInfo() { - return array( - 'name' => 'OG audience field wrapper delta', - 'description' => 'Testing OG audience field returns the expected values when using entity metadata wrapper delta.', - 'group' => 'Organic groups', - ); - } - function setUp() { parent::setUp('og'); diff --git a/tests/og.tests.info b/tests/og.tests.info index 6fbee0a4..84570f79 100644 --- a/tests/og.tests.info +++ b/tests/og.tests.info @@ -34,12 +34,6 @@ description = Test groups with default access field. group = Organic groups file = og.test -[OgMigrate7000TestCase] -name = OG migrate - 7000 -description = Tests the upgrade path of OG from Backdrop 6. -group = Organic groups -file = og.test - [OgFieldWidgetTestCase] name = OG reference widget description = Test the OG reference widget behavior. @@ -52,12 +46,6 @@ description = Test the revocation of group roles group = Organic groups file = og.test -[OgMigrate7200TestCase] -name = OG migrate 7.x-2.x -description = Test the upgrade from 7.x-1.x to 7.x-2.x branch. -group = Organic groups -file = og.test - [OgEntityFieldQueryTestCase] name = OG audience fields query description = Test querying group-audience fields using entityFieldQuery. diff --git a/tests/og_test.module b/tests/og_test.module index 4f4f4fb0..99952ec4 100644 --- a/tests/og_test.module +++ b/tests/og_test.module @@ -122,7 +122,7 @@ function og_test_my_content() { * @see OgBehaviorHandlerTestCase::testSetStateOnInsert() */ function og_test_form_alter(&$form, $form_state) { - if (empty($form['#node_edit_form']) || $form['#bundle'] != 'behavior') { + if ($form_state['build_info']['base_form_id'] != 'node_form' || $form['#bundle'] != 'behavior') { return; }